documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398
  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. * Represents 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. /** @hidden */
  18255. _reset: () => void;
  18256. private _defaultUp;
  18257. /**
  18258. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18259. * This is the base of the follow, arc rotate cameras and Free camera
  18260. * @see http://doc.babylonjs.com/features/cameras
  18261. * @param name Defines the name of the camera in the scene
  18262. * @param position Defines the start position of the camera in the scene
  18263. * @param scene Defines the scene the camera belongs to
  18264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18265. */
  18266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18267. /**
  18268. * Gets the position in front of the camera at a given distance.
  18269. * @param distance The distance from the camera we want the position to be
  18270. * @returns the position
  18271. */
  18272. getFrontPosition(distance: number): Vector3;
  18273. /** @hidden */
  18274. _getLockedTargetPosition(): Nullable<Vector3>;
  18275. private _storedPosition;
  18276. private _storedRotation;
  18277. private _storedRotationQuaternion;
  18278. /**
  18279. * Store current camera state of the camera (fov, position, rotation, etc..)
  18280. * @returns the camera
  18281. */
  18282. storeState(): Camera;
  18283. /**
  18284. * Restored camera state. You must call storeState() first
  18285. * @returns whether it was successful or not
  18286. * @hidden
  18287. */
  18288. _restoreStateValues(): boolean;
  18289. /** @hidden */
  18290. _initCache(): void;
  18291. /** @hidden */
  18292. _updateCache(ignoreParentClass?: boolean): void;
  18293. /** @hidden */
  18294. _isSynchronizedViewMatrix(): boolean;
  18295. /** @hidden */
  18296. _computeLocalCameraSpeed(): number;
  18297. /**
  18298. * Defines the target the camera should look at.
  18299. * @param target Defines the new target as a Vector or a mesh
  18300. */
  18301. setTarget(target: Vector3): void;
  18302. /**
  18303. * Return the current target position of the camera. This value is expressed in local space.
  18304. * @returns the target position
  18305. */
  18306. getTarget(): Vector3;
  18307. /** @hidden */
  18308. _decideIfNeedsToMove(): boolean;
  18309. /** @hidden */
  18310. _updatePosition(): void;
  18311. /** @hidden */
  18312. _checkInputs(): void;
  18313. protected _updateCameraRotationMatrix(): void;
  18314. /**
  18315. * 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)
  18316. * @returns the current camera
  18317. */
  18318. private _rotateUpVectorWithCameraRotationMatrix;
  18319. private _cachedRotationZ;
  18320. private _cachedQuaternionRotationZ;
  18321. /** @hidden */
  18322. _getViewMatrix(): Matrix;
  18323. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18324. /**
  18325. * @hidden
  18326. */
  18327. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18328. /**
  18329. * @hidden
  18330. */
  18331. _updateRigCameras(): void;
  18332. private _getRigCamPositionAndTarget;
  18333. /**
  18334. * Gets the current object class name.
  18335. * @return the class name
  18336. */
  18337. getClassName(): string;
  18338. }
  18339. }
  18340. declare module BABYLON {
  18341. /**
  18342. * Gather the list of keyboard event types as constants.
  18343. */
  18344. export class KeyboardEventTypes {
  18345. /**
  18346. * The keydown event is fired when a key becomes active (pressed).
  18347. */
  18348. static readonly KEYDOWN: number;
  18349. /**
  18350. * The keyup event is fired when a key has been released.
  18351. */
  18352. static readonly KEYUP: number;
  18353. }
  18354. /**
  18355. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18356. */
  18357. export class KeyboardInfo {
  18358. /**
  18359. * Defines the type of event (KeyboardEventTypes)
  18360. */
  18361. type: number;
  18362. /**
  18363. * Defines the related dom event
  18364. */
  18365. event: KeyboardEvent;
  18366. /**
  18367. * Instantiates a new keyboard info.
  18368. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18369. * @param type Defines the type of event (KeyboardEventTypes)
  18370. * @param event Defines the related dom event
  18371. */
  18372. constructor(
  18373. /**
  18374. * Defines the type of event (KeyboardEventTypes)
  18375. */
  18376. type: number,
  18377. /**
  18378. * Defines the related dom event
  18379. */
  18380. event: KeyboardEvent);
  18381. }
  18382. /**
  18383. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18384. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18385. */
  18386. export class KeyboardInfoPre extends KeyboardInfo {
  18387. /**
  18388. * Defines the type of event (KeyboardEventTypes)
  18389. */
  18390. type: number;
  18391. /**
  18392. * Defines the related dom event
  18393. */
  18394. event: KeyboardEvent;
  18395. /**
  18396. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18397. */
  18398. skipOnPointerObservable: boolean;
  18399. /**
  18400. * Instantiates a new keyboard pre info.
  18401. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18402. * @param type Defines the type of event (KeyboardEventTypes)
  18403. * @param event Defines the related dom event
  18404. */
  18405. constructor(
  18406. /**
  18407. * Defines the type of event (KeyboardEventTypes)
  18408. */
  18409. type: number,
  18410. /**
  18411. * Defines the related dom event
  18412. */
  18413. event: KeyboardEvent);
  18414. }
  18415. }
  18416. declare module BABYLON {
  18417. /**
  18418. * Manage the keyboard inputs to control the movement of a free camera.
  18419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18420. */
  18421. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18422. /**
  18423. * Defines the camera the input is attached to.
  18424. */
  18425. camera: FreeCamera;
  18426. /**
  18427. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18428. */
  18429. keysUp: number[];
  18430. /**
  18431. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18432. */
  18433. keysUpward: number[];
  18434. /**
  18435. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18436. */
  18437. keysDown: number[];
  18438. /**
  18439. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18440. */
  18441. keysDownward: number[];
  18442. /**
  18443. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18444. */
  18445. keysLeft: number[];
  18446. /**
  18447. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18448. */
  18449. keysRight: number[];
  18450. private _keys;
  18451. private _onCanvasBlurObserver;
  18452. private _onKeyboardObserver;
  18453. private _engine;
  18454. private _scene;
  18455. /**
  18456. * Attach the input controls to a specific dom element to get the input from.
  18457. * @param element Defines the element the controls should be listened from
  18458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18459. */
  18460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18461. /**
  18462. * Detach the current controls from the specified dom element.
  18463. * @param element Defines the element to stop listening the inputs from
  18464. */
  18465. detachControl(element: Nullable<HTMLElement>): void;
  18466. /**
  18467. * Update the current camera state depending on the inputs that have been used this frame.
  18468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18469. */
  18470. checkInputs(): void;
  18471. /**
  18472. * Gets the class name of the current intput.
  18473. * @returns the class name
  18474. */
  18475. getClassName(): string;
  18476. /** @hidden */
  18477. _onLostFocus(): void;
  18478. /**
  18479. * Get the friendly name associated with the input class.
  18480. * @returns the input friendly name
  18481. */
  18482. getSimpleName(): string;
  18483. }
  18484. }
  18485. declare module BABYLON {
  18486. /**
  18487. * Gather the list of pointer event types as constants.
  18488. */
  18489. export class PointerEventTypes {
  18490. /**
  18491. * 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.
  18492. */
  18493. static readonly POINTERDOWN: number;
  18494. /**
  18495. * The pointerup event is fired when a pointer is no longer active.
  18496. */
  18497. static readonly POINTERUP: number;
  18498. /**
  18499. * The pointermove event is fired when a pointer changes coordinates.
  18500. */
  18501. static readonly POINTERMOVE: number;
  18502. /**
  18503. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18504. */
  18505. static readonly POINTERWHEEL: number;
  18506. /**
  18507. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18508. */
  18509. static readonly POINTERPICK: number;
  18510. /**
  18511. * The pointertap event is fired when a the object has been touched and released without drag.
  18512. */
  18513. static readonly POINTERTAP: number;
  18514. /**
  18515. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18516. */
  18517. static readonly POINTERDOUBLETAP: number;
  18518. }
  18519. /**
  18520. * Base class of pointer info types.
  18521. */
  18522. export class PointerInfoBase {
  18523. /**
  18524. * Defines the type of event (PointerEventTypes)
  18525. */
  18526. type: number;
  18527. /**
  18528. * Defines the related dom event
  18529. */
  18530. event: PointerEvent | MouseWheelEvent;
  18531. /**
  18532. * Instantiates the base class of pointers info.
  18533. * @param type Defines the type of event (PointerEventTypes)
  18534. * @param event Defines the related dom event
  18535. */
  18536. constructor(
  18537. /**
  18538. * Defines the type of event (PointerEventTypes)
  18539. */
  18540. type: number,
  18541. /**
  18542. * Defines the related dom event
  18543. */
  18544. event: PointerEvent | MouseWheelEvent);
  18545. }
  18546. /**
  18547. * This class is used to store pointer related info for the onPrePointerObservable event.
  18548. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18549. */
  18550. export class PointerInfoPre extends PointerInfoBase {
  18551. /**
  18552. * Ray from a pointer if availible (eg. 6dof controller)
  18553. */
  18554. ray: Nullable<Ray>;
  18555. /**
  18556. * Defines the local position of the pointer on the canvas.
  18557. */
  18558. localPosition: Vector2;
  18559. /**
  18560. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18561. */
  18562. skipOnPointerObservable: boolean;
  18563. /**
  18564. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18565. * @param type Defines the type of event (PointerEventTypes)
  18566. * @param event Defines the related dom event
  18567. * @param localX Defines the local x coordinates of the pointer when the event occured
  18568. * @param localY Defines the local y coordinates of the pointer when the event occured
  18569. */
  18570. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18571. }
  18572. /**
  18573. * This type contains all the data related to a pointer event in Babylon.js.
  18574. * 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.
  18575. */
  18576. export class PointerInfo extends PointerInfoBase {
  18577. /**
  18578. * Defines the picking info associated to the info (if any)\
  18579. */
  18580. pickInfo: Nullable<PickingInfo>;
  18581. /**
  18582. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18583. * @param type Defines the type of event (PointerEventTypes)
  18584. * @param event Defines the related dom event
  18585. * @param pickInfo Defines the picking info associated to the info (if any)\
  18586. */
  18587. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18588. /**
  18589. * Defines the picking info associated to the info (if any)\
  18590. */
  18591. pickInfo: Nullable<PickingInfo>);
  18592. }
  18593. /**
  18594. * Data relating to a touch event on the screen.
  18595. */
  18596. export interface PointerTouch {
  18597. /**
  18598. * X coordinate of touch.
  18599. */
  18600. x: number;
  18601. /**
  18602. * Y coordinate of touch.
  18603. */
  18604. y: number;
  18605. /**
  18606. * Id of touch. Unique for each finger.
  18607. */
  18608. pointerId: number;
  18609. /**
  18610. * Event type passed from DOM.
  18611. */
  18612. type: any;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Manage the mouse inputs to control the movement of a free camera.
  18618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18619. */
  18620. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18621. /**
  18622. * Define if touch is enabled in the mouse input
  18623. */
  18624. touchEnabled: boolean;
  18625. /**
  18626. * Defines the camera the input is attached to.
  18627. */
  18628. camera: FreeCamera;
  18629. /**
  18630. * Defines the buttons associated with the input to handle camera move.
  18631. */
  18632. buttons: number[];
  18633. /**
  18634. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18635. */
  18636. angularSensibility: number;
  18637. private _pointerInput;
  18638. private _onMouseMove;
  18639. private _observer;
  18640. private previousPosition;
  18641. /**
  18642. * Observable for when a pointer move event occurs containing the move offset
  18643. */
  18644. onPointerMovedObservable: Observable<{
  18645. offsetX: number;
  18646. offsetY: number;
  18647. }>;
  18648. /**
  18649. * @hidden
  18650. * If the camera should be rotated automatically based on pointer movement
  18651. */
  18652. _allowCameraRotation: boolean;
  18653. /**
  18654. * Manage the mouse inputs to control the movement of a free camera.
  18655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18656. * @param touchEnabled Defines if touch is enabled or not
  18657. */
  18658. constructor(
  18659. /**
  18660. * Define if touch is enabled in the mouse input
  18661. */
  18662. touchEnabled?: boolean);
  18663. /**
  18664. * Attach the input controls to a specific dom element to get the input from.
  18665. * @param element Defines the element the controls should be listened from
  18666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18667. */
  18668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18669. /**
  18670. * Called on JS contextmenu event.
  18671. * Override this method to provide functionality.
  18672. */
  18673. protected onContextMenu(evt: PointerEvent): void;
  18674. /**
  18675. * Detach the current controls from the specified dom element.
  18676. * @param element Defines the element to stop listening the inputs from
  18677. */
  18678. detachControl(element: Nullable<HTMLElement>): void;
  18679. /**
  18680. * Gets the class name of the current intput.
  18681. * @returns the class name
  18682. */
  18683. getClassName(): string;
  18684. /**
  18685. * Get the friendly name associated with the input class.
  18686. * @returns the input friendly name
  18687. */
  18688. getSimpleName(): string;
  18689. }
  18690. }
  18691. declare module BABYLON {
  18692. /**
  18693. * Manage the touch inputs to control the movement of a free camera.
  18694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18695. */
  18696. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18697. /**
  18698. * Defines the camera the input is attached to.
  18699. */
  18700. camera: FreeCamera;
  18701. /**
  18702. * Defines the touch sensibility for rotation.
  18703. * The higher the faster.
  18704. */
  18705. touchAngularSensibility: number;
  18706. /**
  18707. * Defines the touch sensibility for move.
  18708. * The higher the faster.
  18709. */
  18710. touchMoveSensibility: number;
  18711. private _offsetX;
  18712. private _offsetY;
  18713. private _pointerPressed;
  18714. private _pointerInput;
  18715. private _observer;
  18716. private _onLostFocus;
  18717. /**
  18718. * Attach the input controls to a specific dom element to get the input from.
  18719. * @param element Defines the element the controls should be listened from
  18720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18721. */
  18722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18723. /**
  18724. * Detach the current controls from the specified dom element.
  18725. * @param element Defines the element to stop listening the inputs from
  18726. */
  18727. detachControl(element: Nullable<HTMLElement>): void;
  18728. /**
  18729. * Update the current camera state depending on the inputs that have been used this frame.
  18730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18731. */
  18732. checkInputs(): void;
  18733. /**
  18734. * Gets the class name of the current intput.
  18735. * @returns the class name
  18736. */
  18737. getClassName(): string;
  18738. /**
  18739. * Get the friendly name associated with the input class.
  18740. * @returns the input friendly name
  18741. */
  18742. getSimpleName(): string;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /**
  18747. * Default Inputs manager for the FreeCamera.
  18748. * It groups all the default supported inputs for ease of use.
  18749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18750. */
  18751. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18752. /**
  18753. * @hidden
  18754. */
  18755. _mouseInput: Nullable<FreeCameraMouseInput>;
  18756. /**
  18757. * Instantiates a new FreeCameraInputsManager.
  18758. * @param camera Defines the camera the inputs belong to
  18759. */
  18760. constructor(camera: FreeCamera);
  18761. /**
  18762. * Add keyboard input support to the input manager.
  18763. * @returns the current input manager
  18764. */
  18765. addKeyboard(): FreeCameraInputsManager;
  18766. /**
  18767. * Add mouse input support to the input manager.
  18768. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18769. * @returns the current input manager
  18770. */
  18771. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18772. /**
  18773. * Removes the mouse input support from the manager
  18774. * @returns the current input manager
  18775. */
  18776. removeMouse(): FreeCameraInputsManager;
  18777. /**
  18778. * Add touch input support to the input manager.
  18779. * @returns the current input manager
  18780. */
  18781. addTouch(): FreeCameraInputsManager;
  18782. /**
  18783. * Remove all attached input methods from a camera
  18784. */
  18785. clear(): void;
  18786. }
  18787. }
  18788. declare module BABYLON {
  18789. /**
  18790. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18791. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18793. */
  18794. export class FreeCamera extends TargetCamera {
  18795. /**
  18796. * Define the collision ellipsoid of the camera.
  18797. * This is helpful to simulate a camera body like the player body around the camera
  18798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18799. */
  18800. ellipsoid: Vector3;
  18801. /**
  18802. * Define an offset for the position of the ellipsoid around the camera.
  18803. * This can be helpful to determine the center of the body near the gravity center of the body
  18804. * instead of its head.
  18805. */
  18806. ellipsoidOffset: Vector3;
  18807. /**
  18808. * Enable or disable collisions of the camera with the rest of the scene objects.
  18809. */
  18810. checkCollisions: boolean;
  18811. /**
  18812. * Enable or disable gravity on the camera.
  18813. */
  18814. applyGravity: boolean;
  18815. /**
  18816. * Define the input manager associated to the camera.
  18817. */
  18818. inputs: FreeCameraInputsManager;
  18819. /**
  18820. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18821. * Higher values reduce sensitivity.
  18822. */
  18823. get angularSensibility(): number;
  18824. /**
  18825. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18826. * Higher values reduce sensitivity.
  18827. */
  18828. set angularSensibility(value: number);
  18829. /**
  18830. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18831. */
  18832. get keysUp(): number[];
  18833. set keysUp(value: number[]);
  18834. /**
  18835. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18836. */
  18837. get keysUpward(): number[];
  18838. set keysUpward(value: number[]);
  18839. /**
  18840. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18841. */
  18842. get keysDown(): number[];
  18843. set keysDown(value: number[]);
  18844. /**
  18845. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18846. */
  18847. get keysDownward(): number[];
  18848. set keysDownward(value: number[]);
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18851. */
  18852. get keysLeft(): number[];
  18853. set keysLeft(value: number[]);
  18854. /**
  18855. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18856. */
  18857. get keysRight(): number[];
  18858. set keysRight(value: number[]);
  18859. /**
  18860. * Event raised when the camera collide with a mesh in the scene.
  18861. */
  18862. onCollide: (collidedMesh: AbstractMesh) => void;
  18863. private _collider;
  18864. private _needMoveForGravity;
  18865. private _oldPosition;
  18866. private _diffPosition;
  18867. private _newPosition;
  18868. /** @hidden */
  18869. _localDirection: Vector3;
  18870. /** @hidden */
  18871. _transformedDirection: Vector3;
  18872. /**
  18873. * Instantiates a Free Camera.
  18874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18875. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18877. * @param name Define the name of the camera in the scene
  18878. * @param position Define the start position of the camera in the scene
  18879. * @param scene Define the scene the camera belongs to
  18880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18881. */
  18882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18883. /**
  18884. * Attached controls to the current camera.
  18885. * @param element Defines the element the controls should be listened from
  18886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18887. */
  18888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18889. /**
  18890. * Detach the current controls from the camera.
  18891. * The camera will stop reacting to inputs.
  18892. * @param element Defines the element to stop listening the inputs from
  18893. */
  18894. detachControl(element: HTMLElement): void;
  18895. private _collisionMask;
  18896. /**
  18897. * Define a collision mask to limit the list of object the camera can collide with
  18898. */
  18899. get collisionMask(): number;
  18900. set collisionMask(mask: number);
  18901. /** @hidden */
  18902. _collideWithWorld(displacement: Vector3): void;
  18903. private _onCollisionPositionChange;
  18904. /** @hidden */
  18905. _checkInputs(): void;
  18906. /** @hidden */
  18907. _decideIfNeedsToMove(): boolean;
  18908. /** @hidden */
  18909. _updatePosition(): void;
  18910. /**
  18911. * Destroy the camera and release the current resources hold by it.
  18912. */
  18913. dispose(): void;
  18914. /**
  18915. * Gets the current object class name.
  18916. * @return the class name
  18917. */
  18918. getClassName(): string;
  18919. }
  18920. }
  18921. declare module BABYLON {
  18922. /**
  18923. * Represents a gamepad control stick position
  18924. */
  18925. export class StickValues {
  18926. /**
  18927. * The x component of the control stick
  18928. */
  18929. x: number;
  18930. /**
  18931. * The y component of the control stick
  18932. */
  18933. y: number;
  18934. /**
  18935. * Initializes the gamepad x and y control stick values
  18936. * @param x The x component of the gamepad control stick value
  18937. * @param y The y component of the gamepad control stick value
  18938. */
  18939. constructor(
  18940. /**
  18941. * The x component of the control stick
  18942. */
  18943. x: number,
  18944. /**
  18945. * The y component of the control stick
  18946. */
  18947. y: number);
  18948. }
  18949. /**
  18950. * An interface which manages callbacks for gamepad button changes
  18951. */
  18952. export interface GamepadButtonChanges {
  18953. /**
  18954. * Called when a gamepad has been changed
  18955. */
  18956. changed: boolean;
  18957. /**
  18958. * Called when a gamepad press event has been triggered
  18959. */
  18960. pressChanged: boolean;
  18961. /**
  18962. * Called when a touch event has been triggered
  18963. */
  18964. touchChanged: boolean;
  18965. /**
  18966. * Called when a value has changed
  18967. */
  18968. valueChanged: boolean;
  18969. }
  18970. /**
  18971. * Represents a gamepad
  18972. */
  18973. export class Gamepad {
  18974. /**
  18975. * The id of the gamepad
  18976. */
  18977. id: string;
  18978. /**
  18979. * The index of the gamepad
  18980. */
  18981. index: number;
  18982. /**
  18983. * The browser gamepad
  18984. */
  18985. browserGamepad: any;
  18986. /**
  18987. * Specifies what type of gamepad this represents
  18988. */
  18989. type: number;
  18990. private _leftStick;
  18991. private _rightStick;
  18992. /** @hidden */
  18993. _isConnected: boolean;
  18994. private _leftStickAxisX;
  18995. private _leftStickAxisY;
  18996. private _rightStickAxisX;
  18997. private _rightStickAxisY;
  18998. /**
  18999. * Triggered when the left control stick has been changed
  19000. */
  19001. private _onleftstickchanged;
  19002. /**
  19003. * Triggered when the right control stick has been changed
  19004. */
  19005. private _onrightstickchanged;
  19006. /**
  19007. * Represents a gamepad controller
  19008. */
  19009. static GAMEPAD: number;
  19010. /**
  19011. * Represents a generic controller
  19012. */
  19013. static GENERIC: number;
  19014. /**
  19015. * Represents an XBox controller
  19016. */
  19017. static XBOX: number;
  19018. /**
  19019. * Represents a pose-enabled controller
  19020. */
  19021. static POSE_ENABLED: number;
  19022. /**
  19023. * Represents an Dual Shock controller
  19024. */
  19025. static DUALSHOCK: number;
  19026. /**
  19027. * Specifies whether the left control stick should be Y-inverted
  19028. */
  19029. protected _invertLeftStickY: boolean;
  19030. /**
  19031. * Specifies if the gamepad has been connected
  19032. */
  19033. get isConnected(): boolean;
  19034. /**
  19035. * Initializes the gamepad
  19036. * @param id The id of the gamepad
  19037. * @param index The index of the gamepad
  19038. * @param browserGamepad The browser gamepad
  19039. * @param leftStickX The x component of the left joystick
  19040. * @param leftStickY The y component of the left joystick
  19041. * @param rightStickX The x component of the right joystick
  19042. * @param rightStickY The y component of the right joystick
  19043. */
  19044. constructor(
  19045. /**
  19046. * The id of the gamepad
  19047. */
  19048. id: string,
  19049. /**
  19050. * The index of the gamepad
  19051. */
  19052. index: number,
  19053. /**
  19054. * The browser gamepad
  19055. */
  19056. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19057. /**
  19058. * Callback triggered when the left joystick has changed
  19059. * @param callback
  19060. */
  19061. onleftstickchanged(callback: (values: StickValues) => void): void;
  19062. /**
  19063. * Callback triggered when the right joystick has changed
  19064. * @param callback
  19065. */
  19066. onrightstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Gets the left joystick
  19069. */
  19070. get leftStick(): StickValues;
  19071. /**
  19072. * Sets the left joystick values
  19073. */
  19074. set leftStick(newValues: StickValues);
  19075. /**
  19076. * Gets the right joystick
  19077. */
  19078. get rightStick(): StickValues;
  19079. /**
  19080. * Sets the right joystick value
  19081. */
  19082. set rightStick(newValues: StickValues);
  19083. /**
  19084. * Updates the gamepad joystick positions
  19085. */
  19086. update(): void;
  19087. /**
  19088. * Disposes the gamepad
  19089. */
  19090. dispose(): void;
  19091. }
  19092. /**
  19093. * Represents a generic gamepad
  19094. */
  19095. export class GenericPad extends Gamepad {
  19096. private _buttons;
  19097. private _onbuttondown;
  19098. private _onbuttonup;
  19099. /**
  19100. * Observable triggered when a button has been pressed
  19101. */
  19102. onButtonDownObservable: Observable<number>;
  19103. /**
  19104. * Observable triggered when a button has been released
  19105. */
  19106. onButtonUpObservable: Observable<number>;
  19107. /**
  19108. * Callback triggered when a button has been pressed
  19109. * @param callback Called when a button has been pressed
  19110. */
  19111. onbuttondown(callback: (buttonPressed: number) => void): void;
  19112. /**
  19113. * Callback triggered when a button has been released
  19114. * @param callback Called when a button has been released
  19115. */
  19116. onbuttonup(callback: (buttonReleased: number) => void): void;
  19117. /**
  19118. * Initializes the generic gamepad
  19119. * @param id The id of the generic gamepad
  19120. * @param index The index of the generic gamepad
  19121. * @param browserGamepad The browser gamepad
  19122. */
  19123. constructor(id: string, index: number, browserGamepad: any);
  19124. private _setButtonValue;
  19125. /**
  19126. * Updates the generic gamepad
  19127. */
  19128. update(): void;
  19129. /**
  19130. * Disposes the generic gamepad
  19131. */
  19132. dispose(): void;
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * Defines the types of pose enabled controllers that are supported
  19138. */
  19139. export enum PoseEnabledControllerType {
  19140. /**
  19141. * HTC Vive
  19142. */
  19143. VIVE = 0,
  19144. /**
  19145. * Oculus Rift
  19146. */
  19147. OCULUS = 1,
  19148. /**
  19149. * Windows mixed reality
  19150. */
  19151. WINDOWS = 2,
  19152. /**
  19153. * Samsung gear VR
  19154. */
  19155. GEAR_VR = 3,
  19156. /**
  19157. * Google Daydream
  19158. */
  19159. DAYDREAM = 4,
  19160. /**
  19161. * Generic
  19162. */
  19163. GENERIC = 5
  19164. }
  19165. /**
  19166. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19167. */
  19168. export interface MutableGamepadButton {
  19169. /**
  19170. * Value of the button/trigger
  19171. */
  19172. value: number;
  19173. /**
  19174. * If the button/trigger is currently touched
  19175. */
  19176. touched: boolean;
  19177. /**
  19178. * If the button/trigger is currently pressed
  19179. */
  19180. pressed: boolean;
  19181. }
  19182. /**
  19183. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19184. * @hidden
  19185. */
  19186. export interface ExtendedGamepadButton extends GamepadButton {
  19187. /**
  19188. * If the button/trigger is currently pressed
  19189. */
  19190. readonly pressed: boolean;
  19191. /**
  19192. * If the button/trigger is currently touched
  19193. */
  19194. readonly touched: boolean;
  19195. /**
  19196. * Value of the button/trigger
  19197. */
  19198. readonly value: number;
  19199. }
  19200. /** @hidden */
  19201. export interface _GamePadFactory {
  19202. /**
  19203. * Returns whether or not the current gamepad can be created for this type of controller.
  19204. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19205. * @returns true if it can be created, otherwise false
  19206. */
  19207. canCreate(gamepadInfo: any): boolean;
  19208. /**
  19209. * Creates a new instance of the Gamepad.
  19210. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19211. * @returns the new gamepad instance
  19212. */
  19213. create(gamepadInfo: any): Gamepad;
  19214. }
  19215. /**
  19216. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19217. */
  19218. export class PoseEnabledControllerHelper {
  19219. /** @hidden */
  19220. static _ControllerFactories: _GamePadFactory[];
  19221. /** @hidden */
  19222. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19223. /**
  19224. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19225. * @param vrGamepad the gamepad to initialized
  19226. * @returns a vr controller of the type the gamepad identified as
  19227. */
  19228. static InitiateController(vrGamepad: any): Gamepad;
  19229. }
  19230. /**
  19231. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19232. */
  19233. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19234. /**
  19235. * If the controller is used in a webXR session
  19236. */
  19237. isXR: boolean;
  19238. private _deviceRoomPosition;
  19239. private _deviceRoomRotationQuaternion;
  19240. /**
  19241. * The device position in babylon space
  19242. */
  19243. devicePosition: Vector3;
  19244. /**
  19245. * The device rotation in babylon space
  19246. */
  19247. deviceRotationQuaternion: Quaternion;
  19248. /**
  19249. * The scale factor of the device in babylon space
  19250. */
  19251. deviceScaleFactor: number;
  19252. /**
  19253. * (Likely devicePosition should be used instead) The device position in its room space
  19254. */
  19255. position: Vector3;
  19256. /**
  19257. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19258. */
  19259. rotationQuaternion: Quaternion;
  19260. /**
  19261. * The type of controller (Eg. Windows mixed reality)
  19262. */
  19263. controllerType: PoseEnabledControllerType;
  19264. protected _calculatedPosition: Vector3;
  19265. private _calculatedRotation;
  19266. /**
  19267. * The raw pose from the device
  19268. */
  19269. rawPose: DevicePose;
  19270. private _trackPosition;
  19271. private _maxRotationDistFromHeadset;
  19272. private _draggedRoomRotation;
  19273. /**
  19274. * @hidden
  19275. */
  19276. _disableTrackPosition(fixedPosition: Vector3): void;
  19277. /**
  19278. * Internal, the mesh attached to the controller
  19279. * @hidden
  19280. */
  19281. _mesh: Nullable<AbstractMesh>;
  19282. private _poseControlledCamera;
  19283. private _leftHandSystemQuaternion;
  19284. /**
  19285. * Internal, matrix used to convert room space to babylon space
  19286. * @hidden
  19287. */
  19288. _deviceToWorld: Matrix;
  19289. /**
  19290. * Node to be used when casting a ray from the controller
  19291. * @hidden
  19292. */
  19293. _pointingPoseNode: Nullable<TransformNode>;
  19294. /**
  19295. * Name of the child mesh that can be used to cast a ray from the controller
  19296. */
  19297. static readonly POINTING_POSE: string;
  19298. /**
  19299. * Creates a new PoseEnabledController from a gamepad
  19300. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19301. */
  19302. constructor(browserGamepad: any);
  19303. private _workingMatrix;
  19304. /**
  19305. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19306. */
  19307. update(): void;
  19308. /**
  19309. * Updates only the pose device and mesh without doing any button event checking
  19310. */
  19311. protected _updatePoseAndMesh(): void;
  19312. /**
  19313. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19314. * @param poseData raw pose fromthe device
  19315. */
  19316. updateFromDevice(poseData: DevicePose): void;
  19317. /**
  19318. * @hidden
  19319. */
  19320. _meshAttachedObservable: Observable<AbstractMesh>;
  19321. /**
  19322. * Attaches a mesh to the controller
  19323. * @param mesh the mesh to be attached
  19324. */
  19325. attachToMesh(mesh: AbstractMesh): void;
  19326. /**
  19327. * Attaches the controllers mesh to a camera
  19328. * @param camera the camera the mesh should be attached to
  19329. */
  19330. attachToPoseControlledCamera(camera: TargetCamera): void;
  19331. /**
  19332. * Disposes of the controller
  19333. */
  19334. dispose(): void;
  19335. /**
  19336. * The mesh that is attached to the controller
  19337. */
  19338. get mesh(): Nullable<AbstractMesh>;
  19339. /**
  19340. * Gets the ray of the controller in the direction the controller is pointing
  19341. * @param length the length the resulting ray should be
  19342. * @returns a ray in the direction the controller is pointing
  19343. */
  19344. getForwardRay(length?: number): Ray;
  19345. }
  19346. }
  19347. declare module BABYLON {
  19348. /**
  19349. * Defines the WebVRController object that represents controllers tracked in 3D space
  19350. */
  19351. export abstract class WebVRController extends PoseEnabledController {
  19352. /**
  19353. * Internal, the default controller model for the controller
  19354. */
  19355. protected _defaultModel: Nullable<AbstractMesh>;
  19356. /**
  19357. * Fired when the trigger state has changed
  19358. */
  19359. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19360. /**
  19361. * Fired when the main button state has changed
  19362. */
  19363. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19364. /**
  19365. * Fired when the secondary button state has changed
  19366. */
  19367. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19368. /**
  19369. * Fired when the pad state has changed
  19370. */
  19371. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19372. /**
  19373. * Fired when controllers stick values have changed
  19374. */
  19375. onPadValuesChangedObservable: Observable<StickValues>;
  19376. /**
  19377. * Array of button availible on the controller
  19378. */
  19379. protected _buttons: Array<MutableGamepadButton>;
  19380. private _onButtonStateChange;
  19381. /**
  19382. * Fired when a controller button's state has changed
  19383. * @param callback the callback containing the button that was modified
  19384. */
  19385. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19386. /**
  19387. * X and Y axis corresponding to the controllers joystick
  19388. */
  19389. pad: StickValues;
  19390. /**
  19391. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19392. */
  19393. hand: string;
  19394. /**
  19395. * The default controller model for the controller
  19396. */
  19397. get defaultModel(): Nullable<AbstractMesh>;
  19398. /**
  19399. * Creates a new WebVRController from a gamepad
  19400. * @param vrGamepad the gamepad that the WebVRController should be created from
  19401. */
  19402. constructor(vrGamepad: any);
  19403. /**
  19404. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19405. */
  19406. update(): void;
  19407. /**
  19408. * Function to be called when a button is modified
  19409. */
  19410. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19411. /**
  19412. * Loads a mesh and attaches it to the controller
  19413. * @param scene the scene the mesh should be added to
  19414. * @param meshLoaded callback for when the mesh has been loaded
  19415. */
  19416. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19417. private _setButtonValue;
  19418. private _changes;
  19419. private _checkChanges;
  19420. /**
  19421. * Disposes of th webVRCOntroller
  19422. */
  19423. dispose(): void;
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. /**
  19428. * The HemisphericLight simulates the ambient environment light,
  19429. * so the passed direction is the light reflection direction, not the incoming direction.
  19430. */
  19431. export class HemisphericLight extends Light {
  19432. /**
  19433. * The groundColor is the light in the opposite direction to the one specified during creation.
  19434. * 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.
  19435. */
  19436. groundColor: Color3;
  19437. /**
  19438. * The light reflection direction, not the incoming direction.
  19439. */
  19440. direction: Vector3;
  19441. /**
  19442. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19443. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19444. * The HemisphericLight can't cast shadows.
  19445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19446. * @param name The friendly name of the light
  19447. * @param direction The direction of the light reflection
  19448. * @param scene The scene the light belongs to
  19449. */
  19450. constructor(name: string, direction: Vector3, scene: Scene);
  19451. protected _buildUniformLayout(): void;
  19452. /**
  19453. * Returns the string "HemisphericLight".
  19454. * @return The class name
  19455. */
  19456. getClassName(): string;
  19457. /**
  19458. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19459. * Returns the updated direction.
  19460. * @param target The target the direction should point to
  19461. * @return The computed direction
  19462. */
  19463. setDirectionToTarget(target: Vector3): Vector3;
  19464. /**
  19465. * Returns the shadow generator associated to the light.
  19466. * @returns Always null for hemispheric lights because it does not support shadows.
  19467. */
  19468. getShadowGenerator(): Nullable<IShadowGenerator>;
  19469. /**
  19470. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19471. * @param effect The effect to update
  19472. * @param lightIndex The index of the light in the effect to update
  19473. * @returns The hemispheric light
  19474. */
  19475. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19476. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19477. /**
  19478. * Computes the world matrix of the node
  19479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19480. * @param useWasUpdatedFlag defines a reserved property
  19481. * @returns the world matrix
  19482. */
  19483. computeWorldMatrix(): Matrix;
  19484. /**
  19485. * Returns the integer 3.
  19486. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19487. */
  19488. getTypeID(): number;
  19489. /**
  19490. * Prepares the list of defines specific to the light type.
  19491. * @param defines the list of defines
  19492. * @param lightIndex defines the index of the light for the effect
  19493. */
  19494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19495. }
  19496. }
  19497. declare module BABYLON {
  19498. /** @hidden */
  19499. export var vrMultiviewToSingleviewPixelShader: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module BABYLON {
  19505. /**
  19506. * Renders to multiple views with a single draw call
  19507. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19508. */
  19509. export class MultiviewRenderTarget extends RenderTargetTexture {
  19510. /**
  19511. * Creates a multiview render target
  19512. * @param scene scene used with the render target
  19513. * @param size the size of the render target (used for each view)
  19514. */
  19515. constructor(scene: Scene, size?: number | {
  19516. width: number;
  19517. height: number;
  19518. } | {
  19519. ratio: number;
  19520. });
  19521. /**
  19522. * @hidden
  19523. * @param faceIndex the face index, if its a cube texture
  19524. */
  19525. _bindFrameBuffer(faceIndex?: number): void;
  19526. /**
  19527. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19528. * @returns the view count
  19529. */
  19530. getViewCount(): number;
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. interface Engine {
  19535. /**
  19536. * Creates a new multiview render target
  19537. * @param width defines the width of the texture
  19538. * @param height defines the height of the texture
  19539. * @returns the created multiview texture
  19540. */
  19541. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19542. /**
  19543. * Binds a multiview framebuffer to be drawn to
  19544. * @param multiviewTexture texture to bind
  19545. */
  19546. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19547. }
  19548. interface Camera {
  19549. /**
  19550. * @hidden
  19551. * 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)
  19552. */
  19553. _useMultiviewToSingleView: boolean;
  19554. /**
  19555. * @hidden
  19556. * 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)
  19557. */
  19558. _multiviewTexture: Nullable<RenderTargetTexture>;
  19559. /**
  19560. * @hidden
  19561. * ensures the multiview texture of the camera exists and has the specified width/height
  19562. * @param width height to set on the multiview texture
  19563. * @param height width to set on the multiview texture
  19564. */
  19565. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19566. }
  19567. interface Scene {
  19568. /** @hidden */
  19569. _transformMatrixR: Matrix;
  19570. /** @hidden */
  19571. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19572. /** @hidden */
  19573. _createMultiviewUbo(): void;
  19574. /** @hidden */
  19575. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19576. /** @hidden */
  19577. _renderMultiviewToSingleView(camera: Camera): void;
  19578. }
  19579. }
  19580. declare module BABYLON {
  19581. /**
  19582. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19583. * This will not be used for webXR as it supports displaying texture arrays directly
  19584. */
  19585. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19586. /**
  19587. * Initializes a VRMultiviewToSingleview
  19588. * @param name name of the post process
  19589. * @param camera camera to be applied to
  19590. * @param scaleFactor scaling factor to the size of the output texture
  19591. */
  19592. constructor(name: string, camera: Camera, scaleFactor: number);
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * Interface used to define additional presentation attributes
  19598. */
  19599. export interface IVRPresentationAttributes {
  19600. /**
  19601. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19602. */
  19603. highRefreshRate: boolean;
  19604. /**
  19605. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19606. */
  19607. foveationLevel: number;
  19608. }
  19609. interface Engine {
  19610. /** @hidden */
  19611. _vrDisplay: any;
  19612. /** @hidden */
  19613. _vrSupported: boolean;
  19614. /** @hidden */
  19615. _oldSize: Size;
  19616. /** @hidden */
  19617. _oldHardwareScaleFactor: number;
  19618. /** @hidden */
  19619. _vrExclusivePointerMode: boolean;
  19620. /** @hidden */
  19621. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19622. /** @hidden */
  19623. _onVRDisplayPointerRestricted: () => void;
  19624. /** @hidden */
  19625. _onVRDisplayPointerUnrestricted: () => void;
  19626. /** @hidden */
  19627. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19628. /** @hidden */
  19629. _onVrDisplayDisconnect: Nullable<() => void>;
  19630. /** @hidden */
  19631. _onVrDisplayPresentChange: Nullable<() => void>;
  19632. /**
  19633. * Observable signaled when VR display mode changes
  19634. */
  19635. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19636. /**
  19637. * Observable signaled when VR request present is complete
  19638. */
  19639. onVRRequestPresentComplete: Observable<boolean>;
  19640. /**
  19641. * Observable signaled when VR request present starts
  19642. */
  19643. onVRRequestPresentStart: Observable<Engine>;
  19644. /**
  19645. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19646. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19647. */
  19648. isInVRExclusivePointerMode: boolean;
  19649. /**
  19650. * Gets a boolean indicating if a webVR device was detected
  19651. * @returns true if a webVR device was detected
  19652. */
  19653. isVRDevicePresent(): boolean;
  19654. /**
  19655. * Gets the current webVR device
  19656. * @returns the current webVR device (or null)
  19657. */
  19658. getVRDevice(): any;
  19659. /**
  19660. * Initializes a webVR display and starts listening to display change events
  19661. * The onVRDisplayChangedObservable will be notified upon these changes
  19662. * @returns A promise containing a VRDisplay and if vr is supported
  19663. */
  19664. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19665. /** @hidden */
  19666. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19667. /**
  19668. * Gets or sets the presentation attributes used to configure VR rendering
  19669. */
  19670. vrPresentationAttributes?: IVRPresentationAttributes;
  19671. /**
  19672. * Call this function to switch to webVR mode
  19673. * Will do nothing if webVR is not supported or if there is no webVR device
  19674. * @param options the webvr options provided to the camera. mainly used for multiview
  19675. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19676. */
  19677. enableVR(options: WebVROptions): void;
  19678. /** @hidden */
  19679. _onVRFullScreenTriggered(): void;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19685. * IMPORTANT!! The data is right-hand data.
  19686. * @export
  19687. * @interface DevicePose
  19688. */
  19689. export interface DevicePose {
  19690. /**
  19691. * The position of the device, values in array are [x,y,z].
  19692. */
  19693. readonly position: Nullable<Float32Array>;
  19694. /**
  19695. * The linearVelocity of the device, values in array are [x,y,z].
  19696. */
  19697. readonly linearVelocity: Nullable<Float32Array>;
  19698. /**
  19699. * The linearAcceleration of the device, values in array are [x,y,z].
  19700. */
  19701. readonly linearAcceleration: Nullable<Float32Array>;
  19702. /**
  19703. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19704. */
  19705. readonly orientation: Nullable<Float32Array>;
  19706. /**
  19707. * The angularVelocity of the device, values in array are [x,y,z].
  19708. */
  19709. readonly angularVelocity: Nullable<Float32Array>;
  19710. /**
  19711. * The angularAcceleration of the device, values in array are [x,y,z].
  19712. */
  19713. readonly angularAcceleration: Nullable<Float32Array>;
  19714. }
  19715. /**
  19716. * Interface representing a pose controlled object in Babylon.
  19717. * A pose controlled object has both regular pose values as well as pose values
  19718. * from an external device such as a VR head mounted display
  19719. */
  19720. export interface PoseControlled {
  19721. /**
  19722. * The position of the object in babylon space.
  19723. */
  19724. position: Vector3;
  19725. /**
  19726. * The rotation quaternion of the object in babylon space.
  19727. */
  19728. rotationQuaternion: Quaternion;
  19729. /**
  19730. * The position of the device in babylon space.
  19731. */
  19732. devicePosition?: Vector3;
  19733. /**
  19734. * The rotation quaternion of the device in babylon space.
  19735. */
  19736. deviceRotationQuaternion: Quaternion;
  19737. /**
  19738. * The raw pose coming from the device.
  19739. */
  19740. rawPose: Nullable<DevicePose>;
  19741. /**
  19742. * The scale of the device to be used when translating from device space to babylon space.
  19743. */
  19744. deviceScaleFactor: number;
  19745. /**
  19746. * Updates the poseControlled values based on the input device pose.
  19747. * @param poseData the pose data to update the object with
  19748. */
  19749. updateFromDevice(poseData: DevicePose): void;
  19750. }
  19751. /**
  19752. * Set of options to customize the webVRCamera
  19753. */
  19754. export interface WebVROptions {
  19755. /**
  19756. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19757. */
  19758. trackPosition?: boolean;
  19759. /**
  19760. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19761. */
  19762. positionScale?: number;
  19763. /**
  19764. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19765. */
  19766. displayName?: string;
  19767. /**
  19768. * Should the native controller meshes be initialized. (default: true)
  19769. */
  19770. controllerMeshes?: boolean;
  19771. /**
  19772. * Creating a default HemiLight only on controllers. (default: true)
  19773. */
  19774. defaultLightingOnControllers?: boolean;
  19775. /**
  19776. * If you don't want to use the default VR button of the helper. (default: false)
  19777. */
  19778. useCustomVRButton?: boolean;
  19779. /**
  19780. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19781. */
  19782. customVRButton?: HTMLButtonElement;
  19783. /**
  19784. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19785. */
  19786. rayLength?: number;
  19787. /**
  19788. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19789. */
  19790. defaultHeight?: number;
  19791. /**
  19792. * If multiview should be used if availible (default: false)
  19793. */
  19794. useMultiview?: boolean;
  19795. }
  19796. /**
  19797. * This represents a WebVR camera.
  19798. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19799. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19800. */
  19801. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19802. private webVROptions;
  19803. /**
  19804. * @hidden
  19805. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19806. */
  19807. _vrDevice: any;
  19808. /**
  19809. * The rawPose of the vrDevice.
  19810. */
  19811. rawPose: Nullable<DevicePose>;
  19812. private _onVREnabled;
  19813. private _specsVersion;
  19814. private _attached;
  19815. private _frameData;
  19816. protected _descendants: Array<Node>;
  19817. private _deviceRoomPosition;
  19818. /** @hidden */
  19819. _deviceRoomRotationQuaternion: Quaternion;
  19820. private _standingMatrix;
  19821. /**
  19822. * Represents device position in babylon space.
  19823. */
  19824. devicePosition: Vector3;
  19825. /**
  19826. * Represents device rotation in babylon space.
  19827. */
  19828. deviceRotationQuaternion: Quaternion;
  19829. /**
  19830. * The scale of the device to be used when translating from device space to babylon space.
  19831. */
  19832. deviceScaleFactor: number;
  19833. private _deviceToWorld;
  19834. private _worldToDevice;
  19835. /**
  19836. * References to the webVR controllers for the vrDevice.
  19837. */
  19838. controllers: Array<WebVRController>;
  19839. /**
  19840. * Emits an event when a controller is attached.
  19841. */
  19842. onControllersAttachedObservable: Observable<WebVRController[]>;
  19843. /**
  19844. * Emits an event when a controller's mesh has been loaded;
  19845. */
  19846. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19847. /**
  19848. * Emits an event when the HMD's pose has been updated.
  19849. */
  19850. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19851. private _poseSet;
  19852. /**
  19853. * If the rig cameras be used as parent instead of this camera.
  19854. */
  19855. rigParenting: boolean;
  19856. private _lightOnControllers;
  19857. private _defaultHeight?;
  19858. /**
  19859. * Instantiates a WebVRFreeCamera.
  19860. * @param name The name of the WebVRFreeCamera
  19861. * @param position The starting anchor position for the camera
  19862. * @param scene The scene the camera belongs to
  19863. * @param webVROptions a set of customizable options for the webVRCamera
  19864. */
  19865. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19866. /**
  19867. * Gets the device distance from the ground in meters.
  19868. * @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.
  19869. */
  19870. deviceDistanceToRoomGround(): number;
  19871. /**
  19872. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19873. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19874. */
  19875. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19876. /**
  19877. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19878. * @returns A promise with a boolean set to if the standing matrix is supported.
  19879. */
  19880. useStandingMatrixAsync(): Promise<boolean>;
  19881. /**
  19882. * Disposes the camera
  19883. */
  19884. dispose(): void;
  19885. /**
  19886. * Gets a vrController by name.
  19887. * @param name The name of the controller to retreive
  19888. * @returns the controller matching the name specified or null if not found
  19889. */
  19890. getControllerByName(name: string): Nullable<WebVRController>;
  19891. private _leftController;
  19892. /**
  19893. * The controller corresponding to the users left hand.
  19894. */
  19895. get leftController(): Nullable<WebVRController>;
  19896. private _rightController;
  19897. /**
  19898. * The controller corresponding to the users right hand.
  19899. */
  19900. get rightController(): Nullable<WebVRController>;
  19901. /**
  19902. * Casts a ray forward from the vrCamera's gaze.
  19903. * @param length Length of the ray (default: 100)
  19904. * @returns the ray corresponding to the gaze
  19905. */
  19906. getForwardRay(length?: number): Ray;
  19907. /**
  19908. * @hidden
  19909. * Updates the camera based on device's frame data
  19910. */
  19911. _checkInputs(): void;
  19912. /**
  19913. * Updates the poseControlled values based on the input device pose.
  19914. * @param poseData Pose coming from the device
  19915. */
  19916. updateFromDevice(poseData: DevicePose): void;
  19917. private _htmlElementAttached;
  19918. private _detachIfAttached;
  19919. /**
  19920. * WebVR's attach control will start broadcasting frames to the device.
  19921. * Note that in certain browsers (chrome for example) this function must be called
  19922. * within a user-interaction callback. Example:
  19923. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19924. *
  19925. * @param element html element to attach the vrDevice to
  19926. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19927. */
  19928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19929. /**
  19930. * Detaches the camera from the html element and disables VR
  19931. *
  19932. * @param element html element to detach from
  19933. */
  19934. detachControl(element: HTMLElement): void;
  19935. /**
  19936. * @returns the name of this class
  19937. */
  19938. getClassName(): string;
  19939. /**
  19940. * Calls resetPose on the vrDisplay
  19941. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19942. */
  19943. resetToCurrentRotation(): void;
  19944. /**
  19945. * @hidden
  19946. * Updates the rig cameras (left and right eye)
  19947. */
  19948. _updateRigCameras(): void;
  19949. private _workingVector;
  19950. private _oneVector;
  19951. private _workingMatrix;
  19952. private updateCacheCalled;
  19953. private _correctPositionIfNotTrackPosition;
  19954. /**
  19955. * @hidden
  19956. * Updates the cached values of the camera
  19957. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19958. */
  19959. _updateCache(ignoreParentClass?: boolean): void;
  19960. /**
  19961. * @hidden
  19962. * Get current device position in babylon world
  19963. */
  19964. _computeDevicePosition(): void;
  19965. /**
  19966. * Updates the current device position and rotation in the babylon world
  19967. */
  19968. update(): void;
  19969. /**
  19970. * @hidden
  19971. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19972. * @returns an identity matrix
  19973. */
  19974. _getViewMatrix(): Matrix;
  19975. private _tmpMatrix;
  19976. /**
  19977. * This function is called by the two RIG cameras.
  19978. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19979. * @hidden
  19980. */
  19981. _getWebVRViewMatrix(): Matrix;
  19982. /** @hidden */
  19983. _getWebVRProjectionMatrix(): Matrix;
  19984. private _onGamepadConnectedObserver;
  19985. private _onGamepadDisconnectedObserver;
  19986. private _updateCacheWhenTrackingDisabledObserver;
  19987. /**
  19988. * Initializes the controllers and their meshes
  19989. */
  19990. initControllers(): void;
  19991. }
  19992. }
  19993. declare module BABYLON {
  19994. /**
  19995. * "Static Class" containing the most commonly used helper while dealing with material for
  19996. * rendering purpose.
  19997. *
  19998. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19999. *
  20000. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20001. */
  20002. export class MaterialHelper {
  20003. /**
  20004. * Bind the current view position to an effect.
  20005. * @param effect The effect to be bound
  20006. * @param scene The scene the eyes position is used from
  20007. * @param variableName name of the shader variable that will hold the eye position
  20008. */
  20009. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20010. /**
  20011. * Helps preparing the defines values about the UVs in used in the effect.
  20012. * UVs are shared as much as we can accross channels in the shaders.
  20013. * @param texture The texture we are preparing the UVs for
  20014. * @param defines The defines to update
  20015. * @param key The channel key "diffuse", "specular"... used in the shader
  20016. */
  20017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20018. /**
  20019. * Binds a texture matrix value to its corrsponding uniform
  20020. * @param texture The texture to bind the matrix for
  20021. * @param uniformBuffer The uniform buffer receivin the data
  20022. * @param key The channel key "diffuse", "specular"... used in the shader
  20023. */
  20024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20025. /**
  20026. * Gets the current status of the fog (should it be enabled?)
  20027. * @param mesh defines the mesh to evaluate for fog support
  20028. * @param scene defines the hosting scene
  20029. * @returns true if fog must be enabled
  20030. */
  20031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20032. /**
  20033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20034. * @param mesh defines the current mesh
  20035. * @param scene defines the current scene
  20036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20037. * @param pointsCloud defines if point cloud rendering has to be turned on
  20038. * @param fogEnabled defines if fog has to be turned on
  20039. * @param alphaTest defines if alpha testing has to be turned on
  20040. * @param defines defines the current list of defines
  20041. */
  20042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20043. /**
  20044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20045. * @param scene defines the current scene
  20046. * @param engine defines the current engine
  20047. * @param defines specifies the list of active defines
  20048. * @param useInstances defines if instances have to be turned on
  20049. * @param useClipPlane defines if clip plane have to be turned on
  20050. * @param useInstances defines if instances have to be turned on
  20051. * @param useThinInstances defines if thin instances have to be turned on
  20052. */
  20053. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20054. /**
  20055. * Prepares the defines for bones
  20056. * @param mesh The mesh containing the geometry data we will draw
  20057. * @param defines The defines to update
  20058. */
  20059. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20060. /**
  20061. * Prepares the defines for morph targets
  20062. * @param mesh The mesh containing the geometry data we will draw
  20063. * @param defines The defines to update
  20064. */
  20065. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20066. /**
  20067. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20068. * @param mesh The mesh containing the geometry data we will draw
  20069. * @param defines The defines to update
  20070. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20071. * @param useBones Precise whether bones should be used or not (override mesh info)
  20072. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20073. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20074. * @returns false if defines are considered not dirty and have not been checked
  20075. */
  20076. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20077. /**
  20078. * Prepares the defines related to multiview
  20079. * @param scene The scene we are intending to draw
  20080. * @param defines The defines to update
  20081. */
  20082. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20083. /**
  20084. * Prepares the defines related to the light information passed in parameter
  20085. * @param scene The scene we are intending to draw
  20086. * @param mesh The mesh the effect is compiling for
  20087. * @param light The light the effect is compiling for
  20088. * @param lightIndex The index of the light
  20089. * @param defines The defines to update
  20090. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20091. * @param state Defines the current state regarding what is needed (normals, etc...)
  20092. */
  20093. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20094. needNormals: boolean;
  20095. needRebuild: boolean;
  20096. shadowEnabled: boolean;
  20097. specularEnabled: boolean;
  20098. lightmapMode: boolean;
  20099. }): void;
  20100. /**
  20101. * Prepares the defines related to the light information passed in parameter
  20102. * @param scene The scene we are intending to draw
  20103. * @param mesh The mesh the effect is compiling for
  20104. * @param defines The defines to update
  20105. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20106. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20107. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20108. * @returns true if normals will be required for the rest of the effect
  20109. */
  20110. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20111. /**
  20112. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20113. * @param lightIndex defines the light index
  20114. * @param uniformsList The uniform list
  20115. * @param samplersList The sampler list
  20116. * @param projectedLightTexture defines if projected texture must be used
  20117. * @param uniformBuffersList defines an optional list of uniform buffers
  20118. */
  20119. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20120. /**
  20121. * Prepares the uniforms and samplers list to be used in the effect
  20122. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20123. * @param samplersList The sampler list
  20124. * @param defines The defines helping in the list generation
  20125. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20126. */
  20127. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20128. /**
  20129. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20130. * @param defines The defines to update while falling back
  20131. * @param fallbacks The authorized effect fallbacks
  20132. * @param maxSimultaneousLights The maximum number of lights allowed
  20133. * @param rank the current rank of the Effect
  20134. * @returns The newly affected rank
  20135. */
  20136. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20137. private static _TmpMorphInfluencers;
  20138. /**
  20139. * Prepares the list of attributes required for morph targets according to the effect defines.
  20140. * @param attribs The current list of supported attribs
  20141. * @param mesh The mesh to prepare the morph targets attributes for
  20142. * @param influencers The number of influencers
  20143. */
  20144. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20145. /**
  20146. * Prepares the list of attributes required for morph targets according to the effect defines.
  20147. * @param attribs The current list of supported attribs
  20148. * @param mesh The mesh to prepare the morph targets attributes for
  20149. * @param defines The current Defines of the effect
  20150. */
  20151. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20152. /**
  20153. * Prepares the list of attributes required for bones according to the effect defines.
  20154. * @param attribs The current list of supported attribs
  20155. * @param mesh The mesh to prepare the bones attributes for
  20156. * @param defines The current Defines of the effect
  20157. * @param fallbacks The current efffect fallback strategy
  20158. */
  20159. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20160. /**
  20161. * Check and prepare the list of attributes required for instances according to the effect defines.
  20162. * @param attribs The current list of supported attribs
  20163. * @param defines The current MaterialDefines of the effect
  20164. */
  20165. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20166. /**
  20167. * Add the list of attributes required for instances to the attribs array.
  20168. * @param attribs The current list of supported attribs
  20169. */
  20170. static PushAttributesForInstances(attribs: string[]): void;
  20171. /**
  20172. * Binds the light information to the effect.
  20173. * @param light The light containing the generator
  20174. * @param effect The effect we are binding the data to
  20175. * @param lightIndex The light index in the effect used to render
  20176. */
  20177. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20178. /**
  20179. * Binds the lights information from the scene to the effect for the given mesh.
  20180. * @param light Light to bind
  20181. * @param lightIndex Light index
  20182. * @param scene The scene where the light belongs to
  20183. * @param effect The effect we are binding the data to
  20184. * @param useSpecular Defines if specular is supported
  20185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20186. */
  20187. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20188. /**
  20189. * Binds the lights information from the scene to the effect for the given mesh.
  20190. * @param scene The scene the lights belongs to
  20191. * @param mesh The mesh we are binding the information to render
  20192. * @param effect The effect we are binding the data to
  20193. * @param defines The generated defines for the effect
  20194. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20196. */
  20197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20198. private static _tempFogColor;
  20199. /**
  20200. * Binds the fog information from the scene to the effect for the given mesh.
  20201. * @param scene The scene the lights belongs to
  20202. * @param mesh The mesh we are binding the information to render
  20203. * @param effect The effect we are binding the data to
  20204. * @param linearSpace Defines if the fog effect is applied in linear space
  20205. */
  20206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20207. /**
  20208. * Binds the bones information from the mesh to the effect.
  20209. * @param mesh The mesh we are binding the information to render
  20210. * @param effect The effect we are binding the data to
  20211. */
  20212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20213. /**
  20214. * Binds the morph targets information from the mesh to the effect.
  20215. * @param abstractMesh The mesh we are binding the information to render
  20216. * @param effect The effect we are binding the data to
  20217. */
  20218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20219. /**
  20220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20221. * @param defines The generated defines used in the effect
  20222. * @param effect The effect we are binding the data to
  20223. * @param scene The scene we are willing to render with logarithmic scale for
  20224. */
  20225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20226. /**
  20227. * Binds the clip plane information from the scene to the effect.
  20228. * @param scene The scene the clip plane information are extracted from
  20229. * @param effect The effect we are binding the data to
  20230. */
  20231. static BindClipPlane(effect: Effect, scene: Scene): void;
  20232. }
  20233. }
  20234. declare module BABYLON {
  20235. /**
  20236. * Block used to expose an input value
  20237. */
  20238. export class InputBlock extends NodeMaterialBlock {
  20239. private _mode;
  20240. private _associatedVariableName;
  20241. private _storedValue;
  20242. private _valueCallback;
  20243. private _type;
  20244. private _animationType;
  20245. /** Gets or set a value used to limit the range of float values */
  20246. min: number;
  20247. /** Gets or set a value used to limit the range of float values */
  20248. max: number;
  20249. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20250. isBoolean: boolean;
  20251. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20252. matrixMode: number;
  20253. /** @hidden */
  20254. _systemValue: Nullable<NodeMaterialSystemValues>;
  20255. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20256. visibleInInspector: boolean;
  20257. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20258. isConstant: boolean;
  20259. /** Gets or sets the group to use to display this block in the Inspector */
  20260. groupInInspector: string;
  20261. /** Gets an observable raised when the value is changed */
  20262. onValueChangedObservable: Observable<InputBlock>;
  20263. /**
  20264. * Gets or sets the connection point type (default is float)
  20265. */
  20266. get type(): NodeMaterialBlockConnectionPointTypes;
  20267. /**
  20268. * Creates a new InputBlock
  20269. * @param name defines the block name
  20270. * @param target defines the target of that block (Vertex by default)
  20271. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20272. */
  20273. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20274. /**
  20275. * Gets the output component
  20276. */
  20277. get output(): NodeMaterialConnectionPoint;
  20278. /**
  20279. * Set the source of this connection point to a vertex attribute
  20280. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20281. * @returns the current connection point
  20282. */
  20283. setAsAttribute(attributeName?: string): InputBlock;
  20284. /**
  20285. * Set the source of this connection point to a system value
  20286. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20287. * @returns the current connection point
  20288. */
  20289. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20290. /**
  20291. * Gets or sets the value of that point.
  20292. * Please note that this value will be ignored if valueCallback is defined
  20293. */
  20294. get value(): any;
  20295. set value(value: any);
  20296. /**
  20297. * Gets or sets a callback used to get the value of that point.
  20298. * Please note that setting this value will force the connection point to ignore the value property
  20299. */
  20300. get valueCallback(): () => any;
  20301. set valueCallback(value: () => any);
  20302. /**
  20303. * Gets or sets the associated variable name in the shader
  20304. */
  20305. get associatedVariableName(): string;
  20306. set associatedVariableName(value: string);
  20307. /** Gets or sets the type of animation applied to the input */
  20308. get animationType(): AnimatedInputBlockTypes;
  20309. set animationType(value: AnimatedInputBlockTypes);
  20310. /**
  20311. * Gets a boolean indicating that this connection point not defined yet
  20312. */
  20313. get isUndefined(): boolean;
  20314. /**
  20315. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20316. * In this case the connection point name must be the name of the uniform to use.
  20317. * Can only be set on inputs
  20318. */
  20319. get isUniform(): boolean;
  20320. set isUniform(value: boolean);
  20321. /**
  20322. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20323. * In this case the connection point name must be the name of the attribute to use
  20324. * Can only be set on inputs
  20325. */
  20326. get isAttribute(): boolean;
  20327. set isAttribute(value: boolean);
  20328. /**
  20329. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20330. * Can only be set on exit points
  20331. */
  20332. get isVarying(): boolean;
  20333. set isVarying(value: boolean);
  20334. /**
  20335. * Gets a boolean indicating that the current connection point is a system value
  20336. */
  20337. get isSystemValue(): boolean;
  20338. /**
  20339. * Gets or sets the current well known value or null if not defined as a system value
  20340. */
  20341. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20342. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20343. /**
  20344. * Gets the current class name
  20345. * @returns the class name
  20346. */
  20347. getClassName(): string;
  20348. /**
  20349. * Animate the input if animationType !== None
  20350. * @param scene defines the rendering scene
  20351. */
  20352. animate(scene: Scene): void;
  20353. private _emitDefine;
  20354. initialize(state: NodeMaterialBuildState): void;
  20355. /**
  20356. * Set the input block to its default value (based on its type)
  20357. */
  20358. setDefaultValue(): void;
  20359. private _emitConstant;
  20360. /** @hidden */
  20361. get _noContextSwitch(): boolean;
  20362. private _emit;
  20363. /** @hidden */
  20364. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20365. /** @hidden */
  20366. _transmit(effect: Effect, scene: Scene): void;
  20367. protected _buildBlock(state: NodeMaterialBuildState): void;
  20368. protected _dumpPropertiesCode(): string;
  20369. dispose(): void;
  20370. serialize(): any;
  20371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20372. }
  20373. }
  20374. declare module BABYLON {
  20375. /**
  20376. * Enum used to define the compatibility state between two connection points
  20377. */
  20378. export enum NodeMaterialConnectionPointCompatibilityStates {
  20379. /** Points are compatibles */
  20380. Compatible = 0,
  20381. /** Points are incompatible because of their types */
  20382. TypeIncompatible = 1,
  20383. /** Points are incompatible because of their targets (vertex vs fragment) */
  20384. TargetIncompatible = 2
  20385. }
  20386. /**
  20387. * Defines the direction of a connection point
  20388. */
  20389. export enum NodeMaterialConnectionPointDirection {
  20390. /** Input */
  20391. Input = 0,
  20392. /** Output */
  20393. Output = 1
  20394. }
  20395. /**
  20396. * Defines a connection point for a block
  20397. */
  20398. export class NodeMaterialConnectionPoint {
  20399. /** @hidden */
  20400. _ownerBlock: NodeMaterialBlock;
  20401. /** @hidden */
  20402. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20403. private _endpoints;
  20404. private _associatedVariableName;
  20405. private _direction;
  20406. /** @hidden */
  20407. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20408. /** @hidden */
  20409. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20410. private _type;
  20411. /** @hidden */
  20412. _enforceAssociatedVariableName: boolean;
  20413. /** Gets the direction of the point */
  20414. get direction(): NodeMaterialConnectionPointDirection;
  20415. /** Indicates that this connection point needs dual validation before being connected to another point */
  20416. needDualDirectionValidation: boolean;
  20417. /**
  20418. * Gets or sets the additional types supported by this connection point
  20419. */
  20420. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20421. /**
  20422. * Gets or sets the additional types excluded by this connection point
  20423. */
  20424. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20425. /**
  20426. * Observable triggered when this point is connected
  20427. */
  20428. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20429. /**
  20430. * Gets or sets the associated variable name in the shader
  20431. */
  20432. get associatedVariableName(): string;
  20433. set associatedVariableName(value: string);
  20434. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20435. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20436. /**
  20437. * Gets or sets the connection point type (default is float)
  20438. */
  20439. get type(): NodeMaterialBlockConnectionPointTypes;
  20440. set type(value: NodeMaterialBlockConnectionPointTypes);
  20441. /**
  20442. * Gets or sets the connection point name
  20443. */
  20444. name: string;
  20445. /**
  20446. * Gets or sets the connection point name
  20447. */
  20448. displayName: string;
  20449. /**
  20450. * Gets or sets a boolean indicating that this connection point can be omitted
  20451. */
  20452. isOptional: boolean;
  20453. /**
  20454. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20455. */
  20456. isExposedOnFrame: boolean;
  20457. /**
  20458. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20459. */
  20460. define: string;
  20461. /** @hidden */
  20462. _prioritizeVertex: boolean;
  20463. private _target;
  20464. /** Gets or sets the target of that connection point */
  20465. get target(): NodeMaterialBlockTargets;
  20466. set target(value: NodeMaterialBlockTargets);
  20467. /**
  20468. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20469. */
  20470. get isConnected(): boolean;
  20471. /**
  20472. * Gets a boolean indicating that the current point is connected to an input block
  20473. */
  20474. get isConnectedToInputBlock(): boolean;
  20475. /**
  20476. * Gets a the connected input block (if any)
  20477. */
  20478. get connectInputBlock(): Nullable<InputBlock>;
  20479. /** Get the other side of the connection (if any) */
  20480. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20481. /** Get the block that owns this connection point */
  20482. get ownerBlock(): NodeMaterialBlock;
  20483. /** Get the block connected on the other side of this connection (if any) */
  20484. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20485. /** Get the block connected on the endpoints of this connection (if any) */
  20486. get connectedBlocks(): Array<NodeMaterialBlock>;
  20487. /** Gets the list of connected endpoints */
  20488. get endpoints(): NodeMaterialConnectionPoint[];
  20489. /** Gets a boolean indicating if that output point is connected to at least one input */
  20490. get hasEndpoints(): boolean;
  20491. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20492. get isConnectedInVertexShader(): boolean;
  20493. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20494. get isConnectedInFragmentShader(): boolean;
  20495. /**
  20496. * Creates a block suitable to be used as an input for this input point.
  20497. * If null is returned, a block based on the point type will be created.
  20498. * @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
  20499. */
  20500. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20501. /**
  20502. * Creates a new connection point
  20503. * @param name defines the connection point name
  20504. * @param ownerBlock defines the block hosting this connection point
  20505. * @param direction defines the direction of the connection point
  20506. */
  20507. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20508. /**
  20509. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20510. * @returns the class name
  20511. */
  20512. getClassName(): string;
  20513. /**
  20514. * Gets a boolean indicating if the current point can be connected to another point
  20515. * @param connectionPoint defines the other connection point
  20516. * @returns a boolean
  20517. */
  20518. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20519. /**
  20520. * Gets a number indicating if the current point can be connected to another point
  20521. * @param connectionPoint defines the other connection point
  20522. * @returns a number defining the compatibility state
  20523. */
  20524. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20525. /**
  20526. * Connect this point to another connection point
  20527. * @param connectionPoint defines the other connection point
  20528. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20529. * @returns the current connection point
  20530. */
  20531. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20532. /**
  20533. * Disconnect this point from one of his endpoint
  20534. * @param endpoint defines the other connection point
  20535. * @returns the current connection point
  20536. */
  20537. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20538. /**
  20539. * Serializes this point in a JSON representation
  20540. * @param isInput defines if the connection point is an input (default is true)
  20541. * @returns the serialized point object
  20542. */
  20543. serialize(isInput?: boolean): any;
  20544. /**
  20545. * Release resources
  20546. */
  20547. dispose(): void;
  20548. }
  20549. }
  20550. declare module BABYLON {
  20551. /**
  20552. * Enum used to define the material modes
  20553. */
  20554. export enum NodeMaterialModes {
  20555. /** Regular material */
  20556. Material = 0,
  20557. /** For post process */
  20558. PostProcess = 1,
  20559. /** For particle system */
  20560. Particle = 2
  20561. }
  20562. }
  20563. declare module BABYLON {
  20564. /**
  20565. * Block used to read a texture from a sampler
  20566. */
  20567. export class TextureBlock extends NodeMaterialBlock {
  20568. private _defineName;
  20569. private _linearDefineName;
  20570. private _gammaDefineName;
  20571. private _tempTextureRead;
  20572. private _samplerName;
  20573. private _transformedUVName;
  20574. private _textureTransformName;
  20575. private _textureInfoName;
  20576. private _mainUVName;
  20577. private _mainUVDefineName;
  20578. private _fragmentOnly;
  20579. /**
  20580. * Gets or sets the texture associated with the node
  20581. */
  20582. texture: Nullable<Texture>;
  20583. /**
  20584. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20585. */
  20586. convertToGammaSpace: boolean;
  20587. /**
  20588. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20589. */
  20590. convertToLinearSpace: boolean;
  20591. /**
  20592. * Create a new TextureBlock
  20593. * @param name defines the block name
  20594. */
  20595. constructor(name: string, fragmentOnly?: boolean);
  20596. /**
  20597. * Gets the current class name
  20598. * @returns the class name
  20599. */
  20600. getClassName(): string;
  20601. /**
  20602. * Gets the uv input component
  20603. */
  20604. get uv(): NodeMaterialConnectionPoint;
  20605. /**
  20606. * Gets the rgba output component
  20607. */
  20608. get rgba(): NodeMaterialConnectionPoint;
  20609. /**
  20610. * Gets the rgb output component
  20611. */
  20612. get rgb(): NodeMaterialConnectionPoint;
  20613. /**
  20614. * Gets the r output component
  20615. */
  20616. get r(): NodeMaterialConnectionPoint;
  20617. /**
  20618. * Gets the g output component
  20619. */
  20620. get g(): NodeMaterialConnectionPoint;
  20621. /**
  20622. * Gets the b output component
  20623. */
  20624. get b(): NodeMaterialConnectionPoint;
  20625. /**
  20626. * Gets the a output component
  20627. */
  20628. get a(): NodeMaterialConnectionPoint;
  20629. get target(): NodeMaterialBlockTargets;
  20630. autoConfigure(material: NodeMaterial): void;
  20631. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20633. isReady(): boolean;
  20634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20635. private get _isMixed();
  20636. private _injectVertexCode;
  20637. private _writeTextureRead;
  20638. private _writeOutput;
  20639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20640. protected _dumpPropertiesCode(): string;
  20641. serialize(): any;
  20642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20643. }
  20644. }
  20645. declare module BABYLON {
  20646. /** @hidden */
  20647. export var reflectionFunction: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module BABYLON {
  20653. /**
  20654. * Base block used to read a reflection texture from a sampler
  20655. */
  20656. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20657. /** @hidden */
  20658. _define3DName: string;
  20659. /** @hidden */
  20660. _defineCubicName: string;
  20661. /** @hidden */
  20662. _defineExplicitName: string;
  20663. /** @hidden */
  20664. _defineProjectionName: string;
  20665. /** @hidden */
  20666. _defineLocalCubicName: string;
  20667. /** @hidden */
  20668. _defineSphericalName: string;
  20669. /** @hidden */
  20670. _definePlanarName: string;
  20671. /** @hidden */
  20672. _defineEquirectangularName: string;
  20673. /** @hidden */
  20674. _defineMirroredEquirectangularFixedName: string;
  20675. /** @hidden */
  20676. _defineEquirectangularFixedName: string;
  20677. /** @hidden */
  20678. _defineSkyboxName: string;
  20679. /** @hidden */
  20680. _defineOppositeZ: string;
  20681. /** @hidden */
  20682. _cubeSamplerName: string;
  20683. /** @hidden */
  20684. _2DSamplerName: string;
  20685. protected _positionUVWName: string;
  20686. protected _directionWName: string;
  20687. protected _reflectionVectorName: string;
  20688. /** @hidden */
  20689. _reflectionCoordsName: string;
  20690. /** @hidden */
  20691. _reflectionMatrixName: string;
  20692. protected _reflectionColorName: string;
  20693. /**
  20694. * Gets or sets the texture associated with the node
  20695. */
  20696. texture: Nullable<BaseTexture>;
  20697. /**
  20698. * Create a new ReflectionTextureBaseBlock
  20699. * @param name defines the block name
  20700. */
  20701. constructor(name: string);
  20702. /**
  20703. * Gets the current class name
  20704. * @returns the class name
  20705. */
  20706. getClassName(): string;
  20707. /**
  20708. * Gets the world position input component
  20709. */
  20710. abstract get position(): NodeMaterialConnectionPoint;
  20711. /**
  20712. * Gets the world position input component
  20713. */
  20714. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20715. /**
  20716. * Gets the world normal input component
  20717. */
  20718. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20719. /**
  20720. * Gets the world input component
  20721. */
  20722. abstract get world(): NodeMaterialConnectionPoint;
  20723. /**
  20724. * Gets the camera (or eye) position component
  20725. */
  20726. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20727. /**
  20728. * Gets the view input component
  20729. */
  20730. abstract get view(): NodeMaterialConnectionPoint;
  20731. protected _getTexture(): Nullable<BaseTexture>;
  20732. autoConfigure(material: NodeMaterial): void;
  20733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20734. isReady(): boolean;
  20735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20736. /**
  20737. * Gets the code to inject in the vertex shader
  20738. * @param state current state of the node material building
  20739. * @returns the shader code
  20740. */
  20741. handleVertexSide(state: NodeMaterialBuildState): string;
  20742. /**
  20743. * Handles the inits for the fragment code path
  20744. * @param state node material build state
  20745. */
  20746. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20747. /**
  20748. * Generates the reflection coords code for the fragment code path
  20749. * @param worldNormalVarName name of the world normal variable
  20750. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20751. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20752. * @returns the shader code
  20753. */
  20754. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20755. /**
  20756. * Generates the reflection color code for the fragment code path
  20757. * @param lodVarName name of the lod variable
  20758. * @param swizzleLookupTexture swizzle to use for the final color variable
  20759. * @returns the shader code
  20760. */
  20761. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20762. /**
  20763. * Generates the code corresponding to the connected output points
  20764. * @param state node material build state
  20765. * @param varName name of the variable to output
  20766. * @returns the shader code
  20767. */
  20768. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20769. protected _buildBlock(state: NodeMaterialBuildState): this;
  20770. protected _dumpPropertiesCode(): string;
  20771. serialize(): any;
  20772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20773. }
  20774. }
  20775. declare module BABYLON {
  20776. /**
  20777. * Defines a connection point to be used for points with a custom object type
  20778. */
  20779. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20780. private _blockType;
  20781. private _blockName;
  20782. private _nameForCheking?;
  20783. /**
  20784. * Creates a new connection point
  20785. * @param name defines the connection point name
  20786. * @param ownerBlock defines the block hosting this connection point
  20787. * @param direction defines the direction of the connection point
  20788. */
  20789. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20790. /**
  20791. * Gets a number indicating if the current point can be connected to another point
  20792. * @param connectionPoint defines the other connection point
  20793. * @returns a number defining the compatibility state
  20794. */
  20795. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20796. /**
  20797. * Creates a block suitable to be used as an input for this input point.
  20798. * If null is returned, a block based on the point type will be created.
  20799. * @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
  20800. */
  20801. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20802. }
  20803. }
  20804. declare module BABYLON {
  20805. /**
  20806. * Enum defining the type of properties that can be edited in the property pages in the NME
  20807. */
  20808. export enum PropertyTypeForEdition {
  20809. /** property is a boolean */
  20810. Boolean = 0,
  20811. /** property is a float */
  20812. Float = 1,
  20813. /** property is a Vector2 */
  20814. Vector2 = 2,
  20815. /** property is a list of values */
  20816. List = 3
  20817. }
  20818. /**
  20819. * Interface that defines an option in a variable of type list
  20820. */
  20821. export interface IEditablePropertyListOption {
  20822. /** label of the option */
  20823. "label": string;
  20824. /** value of the option */
  20825. "value": number;
  20826. }
  20827. /**
  20828. * Interface that defines the options available for an editable property
  20829. */
  20830. export interface IEditablePropertyOption {
  20831. /** min value */
  20832. "min"?: number;
  20833. /** max value */
  20834. "max"?: number;
  20835. /** notifiers: indicates which actions to take when the property is changed */
  20836. "notifiers"?: {
  20837. /** the material should be rebuilt */
  20838. "rebuild"?: boolean;
  20839. /** the preview should be updated */
  20840. "update"?: boolean;
  20841. };
  20842. /** list of the options for a variable of type list */
  20843. "options"?: IEditablePropertyListOption[];
  20844. }
  20845. /**
  20846. * Interface that describes an editable property
  20847. */
  20848. export interface IPropertyDescriptionForEdition {
  20849. /** name of the property */
  20850. "propertyName": string;
  20851. /** display name of the property */
  20852. "displayName": string;
  20853. /** type of the property */
  20854. "type": PropertyTypeForEdition;
  20855. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20856. "groupName": string;
  20857. /** options for the property */
  20858. "options": IEditablePropertyOption;
  20859. }
  20860. /**
  20861. * Decorator that flags a property in a node material block as being editable
  20862. */
  20863. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20864. }
  20865. declare module BABYLON {
  20866. /**
  20867. * Block used to implement the refraction part of the sub surface module of the PBR material
  20868. */
  20869. export class RefractionBlock extends NodeMaterialBlock {
  20870. /** @hidden */
  20871. _define3DName: string;
  20872. /** @hidden */
  20873. _refractionMatrixName: string;
  20874. /** @hidden */
  20875. _defineLODRefractionAlpha: string;
  20876. /** @hidden */
  20877. _defineLinearSpecularRefraction: string;
  20878. /** @hidden */
  20879. _defineOppositeZ: string;
  20880. /** @hidden */
  20881. _cubeSamplerName: string;
  20882. /** @hidden */
  20883. _2DSamplerName: string;
  20884. /** @hidden */
  20885. _vRefractionMicrosurfaceInfosName: string;
  20886. /** @hidden */
  20887. _vRefractionInfosName: string;
  20888. private _scene;
  20889. /**
  20890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20891. * Materials half opaque for instance using refraction could benefit from this control.
  20892. */
  20893. linkRefractionWithTransparency: boolean;
  20894. /**
  20895. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20896. */
  20897. invertRefractionY: boolean;
  20898. /**
  20899. * Gets or sets the texture associated with the node
  20900. */
  20901. texture: Nullable<BaseTexture>;
  20902. /**
  20903. * Create a new RefractionBlock
  20904. * @param name defines the block name
  20905. */
  20906. constructor(name: string);
  20907. /**
  20908. * Gets the current class name
  20909. * @returns the class name
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Gets the intensity input component
  20914. */
  20915. get intensity(): NodeMaterialConnectionPoint;
  20916. /**
  20917. * Gets the index of refraction input component
  20918. */
  20919. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20920. /**
  20921. * Gets the tint at distance input component
  20922. */
  20923. get tintAtDistance(): NodeMaterialConnectionPoint;
  20924. /**
  20925. * Gets the view input component
  20926. */
  20927. get view(): NodeMaterialConnectionPoint;
  20928. /**
  20929. * Gets the refraction object output component
  20930. */
  20931. get refraction(): NodeMaterialConnectionPoint;
  20932. /**
  20933. * Returns true if the block has a texture
  20934. */
  20935. get hasTexture(): boolean;
  20936. protected _getTexture(): Nullable<BaseTexture>;
  20937. autoConfigure(material: NodeMaterial): void;
  20938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20939. isReady(): boolean;
  20940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20941. /**
  20942. * Gets the main code of the block (fragment side)
  20943. * @param state current state of the node material building
  20944. * @returns the shader code
  20945. */
  20946. getCode(state: NodeMaterialBuildState): string;
  20947. protected _buildBlock(state: NodeMaterialBuildState): this;
  20948. protected _dumpPropertiesCode(): string;
  20949. serialize(): any;
  20950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20951. }
  20952. }
  20953. declare module BABYLON {
  20954. /**
  20955. * Base block used as input for post process
  20956. */
  20957. export class CurrentScreenBlock extends NodeMaterialBlock {
  20958. private _samplerName;
  20959. private _linearDefineName;
  20960. private _gammaDefineName;
  20961. private _mainUVName;
  20962. private _tempTextureRead;
  20963. /**
  20964. * Gets or sets the texture associated with the node
  20965. */
  20966. texture: Nullable<BaseTexture>;
  20967. /**
  20968. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20969. */
  20970. convertToGammaSpace: boolean;
  20971. /**
  20972. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20973. */
  20974. convertToLinearSpace: boolean;
  20975. /**
  20976. * Create a new CurrentScreenBlock
  20977. * @param name defines the block name
  20978. */
  20979. constructor(name: string);
  20980. /**
  20981. * Gets the current class name
  20982. * @returns the class name
  20983. */
  20984. getClassName(): string;
  20985. /**
  20986. * Gets the uv input component
  20987. */
  20988. get uv(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the rgba output component
  20991. */
  20992. get rgba(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the rgb output component
  20995. */
  20996. get rgb(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the r output component
  20999. */
  21000. get r(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Gets the g output component
  21003. */
  21004. get g(): NodeMaterialConnectionPoint;
  21005. /**
  21006. * Gets the b output component
  21007. */
  21008. get b(): NodeMaterialConnectionPoint;
  21009. /**
  21010. * Gets the a output component
  21011. */
  21012. get a(): NodeMaterialConnectionPoint;
  21013. /**
  21014. * Initialize the block and prepare the context for build
  21015. * @param state defines the state that will be used for the build
  21016. */
  21017. initialize(state: NodeMaterialBuildState): void;
  21018. get target(): NodeMaterialBlockTargets;
  21019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21020. isReady(): boolean;
  21021. private _injectVertexCode;
  21022. private _writeTextureRead;
  21023. private _writeOutput;
  21024. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21025. serialize(): any;
  21026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21027. }
  21028. }
  21029. declare module BABYLON {
  21030. /**
  21031. * Base block used for the particle texture
  21032. */
  21033. export class ParticleTextureBlock extends NodeMaterialBlock {
  21034. private _samplerName;
  21035. private _linearDefineName;
  21036. private _gammaDefineName;
  21037. private _tempTextureRead;
  21038. /**
  21039. * Gets or sets the texture associated with the node
  21040. */
  21041. texture: Nullable<BaseTexture>;
  21042. /**
  21043. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21044. */
  21045. convertToGammaSpace: boolean;
  21046. /**
  21047. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21048. */
  21049. convertToLinearSpace: boolean;
  21050. /**
  21051. * Create a new ParticleTextureBlock
  21052. * @param name defines the block name
  21053. */
  21054. constructor(name: string);
  21055. /**
  21056. * Gets the current class name
  21057. * @returns the class name
  21058. */
  21059. getClassName(): string;
  21060. /**
  21061. * Gets the uv input component
  21062. */
  21063. get uv(): NodeMaterialConnectionPoint;
  21064. /**
  21065. * Gets the rgba output component
  21066. */
  21067. get rgba(): NodeMaterialConnectionPoint;
  21068. /**
  21069. * Gets the rgb output component
  21070. */
  21071. get rgb(): NodeMaterialConnectionPoint;
  21072. /**
  21073. * Gets the r output component
  21074. */
  21075. get r(): NodeMaterialConnectionPoint;
  21076. /**
  21077. * Gets the g output component
  21078. */
  21079. get g(): NodeMaterialConnectionPoint;
  21080. /**
  21081. * Gets the b output component
  21082. */
  21083. get b(): NodeMaterialConnectionPoint;
  21084. /**
  21085. * Gets the a output component
  21086. */
  21087. get a(): NodeMaterialConnectionPoint;
  21088. /**
  21089. * Initialize the block and prepare the context for build
  21090. * @param state defines the state that will be used for the build
  21091. */
  21092. initialize(state: NodeMaterialBuildState): void;
  21093. autoConfigure(material: NodeMaterial): void;
  21094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21095. isReady(): boolean;
  21096. private _writeOutput;
  21097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21098. serialize(): any;
  21099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21100. }
  21101. }
  21102. declare module BABYLON {
  21103. /**
  21104. * Class used to store shared data between 2 NodeMaterialBuildState
  21105. */
  21106. export class NodeMaterialBuildStateSharedData {
  21107. /**
  21108. * Gets the list of emitted varyings
  21109. */
  21110. temps: string[];
  21111. /**
  21112. * Gets the list of emitted varyings
  21113. */
  21114. varyings: string[];
  21115. /**
  21116. * Gets the varying declaration string
  21117. */
  21118. varyingDeclaration: string;
  21119. /**
  21120. * Input blocks
  21121. */
  21122. inputBlocks: InputBlock[];
  21123. /**
  21124. * Input blocks
  21125. */
  21126. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21127. /**
  21128. * Bindable blocks (Blocks that need to set data to the effect)
  21129. */
  21130. bindableBlocks: NodeMaterialBlock[];
  21131. /**
  21132. * List of blocks that can provide a compilation fallback
  21133. */
  21134. blocksWithFallbacks: NodeMaterialBlock[];
  21135. /**
  21136. * List of blocks that can provide a define update
  21137. */
  21138. blocksWithDefines: NodeMaterialBlock[];
  21139. /**
  21140. * List of blocks that can provide a repeatable content
  21141. */
  21142. repeatableContentBlocks: NodeMaterialBlock[];
  21143. /**
  21144. * List of blocks that can provide a dynamic list of uniforms
  21145. */
  21146. dynamicUniformBlocks: NodeMaterialBlock[];
  21147. /**
  21148. * List of blocks that can block the isReady function for the material
  21149. */
  21150. blockingBlocks: NodeMaterialBlock[];
  21151. /**
  21152. * Gets the list of animated inputs
  21153. */
  21154. animatedInputs: InputBlock[];
  21155. /**
  21156. * Build Id used to avoid multiple recompilations
  21157. */
  21158. buildId: number;
  21159. /** List of emitted variables */
  21160. variableNames: {
  21161. [key: string]: number;
  21162. };
  21163. /** List of emitted defines */
  21164. defineNames: {
  21165. [key: string]: number;
  21166. };
  21167. /** Should emit comments? */
  21168. emitComments: boolean;
  21169. /** Emit build activity */
  21170. verbose: boolean;
  21171. /** Gets or sets the hosting scene */
  21172. scene: Scene;
  21173. /**
  21174. * Gets the compilation hints emitted at compilation time
  21175. */
  21176. hints: {
  21177. needWorldViewMatrix: boolean;
  21178. needWorldViewProjectionMatrix: boolean;
  21179. needAlphaBlending: boolean;
  21180. needAlphaTesting: boolean;
  21181. };
  21182. /**
  21183. * List of compilation checks
  21184. */
  21185. checks: {
  21186. emitVertex: boolean;
  21187. emitFragment: boolean;
  21188. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21189. };
  21190. /**
  21191. * Is vertex program allowed to be empty?
  21192. */
  21193. allowEmptyVertexProgram: boolean;
  21194. /** Creates a new shared data */
  21195. constructor();
  21196. /**
  21197. * Emits console errors and exceptions if there is a failing check
  21198. */
  21199. emitErrors(): void;
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Class used to store node based material build state
  21205. */
  21206. export class NodeMaterialBuildState {
  21207. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21208. supportUniformBuffers: boolean;
  21209. /**
  21210. * Gets the list of emitted attributes
  21211. */
  21212. attributes: string[];
  21213. /**
  21214. * Gets the list of emitted uniforms
  21215. */
  21216. uniforms: string[];
  21217. /**
  21218. * Gets the list of emitted constants
  21219. */
  21220. constants: string[];
  21221. /**
  21222. * Gets the list of emitted samplers
  21223. */
  21224. samplers: string[];
  21225. /**
  21226. * Gets the list of emitted functions
  21227. */
  21228. functions: {
  21229. [key: string]: string;
  21230. };
  21231. /**
  21232. * Gets the list of emitted extensions
  21233. */
  21234. extensions: {
  21235. [key: string]: string;
  21236. };
  21237. /**
  21238. * Gets the target of the compilation state
  21239. */
  21240. target: NodeMaterialBlockTargets;
  21241. /**
  21242. * Gets the list of emitted counters
  21243. */
  21244. counters: {
  21245. [key: string]: number;
  21246. };
  21247. /**
  21248. * Shared data between multiple NodeMaterialBuildState instances
  21249. */
  21250. sharedData: NodeMaterialBuildStateSharedData;
  21251. /** @hidden */
  21252. _vertexState: NodeMaterialBuildState;
  21253. /** @hidden */
  21254. _attributeDeclaration: string;
  21255. /** @hidden */
  21256. _uniformDeclaration: string;
  21257. /** @hidden */
  21258. _constantDeclaration: string;
  21259. /** @hidden */
  21260. _samplerDeclaration: string;
  21261. /** @hidden */
  21262. _varyingTransfer: string;
  21263. /** @hidden */
  21264. _injectAtEnd: string;
  21265. private _repeatableContentAnchorIndex;
  21266. /** @hidden */
  21267. _builtCompilationString: string;
  21268. /**
  21269. * Gets the emitted compilation strings
  21270. */
  21271. compilationString: string;
  21272. /**
  21273. * Finalize the compilation strings
  21274. * @param state defines the current compilation state
  21275. */
  21276. finalize(state: NodeMaterialBuildState): void;
  21277. /** @hidden */
  21278. get _repeatableContentAnchor(): string;
  21279. /** @hidden */
  21280. _getFreeVariableName(prefix: string): string;
  21281. /** @hidden */
  21282. _getFreeDefineName(prefix: string): string;
  21283. /** @hidden */
  21284. _excludeVariableName(name: string): void;
  21285. /** @hidden */
  21286. _emit2DSampler(name: string): void;
  21287. /** @hidden */
  21288. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21289. /** @hidden */
  21290. _emitExtension(name: string, extension: string, define?: string): void;
  21291. /** @hidden */
  21292. _emitFunction(name: string, code: string, comments: string): void;
  21293. /** @hidden */
  21294. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21295. replaceStrings?: {
  21296. search: RegExp;
  21297. replace: string;
  21298. }[];
  21299. repeatKey?: string;
  21300. }): string;
  21301. /** @hidden */
  21302. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21303. repeatKey?: string;
  21304. removeAttributes?: boolean;
  21305. removeUniforms?: boolean;
  21306. removeVaryings?: boolean;
  21307. removeIfDef?: boolean;
  21308. replaceStrings?: {
  21309. search: RegExp;
  21310. replace: string;
  21311. }[];
  21312. }, storeKey?: string): void;
  21313. /** @hidden */
  21314. _registerTempVariable(name: string): boolean;
  21315. /** @hidden */
  21316. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21317. /** @hidden */
  21318. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21319. /** @hidden */
  21320. _emitFloat(value: number): string;
  21321. }
  21322. }
  21323. declare module BABYLON {
  21324. /**
  21325. * Helper class used to generate session unique ID
  21326. */
  21327. export class UniqueIdGenerator {
  21328. private static _UniqueIdCounter;
  21329. /**
  21330. * Gets an unique (relatively to the current scene) Id
  21331. */
  21332. static get UniqueId(): number;
  21333. }
  21334. }
  21335. declare module BABYLON {
  21336. /**
  21337. * Defines a block that can be used inside a node based material
  21338. */
  21339. export class NodeMaterialBlock {
  21340. private _buildId;
  21341. private _buildTarget;
  21342. private _target;
  21343. private _isFinalMerger;
  21344. private _isInput;
  21345. protected _isUnique: boolean;
  21346. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21347. inputsAreExclusive: boolean;
  21348. /** @hidden */
  21349. _codeVariableName: string;
  21350. /** @hidden */
  21351. _inputs: NodeMaterialConnectionPoint[];
  21352. /** @hidden */
  21353. _outputs: NodeMaterialConnectionPoint[];
  21354. /** @hidden */
  21355. _preparationId: number;
  21356. /**
  21357. * Gets or sets the name of the block
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the unique id of the node
  21362. */
  21363. uniqueId: number;
  21364. /**
  21365. * Gets or sets the comments associated with this block
  21366. */
  21367. comments: string;
  21368. /**
  21369. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21370. */
  21371. get isUnique(): boolean;
  21372. /**
  21373. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21374. */
  21375. get isFinalMerger(): boolean;
  21376. /**
  21377. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21378. */
  21379. get isInput(): boolean;
  21380. /**
  21381. * Gets or sets the build Id
  21382. */
  21383. get buildId(): number;
  21384. set buildId(value: number);
  21385. /**
  21386. * Gets or sets the target of the block
  21387. */
  21388. get target(): NodeMaterialBlockTargets;
  21389. set target(value: NodeMaterialBlockTargets);
  21390. /**
  21391. * Gets the list of input points
  21392. */
  21393. get inputs(): NodeMaterialConnectionPoint[];
  21394. /** Gets the list of output points */
  21395. get outputs(): NodeMaterialConnectionPoint[];
  21396. /**
  21397. * Find an input by its name
  21398. * @param name defines the name of the input to look for
  21399. * @returns the input or null if not found
  21400. */
  21401. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21402. /**
  21403. * Find an output by its name
  21404. * @param name defines the name of the outputto look for
  21405. * @returns the output or null if not found
  21406. */
  21407. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21408. /**
  21409. * Creates a new NodeMaterialBlock
  21410. * @param name defines the block name
  21411. * @param target defines the target of that block (Vertex by default)
  21412. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21413. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21414. */
  21415. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21416. /**
  21417. * Initialize the block and prepare the context for build
  21418. * @param state defines the state that will be used for the build
  21419. */
  21420. initialize(state: NodeMaterialBuildState): void;
  21421. /**
  21422. * Bind data to effect. Will only be called for blocks with isBindable === true
  21423. * @param effect defines the effect to bind data to
  21424. * @param nodeMaterial defines the hosting NodeMaterial
  21425. * @param mesh defines the mesh that will be rendered
  21426. * @param subMesh defines the submesh that will be rendered
  21427. */
  21428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21429. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21430. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21431. protected _writeFloat(value: number): string;
  21432. /**
  21433. * Gets the current class name e.g. "NodeMaterialBlock"
  21434. * @returns the class name
  21435. */
  21436. getClassName(): string;
  21437. /**
  21438. * Register a new input. Must be called inside a block constructor
  21439. * @param name defines the connection point name
  21440. * @param type defines the connection point type
  21441. * @param isOptional defines a boolean indicating that this input can be omitted
  21442. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21443. * @param point an already created connection point. If not provided, create a new one
  21444. * @returns the current block
  21445. */
  21446. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21447. /**
  21448. * Register a new output. Must be called inside a block constructor
  21449. * @param name defines the connection point name
  21450. * @param type defines the connection point type
  21451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21452. * @param point an already created connection point. If not provided, create a new one
  21453. * @returns the current block
  21454. */
  21455. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21456. /**
  21457. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21458. * @param forOutput defines an optional connection point to check compatibility with
  21459. * @returns the first available input or null
  21460. */
  21461. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21462. /**
  21463. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21464. * @param forBlock defines an optional block to check compatibility with
  21465. * @returns the first available input or null
  21466. */
  21467. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21468. /**
  21469. * Gets the sibling of the given output
  21470. * @param current defines the current output
  21471. * @returns the next output in the list or null
  21472. */
  21473. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21474. /**
  21475. * Connect current block with another block
  21476. * @param other defines the block to connect with
  21477. * @param options define the various options to help pick the right connections
  21478. * @returns the current block
  21479. */
  21480. connectTo(other: NodeMaterialBlock, options?: {
  21481. input?: string;
  21482. output?: string;
  21483. outputSwizzle?: string;
  21484. }): this | undefined;
  21485. protected _buildBlock(state: NodeMaterialBuildState): void;
  21486. /**
  21487. * Add uniforms, samplers and uniform buffers at compilation time
  21488. * @param state defines the state to update
  21489. * @param nodeMaterial defines the node material requesting the update
  21490. * @param defines defines the material defines to update
  21491. * @param uniformBuffers defines the list of uniform buffer names
  21492. */
  21493. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21494. /**
  21495. * Add potential fallbacks if shader compilation fails
  21496. * @param mesh defines the mesh to be rendered
  21497. * @param fallbacks defines the current prioritized list of fallbacks
  21498. */
  21499. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21500. /**
  21501. * Initialize defines for shader compilation
  21502. * @param mesh defines the mesh to be rendered
  21503. * @param nodeMaterial defines the node material requesting the update
  21504. * @param defines defines the material defines to update
  21505. * @param useInstances specifies that instances should be used
  21506. */
  21507. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21508. /**
  21509. * Update defines for shader compilation
  21510. * @param mesh defines the mesh to be rendered
  21511. * @param nodeMaterial defines the node material requesting the update
  21512. * @param defines defines the material defines to update
  21513. * @param useInstances specifies that instances should be used
  21514. * @param subMesh defines which submesh to render
  21515. */
  21516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21517. /**
  21518. * Lets the block try to connect some inputs automatically
  21519. * @param material defines the hosting NodeMaterial
  21520. */
  21521. autoConfigure(material: NodeMaterial): void;
  21522. /**
  21523. * Function called when a block is declared as repeatable content generator
  21524. * @param vertexShaderState defines the current compilation state for the vertex shader
  21525. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21526. * @param mesh defines the mesh to be rendered
  21527. * @param defines defines the material defines to update
  21528. */
  21529. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21530. /**
  21531. * Checks if the block is ready
  21532. * @param mesh defines the mesh to be rendered
  21533. * @param nodeMaterial defines the node material requesting the update
  21534. * @param defines defines the material defines to update
  21535. * @param useInstances specifies that instances should be used
  21536. * @returns true if the block is ready
  21537. */
  21538. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21539. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21540. private _processBuild;
  21541. /**
  21542. * Compile the current node and generate the shader code
  21543. * @param state defines the current compilation state (uniforms, samplers, current string)
  21544. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21545. * @returns true if already built
  21546. */
  21547. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21548. protected _inputRename(name: string): string;
  21549. protected _outputRename(name: string): string;
  21550. protected _dumpPropertiesCode(): string;
  21551. /** @hidden */
  21552. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21553. /** @hidden */
  21554. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21555. /**
  21556. * Clone the current block to a new identical block
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21559. * @returns a copy of the current block
  21560. */
  21561. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21562. /**
  21563. * Serializes this block in a JSON representation
  21564. * @returns the serialized block object
  21565. */
  21566. serialize(): any;
  21567. /** @hidden */
  21568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21569. private _deserializePortDisplayNamesAndExposedOnFrame;
  21570. /**
  21571. * Release resources
  21572. */
  21573. dispose(): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Base class of materials working in push mode in babylon JS
  21579. * @hidden
  21580. */
  21581. export class PushMaterial extends Material {
  21582. protected _activeEffect: Effect;
  21583. protected _normalMatrix: Matrix;
  21584. constructor(name: string, scene: Scene);
  21585. getEffect(): Effect;
  21586. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21587. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21588. /**
  21589. * Binds the given world matrix to the active effect
  21590. *
  21591. * @param world the matrix to bind
  21592. */
  21593. bindOnlyWorldMatrix(world: Matrix): void;
  21594. /**
  21595. * Binds the given normal matrix to the active effect
  21596. *
  21597. * @param normalMatrix the matrix to bind
  21598. */
  21599. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21600. bind(world: Matrix, mesh?: Mesh): void;
  21601. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21602. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21603. }
  21604. }
  21605. declare module BABYLON {
  21606. /**
  21607. * Root class for all node material optimizers
  21608. */
  21609. export class NodeMaterialOptimizer {
  21610. /**
  21611. * Function used to optimize a NodeMaterial graph
  21612. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21613. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21614. */
  21615. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21616. }
  21617. }
  21618. declare module BABYLON {
  21619. /**
  21620. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21621. */
  21622. export class TransformBlock extends NodeMaterialBlock {
  21623. /**
  21624. * Defines the value to use to complement W value to transform it to a Vector4
  21625. */
  21626. complementW: number;
  21627. /**
  21628. * Defines the value to use to complement z value to transform it to a Vector4
  21629. */
  21630. complementZ: number;
  21631. /**
  21632. * Creates a new TransformBlock
  21633. * @param name defines the block name
  21634. */
  21635. constructor(name: string);
  21636. /**
  21637. * Gets the current class name
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Gets the vector input
  21643. */
  21644. get vector(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Gets the output component
  21647. */
  21648. get output(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Gets the xyz output component
  21651. */
  21652. get xyz(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the matrix transform input
  21655. */
  21656. get transform(): NodeMaterialConnectionPoint;
  21657. protected _buildBlock(state: NodeMaterialBuildState): this;
  21658. /**
  21659. * Update defines for shader compilation
  21660. * @param mesh defines the mesh to be rendered
  21661. * @param nodeMaterial defines the node material requesting the update
  21662. * @param defines defines the material defines to update
  21663. * @param useInstances specifies that instances should be used
  21664. * @param subMesh defines which submesh to render
  21665. */
  21666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21667. serialize(): any;
  21668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21669. protected _dumpPropertiesCode(): string;
  21670. }
  21671. }
  21672. declare module BABYLON {
  21673. /**
  21674. * Block used to output the vertex position
  21675. */
  21676. export class VertexOutputBlock extends NodeMaterialBlock {
  21677. /**
  21678. * Creates a new VertexOutputBlock
  21679. * @param name defines the block name
  21680. */
  21681. constructor(name: string);
  21682. /**
  21683. * Gets the current class name
  21684. * @returns the class name
  21685. */
  21686. getClassName(): string;
  21687. /**
  21688. * Gets the vector input component
  21689. */
  21690. get vector(): NodeMaterialConnectionPoint;
  21691. protected _buildBlock(state: NodeMaterialBuildState): this;
  21692. }
  21693. }
  21694. declare module BABYLON {
  21695. /**
  21696. * Block used to output the final color
  21697. */
  21698. export class FragmentOutputBlock extends NodeMaterialBlock {
  21699. /**
  21700. * Create a new FragmentOutputBlock
  21701. * @param name defines the block name
  21702. */
  21703. constructor(name: string);
  21704. /**
  21705. * Gets the current class name
  21706. * @returns the class name
  21707. */
  21708. getClassName(): string;
  21709. /**
  21710. * Gets the rgba input component
  21711. */
  21712. get rgba(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the rgb input component
  21715. */
  21716. get rgb(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the a input component
  21719. */
  21720. get a(): NodeMaterialConnectionPoint;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this;
  21722. }
  21723. }
  21724. declare module BABYLON {
  21725. /**
  21726. * Block used for the particle ramp gradient section
  21727. */
  21728. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21729. /**
  21730. * Create a new ParticleRampGradientBlock
  21731. * @param name defines the block name
  21732. */
  21733. constructor(name: string);
  21734. /**
  21735. * Gets the current class name
  21736. * @returns the class name
  21737. */
  21738. getClassName(): string;
  21739. /**
  21740. * Gets the color input component
  21741. */
  21742. get color(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the rampColor output component
  21745. */
  21746. get rampColor(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Initialize the block and prepare the context for build
  21749. * @param state defines the state that will be used for the build
  21750. */
  21751. initialize(state: NodeMaterialBuildState): void;
  21752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Block used for the particle blend multiply section
  21758. */
  21759. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21760. /**
  21761. * Create a new ParticleBlendMultiplyBlock
  21762. * @param name defines the block name
  21763. */
  21764. constructor(name: string);
  21765. /**
  21766. * Gets the current class name
  21767. * @returns the class name
  21768. */
  21769. getClassName(): string;
  21770. /**
  21771. * Gets the color input component
  21772. */
  21773. get color(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the alphaTexture input component
  21776. */
  21777. get alphaTexture(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the alphaColor input component
  21780. */
  21781. get alphaColor(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the blendColor output component
  21784. */
  21785. get blendColor(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Initialize the block and prepare the context for build
  21788. * @param state defines the state that will be used for the build
  21789. */
  21790. initialize(state: NodeMaterialBuildState): void;
  21791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21792. }
  21793. }
  21794. declare module BABYLON {
  21795. /**
  21796. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21797. */
  21798. export class VectorMergerBlock extends NodeMaterialBlock {
  21799. /**
  21800. * Create a new VectorMergerBlock
  21801. * @param name defines the block name
  21802. */
  21803. constructor(name: string);
  21804. /**
  21805. * Gets the current class name
  21806. * @returns the class name
  21807. */
  21808. getClassName(): string;
  21809. /**
  21810. * Gets the xyz component (input)
  21811. */
  21812. get xyzIn(): NodeMaterialConnectionPoint;
  21813. /**
  21814. * Gets the xy component (input)
  21815. */
  21816. get xyIn(): NodeMaterialConnectionPoint;
  21817. /**
  21818. * Gets the x component (input)
  21819. */
  21820. get x(): NodeMaterialConnectionPoint;
  21821. /**
  21822. * Gets the y component (input)
  21823. */
  21824. get y(): NodeMaterialConnectionPoint;
  21825. /**
  21826. * Gets the z component (input)
  21827. */
  21828. get z(): NodeMaterialConnectionPoint;
  21829. /**
  21830. * Gets the w component (input)
  21831. */
  21832. get w(): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Gets the xyzw component (output)
  21835. */
  21836. get xyzw(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the xyz component (output)
  21839. */
  21840. get xyzOut(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the xy component (output)
  21843. */
  21844. get xyOut(): NodeMaterialConnectionPoint;
  21845. /**
  21846. * Gets the xy component (output)
  21847. * @deprecated Please use xyOut instead.
  21848. */
  21849. get xy(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the xyz component (output)
  21852. * @deprecated Please use xyzOut instead.
  21853. */
  21854. get xyz(): NodeMaterialConnectionPoint;
  21855. protected _buildBlock(state: NodeMaterialBuildState): this;
  21856. }
  21857. }
  21858. declare module BABYLON {
  21859. /**
  21860. * Block used to remap a float from a range to a new one
  21861. */
  21862. export class RemapBlock extends NodeMaterialBlock {
  21863. /**
  21864. * Gets or sets the source range
  21865. */
  21866. sourceRange: Vector2;
  21867. /**
  21868. * Gets or sets the target range
  21869. */
  21870. targetRange: Vector2;
  21871. /**
  21872. * Creates a new RemapBlock
  21873. * @param name defines the block name
  21874. */
  21875. constructor(name: string);
  21876. /**
  21877. * Gets the current class name
  21878. * @returns the class name
  21879. */
  21880. getClassName(): string;
  21881. /**
  21882. * Gets the input component
  21883. */
  21884. get input(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the source min input component
  21887. */
  21888. get sourceMin(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the source max input component
  21891. */
  21892. get sourceMax(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the target min input component
  21895. */
  21896. get targetMin(): NodeMaterialConnectionPoint;
  21897. /**
  21898. * Gets the target max input component
  21899. */
  21900. get targetMax(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the output component
  21903. */
  21904. get output(): NodeMaterialConnectionPoint;
  21905. protected _buildBlock(state: NodeMaterialBuildState): this;
  21906. protected _dumpPropertiesCode(): string;
  21907. serialize(): any;
  21908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21909. }
  21910. }
  21911. declare module BABYLON {
  21912. /**
  21913. * Block used to multiply 2 values
  21914. */
  21915. export class MultiplyBlock extends NodeMaterialBlock {
  21916. /**
  21917. * Creates a new MultiplyBlock
  21918. * @param name defines the block name
  21919. */
  21920. constructor(name: string);
  21921. /**
  21922. * Gets the current class name
  21923. * @returns the class name
  21924. */
  21925. getClassName(): string;
  21926. /**
  21927. * Gets the left operand input component
  21928. */
  21929. get left(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the right operand input component
  21932. */
  21933. get right(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the output component
  21936. */
  21937. get output(): NodeMaterialConnectionPoint;
  21938. protected _buildBlock(state: NodeMaterialBuildState): this;
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. /**
  21943. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21944. */
  21945. export class ColorSplitterBlock extends NodeMaterialBlock {
  21946. /**
  21947. * Create a new ColorSplitterBlock
  21948. * @param name defines the block name
  21949. */
  21950. constructor(name: string);
  21951. /**
  21952. * Gets the current class name
  21953. * @returns the class name
  21954. */
  21955. getClassName(): string;
  21956. /**
  21957. * Gets the rgba component (input)
  21958. */
  21959. get rgba(): NodeMaterialConnectionPoint;
  21960. /**
  21961. * Gets the rgb component (input)
  21962. */
  21963. get rgbIn(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the rgb component (output)
  21966. */
  21967. get rgbOut(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the r component (output)
  21970. */
  21971. get r(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the g component (output)
  21974. */
  21975. get g(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the b component (output)
  21978. */
  21979. get b(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the a component (output)
  21982. */
  21983. get a(): NodeMaterialConnectionPoint;
  21984. protected _inputRename(name: string): string;
  21985. protected _outputRename(name: string): string;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Interface used to configure the node material editor
  21992. */
  21993. export interface INodeMaterialEditorOptions {
  21994. /** Define the URl to load node editor script */
  21995. editorURL?: string;
  21996. }
  21997. /** @hidden */
  21998. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21999. NORMAL: boolean;
  22000. TANGENT: boolean;
  22001. UV1: boolean;
  22002. /** BONES */
  22003. NUM_BONE_INFLUENCERS: number;
  22004. BonesPerMesh: number;
  22005. BONETEXTURE: boolean;
  22006. /** MORPH TARGETS */
  22007. MORPHTARGETS: boolean;
  22008. MORPHTARGETS_NORMAL: boolean;
  22009. MORPHTARGETS_TANGENT: boolean;
  22010. MORPHTARGETS_UV: boolean;
  22011. NUM_MORPH_INFLUENCERS: number;
  22012. /** IMAGE PROCESSING */
  22013. IMAGEPROCESSING: boolean;
  22014. VIGNETTE: boolean;
  22015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22016. VIGNETTEBLENDMODEOPAQUE: boolean;
  22017. TONEMAPPING: boolean;
  22018. TONEMAPPING_ACES: boolean;
  22019. CONTRAST: boolean;
  22020. EXPOSURE: boolean;
  22021. COLORCURVES: boolean;
  22022. COLORGRADING: boolean;
  22023. COLORGRADING3D: boolean;
  22024. SAMPLER3DGREENDEPTH: boolean;
  22025. SAMPLER3DBGRMAP: boolean;
  22026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22027. /** MISC. */
  22028. BUMPDIRECTUV: number;
  22029. constructor();
  22030. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22031. }
  22032. /**
  22033. * Class used to configure NodeMaterial
  22034. */
  22035. export interface INodeMaterialOptions {
  22036. /**
  22037. * Defines if blocks should emit comments
  22038. */
  22039. emitComments: boolean;
  22040. }
  22041. /**
  22042. * Class used to create a node based material built by assembling shader blocks
  22043. */
  22044. export class NodeMaterial extends PushMaterial {
  22045. private static _BuildIdGenerator;
  22046. private _options;
  22047. private _vertexCompilationState;
  22048. private _fragmentCompilationState;
  22049. private _sharedData;
  22050. private _buildId;
  22051. private _buildWasSuccessful;
  22052. private _cachedWorldViewMatrix;
  22053. private _cachedWorldViewProjectionMatrix;
  22054. private _optimizers;
  22055. private _animationFrame;
  22056. /** Define the Url to load node editor script */
  22057. static EditorURL: string;
  22058. /** Define the Url to load snippets */
  22059. static SnippetUrl: string;
  22060. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22061. static IgnoreTexturesAtLoadTime: boolean;
  22062. private BJSNODEMATERIALEDITOR;
  22063. /** Get the inspector from bundle or global */
  22064. private _getGlobalNodeMaterialEditor;
  22065. /**
  22066. * Snippet ID if the material was created from the snippet server
  22067. */
  22068. snippetId: string;
  22069. /**
  22070. * Gets or sets data used by visual editor
  22071. * @see https://nme.babylonjs.com
  22072. */
  22073. editorData: any;
  22074. /**
  22075. * 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)
  22076. */
  22077. ignoreAlpha: boolean;
  22078. /**
  22079. * Defines the maximum number of lights that can be used in the material
  22080. */
  22081. maxSimultaneousLights: number;
  22082. /**
  22083. * Observable raised when the material is built
  22084. */
  22085. onBuildObservable: Observable<NodeMaterial>;
  22086. /**
  22087. * Gets or sets the root nodes of the material vertex shader
  22088. */
  22089. _vertexOutputNodes: NodeMaterialBlock[];
  22090. /**
  22091. * Gets or sets the root nodes of the material fragment (pixel) shader
  22092. */
  22093. _fragmentOutputNodes: NodeMaterialBlock[];
  22094. /** Gets or sets options to control the node material overall behavior */
  22095. get options(): INodeMaterialOptions;
  22096. set options(options: INodeMaterialOptions);
  22097. /**
  22098. * Default configuration related to image processing available in the standard Material.
  22099. */
  22100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22101. /**
  22102. * Gets the image processing configuration used either in this material.
  22103. */
  22104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22105. /**
  22106. * Sets the Default image processing configuration used either in the this material.
  22107. *
  22108. * If sets to null, the scene one is in use.
  22109. */
  22110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22111. /**
  22112. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22113. */
  22114. attachedBlocks: NodeMaterialBlock[];
  22115. /**
  22116. * Specifies the mode of the node material
  22117. * @hidden
  22118. */
  22119. _mode: NodeMaterialModes;
  22120. /**
  22121. * Gets the mode property
  22122. */
  22123. get mode(): NodeMaterialModes;
  22124. /**
  22125. * Create a new node based material
  22126. * @param name defines the material name
  22127. * @param scene defines the hosting scene
  22128. * @param options defines creation option
  22129. */
  22130. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22131. /**
  22132. * Gets the current class name of the material e.g. "NodeMaterial"
  22133. * @returns the class name
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Keep track of the image processing observer to allow dispose and replace.
  22138. */
  22139. private _imageProcessingObserver;
  22140. /**
  22141. * Attaches a new image processing configuration to the Standard Material.
  22142. * @param configuration
  22143. */
  22144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22145. /**
  22146. * Get a block by its name
  22147. * @param name defines the name of the block to retrieve
  22148. * @returns the required block or null if not found
  22149. */
  22150. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22151. /**
  22152. * Get a block by its name
  22153. * @param predicate defines the predicate used to find the good candidate
  22154. * @returns the required block or null if not found
  22155. */
  22156. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22157. /**
  22158. * Get an input block by its name
  22159. * @param predicate defines the predicate used to find the good candidate
  22160. * @returns the required input block or null if not found
  22161. */
  22162. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22163. /**
  22164. * Gets the list of input blocks attached to this material
  22165. * @returns an array of InputBlocks
  22166. */
  22167. getInputBlocks(): InputBlock[];
  22168. /**
  22169. * Adds a new optimizer to the list of optimizers
  22170. * @param optimizer defines the optimizers to add
  22171. * @returns the current material
  22172. */
  22173. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22174. /**
  22175. * Remove an optimizer from the list of optimizers
  22176. * @param optimizer defines the optimizers to remove
  22177. * @returns the current material
  22178. */
  22179. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22180. /**
  22181. * Add a new block to the list of output nodes
  22182. * @param node defines the node to add
  22183. * @returns the current material
  22184. */
  22185. addOutputNode(node: NodeMaterialBlock): this;
  22186. /**
  22187. * Remove a block from the list of root nodes
  22188. * @param node defines the node to remove
  22189. * @returns the current material
  22190. */
  22191. removeOutputNode(node: NodeMaterialBlock): this;
  22192. private _addVertexOutputNode;
  22193. private _removeVertexOutputNode;
  22194. private _addFragmentOutputNode;
  22195. private _removeFragmentOutputNode;
  22196. /**
  22197. * Specifies if the material will require alpha blending
  22198. * @returns a boolean specifying if alpha blending is needed
  22199. */
  22200. needAlphaBlending(): boolean;
  22201. /**
  22202. * Specifies if this material should be rendered in alpha test mode
  22203. * @returns a boolean specifying if an alpha test is needed.
  22204. */
  22205. needAlphaTesting(): boolean;
  22206. private _initializeBlock;
  22207. private _resetDualBlocks;
  22208. /**
  22209. * Remove a block from the current node material
  22210. * @param block defines the block to remove
  22211. */
  22212. removeBlock(block: NodeMaterialBlock): void;
  22213. /**
  22214. * Build the material and generates the inner effect
  22215. * @param verbose defines if the build should log activity
  22216. */
  22217. build(verbose?: boolean): void;
  22218. /**
  22219. * Runs an otpimization phase to try to improve the shader code
  22220. */
  22221. optimize(): void;
  22222. private _prepareDefinesForAttributes;
  22223. /**
  22224. * Create a post process from the material
  22225. * @param camera The camera to apply the render pass to.
  22226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22228. * @param engine The engine which the post process will be applied. (default: current engine)
  22229. * @param reusable If the post process can be reused on the same frame. (default: false)
  22230. * @param textureType Type of textures used when performing the post process. (default: 0)
  22231. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22232. * @returns the post process created
  22233. */
  22234. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22235. /**
  22236. * Create the post process effect from the material
  22237. * @param postProcess The post process to create the effect for
  22238. */
  22239. createEffectForPostProcess(postProcess: PostProcess): void;
  22240. private _createEffectOrPostProcess;
  22241. private _createEffectForParticles;
  22242. /**
  22243. * Create the effect to be used as the custom effect for a particle system
  22244. * @param particleSystem Particle system to create the effect for
  22245. * @param onCompiled defines a function to call when the effect creation is successful
  22246. * @param onError defines a function to call when the effect creation has failed
  22247. */
  22248. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22249. private _processDefines;
  22250. /**
  22251. * Get if the submesh is ready to be used and all its information available.
  22252. * Child classes can use it to update shaders
  22253. * @param mesh defines the mesh to check
  22254. * @param subMesh defines which submesh to check
  22255. * @param useInstances specifies that instances should be used
  22256. * @returns a boolean indicating that the submesh is ready or not
  22257. */
  22258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22259. /**
  22260. * Get a string representing the shaders built by the current node graph
  22261. */
  22262. get compiledShaders(): string;
  22263. /**
  22264. * Binds the world matrix to the material
  22265. * @param world defines the world transformation matrix
  22266. */
  22267. bindOnlyWorldMatrix(world: Matrix): void;
  22268. /**
  22269. * Binds the submesh to this material by preparing the effect and shader to draw
  22270. * @param world defines the world transformation matrix
  22271. * @param mesh defines the mesh containing the submesh
  22272. * @param subMesh defines the submesh to bind the material to
  22273. */
  22274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22275. /**
  22276. * Gets the active textures from the material
  22277. * @returns an array of textures
  22278. */
  22279. getActiveTextures(): BaseTexture[];
  22280. /**
  22281. * Gets the list of texture blocks
  22282. * @returns an array of texture blocks
  22283. */
  22284. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22285. /**
  22286. * Specifies if the material uses a texture
  22287. * @param texture defines the texture to check against the material
  22288. * @returns a boolean specifying if the material uses the texture
  22289. */
  22290. hasTexture(texture: BaseTexture): boolean;
  22291. /**
  22292. * Disposes the material
  22293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22296. */
  22297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22298. /** Creates the node editor window. */
  22299. private _createNodeEditor;
  22300. /**
  22301. * Launch the node material editor
  22302. * @param config Define the configuration of the editor
  22303. * @return a promise fulfilled when the node editor is visible
  22304. */
  22305. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22306. /**
  22307. * Clear the current material
  22308. */
  22309. clear(): void;
  22310. /**
  22311. * Clear the current material and set it to a default state
  22312. */
  22313. setToDefault(): void;
  22314. /**
  22315. * Clear the current material and set it to a default state for post process
  22316. */
  22317. setToDefaultPostProcess(): void;
  22318. /**
  22319. * Clear the current material and set it to a default state for particle
  22320. */
  22321. setToDefaultParticle(): void;
  22322. /**
  22323. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22324. * @param url defines the url to load from
  22325. * @returns a promise that will fullfil when the material is fully loaded
  22326. */
  22327. loadAsync(url: string): Promise<void>;
  22328. private _gatherBlocks;
  22329. /**
  22330. * Generate a string containing the code declaration required to create an equivalent of this material
  22331. * @returns a string
  22332. */
  22333. generateCode(): string;
  22334. /**
  22335. * Serializes this material in a JSON representation
  22336. * @returns the serialized material object
  22337. */
  22338. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22339. private _restoreConnections;
  22340. /**
  22341. * Clear the current graph and load a new one from a serialization object
  22342. * @param source defines the JSON representation of the material
  22343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22344. */
  22345. loadFromSerialization(source: any, rootUrl?: string): void;
  22346. /**
  22347. * Makes a duplicate of the current material.
  22348. * @param name - name to use for the new material.
  22349. */
  22350. clone(name: string): NodeMaterial;
  22351. /**
  22352. * Creates a node material from parsed material data
  22353. * @param source defines the JSON representation of the material
  22354. * @param scene defines the hosting scene
  22355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22356. * @returns a new node material
  22357. */
  22358. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22359. /**
  22360. * Creates a node material from a snippet saved in a remote file
  22361. * @param name defines the name of the material to create
  22362. * @param url defines the url to load from
  22363. * @param scene defines the hosting scene
  22364. * @returns a promise that will resolve to the new node material
  22365. */
  22366. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22367. /**
  22368. * Creates a node material from a snippet saved by the node material editor
  22369. * @param snippetId defines the snippet to load
  22370. * @param scene defines the hosting scene
  22371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22372. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22373. * @returns a promise that will resolve to the new node material
  22374. */
  22375. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22376. /**
  22377. * Creates a new node material set to default basic configuration
  22378. * @param name defines the name of the material
  22379. * @param scene defines the hosting scene
  22380. * @returns a new NodeMaterial
  22381. */
  22382. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * Size options for a post process
  22388. */
  22389. export type PostProcessOptions = {
  22390. width: number;
  22391. height: number;
  22392. };
  22393. /**
  22394. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22395. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22396. */
  22397. export class PostProcess {
  22398. /** Name of the PostProcess. */
  22399. name: string;
  22400. /**
  22401. * Gets or sets the unique id of the post process
  22402. */
  22403. uniqueId: number;
  22404. /**
  22405. * Width of the texture to apply the post process on
  22406. */
  22407. width: number;
  22408. /**
  22409. * Height of the texture to apply the post process on
  22410. */
  22411. height: number;
  22412. /**
  22413. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22414. */
  22415. nodeMaterialSource: Nullable<NodeMaterial>;
  22416. /**
  22417. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22418. * @hidden
  22419. */
  22420. _outputTexture: Nullable<InternalTexture>;
  22421. /**
  22422. * Sampling mode used by the shader
  22423. * See https://doc.babylonjs.com/classes/3.1/texture
  22424. */
  22425. renderTargetSamplingMode: number;
  22426. /**
  22427. * Clear color to use when screen clearing
  22428. */
  22429. clearColor: Color4;
  22430. /**
  22431. * If the buffer needs to be cleared before applying the post process. (default: true)
  22432. * Should be set to false if shader will overwrite all previous pixels.
  22433. */
  22434. autoClear: boolean;
  22435. /**
  22436. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22437. */
  22438. alphaMode: number;
  22439. /**
  22440. * Sets the setAlphaBlendConstants of the babylon engine
  22441. */
  22442. alphaConstants: Color4;
  22443. /**
  22444. * Animations to be used for the post processing
  22445. */
  22446. animations: Animation[];
  22447. /**
  22448. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22449. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22450. */
  22451. enablePixelPerfectMode: boolean;
  22452. /**
  22453. * Force the postprocess to be applied without taking in account viewport
  22454. */
  22455. forceFullscreenViewport: boolean;
  22456. /**
  22457. * List of inspectable custom properties (used by the Inspector)
  22458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22459. */
  22460. inspectableCustomProperties: IInspectable[];
  22461. /**
  22462. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22463. *
  22464. * | Value | Type | Description |
  22465. * | ----- | ----------------------------------- | ----------- |
  22466. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22467. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22468. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22469. *
  22470. */
  22471. scaleMode: number;
  22472. /**
  22473. * Force textures to be a power of two (default: false)
  22474. */
  22475. alwaysForcePOT: boolean;
  22476. private _samples;
  22477. /**
  22478. * Number of sample textures (default: 1)
  22479. */
  22480. get samples(): number;
  22481. set samples(n: number);
  22482. /**
  22483. * Modify the scale of the post process to be the same as the viewport (default: false)
  22484. */
  22485. adaptScaleToCurrentViewport: boolean;
  22486. private _camera;
  22487. private _scene;
  22488. private _engine;
  22489. private _options;
  22490. private _reusable;
  22491. private _textureType;
  22492. private _textureFormat;
  22493. /**
  22494. * Smart array of input and output textures for the post process.
  22495. * @hidden
  22496. */
  22497. _textures: SmartArray<InternalTexture>;
  22498. /**
  22499. * The index in _textures that corresponds to the output texture.
  22500. * @hidden
  22501. */
  22502. _currentRenderTextureInd: number;
  22503. private _effect;
  22504. private _samplers;
  22505. private _fragmentUrl;
  22506. private _vertexUrl;
  22507. private _parameters;
  22508. private _scaleRatio;
  22509. protected _indexParameters: any;
  22510. private _shareOutputWithPostProcess;
  22511. private _texelSize;
  22512. private _forcedOutputTexture;
  22513. /**
  22514. * Returns the fragment url or shader name used in the post process.
  22515. * @returns the fragment url or name in the shader store.
  22516. */
  22517. getEffectName(): string;
  22518. /**
  22519. * An event triggered when the postprocess is activated.
  22520. */
  22521. onActivateObservable: Observable<Camera>;
  22522. private _onActivateObserver;
  22523. /**
  22524. * A function that is added to the onActivateObservable
  22525. */
  22526. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22527. /**
  22528. * An event triggered when the postprocess changes its size.
  22529. */
  22530. onSizeChangedObservable: Observable<PostProcess>;
  22531. private _onSizeChangedObserver;
  22532. /**
  22533. * A function that is added to the onSizeChangedObservable
  22534. */
  22535. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22536. /**
  22537. * An event triggered when the postprocess applies its effect.
  22538. */
  22539. onApplyObservable: Observable<Effect>;
  22540. private _onApplyObserver;
  22541. /**
  22542. * A function that is added to the onApplyObservable
  22543. */
  22544. set onApply(callback: (effect: Effect) => void);
  22545. /**
  22546. * An event triggered before rendering the postprocess
  22547. */
  22548. onBeforeRenderObservable: Observable<Effect>;
  22549. private _onBeforeRenderObserver;
  22550. /**
  22551. * A function that is added to the onBeforeRenderObservable
  22552. */
  22553. set onBeforeRender(callback: (effect: Effect) => void);
  22554. /**
  22555. * An event triggered after rendering the postprocess
  22556. */
  22557. onAfterRenderObservable: Observable<Effect>;
  22558. private _onAfterRenderObserver;
  22559. /**
  22560. * A function that is added to the onAfterRenderObservable
  22561. */
  22562. set onAfterRender(callback: (efect: Effect) => void);
  22563. /**
  22564. * 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
  22565. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22566. */
  22567. get inputTexture(): InternalTexture;
  22568. set inputTexture(value: InternalTexture);
  22569. /**
  22570. * Gets the camera which post process is applied to.
  22571. * @returns The camera the post process is applied to.
  22572. */
  22573. getCamera(): Camera;
  22574. /**
  22575. * Gets the texel size of the postprocess.
  22576. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22577. */
  22578. get texelSize(): Vector2;
  22579. /**
  22580. * Creates a new instance PostProcess
  22581. * @param name The name of the PostProcess.
  22582. * @param fragmentUrl The url of the fragment shader to be used.
  22583. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22584. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22586. * @param camera The camera to apply the render pass to.
  22587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22588. * @param engine The engine which the post process will be applied. (default: current engine)
  22589. * @param reusable If the post process can be reused on the same frame. (default: false)
  22590. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22591. * @param textureType Type of textures used when performing the post process. (default: 0)
  22592. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22593. * @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
  22594. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22595. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22596. */
  22597. constructor(
  22598. /** Name of the PostProcess. */
  22599. 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);
  22600. /**
  22601. * Gets a string idenfifying the name of the class
  22602. * @returns "PostProcess" string
  22603. */
  22604. getClassName(): string;
  22605. /**
  22606. * Gets the engine which this post process belongs to.
  22607. * @returns The engine the post process was enabled with.
  22608. */
  22609. getEngine(): Engine;
  22610. /**
  22611. * The effect that is created when initializing the post process.
  22612. * @returns The created effect corresponding the the postprocess.
  22613. */
  22614. getEffect(): Effect;
  22615. /**
  22616. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22617. * @param postProcess The post process to share the output with.
  22618. * @returns This post process.
  22619. */
  22620. shareOutputWith(postProcess: PostProcess): PostProcess;
  22621. /**
  22622. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22623. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22624. */
  22625. useOwnOutput(): void;
  22626. /**
  22627. * Updates the effect with the current post process compile time values and recompiles the shader.
  22628. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22629. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22630. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22631. * @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
  22632. * @param onCompiled Called when the shader has been compiled.
  22633. * @param onError Called if there is an error when compiling a shader.
  22634. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22635. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22636. */
  22637. 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;
  22638. /**
  22639. * The post process is reusable if it can be used multiple times within one frame.
  22640. * @returns If the post process is reusable
  22641. */
  22642. isReusable(): boolean;
  22643. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22644. markTextureDirty(): void;
  22645. /**
  22646. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22647. * 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.
  22648. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22649. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22650. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22651. * @returns The target texture that was bound to be written to.
  22652. */
  22653. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22654. /**
  22655. * If the post process is supported.
  22656. */
  22657. get isSupported(): boolean;
  22658. /**
  22659. * The aspect ratio of the output texture.
  22660. */
  22661. get aspectRatio(): number;
  22662. /**
  22663. * Get a value indicating if the post-process is ready to be used
  22664. * @returns true if the post-process is ready (shader is compiled)
  22665. */
  22666. isReady(): boolean;
  22667. /**
  22668. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22669. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22670. */
  22671. apply(): Nullable<Effect>;
  22672. private _disposeTextures;
  22673. /**
  22674. * Disposes the post process.
  22675. * @param camera The camera to dispose the post process on.
  22676. */
  22677. dispose(camera?: Camera): void;
  22678. }
  22679. }
  22680. declare module BABYLON {
  22681. /** @hidden */
  22682. export var kernelBlurVaryingDeclaration: {
  22683. name: string;
  22684. shader: string;
  22685. };
  22686. }
  22687. declare module BABYLON {
  22688. /** @hidden */
  22689. export var kernelBlurFragment: {
  22690. name: string;
  22691. shader: string;
  22692. };
  22693. }
  22694. declare module BABYLON {
  22695. /** @hidden */
  22696. export var kernelBlurFragment2: {
  22697. name: string;
  22698. shader: string;
  22699. };
  22700. }
  22701. declare module BABYLON {
  22702. /** @hidden */
  22703. export var kernelBlurPixelShader: {
  22704. name: string;
  22705. shader: string;
  22706. };
  22707. }
  22708. declare module BABYLON {
  22709. /** @hidden */
  22710. export var kernelBlurVertex: {
  22711. name: string;
  22712. shader: string;
  22713. };
  22714. }
  22715. declare module BABYLON {
  22716. /** @hidden */
  22717. export var kernelBlurVertexShader: {
  22718. name: string;
  22719. shader: string;
  22720. };
  22721. }
  22722. declare module BABYLON {
  22723. /**
  22724. * The Blur Post Process which blurs an image based on a kernel and direction.
  22725. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22726. */
  22727. export class BlurPostProcess extends PostProcess {
  22728. /** The direction in which to blur the image. */
  22729. direction: Vector2;
  22730. private blockCompilation;
  22731. protected _kernel: number;
  22732. protected _idealKernel: number;
  22733. protected _packedFloat: boolean;
  22734. private _staticDefines;
  22735. /**
  22736. * Sets the length in pixels of the blur sample region
  22737. */
  22738. set kernel(v: number);
  22739. /**
  22740. * Gets the length in pixels of the blur sample region
  22741. */
  22742. get kernel(): number;
  22743. /**
  22744. * Sets wether or not the blur needs to unpack/repack floats
  22745. */
  22746. set packedFloat(v: boolean);
  22747. /**
  22748. * Gets wether or not the blur is unpacking/repacking floats
  22749. */
  22750. get packedFloat(): boolean;
  22751. /**
  22752. * Creates a new instance BlurPostProcess
  22753. * @param name The name of the effect.
  22754. * @param direction The direction in which to blur the image.
  22755. * @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.
  22756. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22757. * @param camera The camera to apply the render pass to.
  22758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22759. * @param engine The engine which the post process will be applied. (default: current engine)
  22760. * @param reusable If the post process can be reused on the same frame. (default: false)
  22761. * @param textureType Type of textures used when performing the post process. (default: 0)
  22762. * @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)
  22763. */
  22764. constructor(name: string,
  22765. /** The direction in which to blur the image. */
  22766. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22767. /**
  22768. * Updates the effect with the current post process compile time values and recompiles the shader.
  22769. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22770. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22771. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22772. * @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
  22773. * @param onCompiled Called when the shader has been compiled.
  22774. * @param onError Called if there is an error when compiling a shader.
  22775. */
  22776. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22777. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22778. /**
  22779. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22780. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22781. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22782. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22783. * The gaps between physical kernels are compensated for in the weighting of the samples
  22784. * @param idealKernel Ideal blur kernel.
  22785. * @return Nearest best kernel.
  22786. */
  22787. protected _nearestBestKernel(idealKernel: number): number;
  22788. /**
  22789. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22790. * @param x The point on the Gaussian distribution to sample.
  22791. * @return the value of the Gaussian function at x.
  22792. */
  22793. protected _gaussianWeight(x: number): number;
  22794. /**
  22795. * Generates a string that can be used as a floating point number in GLSL.
  22796. * @param x Value to print.
  22797. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22798. * @return GLSL float string.
  22799. */
  22800. protected _glslFloat(x: number, decimalFigures?: number): string;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22807. * You can then easily use it as a reflectionTexture on a flat surface.
  22808. * In case the surface is not a plane, please consider relying on reflection probes.
  22809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22810. */
  22811. export class MirrorTexture extends RenderTargetTexture {
  22812. private scene;
  22813. /**
  22814. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22815. * 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.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. mirrorPlane: Plane;
  22819. /**
  22820. * Define the blur ratio used to blur the reflection if needed.
  22821. */
  22822. set blurRatio(value: number);
  22823. get blurRatio(): number;
  22824. /**
  22825. * Define the adaptive blur kernel used to blur the reflection if needed.
  22826. * This will autocompute the closest best match for the `blurKernel`
  22827. */
  22828. set adaptiveBlurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel used to blur the reflection if needed.
  22831. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22832. */
  22833. set blurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernelX(value: number);
  22839. get blurKernelX(): number;
  22840. /**
  22841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22843. */
  22844. set blurKernelY(value: number);
  22845. get blurKernelY(): number;
  22846. private _autoComputeBlurKernel;
  22847. protected _onRatioRescale(): void;
  22848. private _updateGammaSpace;
  22849. private _imageProcessingConfigChangeObserver;
  22850. private _transformMatrix;
  22851. private _mirrorMatrix;
  22852. private _savedViewMatrix;
  22853. private _blurX;
  22854. private _blurY;
  22855. private _adaptiveBlurKernel;
  22856. private _blurKernelX;
  22857. private _blurKernelY;
  22858. private _blurRatio;
  22859. /**
  22860. * Instantiates a Mirror Texture.
  22861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22863. * You can then easily use it as a reflectionTexture on a flat surface.
  22864. * In case the surface is not a plane, please consider relying on reflection probes.
  22865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22866. * @param name
  22867. * @param size
  22868. * @param scene
  22869. * @param generateMipMaps
  22870. * @param type
  22871. * @param samplingMode
  22872. * @param generateDepthBuffer
  22873. */
  22874. constructor(name: string, size: number | {
  22875. width: number;
  22876. height: number;
  22877. } | {
  22878. ratio: number;
  22879. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22880. private _preparePostProcesses;
  22881. /**
  22882. * Clone the mirror texture.
  22883. * @returns the cloned texture
  22884. */
  22885. clone(): MirrorTexture;
  22886. /**
  22887. * Serialize the texture to a JSON representation you could use in Parse later on
  22888. * @returns the serialized JSON representation
  22889. */
  22890. serialize(): any;
  22891. /**
  22892. * Dispose the texture and release its associated resources.
  22893. */
  22894. dispose(): void;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22900. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22901. */
  22902. export class Texture extends BaseTexture {
  22903. /**
  22904. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22905. */
  22906. static SerializeBuffers: boolean;
  22907. /** @hidden */
  22908. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22909. /** @hidden */
  22910. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22911. /** @hidden */
  22912. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22913. /** nearest is mag = nearest and min = nearest and mip = linear */
  22914. static readonly NEAREST_SAMPLINGMODE: number;
  22915. /** nearest is mag = nearest and min = nearest and mip = linear */
  22916. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22917. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22918. static readonly BILINEAR_SAMPLINGMODE: number;
  22919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22920. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22921. /** Trilinear is mag = linear and min = linear and mip = linear */
  22922. static readonly TRILINEAR_SAMPLINGMODE: number;
  22923. /** Trilinear is mag = linear and min = linear and mip = linear */
  22924. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22925. /** mag = nearest and min = nearest and mip = nearest */
  22926. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22927. /** mag = nearest and min = linear and mip = nearest */
  22928. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22929. /** mag = nearest and min = linear and mip = linear */
  22930. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22931. /** mag = nearest and min = linear and mip = none */
  22932. static readonly NEAREST_LINEAR: number;
  22933. /** mag = nearest and min = nearest and mip = none */
  22934. static readonly NEAREST_NEAREST: number;
  22935. /** mag = linear and min = nearest and mip = nearest */
  22936. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22937. /** mag = linear and min = nearest and mip = linear */
  22938. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22939. /** mag = linear and min = linear and mip = none */
  22940. static readonly LINEAR_LINEAR: number;
  22941. /** mag = linear and min = nearest and mip = none */
  22942. static readonly LINEAR_NEAREST: number;
  22943. /** Explicit coordinates mode */
  22944. static readonly EXPLICIT_MODE: number;
  22945. /** Spherical coordinates mode */
  22946. static readonly SPHERICAL_MODE: number;
  22947. /** Planar coordinates mode */
  22948. static readonly PLANAR_MODE: number;
  22949. /** Cubic coordinates mode */
  22950. static readonly CUBIC_MODE: number;
  22951. /** Projection coordinates mode */
  22952. static readonly PROJECTION_MODE: number;
  22953. /** Inverse Cubic coordinates mode */
  22954. static readonly SKYBOX_MODE: number;
  22955. /** Inverse Cubic coordinates mode */
  22956. static readonly INVCUBIC_MODE: number;
  22957. /** Equirectangular coordinates mode */
  22958. static readonly EQUIRECTANGULAR_MODE: number;
  22959. /** Equirectangular Fixed coordinates mode */
  22960. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22961. /** Equirectangular Fixed Mirrored coordinates mode */
  22962. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22963. /** Texture is not repeating outside of 0..1 UVs */
  22964. static readonly CLAMP_ADDRESSMODE: number;
  22965. /** Texture is repeating outside of 0..1 UVs */
  22966. static readonly WRAP_ADDRESSMODE: number;
  22967. /** Texture is repeating and mirrored */
  22968. static readonly MIRROR_ADDRESSMODE: number;
  22969. /**
  22970. * 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
  22971. */
  22972. static UseSerializedUrlIfAny: boolean;
  22973. /**
  22974. * Define the url of the texture.
  22975. */
  22976. url: Nullable<string>;
  22977. /**
  22978. * Define an offset on the texture to offset the u coordinates of the UVs
  22979. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22980. */
  22981. uOffset: number;
  22982. /**
  22983. * Define an offset on the texture to offset the v coordinates of the UVs
  22984. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. vOffset: number;
  22987. /**
  22988. * Define an offset on the texture to scale the u coordinates of the UVs
  22989. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22990. */
  22991. uScale: number;
  22992. /**
  22993. * Define an offset on the texture to scale the v coordinates of the UVs
  22994. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. vScale: number;
  22997. /**
  22998. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22999. * @see http://doc.babylonjs.com/how_to/more_materials
  23000. */
  23001. uAng: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23004. * @see http://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. vAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23009. * @see http://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. wAng: number;
  23012. /**
  23013. * Defines the center of rotation (U)
  23014. */
  23015. uRotationCenter: number;
  23016. /**
  23017. * Defines the center of rotation (V)
  23018. */
  23019. vRotationCenter: number;
  23020. /**
  23021. * Defines the center of rotation (W)
  23022. */
  23023. wRotationCenter: number;
  23024. /**
  23025. * Are mip maps generated for this texture or not.
  23026. */
  23027. get noMipmap(): boolean;
  23028. /**
  23029. * List of inspectable custom properties (used by the Inspector)
  23030. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23031. */
  23032. inspectableCustomProperties: Nullable<IInspectable[]>;
  23033. private _noMipmap;
  23034. /** @hidden */
  23035. _invertY: boolean;
  23036. private _rowGenerationMatrix;
  23037. private _cachedTextureMatrix;
  23038. private _projectionModeMatrix;
  23039. private _t0;
  23040. private _t1;
  23041. private _t2;
  23042. private _cachedUOffset;
  23043. private _cachedVOffset;
  23044. private _cachedUScale;
  23045. private _cachedVScale;
  23046. private _cachedUAng;
  23047. private _cachedVAng;
  23048. private _cachedWAng;
  23049. private _cachedProjectionMatrixId;
  23050. private _cachedCoordinatesMode;
  23051. /** @hidden */
  23052. protected _initialSamplingMode: number;
  23053. /** @hidden */
  23054. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23055. private _deleteBuffer;
  23056. protected _format: Nullable<number>;
  23057. private _delayedOnLoad;
  23058. private _delayedOnError;
  23059. private _mimeType?;
  23060. /**
  23061. * Observable triggered once the texture has been loaded.
  23062. */
  23063. onLoadObservable: Observable<Texture>;
  23064. protected _isBlocking: boolean;
  23065. /**
  23066. * Is the texture preventing material to render while loading.
  23067. * If false, a default texture will be used instead of the loading one during the preparation step.
  23068. */
  23069. set isBlocking(value: boolean);
  23070. get isBlocking(): boolean;
  23071. /**
  23072. * Get the current sampling mode associated with the texture.
  23073. */
  23074. get samplingMode(): number;
  23075. /**
  23076. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23077. */
  23078. get invertY(): boolean;
  23079. /**
  23080. * Instantiates a new texture.
  23081. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23082. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23083. * @param url defines the url of the picture to load as a texture
  23084. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23085. * @param noMipmap defines if the texture will require mip maps or not
  23086. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23087. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23088. * @param onLoad defines a callback triggered when the texture has been loaded
  23089. * @param onError defines a callback triggered when an error occurred during the loading session
  23090. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23091. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23092. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23093. * @param mimeType defines an optional mime type information
  23094. */
  23095. 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);
  23096. /**
  23097. * Update the url (and optional buffer) of this texture if url was null during construction.
  23098. * @param url the url of the texture
  23099. * @param buffer the buffer of the texture (defaults to null)
  23100. * @param onLoad callback called when the texture is loaded (defaults to null)
  23101. */
  23102. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23103. /**
  23104. * Finish the loading sequence of a texture flagged as delayed load.
  23105. * @hidden
  23106. */
  23107. delayLoad(): void;
  23108. private _prepareRowForTextureGeneration;
  23109. /**
  23110. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23111. * @returns the transform matrix of the texture.
  23112. */
  23113. getTextureMatrix(uBase?: number): Matrix;
  23114. /**
  23115. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23116. * @returns The reflection texture transform
  23117. */
  23118. getReflectionTextureMatrix(): Matrix;
  23119. /**
  23120. * Clones the texture.
  23121. * @returns the cloned texture
  23122. */
  23123. clone(): Texture;
  23124. /**
  23125. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23126. * @returns The JSON representation of the texture
  23127. */
  23128. serialize(): any;
  23129. /**
  23130. * Get the current class name of the texture useful for serialization or dynamic coding.
  23131. * @returns "Texture"
  23132. */
  23133. getClassName(): string;
  23134. /**
  23135. * Dispose the texture and release its associated resources.
  23136. */
  23137. dispose(): void;
  23138. /**
  23139. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23140. * @param parsedTexture Define the JSON representation of the texture
  23141. * @param scene Define the scene the parsed texture should be instantiated in
  23142. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23143. * @returns The parsed texture if successful
  23144. */
  23145. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23146. /**
  23147. * Creates a texture from its base 64 representation.
  23148. * @param data Define the base64 payload without the data: prefix
  23149. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23150. * @param scene Define the scene the texture should belong to
  23151. * @param noMipmap Forces the texture to not create mip map information if true
  23152. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23153. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23154. * @param onLoad define a callback triggered when the texture has been loaded
  23155. * @param onError define a callback triggered when an error occurred during the loading session
  23156. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23157. * @returns the created texture
  23158. */
  23159. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23160. /**
  23161. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23162. * @param data Define the base64 payload without the data: prefix
  23163. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23164. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23165. * @param scene Define the scene the texture should belong to
  23166. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23167. * @param noMipmap Forces the texture to not create mip map information if true
  23168. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23169. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23170. * @param onLoad define a callback triggered when the texture has been loaded
  23171. * @param onError define a callback triggered when an error occurred during the loading session
  23172. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23173. * @returns the created texture
  23174. */
  23175. 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;
  23176. }
  23177. }
  23178. declare module BABYLON {
  23179. /**
  23180. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23181. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23182. */
  23183. export class PostProcessManager {
  23184. private _scene;
  23185. private _indexBuffer;
  23186. private _vertexBuffers;
  23187. /**
  23188. * Creates a new instance PostProcess
  23189. * @param scene The scene that the post process is associated with.
  23190. */
  23191. constructor(scene: Scene);
  23192. private _prepareBuffers;
  23193. private _buildIndexBuffer;
  23194. /**
  23195. * Rebuilds the vertex buffers of the manager.
  23196. * @hidden
  23197. */
  23198. _rebuild(): void;
  23199. /**
  23200. * Prepares a frame to be run through a post process.
  23201. * @param sourceTexture The input texture to the post procesess. (default: null)
  23202. * @param postProcesses An array of post processes to be run. (default: null)
  23203. * @returns True if the post processes were able to be run.
  23204. * @hidden
  23205. */
  23206. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23207. /**
  23208. * Manually render a set of post processes to a texture.
  23209. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23210. * @param postProcesses An array of post processes to be run.
  23211. * @param targetTexture The target texture to render to.
  23212. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23213. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23214. * @param lodLevel defines which lod of the texture to render to
  23215. */
  23216. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23217. /**
  23218. * Finalize the result of the output of the postprocesses.
  23219. * @param doNotPresent If true the result will not be displayed to the screen.
  23220. * @param targetTexture The target texture to render to.
  23221. * @param faceIndex The index of the face to bind the target texture to.
  23222. * @param postProcesses The array of post processes to render.
  23223. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23224. * @hidden
  23225. */
  23226. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23227. /**
  23228. * Disposes of the post process manager.
  23229. */
  23230. dispose(): void;
  23231. }
  23232. }
  23233. declare module BABYLON {
  23234. /**
  23235. * This Helps creating a texture that will be created from a camera in your scene.
  23236. * It is basically a dynamic texture that could be used to create special effects for instance.
  23237. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23238. */
  23239. export class RenderTargetTexture extends Texture {
  23240. isCube: boolean;
  23241. /**
  23242. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23243. */
  23244. static readonly REFRESHRATE_RENDER_ONCE: number;
  23245. /**
  23246. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23247. */
  23248. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23249. /**
  23250. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23251. * the central point of your effect and can save a lot of performances.
  23252. */
  23253. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23254. /**
  23255. * Use this predicate to dynamically define the list of mesh you want to render.
  23256. * If set, the renderList property will be overwritten.
  23257. */
  23258. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23259. private _renderList;
  23260. /**
  23261. * Use this list to define the list of mesh you want to render.
  23262. */
  23263. get renderList(): Nullable<Array<AbstractMesh>>;
  23264. set renderList(value: Nullable<Array<AbstractMesh>>);
  23265. /**
  23266. * Use this function to overload the renderList array at rendering time.
  23267. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23268. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23269. * the cube (if the RTT is a cube, else layerOrFace=0).
  23270. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23271. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23272. * hold dummy elements!
  23273. */
  23274. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23275. private _hookArray;
  23276. /**
  23277. * Define if particles should be rendered in your texture.
  23278. */
  23279. renderParticles: boolean;
  23280. /**
  23281. * Define if sprites should be rendered in your texture.
  23282. */
  23283. renderSprites: boolean;
  23284. /**
  23285. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23286. */
  23287. coordinatesMode: number;
  23288. /**
  23289. * Define the camera used to render the texture.
  23290. */
  23291. activeCamera: Nullable<Camera>;
  23292. /**
  23293. * Override the mesh isReady function with your own one.
  23294. */
  23295. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23296. /**
  23297. * Override the render function of the texture with your own one.
  23298. */
  23299. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23300. /**
  23301. * Define if camera post processes should be use while rendering the texture.
  23302. */
  23303. useCameraPostProcesses: boolean;
  23304. /**
  23305. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23306. */
  23307. ignoreCameraViewport: boolean;
  23308. private _postProcessManager;
  23309. private _postProcesses;
  23310. private _resizeObserver;
  23311. /**
  23312. * An event triggered when the texture is unbind.
  23313. */
  23314. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23315. /**
  23316. * An event triggered when the texture is unbind.
  23317. */
  23318. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23319. private _onAfterUnbindObserver;
  23320. /**
  23321. * Set a after unbind callback in the texture.
  23322. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23323. */
  23324. set onAfterUnbind(callback: () => void);
  23325. /**
  23326. * An event triggered before rendering the texture
  23327. */
  23328. onBeforeRenderObservable: Observable<number>;
  23329. private _onBeforeRenderObserver;
  23330. /**
  23331. * Set a before render callback in the texture.
  23332. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23333. */
  23334. set onBeforeRender(callback: (faceIndex: number) => void);
  23335. /**
  23336. * An event triggered after rendering the texture
  23337. */
  23338. onAfterRenderObservable: Observable<number>;
  23339. private _onAfterRenderObserver;
  23340. /**
  23341. * Set a after render callback in the texture.
  23342. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23343. */
  23344. set onAfterRender(callback: (faceIndex: number) => void);
  23345. /**
  23346. * An event triggered after the texture clear
  23347. */
  23348. onClearObservable: Observable<Engine>;
  23349. private _onClearObserver;
  23350. /**
  23351. * Set a clear callback in the texture.
  23352. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23353. */
  23354. set onClear(callback: (Engine: Engine) => void);
  23355. /**
  23356. * An event triggered when the texture is resized.
  23357. */
  23358. onResizeObservable: Observable<RenderTargetTexture>;
  23359. /**
  23360. * Define the clear color of the Render Target if it should be different from the scene.
  23361. */
  23362. clearColor: Color4;
  23363. protected _size: number | {
  23364. width: number;
  23365. height: number;
  23366. layers?: number;
  23367. };
  23368. protected _initialSizeParameter: number | {
  23369. width: number;
  23370. height: number;
  23371. } | {
  23372. ratio: number;
  23373. };
  23374. protected _sizeRatio: Nullable<number>;
  23375. /** @hidden */
  23376. _generateMipMaps: boolean;
  23377. protected _renderingManager: RenderingManager;
  23378. /** @hidden */
  23379. _waitingRenderList: string[];
  23380. protected _doNotChangeAspectRatio: boolean;
  23381. protected _currentRefreshId: number;
  23382. protected _refreshRate: number;
  23383. protected _textureMatrix: Matrix;
  23384. protected _samples: number;
  23385. protected _renderTargetOptions: RenderTargetCreationOptions;
  23386. /**
  23387. * Gets render target creation options that were used.
  23388. */
  23389. get renderTargetOptions(): RenderTargetCreationOptions;
  23390. protected _onRatioRescale(): void;
  23391. /**
  23392. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23393. * It must define where the camera used to render the texture is set
  23394. */
  23395. boundingBoxPosition: Vector3;
  23396. private _boundingBoxSize;
  23397. /**
  23398. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23399. * When defined, the cubemap will switch to local mode
  23400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23401. * @example https://www.babylonjs-playground.com/#RNASML
  23402. */
  23403. set boundingBoxSize(value: Vector3);
  23404. get boundingBoxSize(): Vector3;
  23405. /**
  23406. * In case the RTT has been created with a depth texture, get the associated
  23407. * depth texture.
  23408. * Otherwise, return null.
  23409. */
  23410. get depthStencilTexture(): Nullable<InternalTexture>;
  23411. /**
  23412. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23413. * or used a shadow, depth texture...
  23414. * @param name The friendly name of the texture
  23415. * @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)
  23416. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23417. * @param generateMipMaps True if mip maps need to be generated after render.
  23418. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23419. * @param type The type of the buffer in the RTT (int, half float, float...)
  23420. * @param isCube True if a cube texture needs to be created
  23421. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23422. * @param generateDepthBuffer True to generate a depth buffer
  23423. * @param generateStencilBuffer True to generate a stencil buffer
  23424. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23425. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23426. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23427. */
  23428. constructor(name: string, size: number | {
  23429. width: number;
  23430. height: number;
  23431. layers?: number;
  23432. } | {
  23433. ratio: number;
  23434. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23435. /**
  23436. * Creates a depth stencil texture.
  23437. * This is only available in WebGL 2 or with the depth texture extension available.
  23438. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23439. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23440. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23441. */
  23442. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23443. private _processSizeParameter;
  23444. /**
  23445. * Define the number of samples to use in case of MSAA.
  23446. * It defaults to one meaning no MSAA has been enabled.
  23447. */
  23448. get samples(): number;
  23449. set samples(value: number);
  23450. /**
  23451. * Resets the refresh counter of the texture and start bak from scratch.
  23452. * Could be useful to regenerate the texture if it is setup to render only once.
  23453. */
  23454. resetRefreshCounter(): void;
  23455. /**
  23456. * Define the refresh rate of the texture or the rendering frequency.
  23457. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23458. */
  23459. get refreshRate(): number;
  23460. set refreshRate(value: number);
  23461. /**
  23462. * Adds a post process to the render target rendering passes.
  23463. * @param postProcess define the post process to add
  23464. */
  23465. addPostProcess(postProcess: PostProcess): void;
  23466. /**
  23467. * Clear all the post processes attached to the render target
  23468. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23469. */
  23470. clearPostProcesses(dispose?: boolean): void;
  23471. /**
  23472. * Remove one of the post process from the list of attached post processes to the texture
  23473. * @param postProcess define the post process to remove from the list
  23474. */
  23475. removePostProcess(postProcess: PostProcess): void;
  23476. /** @hidden */
  23477. _shouldRender(): boolean;
  23478. /**
  23479. * Gets the actual render size of the texture.
  23480. * @returns the width of the render size
  23481. */
  23482. getRenderSize(): number;
  23483. /**
  23484. * Gets the actual render width of the texture.
  23485. * @returns the width of the render size
  23486. */
  23487. getRenderWidth(): number;
  23488. /**
  23489. * Gets the actual render height of the texture.
  23490. * @returns the height of the render size
  23491. */
  23492. getRenderHeight(): number;
  23493. /**
  23494. * Gets the actual number of layers of the texture.
  23495. * @returns the number of layers
  23496. */
  23497. getRenderLayers(): number;
  23498. /**
  23499. * Get if the texture can be rescaled or not.
  23500. */
  23501. get canRescale(): boolean;
  23502. /**
  23503. * Resize the texture using a ratio.
  23504. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23505. */
  23506. scale(ratio: number): void;
  23507. /**
  23508. * Get the texture reflection matrix used to rotate/transform the reflection.
  23509. * @returns the reflection matrix
  23510. */
  23511. getReflectionTextureMatrix(): Matrix;
  23512. /**
  23513. * Resize the texture to a new desired size.
  23514. * Be carrefull as it will recreate all the data in the new texture.
  23515. * @param size Define the new size. It can be:
  23516. * - a number for squared texture,
  23517. * - an object containing { width: number, height: number }
  23518. * - or an object containing a ratio { ratio: number }
  23519. */
  23520. resize(size: number | {
  23521. width: number;
  23522. height: number;
  23523. } | {
  23524. ratio: number;
  23525. }): void;
  23526. private _defaultRenderListPrepared;
  23527. /**
  23528. * Renders all the objects from the render list into the texture.
  23529. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23530. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23531. */
  23532. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23533. private _bestReflectionRenderTargetDimension;
  23534. private _prepareRenderingManager;
  23535. /**
  23536. * @hidden
  23537. * @param faceIndex face index to bind to if this is a cubetexture
  23538. * @param layer defines the index of the texture to bind in the array
  23539. */
  23540. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23542. private renderToTarget;
  23543. /**
  23544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23545. * This allowed control for front to back rendering or reversly depending of the special needs.
  23546. *
  23547. * @param renderingGroupId The rendering group id corresponding to its index
  23548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23551. */
  23552. 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;
  23553. /**
  23554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23555. *
  23556. * @param renderingGroupId The rendering group id corresponding to its index
  23557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23558. */
  23559. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23560. /**
  23561. * Clones the texture.
  23562. * @returns the cloned texture
  23563. */
  23564. clone(): RenderTargetTexture;
  23565. /**
  23566. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23567. * @returns The JSON representation of the texture
  23568. */
  23569. serialize(): any;
  23570. /**
  23571. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23572. */
  23573. disposeFramebufferObjects(): void;
  23574. /**
  23575. * Dispose the texture and release its associated resources.
  23576. */
  23577. dispose(): void;
  23578. /** @hidden */
  23579. _rebuild(): void;
  23580. /**
  23581. * Clear the info related to rendering groups preventing retention point in material dispose.
  23582. */
  23583. freeRenderingGroups(): void;
  23584. /**
  23585. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23586. * @returns the view count
  23587. */
  23588. getViewCount(): number;
  23589. }
  23590. }
  23591. declare module BABYLON {
  23592. /**
  23593. * Class used to manipulate GUIDs
  23594. */
  23595. export class GUID {
  23596. /**
  23597. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23598. * Be aware Math.random() could cause collisions, but:
  23599. * "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"
  23600. * @returns a pseudo random id
  23601. */
  23602. static RandomId(): string;
  23603. }
  23604. }
  23605. declare module BABYLON {
  23606. /**
  23607. * Options to be used when creating a shadow depth material
  23608. */
  23609. export interface IIOptionShadowDepthMaterial {
  23610. /** Variables in the vertex shader code that need to have their names remapped.
  23611. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23612. * "var_name" should be either: worldPos or vNormalW
  23613. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23614. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23615. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23616. */
  23617. remappedVariables?: string[];
  23618. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23619. standalone?: boolean;
  23620. }
  23621. /**
  23622. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23623. */
  23624. export class ShadowDepthWrapper {
  23625. private _scene;
  23626. private _options?;
  23627. private _baseMaterial;
  23628. private _onEffectCreatedObserver;
  23629. private _subMeshToEffect;
  23630. private _subMeshToDepthEffect;
  23631. private _meshes;
  23632. /** @hidden */
  23633. _matriceNames: any;
  23634. /** Gets the standalone status of the wrapper */
  23635. get standalone(): boolean;
  23636. /** Gets the base material the wrapper is built upon */
  23637. get baseMaterial(): Material;
  23638. /**
  23639. * Instantiate a new shadow depth wrapper.
  23640. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23641. * generate the shadow depth map. For more information, please refer to the documentation:
  23642. * https://doc.babylonjs.com/babylon101/shadows
  23643. * @param baseMaterial Material to wrap
  23644. * @param scene Define the scene the material belongs to
  23645. * @param options Options used to create the wrapper
  23646. */
  23647. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23648. /**
  23649. * Gets the effect to use to generate the depth map
  23650. * @param subMesh subMesh to get the effect for
  23651. * @param shadowGenerator shadow generator to get the effect for
  23652. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23653. */
  23654. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23655. /**
  23656. * Specifies that the submesh is ready to be used for depth rendering
  23657. * @param subMesh submesh to check
  23658. * @param defines the list of defines to take into account when checking the effect
  23659. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23660. * @param useInstances specifies that instances should be used
  23661. * @returns a boolean indicating that the submesh is ready or not
  23662. */
  23663. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23664. /**
  23665. * Disposes the resources
  23666. */
  23667. dispose(): void;
  23668. private _makeEffect;
  23669. }
  23670. }
  23671. declare module BABYLON {
  23672. /**
  23673. * Options for compiling materials.
  23674. */
  23675. export interface IMaterialCompilationOptions {
  23676. /**
  23677. * Defines whether clip planes are enabled.
  23678. */
  23679. clipPlane: boolean;
  23680. /**
  23681. * Defines whether instances are enabled.
  23682. */
  23683. useInstances: boolean;
  23684. }
  23685. /**
  23686. * Options passed when calling customShaderNameResolve
  23687. */
  23688. export interface ICustomShaderNameResolveOptions {
  23689. /**
  23690. * 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
  23691. */
  23692. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23693. }
  23694. /**
  23695. * Base class for the main features of a material in Babylon.js
  23696. */
  23697. export class Material implements IAnimatable {
  23698. /**
  23699. * Returns the triangle fill mode
  23700. */
  23701. static readonly TriangleFillMode: number;
  23702. /**
  23703. * Returns the wireframe mode
  23704. */
  23705. static readonly WireFrameFillMode: number;
  23706. /**
  23707. * Returns the point fill mode
  23708. */
  23709. static readonly PointFillMode: number;
  23710. /**
  23711. * Returns the point list draw mode
  23712. */
  23713. static readonly PointListDrawMode: number;
  23714. /**
  23715. * Returns the line list draw mode
  23716. */
  23717. static readonly LineListDrawMode: number;
  23718. /**
  23719. * Returns the line loop draw mode
  23720. */
  23721. static readonly LineLoopDrawMode: number;
  23722. /**
  23723. * Returns the line strip draw mode
  23724. */
  23725. static readonly LineStripDrawMode: number;
  23726. /**
  23727. * Returns the triangle strip draw mode
  23728. */
  23729. static readonly TriangleStripDrawMode: number;
  23730. /**
  23731. * Returns the triangle fan draw mode
  23732. */
  23733. static readonly TriangleFanDrawMode: number;
  23734. /**
  23735. * Stores the clock-wise side orientation
  23736. */
  23737. static readonly ClockWiseSideOrientation: number;
  23738. /**
  23739. * Stores the counter clock-wise side orientation
  23740. */
  23741. static readonly CounterClockWiseSideOrientation: number;
  23742. /**
  23743. * The dirty texture flag value
  23744. */
  23745. static readonly TextureDirtyFlag: number;
  23746. /**
  23747. * The dirty light flag value
  23748. */
  23749. static readonly LightDirtyFlag: number;
  23750. /**
  23751. * The dirty fresnel flag value
  23752. */
  23753. static readonly FresnelDirtyFlag: number;
  23754. /**
  23755. * The dirty attribute flag value
  23756. */
  23757. static readonly AttributesDirtyFlag: number;
  23758. /**
  23759. * The dirty misc flag value
  23760. */
  23761. static readonly MiscDirtyFlag: number;
  23762. /**
  23763. * The all dirty flag value
  23764. */
  23765. static readonly AllDirtyFlag: number;
  23766. /**
  23767. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23768. */
  23769. static readonly MATERIAL_OPAQUE: number;
  23770. /**
  23771. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23772. */
  23773. static readonly MATERIAL_ALPHATEST: number;
  23774. /**
  23775. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23776. */
  23777. static readonly MATERIAL_ALPHABLEND: number;
  23778. /**
  23779. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23780. * They are also discarded below the alpha cutoff threshold to improve performances.
  23781. */
  23782. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23783. /**
  23784. * Custom callback helping to override the default shader used in the material.
  23785. */
  23786. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23787. /**
  23788. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23789. */
  23790. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23791. /**
  23792. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23793. * This means that the material can keep using a previous shader while a new one is being compiled.
  23794. * This is mostly used when shader parallel compilation is supported (true by default)
  23795. */
  23796. allowShaderHotSwapping: boolean;
  23797. /**
  23798. * The ID of the material
  23799. */
  23800. id: string;
  23801. /**
  23802. * Gets or sets the unique id of the material
  23803. */
  23804. uniqueId: number;
  23805. /**
  23806. * The name of the material
  23807. */
  23808. name: string;
  23809. /**
  23810. * Gets or sets user defined metadata
  23811. */
  23812. metadata: any;
  23813. /**
  23814. * For internal use only. Please do not use.
  23815. */
  23816. reservedDataStore: any;
  23817. /**
  23818. * Specifies if the ready state should be checked on each call
  23819. */
  23820. checkReadyOnEveryCall: boolean;
  23821. /**
  23822. * Specifies if the ready state should be checked once
  23823. */
  23824. checkReadyOnlyOnce: boolean;
  23825. /**
  23826. * The state of the material
  23827. */
  23828. state: string;
  23829. /**
  23830. * The alpha value of the material
  23831. */
  23832. protected _alpha: number;
  23833. /**
  23834. * List of inspectable custom properties (used by the Inspector)
  23835. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23836. */
  23837. inspectableCustomProperties: IInspectable[];
  23838. /**
  23839. * Sets the alpha value of the material
  23840. */
  23841. set alpha(value: number);
  23842. /**
  23843. * Gets the alpha value of the material
  23844. */
  23845. get alpha(): number;
  23846. /**
  23847. * Specifies if back face culling is enabled
  23848. */
  23849. protected _backFaceCulling: boolean;
  23850. /**
  23851. * Sets the back-face culling state
  23852. */
  23853. set backFaceCulling(value: boolean);
  23854. /**
  23855. * Gets the back-face culling state
  23856. */
  23857. get backFaceCulling(): boolean;
  23858. /**
  23859. * Stores the value for side orientation
  23860. */
  23861. sideOrientation: number;
  23862. /**
  23863. * Callback triggered when the material is compiled
  23864. */
  23865. onCompiled: Nullable<(effect: Effect) => void>;
  23866. /**
  23867. * Callback triggered when an error occurs
  23868. */
  23869. onError: Nullable<(effect: Effect, errors: string) => void>;
  23870. /**
  23871. * Callback triggered to get the render target textures
  23872. */
  23873. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23874. /**
  23875. * Gets a boolean indicating that current material needs to register RTT
  23876. */
  23877. get hasRenderTargetTextures(): boolean;
  23878. /**
  23879. * Specifies if the material should be serialized
  23880. */
  23881. doNotSerialize: boolean;
  23882. /**
  23883. * @hidden
  23884. */
  23885. _storeEffectOnSubMeshes: boolean;
  23886. /**
  23887. * Stores the animations for the material
  23888. */
  23889. animations: Nullable<Array<Animation>>;
  23890. /**
  23891. * An event triggered when the material is disposed
  23892. */
  23893. onDisposeObservable: Observable<Material>;
  23894. /**
  23895. * An observer which watches for dispose events
  23896. */
  23897. private _onDisposeObserver;
  23898. private _onUnBindObservable;
  23899. /**
  23900. * Called during a dispose event
  23901. */
  23902. set onDispose(callback: () => void);
  23903. private _onBindObservable;
  23904. /**
  23905. * An event triggered when the material is bound
  23906. */
  23907. get onBindObservable(): Observable<AbstractMesh>;
  23908. /**
  23909. * An observer which watches for bind events
  23910. */
  23911. private _onBindObserver;
  23912. /**
  23913. * Called during a bind event
  23914. */
  23915. set onBind(callback: (Mesh: AbstractMesh) => void);
  23916. /**
  23917. * An event triggered when the material is unbound
  23918. */
  23919. get onUnBindObservable(): Observable<Material>;
  23920. protected _onEffectCreatedObservable: Nullable<Observable<{
  23921. effect: Effect;
  23922. subMesh: Nullable<SubMesh>;
  23923. }>>;
  23924. /**
  23925. * An event triggered when the effect is (re)created
  23926. */
  23927. get onEffectCreatedObservable(): Observable<{
  23928. effect: Effect;
  23929. subMesh: Nullable<SubMesh>;
  23930. }>;
  23931. /**
  23932. * Stores the value of the alpha mode
  23933. */
  23934. private _alphaMode;
  23935. /**
  23936. * Sets the value of the alpha mode.
  23937. *
  23938. * | Value | Type | Description |
  23939. * | --- | --- | --- |
  23940. * | 0 | ALPHA_DISABLE | |
  23941. * | 1 | ALPHA_ADD | |
  23942. * | 2 | ALPHA_COMBINE | |
  23943. * | 3 | ALPHA_SUBTRACT | |
  23944. * | 4 | ALPHA_MULTIPLY | |
  23945. * | 5 | ALPHA_MAXIMIZED | |
  23946. * | 6 | ALPHA_ONEONE | |
  23947. * | 7 | ALPHA_PREMULTIPLIED | |
  23948. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23949. * | 9 | ALPHA_INTERPOLATE | |
  23950. * | 10 | ALPHA_SCREENMODE | |
  23951. *
  23952. */
  23953. set alphaMode(value: number);
  23954. /**
  23955. * Gets the value of the alpha mode
  23956. */
  23957. get alphaMode(): number;
  23958. /**
  23959. * Stores the state of the need depth pre-pass value
  23960. */
  23961. private _needDepthPrePass;
  23962. /**
  23963. * Sets the need depth pre-pass value
  23964. */
  23965. set needDepthPrePass(value: boolean);
  23966. /**
  23967. * Gets the depth pre-pass value
  23968. */
  23969. get needDepthPrePass(): boolean;
  23970. /**
  23971. * Specifies if depth writing should be disabled
  23972. */
  23973. disableDepthWrite: boolean;
  23974. /**
  23975. * Specifies if color writing should be disabled
  23976. */
  23977. disableColorWrite: boolean;
  23978. /**
  23979. * Specifies if depth writing should be forced
  23980. */
  23981. forceDepthWrite: boolean;
  23982. /**
  23983. * Specifies the depth function that should be used. 0 means the default engine function
  23984. */
  23985. depthFunction: number;
  23986. /**
  23987. * Specifies if there should be a separate pass for culling
  23988. */
  23989. separateCullingPass: boolean;
  23990. /**
  23991. * Stores the state specifing if fog should be enabled
  23992. */
  23993. private _fogEnabled;
  23994. /**
  23995. * Sets the state for enabling fog
  23996. */
  23997. set fogEnabled(value: boolean);
  23998. /**
  23999. * Gets the value of the fog enabled state
  24000. */
  24001. get fogEnabled(): boolean;
  24002. /**
  24003. * Stores the size of points
  24004. */
  24005. pointSize: number;
  24006. /**
  24007. * Stores the z offset value
  24008. */
  24009. zOffset: number;
  24010. get wireframe(): boolean;
  24011. /**
  24012. * Sets the state of wireframe mode
  24013. */
  24014. set wireframe(value: boolean);
  24015. /**
  24016. * Gets the value specifying if point clouds are enabled
  24017. */
  24018. get pointsCloud(): boolean;
  24019. /**
  24020. * Sets the state of point cloud mode
  24021. */
  24022. set pointsCloud(value: boolean);
  24023. /**
  24024. * Gets the material fill mode
  24025. */
  24026. get fillMode(): number;
  24027. /**
  24028. * Sets the material fill mode
  24029. */
  24030. set fillMode(value: number);
  24031. /**
  24032. * @hidden
  24033. * Stores the effects for the material
  24034. */
  24035. _effect: Nullable<Effect>;
  24036. /**
  24037. * Specifies if uniform buffers should be used
  24038. */
  24039. private _useUBO;
  24040. /**
  24041. * Stores a reference to the scene
  24042. */
  24043. private _scene;
  24044. /**
  24045. * Stores the fill mode state
  24046. */
  24047. private _fillMode;
  24048. /**
  24049. * Specifies if the depth write state should be cached
  24050. */
  24051. private _cachedDepthWriteState;
  24052. /**
  24053. * Specifies if the color write state should be cached
  24054. */
  24055. private _cachedColorWriteState;
  24056. /**
  24057. * Specifies if the depth function state should be cached
  24058. */
  24059. private _cachedDepthFunctionState;
  24060. /**
  24061. * Stores the uniform buffer
  24062. */
  24063. protected _uniformBuffer: UniformBuffer;
  24064. /** @hidden */
  24065. _indexInSceneMaterialArray: number;
  24066. /** @hidden */
  24067. meshMap: Nullable<{
  24068. [id: string]: AbstractMesh | undefined;
  24069. }>;
  24070. /**
  24071. * Creates a material instance
  24072. * @param name defines the name of the material
  24073. * @param scene defines the scene to reference
  24074. * @param doNotAdd specifies if the material should be added to the scene
  24075. */
  24076. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24077. /**
  24078. * Returns a string representation of the current material
  24079. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24080. * @returns a string with material information
  24081. */
  24082. toString(fullDetails?: boolean): string;
  24083. /**
  24084. * Gets the class name of the material
  24085. * @returns a string with the class name of the material
  24086. */
  24087. getClassName(): string;
  24088. /**
  24089. * Specifies if updates for the material been locked
  24090. */
  24091. get isFrozen(): boolean;
  24092. /**
  24093. * Locks updates for the material
  24094. */
  24095. freeze(): void;
  24096. /**
  24097. * Unlocks updates for the material
  24098. */
  24099. unfreeze(): void;
  24100. /**
  24101. * Specifies if the material is ready to be used
  24102. * @param mesh defines the mesh to check
  24103. * @param useInstances specifies if instances should be used
  24104. * @returns a boolean indicating if the material is ready to be used
  24105. */
  24106. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24107. /**
  24108. * Specifies that the submesh is ready to be used
  24109. * @param mesh defines the mesh to check
  24110. * @param subMesh defines which submesh to check
  24111. * @param useInstances specifies that instances should be used
  24112. * @returns a boolean indicating that the submesh is ready or not
  24113. */
  24114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24115. /**
  24116. * Returns the material effect
  24117. * @returns the effect associated with the material
  24118. */
  24119. getEffect(): Nullable<Effect>;
  24120. /**
  24121. * Returns the current scene
  24122. * @returns a Scene
  24123. */
  24124. getScene(): Scene;
  24125. /**
  24126. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24127. */
  24128. protected _forceAlphaTest: boolean;
  24129. /**
  24130. * The transparency mode of the material.
  24131. */
  24132. protected _transparencyMode: Nullable<number>;
  24133. /**
  24134. * Gets the current transparency mode.
  24135. */
  24136. get transparencyMode(): Nullable<number>;
  24137. /**
  24138. * Sets the transparency mode of the material.
  24139. *
  24140. * | Value | Type | Description |
  24141. * | ----- | ----------------------------------- | ----------- |
  24142. * | 0 | OPAQUE | |
  24143. * | 1 | ALPHATEST | |
  24144. * | 2 | ALPHABLEND | |
  24145. * | 3 | ALPHATESTANDBLEND | |
  24146. *
  24147. */
  24148. set transparencyMode(value: Nullable<number>);
  24149. /**
  24150. * Returns true if alpha blending should be disabled.
  24151. */
  24152. protected get _disableAlphaBlending(): boolean;
  24153. /**
  24154. * Specifies whether or not this material should be rendered in alpha blend mode.
  24155. * @returns a boolean specifying if alpha blending is needed
  24156. */
  24157. needAlphaBlending(): boolean;
  24158. /**
  24159. * Specifies if the mesh will require alpha blending
  24160. * @param mesh defines the mesh to check
  24161. * @returns a boolean specifying if alpha blending is needed for the mesh
  24162. */
  24163. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24164. /**
  24165. * Specifies whether or not this material should be rendered in alpha test mode.
  24166. * @returns a boolean specifying if an alpha test is needed.
  24167. */
  24168. needAlphaTesting(): boolean;
  24169. /**
  24170. * Specifies if material alpha testing should be turned on for the mesh
  24171. * @param mesh defines the mesh to check
  24172. */
  24173. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24174. /**
  24175. * Gets the texture used for the alpha test
  24176. * @returns the texture to use for alpha testing
  24177. */
  24178. getAlphaTestTexture(): Nullable<BaseTexture>;
  24179. /**
  24180. * Marks the material to indicate that it needs to be re-calculated
  24181. */
  24182. markDirty(): void;
  24183. /** @hidden */
  24184. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24185. /**
  24186. * Binds the material to the mesh
  24187. * @param world defines the world transformation matrix
  24188. * @param mesh defines the mesh to bind the material to
  24189. */
  24190. bind(world: Matrix, mesh?: Mesh): void;
  24191. /**
  24192. * Binds the submesh to the material
  24193. * @param world defines the world transformation matrix
  24194. * @param mesh defines the mesh containing the submesh
  24195. * @param subMesh defines the submesh to bind the material to
  24196. */
  24197. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24198. /**
  24199. * Binds the world matrix to the material
  24200. * @param world defines the world transformation matrix
  24201. */
  24202. bindOnlyWorldMatrix(world: Matrix): void;
  24203. /**
  24204. * Binds the scene's uniform buffer to the effect.
  24205. * @param effect defines the effect to bind to the scene uniform buffer
  24206. * @param sceneUbo defines the uniform buffer storing scene data
  24207. */
  24208. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24209. /**
  24210. * Binds the view matrix to the effect
  24211. * @param effect defines the effect to bind the view matrix to
  24212. */
  24213. bindView(effect: Effect): void;
  24214. /**
  24215. * Binds the view projection matrix to the effect
  24216. * @param effect defines the effect to bind the view projection matrix to
  24217. */
  24218. bindViewProjection(effect: Effect): void;
  24219. /**
  24220. * Processes to execute after binding the material to a mesh
  24221. * @param mesh defines the rendered mesh
  24222. */
  24223. protected _afterBind(mesh?: Mesh): void;
  24224. /**
  24225. * Unbinds the material from the mesh
  24226. */
  24227. unbind(): void;
  24228. /**
  24229. * Gets the active textures from the material
  24230. * @returns an array of textures
  24231. */
  24232. getActiveTextures(): BaseTexture[];
  24233. /**
  24234. * Specifies if the material uses a texture
  24235. * @param texture defines the texture to check against the material
  24236. * @returns a boolean specifying if the material uses the texture
  24237. */
  24238. hasTexture(texture: BaseTexture): boolean;
  24239. /**
  24240. * Makes a duplicate of the material, and gives it a new name
  24241. * @param name defines the new name for the duplicated material
  24242. * @returns the cloned material
  24243. */
  24244. clone(name: string): Nullable<Material>;
  24245. /**
  24246. * Gets the meshes bound to the material
  24247. * @returns an array of meshes bound to the material
  24248. */
  24249. getBindedMeshes(): AbstractMesh[];
  24250. /**
  24251. * Force shader compilation
  24252. * @param mesh defines the mesh associated with this material
  24253. * @param onCompiled defines a function to execute once the material is compiled
  24254. * @param options defines the options to configure the compilation
  24255. * @param onError defines a function to execute if the material fails compiling
  24256. */
  24257. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24258. /**
  24259. * Force shader compilation
  24260. * @param mesh defines the mesh that will use this material
  24261. * @param options defines additional options for compiling the shaders
  24262. * @returns a promise that resolves when the compilation completes
  24263. */
  24264. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24265. private static readonly _AllDirtyCallBack;
  24266. private static readonly _ImageProcessingDirtyCallBack;
  24267. private static readonly _TextureDirtyCallBack;
  24268. private static readonly _FresnelDirtyCallBack;
  24269. private static readonly _MiscDirtyCallBack;
  24270. private static readonly _LightsDirtyCallBack;
  24271. private static readonly _AttributeDirtyCallBack;
  24272. private static _FresnelAndMiscDirtyCallBack;
  24273. private static _TextureAndMiscDirtyCallBack;
  24274. private static readonly _DirtyCallbackArray;
  24275. private static readonly _RunDirtyCallBacks;
  24276. /**
  24277. * Marks a define in the material to indicate that it needs to be re-computed
  24278. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24279. */
  24280. markAsDirty(flag: number): void;
  24281. /**
  24282. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24283. * @param func defines a function which checks material defines against the submeshes
  24284. */
  24285. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24286. /**
  24287. * Indicates that we need to re-calculated for all submeshes
  24288. */
  24289. protected _markAllSubMeshesAsAllDirty(): void;
  24290. /**
  24291. * Indicates that image processing needs to be re-calculated for all submeshes
  24292. */
  24293. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24294. /**
  24295. * Indicates that textures need to be re-calculated for all submeshes
  24296. */
  24297. protected _markAllSubMeshesAsTexturesDirty(): void;
  24298. /**
  24299. * Indicates that fresnel needs to be re-calculated for all submeshes
  24300. */
  24301. protected _markAllSubMeshesAsFresnelDirty(): void;
  24302. /**
  24303. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24304. */
  24305. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24306. /**
  24307. * Indicates that lights need to be re-calculated for all submeshes
  24308. */
  24309. protected _markAllSubMeshesAsLightsDirty(): void;
  24310. /**
  24311. * Indicates that attributes need to be re-calculated for all submeshes
  24312. */
  24313. protected _markAllSubMeshesAsAttributesDirty(): void;
  24314. /**
  24315. * Indicates that misc needs to be re-calculated for all submeshes
  24316. */
  24317. protected _markAllSubMeshesAsMiscDirty(): void;
  24318. /**
  24319. * Indicates that textures and misc need to be re-calculated for all submeshes
  24320. */
  24321. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24322. /**
  24323. * Disposes the material
  24324. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24325. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24326. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24327. */
  24328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24329. /** @hidden */
  24330. private releaseVertexArrayObject;
  24331. /**
  24332. * Serializes this material
  24333. * @returns the serialized material object
  24334. */
  24335. serialize(): any;
  24336. /**
  24337. * Creates a material from parsed material data
  24338. * @param parsedMaterial defines parsed material data
  24339. * @param scene defines the hosting scene
  24340. * @param rootUrl defines the root URL to use to load textures
  24341. * @returns a new material
  24342. */
  24343. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24344. }
  24345. }
  24346. declare module BABYLON {
  24347. /**
  24348. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24349. * separate meshes. This can be use to improve performances.
  24350. * @see http://doc.babylonjs.com/how_to/multi_materials
  24351. */
  24352. export class MultiMaterial extends Material {
  24353. private _subMaterials;
  24354. /**
  24355. * Gets or Sets the list of Materials used within the multi material.
  24356. * They need to be ordered according to the submeshes order in the associated mesh
  24357. */
  24358. get subMaterials(): Nullable<Material>[];
  24359. set subMaterials(value: Nullable<Material>[]);
  24360. /**
  24361. * Function used to align with Node.getChildren()
  24362. * @returns the list of Materials used within the multi material
  24363. */
  24364. getChildren(): Nullable<Material>[];
  24365. /**
  24366. * Instantiates a new Multi Material
  24367. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24368. * separate meshes. This can be use to improve performances.
  24369. * @see http://doc.babylonjs.com/how_to/multi_materials
  24370. * @param name Define the name in the scene
  24371. * @param scene Define the scene the material belongs to
  24372. */
  24373. constructor(name: string, scene: Scene);
  24374. private _hookArray;
  24375. /**
  24376. * Get one of the submaterial by its index in the submaterials array
  24377. * @param index The index to look the sub material at
  24378. * @returns The Material if the index has been defined
  24379. */
  24380. getSubMaterial(index: number): Nullable<Material>;
  24381. /**
  24382. * Get the list of active textures for the whole sub materials list.
  24383. * @returns All the textures that will be used during the rendering
  24384. */
  24385. getActiveTextures(): BaseTexture[];
  24386. /**
  24387. * Gets the current class name of the material e.g. "MultiMaterial"
  24388. * Mainly use in serialization.
  24389. * @returns the class name
  24390. */
  24391. getClassName(): string;
  24392. /**
  24393. * Checks if the material is ready to render the requested sub mesh
  24394. * @param mesh Define the mesh the submesh belongs to
  24395. * @param subMesh Define the sub mesh to look readyness for
  24396. * @param useInstances Define whether or not the material is used with instances
  24397. * @returns true if ready, otherwise false
  24398. */
  24399. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24400. /**
  24401. * Clones the current material and its related sub materials
  24402. * @param name Define the name of the newly cloned material
  24403. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24404. * @returns the cloned material
  24405. */
  24406. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24407. /**
  24408. * Serializes the materials into a JSON representation.
  24409. * @returns the JSON representation
  24410. */
  24411. serialize(): any;
  24412. /**
  24413. * Dispose the material and release its associated resources
  24414. * @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)
  24415. * @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)
  24416. * @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)
  24417. */
  24418. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24419. /**
  24420. * Creates a MultiMaterial from parsed MultiMaterial data.
  24421. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24422. * @param scene defines the hosting scene
  24423. * @returns a new MultiMaterial
  24424. */
  24425. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24426. }
  24427. }
  24428. declare module BABYLON {
  24429. /**
  24430. * Defines a subdivision inside a mesh
  24431. */
  24432. export class SubMesh implements ICullable {
  24433. /** the material index to use */
  24434. materialIndex: number;
  24435. /** vertex index start */
  24436. verticesStart: number;
  24437. /** vertices count */
  24438. verticesCount: number;
  24439. /** index start */
  24440. indexStart: number;
  24441. /** indices count */
  24442. indexCount: number;
  24443. /** @hidden */
  24444. _materialDefines: Nullable<MaterialDefines>;
  24445. /** @hidden */
  24446. _materialEffect: Nullable<Effect>;
  24447. /** @hidden */
  24448. _effectOverride: Nullable<Effect>;
  24449. /**
  24450. * Gets material defines used by the effect associated to the sub mesh
  24451. */
  24452. get materialDefines(): Nullable<MaterialDefines>;
  24453. /**
  24454. * Sets material defines used by the effect associated to the sub mesh
  24455. */
  24456. set materialDefines(defines: Nullable<MaterialDefines>);
  24457. /**
  24458. * Gets associated effect
  24459. */
  24460. get effect(): Nullable<Effect>;
  24461. /**
  24462. * Sets associated effect (effect used to render this submesh)
  24463. * @param effect defines the effect to associate with
  24464. * @param defines defines the set of defines used to compile this effect
  24465. */
  24466. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24467. /** @hidden */
  24468. _linesIndexCount: number;
  24469. private _mesh;
  24470. private _renderingMesh;
  24471. private _boundingInfo;
  24472. private _linesIndexBuffer;
  24473. /** @hidden */
  24474. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24475. /** @hidden */
  24476. _trianglePlanes: Plane[];
  24477. /** @hidden */
  24478. _lastColliderTransformMatrix: Nullable<Matrix>;
  24479. /** @hidden */
  24480. _renderId: number;
  24481. /** @hidden */
  24482. _alphaIndex: number;
  24483. /** @hidden */
  24484. _distanceToCamera: number;
  24485. /** @hidden */
  24486. _id: number;
  24487. private _currentMaterial;
  24488. /**
  24489. * Add a new submesh to a mesh
  24490. * @param materialIndex defines the material index to use
  24491. * @param verticesStart defines vertex index start
  24492. * @param verticesCount defines vertices count
  24493. * @param indexStart defines index start
  24494. * @param indexCount defines indices count
  24495. * @param mesh defines the parent mesh
  24496. * @param renderingMesh defines an optional rendering mesh
  24497. * @param createBoundingBox defines if bounding box should be created for this submesh
  24498. * @returns the new submesh
  24499. */
  24500. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24501. /**
  24502. * Creates a new submesh
  24503. * @param materialIndex defines the material index to use
  24504. * @param verticesStart defines vertex index start
  24505. * @param verticesCount defines vertices count
  24506. * @param indexStart defines index start
  24507. * @param indexCount defines indices count
  24508. * @param mesh defines the parent mesh
  24509. * @param renderingMesh defines an optional rendering mesh
  24510. * @param createBoundingBox defines if bounding box should be created for this submesh
  24511. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24512. */
  24513. constructor(
  24514. /** the material index to use */
  24515. materialIndex: number,
  24516. /** vertex index start */
  24517. verticesStart: number,
  24518. /** vertices count */
  24519. verticesCount: number,
  24520. /** index start */
  24521. indexStart: number,
  24522. /** indices count */
  24523. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24524. /**
  24525. * Returns true if this submesh covers the entire parent mesh
  24526. * @ignorenaming
  24527. */
  24528. get IsGlobal(): boolean;
  24529. /**
  24530. * Returns the submesh BoudingInfo object
  24531. * @returns current bounding info (or mesh's one if the submesh is global)
  24532. */
  24533. getBoundingInfo(): BoundingInfo;
  24534. /**
  24535. * Sets the submesh BoundingInfo
  24536. * @param boundingInfo defines the new bounding info to use
  24537. * @returns the SubMesh
  24538. */
  24539. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24540. /**
  24541. * Returns the mesh of the current submesh
  24542. * @return the parent mesh
  24543. */
  24544. getMesh(): AbstractMesh;
  24545. /**
  24546. * Returns the rendering mesh of the submesh
  24547. * @returns the rendering mesh (could be different from parent mesh)
  24548. */
  24549. getRenderingMesh(): Mesh;
  24550. /**
  24551. * Returns the replacement mesh of the submesh
  24552. * @returns the replacement mesh (could be different from parent mesh)
  24553. */
  24554. getReplacementMesh(): Nullable<AbstractMesh>;
  24555. /**
  24556. * Returns the effective mesh of the submesh
  24557. * @returns the effective mesh (could be different from parent mesh)
  24558. */
  24559. getEffectiveMesh(): AbstractMesh;
  24560. /**
  24561. * Returns the submesh material
  24562. * @returns null or the current material
  24563. */
  24564. getMaterial(): Nullable<Material>;
  24565. /**
  24566. * Sets a new updated BoundingInfo object to the submesh
  24567. * @param data defines an optional position array to use to determine the bounding info
  24568. * @returns the SubMesh
  24569. */
  24570. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24571. /** @hidden */
  24572. _checkCollision(collider: Collider): boolean;
  24573. /**
  24574. * Updates the submesh BoundingInfo
  24575. * @param world defines the world matrix to use to update the bounding info
  24576. * @returns the submesh
  24577. */
  24578. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24579. /**
  24580. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24581. * @param frustumPlanes defines the frustum planes
  24582. * @returns true if the submesh is intersecting with the frustum
  24583. */
  24584. isInFrustum(frustumPlanes: Plane[]): boolean;
  24585. /**
  24586. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24587. * @param frustumPlanes defines the frustum planes
  24588. * @returns true if the submesh is inside the frustum
  24589. */
  24590. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24591. /**
  24592. * Renders the submesh
  24593. * @param enableAlphaMode defines if alpha needs to be used
  24594. * @returns the submesh
  24595. */
  24596. render(enableAlphaMode: boolean): SubMesh;
  24597. /**
  24598. * @hidden
  24599. */
  24600. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24601. /**
  24602. * Checks if the submesh intersects with a ray
  24603. * @param ray defines the ray to test
  24604. * @returns true is the passed ray intersects the submesh bounding box
  24605. */
  24606. canIntersects(ray: Ray): boolean;
  24607. /**
  24608. * Intersects current submesh with a ray
  24609. * @param ray defines the ray to test
  24610. * @param positions defines mesh's positions array
  24611. * @param indices defines mesh's indices array
  24612. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24613. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24614. * @returns intersection info or null if no intersection
  24615. */
  24616. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24617. /** @hidden */
  24618. private _intersectLines;
  24619. /** @hidden */
  24620. private _intersectUnIndexedLines;
  24621. /** @hidden */
  24622. private _intersectTriangles;
  24623. /** @hidden */
  24624. private _intersectUnIndexedTriangles;
  24625. /** @hidden */
  24626. _rebuild(): void;
  24627. /**
  24628. * Creates a new submesh from the passed mesh
  24629. * @param newMesh defines the new hosting mesh
  24630. * @param newRenderingMesh defines an optional rendering mesh
  24631. * @returns the new submesh
  24632. */
  24633. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24634. /**
  24635. * Release associated resources
  24636. */
  24637. dispose(): void;
  24638. /**
  24639. * Gets the class name
  24640. * @returns the string "SubMesh".
  24641. */
  24642. getClassName(): string;
  24643. /**
  24644. * Creates a new submesh from indices data
  24645. * @param materialIndex the index of the main mesh material
  24646. * @param startIndex the index where to start the copy in the mesh indices array
  24647. * @param indexCount the number of indices to copy then from the startIndex
  24648. * @param mesh the main mesh to create the submesh from
  24649. * @param renderingMesh the optional rendering mesh
  24650. * @returns a new submesh
  24651. */
  24652. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24653. }
  24654. }
  24655. declare module BABYLON {
  24656. /**
  24657. * Class used to represent data loading progression
  24658. */
  24659. export class SceneLoaderFlags {
  24660. private static _ForceFullSceneLoadingForIncremental;
  24661. private static _ShowLoadingScreen;
  24662. private static _CleanBoneMatrixWeights;
  24663. private static _loggingLevel;
  24664. /**
  24665. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24666. */
  24667. static get ForceFullSceneLoadingForIncremental(): boolean;
  24668. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24669. /**
  24670. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24671. */
  24672. static get ShowLoadingScreen(): boolean;
  24673. static set ShowLoadingScreen(value: boolean);
  24674. /**
  24675. * Defines the current logging level (while loading the scene)
  24676. * @ignorenaming
  24677. */
  24678. static get loggingLevel(): number;
  24679. static set loggingLevel(value: number);
  24680. /**
  24681. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24682. */
  24683. static get CleanBoneMatrixWeights(): boolean;
  24684. static set CleanBoneMatrixWeights(value: boolean);
  24685. }
  24686. }
  24687. declare module BABYLON {
  24688. /**
  24689. * Class used to store geometry data (vertex buffers + index buffer)
  24690. */
  24691. export class Geometry implements IGetSetVerticesData {
  24692. /**
  24693. * Gets or sets the ID of the geometry
  24694. */
  24695. id: string;
  24696. /**
  24697. * Gets or sets the unique ID of the geometry
  24698. */
  24699. uniqueId: number;
  24700. /**
  24701. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24702. */
  24703. delayLoadState: number;
  24704. /**
  24705. * Gets the file containing the data to load when running in delay load state
  24706. */
  24707. delayLoadingFile: Nullable<string>;
  24708. /**
  24709. * Callback called when the geometry is updated
  24710. */
  24711. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24712. private _scene;
  24713. private _engine;
  24714. private _meshes;
  24715. private _totalVertices;
  24716. /** @hidden */
  24717. _indices: IndicesArray;
  24718. /** @hidden */
  24719. _vertexBuffers: {
  24720. [key: string]: VertexBuffer;
  24721. };
  24722. private _isDisposed;
  24723. private _extend;
  24724. private _boundingBias;
  24725. /** @hidden */
  24726. _delayInfo: Array<string>;
  24727. private _indexBuffer;
  24728. private _indexBufferIsUpdatable;
  24729. /** @hidden */
  24730. _boundingInfo: Nullable<BoundingInfo>;
  24731. /** @hidden */
  24732. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24733. /** @hidden */
  24734. _softwareSkinningFrameId: number;
  24735. private _vertexArrayObjects;
  24736. private _updatable;
  24737. /** @hidden */
  24738. _positions: Nullable<Vector3[]>;
  24739. /**
  24740. * 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
  24741. */
  24742. get boundingBias(): Vector2;
  24743. /**
  24744. * 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
  24745. */
  24746. set boundingBias(value: Vector2);
  24747. /**
  24748. * Static function used to attach a new empty geometry to a mesh
  24749. * @param mesh defines the mesh to attach the geometry to
  24750. * @returns the new Geometry
  24751. */
  24752. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24753. /** Get the list of meshes using this geometry */
  24754. get meshes(): Mesh[];
  24755. /**
  24756. * Creates a new geometry
  24757. * @param id defines the unique ID
  24758. * @param scene defines the hosting scene
  24759. * @param vertexData defines the VertexData used to get geometry data
  24760. * @param updatable defines if geometry must be updatable (false by default)
  24761. * @param mesh defines the mesh that will be associated with the geometry
  24762. */
  24763. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24764. /**
  24765. * Gets the current extend of the geometry
  24766. */
  24767. get extend(): {
  24768. minimum: Vector3;
  24769. maximum: Vector3;
  24770. };
  24771. /**
  24772. * Gets the hosting scene
  24773. * @returns the hosting Scene
  24774. */
  24775. getScene(): Scene;
  24776. /**
  24777. * Gets the hosting engine
  24778. * @returns the hosting Engine
  24779. */
  24780. getEngine(): Engine;
  24781. /**
  24782. * Defines if the geometry is ready to use
  24783. * @returns true if the geometry is ready to be used
  24784. */
  24785. isReady(): boolean;
  24786. /**
  24787. * Gets a value indicating that the geometry should not be serialized
  24788. */
  24789. get doNotSerialize(): boolean;
  24790. /** @hidden */
  24791. _rebuild(): void;
  24792. /**
  24793. * Affects all geometry data in one call
  24794. * @param vertexData defines the geometry data
  24795. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24796. */
  24797. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24798. /**
  24799. * Set specific vertex data
  24800. * @param kind defines the data kind (Position, normal, etc...)
  24801. * @param data defines the vertex data to use
  24802. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24803. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24804. */
  24805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24806. /**
  24807. * Removes a specific vertex data
  24808. * @param kind defines the data kind (Position, normal, etc...)
  24809. */
  24810. removeVerticesData(kind: string): void;
  24811. /**
  24812. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24813. * @param buffer defines the vertex buffer to use
  24814. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24815. */
  24816. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24817. /**
  24818. * Update a specific vertex buffer
  24819. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24820. * It will do nothing if the buffer is not updatable
  24821. * @param kind defines the data kind (Position, normal, etc...)
  24822. * @param data defines the data to use
  24823. * @param offset defines the offset in the target buffer where to store the data
  24824. * @param useBytes set to true if the offset is in bytes
  24825. */
  24826. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24827. /**
  24828. * Update a specific vertex buffer
  24829. * This function will create a new buffer if the current one is not updatable
  24830. * @param kind defines the data kind (Position, normal, etc...)
  24831. * @param data defines the data to use
  24832. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24833. */
  24834. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24835. private _updateBoundingInfo;
  24836. /** @hidden */
  24837. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24838. /**
  24839. * Gets total number of vertices
  24840. * @returns the total number of vertices
  24841. */
  24842. getTotalVertices(): number;
  24843. /**
  24844. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24845. * @param kind defines the data kind (Position, normal, etc...)
  24846. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24847. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24848. * @returns a float array containing vertex data
  24849. */
  24850. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24851. /**
  24852. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24853. * @param kind defines the data kind (Position, normal, etc...)
  24854. * @returns true if the vertex buffer with the specified kind is updatable
  24855. */
  24856. isVertexBufferUpdatable(kind: string): boolean;
  24857. /**
  24858. * Gets a specific vertex buffer
  24859. * @param kind defines the data kind (Position, normal, etc...)
  24860. * @returns a VertexBuffer
  24861. */
  24862. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24863. /**
  24864. * Returns all vertex buffers
  24865. * @return an object holding all vertex buffers indexed by kind
  24866. */
  24867. getVertexBuffers(): Nullable<{
  24868. [key: string]: VertexBuffer;
  24869. }>;
  24870. /**
  24871. * Gets a boolean indicating if specific vertex buffer is present
  24872. * @param kind defines the data kind (Position, normal, etc...)
  24873. * @returns true if data is present
  24874. */
  24875. isVerticesDataPresent(kind: string): boolean;
  24876. /**
  24877. * Gets a list of all attached data kinds (Position, normal, etc...)
  24878. * @returns a list of string containing all kinds
  24879. */
  24880. getVerticesDataKinds(): string[];
  24881. /**
  24882. * Update index buffer
  24883. * @param indices defines the indices to store in the index buffer
  24884. * @param offset defines the offset in the target buffer where to store the data
  24885. * @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)
  24886. */
  24887. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24888. /**
  24889. * Creates a new index buffer
  24890. * @param indices defines the indices to store in the index buffer
  24891. * @param totalVertices defines the total number of vertices (could be null)
  24892. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24893. */
  24894. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24895. /**
  24896. * Return the total number of indices
  24897. * @returns the total number of indices
  24898. */
  24899. getTotalIndices(): number;
  24900. /**
  24901. * Gets the index buffer array
  24902. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24903. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24904. * @returns the index buffer array
  24905. */
  24906. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24907. /**
  24908. * Gets the index buffer
  24909. * @return the index buffer
  24910. */
  24911. getIndexBuffer(): Nullable<DataBuffer>;
  24912. /** @hidden */
  24913. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24914. /**
  24915. * Release the associated resources for a specific mesh
  24916. * @param mesh defines the source mesh
  24917. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24918. */
  24919. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24920. /**
  24921. * Apply current geometry to a given mesh
  24922. * @param mesh defines the mesh to apply geometry to
  24923. */
  24924. applyToMesh(mesh: Mesh): void;
  24925. private _updateExtend;
  24926. private _applyToMesh;
  24927. private notifyUpdate;
  24928. /**
  24929. * Load the geometry if it was flagged as delay loaded
  24930. * @param scene defines the hosting scene
  24931. * @param onLoaded defines a callback called when the geometry is loaded
  24932. */
  24933. load(scene: Scene, onLoaded?: () => void): void;
  24934. private _queueLoad;
  24935. /**
  24936. * Invert the geometry to move from a right handed system to a left handed one.
  24937. */
  24938. toLeftHanded(): void;
  24939. /** @hidden */
  24940. _resetPointsArrayCache(): void;
  24941. /** @hidden */
  24942. _generatePointsArray(): boolean;
  24943. /**
  24944. * Gets a value indicating if the geometry is disposed
  24945. * @returns true if the geometry was disposed
  24946. */
  24947. isDisposed(): boolean;
  24948. private _disposeVertexArrayObjects;
  24949. /**
  24950. * Free all associated resources
  24951. */
  24952. dispose(): void;
  24953. /**
  24954. * Clone the current geometry into a new geometry
  24955. * @param id defines the unique ID of the new geometry
  24956. * @returns a new geometry object
  24957. */
  24958. copy(id: string): Geometry;
  24959. /**
  24960. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24961. * @return a JSON representation of the current geometry data (without the vertices data)
  24962. */
  24963. serialize(): any;
  24964. private toNumberArray;
  24965. /**
  24966. * Serialize all vertices data into a JSON oject
  24967. * @returns a JSON representation of the current geometry data
  24968. */
  24969. serializeVerticeData(): any;
  24970. /**
  24971. * Extracts a clone of a mesh geometry
  24972. * @param mesh defines the source mesh
  24973. * @param id defines the unique ID of the new geometry object
  24974. * @returns the new geometry object
  24975. */
  24976. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24977. /**
  24978. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24979. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24980. * Be aware Math.random() could cause collisions, but:
  24981. * "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"
  24982. * @returns a string containing a new GUID
  24983. */
  24984. static RandomId(): string;
  24985. /** @hidden */
  24986. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24987. private static _CleanMatricesWeights;
  24988. /**
  24989. * Create a new geometry from persisted data (Using .babylon file format)
  24990. * @param parsedVertexData defines the persisted data
  24991. * @param scene defines the hosting scene
  24992. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24993. * @returns the new geometry object
  24994. */
  24995. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24996. }
  24997. }
  24998. declare module BABYLON {
  24999. /**
  25000. * Define an interface for all classes that will get and set the data on vertices
  25001. */
  25002. export interface IGetSetVerticesData {
  25003. /**
  25004. * Gets a boolean indicating if specific vertex data is present
  25005. * @param kind defines the vertex data kind to use
  25006. * @returns true is data kind is present
  25007. */
  25008. isVerticesDataPresent(kind: string): boolean;
  25009. /**
  25010. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25011. * @param kind defines the data kind (Position, normal, etc...)
  25012. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25013. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25014. * @returns a float array containing vertex data
  25015. */
  25016. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25017. /**
  25018. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25019. * @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.
  25020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25021. * @returns the indices array or an empty array if the mesh has no geometry
  25022. */
  25023. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25024. /**
  25025. * Set specific vertex data
  25026. * @param kind defines the data kind (Position, normal, etc...)
  25027. * @param data defines the vertex data to use
  25028. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25029. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25030. */
  25031. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25032. /**
  25033. * Update a specific associated vertex buffer
  25034. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25035. * - VertexBuffer.PositionKind
  25036. * - VertexBuffer.UVKind
  25037. * - VertexBuffer.UV2Kind
  25038. * - VertexBuffer.UV3Kind
  25039. * - VertexBuffer.UV4Kind
  25040. * - VertexBuffer.UV5Kind
  25041. * - VertexBuffer.UV6Kind
  25042. * - VertexBuffer.ColorKind
  25043. * - VertexBuffer.MatricesIndicesKind
  25044. * - VertexBuffer.MatricesIndicesExtraKind
  25045. * - VertexBuffer.MatricesWeightsKind
  25046. * - VertexBuffer.MatricesWeightsExtraKind
  25047. * @param data defines the data source
  25048. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25049. * @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)
  25050. */
  25051. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25052. /**
  25053. * Creates a new index buffer
  25054. * @param indices defines the indices to store in the index buffer
  25055. * @param totalVertices defines the total number of vertices (could be null)
  25056. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25057. */
  25058. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25059. }
  25060. /**
  25061. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25062. */
  25063. export class VertexData {
  25064. /**
  25065. * Mesh side orientation : usually the external or front surface
  25066. */
  25067. static readonly FRONTSIDE: number;
  25068. /**
  25069. * Mesh side orientation : usually the internal or back surface
  25070. */
  25071. static readonly BACKSIDE: number;
  25072. /**
  25073. * Mesh side orientation : both internal and external or front and back surfaces
  25074. */
  25075. static readonly DOUBLESIDE: number;
  25076. /**
  25077. * Mesh side orientation : by default, `FRONTSIDE`
  25078. */
  25079. static readonly DEFAULTSIDE: number;
  25080. /**
  25081. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25082. */
  25083. positions: Nullable<FloatArray>;
  25084. /**
  25085. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25086. */
  25087. normals: Nullable<FloatArray>;
  25088. /**
  25089. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25090. */
  25091. tangents: Nullable<FloatArray>;
  25092. /**
  25093. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25094. */
  25095. uvs: Nullable<FloatArray>;
  25096. /**
  25097. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25098. */
  25099. uvs2: Nullable<FloatArray>;
  25100. /**
  25101. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25102. */
  25103. uvs3: Nullable<FloatArray>;
  25104. /**
  25105. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25106. */
  25107. uvs4: Nullable<FloatArray>;
  25108. /**
  25109. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25110. */
  25111. uvs5: Nullable<FloatArray>;
  25112. /**
  25113. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25114. */
  25115. uvs6: Nullable<FloatArray>;
  25116. /**
  25117. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25118. */
  25119. colors: Nullable<FloatArray>;
  25120. /**
  25121. * 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).
  25122. */
  25123. matricesIndices: Nullable<FloatArray>;
  25124. /**
  25125. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25126. */
  25127. matricesWeights: Nullable<FloatArray>;
  25128. /**
  25129. * An array extending the number of possible indices
  25130. */
  25131. matricesIndicesExtra: Nullable<FloatArray>;
  25132. /**
  25133. * An array extending the number of possible weights when the number of indices is extended
  25134. */
  25135. matricesWeightsExtra: Nullable<FloatArray>;
  25136. /**
  25137. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25138. */
  25139. indices: Nullable<IndicesArray>;
  25140. /**
  25141. * Uses the passed data array to set the set the values for the specified kind of data
  25142. * @param data a linear array of floating numbers
  25143. * @param kind the type of data that is being set, eg positions, colors etc
  25144. */
  25145. set(data: FloatArray, kind: string): void;
  25146. /**
  25147. * Associates the vertexData to the passed Mesh.
  25148. * Sets it as updatable or not (default `false`)
  25149. * @param mesh the mesh the vertexData is applied to
  25150. * @param updatable when used and having the value true allows new data to update the vertexData
  25151. * @returns the VertexData
  25152. */
  25153. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25154. /**
  25155. * Associates the vertexData to the passed Geometry.
  25156. * Sets it as updatable or not (default `false`)
  25157. * @param geometry the geometry the vertexData is applied to
  25158. * @param updatable when used and having the value true allows new data to update the vertexData
  25159. * @returns VertexData
  25160. */
  25161. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25162. /**
  25163. * Updates the associated mesh
  25164. * @param mesh the mesh to be updated
  25165. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25166. * @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
  25167. * @returns VertexData
  25168. */
  25169. updateMesh(mesh: Mesh): VertexData;
  25170. /**
  25171. * Updates the associated geometry
  25172. * @param geometry the geometry to be updated
  25173. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25174. * @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
  25175. * @returns VertexData.
  25176. */
  25177. updateGeometry(geometry: Geometry): VertexData;
  25178. private _applyTo;
  25179. private _update;
  25180. /**
  25181. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25182. * @param matrix the transforming matrix
  25183. * @returns the VertexData
  25184. */
  25185. transform(matrix: Matrix): VertexData;
  25186. /**
  25187. * Merges the passed VertexData into the current one
  25188. * @param other the VertexData to be merged into the current one
  25189. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25190. * @returns the modified VertexData
  25191. */
  25192. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25193. private _mergeElement;
  25194. private _validate;
  25195. /**
  25196. * Serializes the VertexData
  25197. * @returns a serialized object
  25198. */
  25199. serialize(): any;
  25200. /**
  25201. * Extracts the vertexData from a mesh
  25202. * @param mesh the mesh from which to extract the VertexData
  25203. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25204. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25205. * @returns the object VertexData associated to the passed mesh
  25206. */
  25207. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25208. /**
  25209. * Extracts the vertexData from the geometry
  25210. * @param geometry the geometry from which to extract the VertexData
  25211. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25212. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25213. * @returns the object VertexData associated to the passed mesh
  25214. */
  25215. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25216. private static _ExtractFrom;
  25217. /**
  25218. * Creates the VertexData for a Ribbon
  25219. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25220. * * pathArray array of paths, each of which an array of successive Vector3
  25221. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25222. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25223. * * 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
  25224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25225. * * 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)
  25226. * * 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)
  25227. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25228. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25229. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25230. * @returns the VertexData of the ribbon
  25231. */
  25232. static CreateRibbon(options: {
  25233. pathArray: Vector3[][];
  25234. closeArray?: boolean;
  25235. closePath?: boolean;
  25236. offset?: number;
  25237. sideOrientation?: number;
  25238. frontUVs?: Vector4;
  25239. backUVs?: Vector4;
  25240. invertUV?: boolean;
  25241. uvs?: Vector2[];
  25242. colors?: Color4[];
  25243. }): VertexData;
  25244. /**
  25245. * Creates the VertexData for a box
  25246. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25247. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25248. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25249. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25250. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25251. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25252. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25253. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25254. * * 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)
  25255. * * 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)
  25256. * @returns the VertexData of the box
  25257. */
  25258. static CreateBox(options: {
  25259. size?: number;
  25260. width?: number;
  25261. height?: number;
  25262. depth?: number;
  25263. faceUV?: Vector4[];
  25264. faceColors?: Color4[];
  25265. sideOrientation?: number;
  25266. frontUVs?: Vector4;
  25267. backUVs?: Vector4;
  25268. }): VertexData;
  25269. /**
  25270. * Creates the VertexData for a tiled box
  25271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25272. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25273. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25274. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25276. * @returns the VertexData of the box
  25277. */
  25278. static CreateTiledBox(options: {
  25279. pattern?: number;
  25280. width?: number;
  25281. height?: number;
  25282. depth?: number;
  25283. tileSize?: number;
  25284. tileWidth?: number;
  25285. tileHeight?: number;
  25286. alignHorizontal?: number;
  25287. alignVertical?: number;
  25288. faceUV?: Vector4[];
  25289. faceColors?: Color4[];
  25290. sideOrientation?: number;
  25291. }): VertexData;
  25292. /**
  25293. * Creates the VertexData for a tiled plane
  25294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25295. * * pattern a limited pattern arrangement depending on the number
  25296. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25297. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25298. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25300. * * 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)
  25301. * * 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)
  25302. * @returns the VertexData of the tiled plane
  25303. */
  25304. static CreateTiledPlane(options: {
  25305. pattern?: number;
  25306. tileSize?: number;
  25307. tileWidth?: number;
  25308. tileHeight?: number;
  25309. size?: number;
  25310. width?: number;
  25311. height?: number;
  25312. alignHorizontal?: number;
  25313. alignVertical?: number;
  25314. sideOrientation?: number;
  25315. frontUVs?: Vector4;
  25316. backUVs?: Vector4;
  25317. }): VertexData;
  25318. /**
  25319. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25320. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25321. * * segments sets the number of horizontal strips optional, default 32
  25322. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25323. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25324. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25325. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25326. * * 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
  25327. * * 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
  25328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25329. * * 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)
  25330. * * 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)
  25331. * @returns the VertexData of the ellipsoid
  25332. */
  25333. static CreateSphere(options: {
  25334. segments?: number;
  25335. diameter?: number;
  25336. diameterX?: number;
  25337. diameterY?: number;
  25338. diameterZ?: number;
  25339. arc?: number;
  25340. slice?: number;
  25341. sideOrientation?: number;
  25342. frontUVs?: Vector4;
  25343. backUVs?: Vector4;
  25344. }): VertexData;
  25345. /**
  25346. * Creates the VertexData for a cylinder, cone or prism
  25347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25348. * * height sets the height (y direction) of the cylinder, optional, default 2
  25349. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25350. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25351. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25352. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25353. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25354. * * 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
  25355. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25356. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25357. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25358. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25360. * * 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)
  25361. * * 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)
  25362. * @returns the VertexData of the cylinder, cone or prism
  25363. */
  25364. static CreateCylinder(options: {
  25365. height?: number;
  25366. diameterTop?: number;
  25367. diameterBottom?: number;
  25368. diameter?: number;
  25369. tessellation?: number;
  25370. subdivisions?: number;
  25371. arc?: number;
  25372. faceColors?: Color4[];
  25373. faceUV?: Vector4[];
  25374. hasRings?: boolean;
  25375. enclose?: boolean;
  25376. sideOrientation?: number;
  25377. frontUVs?: Vector4;
  25378. backUVs?: Vector4;
  25379. }): VertexData;
  25380. /**
  25381. * Creates the VertexData for a torus
  25382. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25383. * * diameter the diameter of the torus, optional default 1
  25384. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25385. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25387. * * 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)
  25388. * * 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)
  25389. * @returns the VertexData of the torus
  25390. */
  25391. static CreateTorus(options: {
  25392. diameter?: number;
  25393. thickness?: number;
  25394. tessellation?: number;
  25395. sideOrientation?: number;
  25396. frontUVs?: Vector4;
  25397. backUVs?: Vector4;
  25398. }): VertexData;
  25399. /**
  25400. * Creates the VertexData of the LineSystem
  25401. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25402. * - lines an array of lines, each line being an array of successive Vector3
  25403. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25404. * @returns the VertexData of the LineSystem
  25405. */
  25406. static CreateLineSystem(options: {
  25407. lines: Vector3[][];
  25408. colors?: Nullable<Color4[][]>;
  25409. }): VertexData;
  25410. /**
  25411. * Create the VertexData for a DashedLines
  25412. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25413. * - points an array successive Vector3
  25414. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25415. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25416. * - dashNb the intended total number of dashes, optional, default 200
  25417. * @returns the VertexData for the DashedLines
  25418. */
  25419. static CreateDashedLines(options: {
  25420. points: Vector3[];
  25421. dashSize?: number;
  25422. gapSize?: number;
  25423. dashNb?: number;
  25424. }): VertexData;
  25425. /**
  25426. * Creates the VertexData for a Ground
  25427. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25428. * - width the width (x direction) of the ground, optional, default 1
  25429. * - height the height (z direction) of the ground, optional, default 1
  25430. * - subdivisions the number of subdivisions per side, optional, default 1
  25431. * @returns the VertexData of the Ground
  25432. */
  25433. static CreateGround(options: {
  25434. width?: number;
  25435. height?: number;
  25436. subdivisions?: number;
  25437. subdivisionsX?: number;
  25438. subdivisionsY?: number;
  25439. }): VertexData;
  25440. /**
  25441. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25442. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25443. * * xmin the ground minimum X coordinate, optional, default -1
  25444. * * zmin the ground minimum Z coordinate, optional, default -1
  25445. * * xmax the ground maximum X coordinate, optional, default 1
  25446. * * zmax the ground maximum Z coordinate, optional, default 1
  25447. * * 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}
  25448. * * 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}
  25449. * @returns the VertexData of the TiledGround
  25450. */
  25451. static CreateTiledGround(options: {
  25452. xmin: number;
  25453. zmin: number;
  25454. xmax: number;
  25455. zmax: number;
  25456. subdivisions?: {
  25457. w: number;
  25458. h: number;
  25459. };
  25460. precision?: {
  25461. w: number;
  25462. h: number;
  25463. };
  25464. }): VertexData;
  25465. /**
  25466. * Creates the VertexData of the Ground designed from a heightmap
  25467. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25468. * * width the width (x direction) of the ground
  25469. * * height the height (z direction) of the ground
  25470. * * subdivisions the number of subdivisions per side
  25471. * * minHeight the minimum altitude on the ground, optional, default 0
  25472. * * maxHeight the maximum altitude on the ground, optional default 1
  25473. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25474. * * buffer the array holding the image color data
  25475. * * bufferWidth the width of image
  25476. * * bufferHeight the height of image
  25477. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25478. * @returns the VertexData of the Ground designed from a heightmap
  25479. */
  25480. static CreateGroundFromHeightMap(options: {
  25481. width: number;
  25482. height: number;
  25483. subdivisions: number;
  25484. minHeight: number;
  25485. maxHeight: number;
  25486. colorFilter: Color3;
  25487. buffer: Uint8Array;
  25488. bufferWidth: number;
  25489. bufferHeight: number;
  25490. alphaFilter: number;
  25491. }): VertexData;
  25492. /**
  25493. * Creates the VertexData for a Plane
  25494. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25495. * * size sets the width and height of the plane to the value of size, optional default 1
  25496. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25497. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25499. * * 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)
  25500. * * 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)
  25501. * @returns the VertexData of the box
  25502. */
  25503. static CreatePlane(options: {
  25504. size?: number;
  25505. width?: number;
  25506. height?: number;
  25507. sideOrientation?: number;
  25508. frontUVs?: Vector4;
  25509. backUVs?: Vector4;
  25510. }): VertexData;
  25511. /**
  25512. * Creates the VertexData of the Disc or regular Polygon
  25513. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25514. * * radius the radius of the disc, optional default 0.5
  25515. * * tessellation the number of polygon sides, optional, default 64
  25516. * * 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
  25517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25518. * * 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)
  25519. * * 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)
  25520. * @returns the VertexData of the box
  25521. */
  25522. static CreateDisc(options: {
  25523. radius?: number;
  25524. tessellation?: number;
  25525. arc?: number;
  25526. sideOrientation?: number;
  25527. frontUVs?: Vector4;
  25528. backUVs?: Vector4;
  25529. }): VertexData;
  25530. /**
  25531. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25532. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25533. * @param polygon a mesh built from polygonTriangulation.build()
  25534. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25535. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25536. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25537. * @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)
  25538. * @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)
  25539. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25540. * @returns the VertexData of the Polygon
  25541. */
  25542. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25543. /**
  25544. * Creates the VertexData of the IcoSphere
  25545. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25546. * * radius the radius of the IcoSphere, optional default 1
  25547. * * radiusX allows stretching in the x direction, optional, default radius
  25548. * * radiusY allows stretching in the y direction, optional, default radius
  25549. * * radiusZ allows stretching in the z direction, optional, default radius
  25550. * * flat when true creates a flat shaded mesh, optional, default true
  25551. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25553. * * 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)
  25554. * * 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)
  25555. * @returns the VertexData of the IcoSphere
  25556. */
  25557. static CreateIcoSphere(options: {
  25558. radius?: number;
  25559. radiusX?: number;
  25560. radiusY?: number;
  25561. radiusZ?: number;
  25562. flat?: boolean;
  25563. subdivisions?: number;
  25564. sideOrientation?: number;
  25565. frontUVs?: Vector4;
  25566. backUVs?: Vector4;
  25567. }): VertexData;
  25568. /**
  25569. * Creates the VertexData for a Polyhedron
  25570. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25571. * * type provided types are:
  25572. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25573. * * 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)
  25574. * * size the size of the IcoSphere, optional default 1
  25575. * * sizeX allows stretching in the x direction, optional, default size
  25576. * * sizeY allows stretching in the y direction, optional, default size
  25577. * * sizeZ allows stretching in the z direction, optional, default size
  25578. * * 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
  25579. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25580. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25581. * * flat when true creates a flat shaded mesh, optional, default true
  25582. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25584. * * 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)
  25585. * * 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)
  25586. * @returns the VertexData of the Polyhedron
  25587. */
  25588. static CreatePolyhedron(options: {
  25589. type?: number;
  25590. size?: number;
  25591. sizeX?: number;
  25592. sizeY?: number;
  25593. sizeZ?: number;
  25594. custom?: any;
  25595. faceUV?: Vector4[];
  25596. faceColors?: Color4[];
  25597. flat?: boolean;
  25598. sideOrientation?: number;
  25599. frontUVs?: Vector4;
  25600. backUVs?: Vector4;
  25601. }): VertexData;
  25602. /**
  25603. * Creates the VertexData for a TorusKnot
  25604. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25605. * * radius the radius of the torus knot, optional, default 2
  25606. * * tube the thickness of the tube, optional, default 0.5
  25607. * * radialSegments the number of sides on each tube segments, optional, default 32
  25608. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25609. * * p the number of windings around the z axis, optional, default 2
  25610. * * q the number of windings around the x axis, optional, default 3
  25611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25612. * * 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)
  25613. * * 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)
  25614. * @returns the VertexData of the Torus Knot
  25615. */
  25616. static CreateTorusKnot(options: {
  25617. radius?: number;
  25618. tube?: number;
  25619. radialSegments?: number;
  25620. tubularSegments?: number;
  25621. p?: number;
  25622. q?: number;
  25623. sideOrientation?: number;
  25624. frontUVs?: Vector4;
  25625. backUVs?: Vector4;
  25626. }): VertexData;
  25627. /**
  25628. * Compute normals for given positions and indices
  25629. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25630. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25631. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25632. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25633. * * facetNormals : optional array of facet normals (vector3)
  25634. * * facetPositions : optional array of facet positions (vector3)
  25635. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25636. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25637. * * bInfo : optional bounding info, required for facetPartitioning computation
  25638. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25639. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25640. * * useRightHandedSystem: optional boolean to for right handed system computation
  25641. * * depthSort : optional boolean to enable the facet depth sort computation
  25642. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25643. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25644. */
  25645. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25646. facetNormals?: any;
  25647. facetPositions?: any;
  25648. facetPartitioning?: any;
  25649. ratio?: number;
  25650. bInfo?: any;
  25651. bbSize?: Vector3;
  25652. subDiv?: any;
  25653. useRightHandedSystem?: boolean;
  25654. depthSort?: boolean;
  25655. distanceTo?: Vector3;
  25656. depthSortedFacets?: any;
  25657. }): void;
  25658. /** @hidden */
  25659. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25660. /**
  25661. * Applies VertexData created from the imported parameters to the geometry
  25662. * @param parsedVertexData the parsed data from an imported file
  25663. * @param geometry the geometry to apply the VertexData to
  25664. */
  25665. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25666. }
  25667. }
  25668. declare module BABYLON {
  25669. /**
  25670. * Defines a target to use with MorphTargetManager
  25671. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25672. */
  25673. export class MorphTarget implements IAnimatable {
  25674. /** defines the name of the target */
  25675. name: string;
  25676. /**
  25677. * Gets or sets the list of animations
  25678. */
  25679. animations: Animation[];
  25680. private _scene;
  25681. private _positions;
  25682. private _normals;
  25683. private _tangents;
  25684. private _uvs;
  25685. private _influence;
  25686. private _uniqueId;
  25687. /**
  25688. * Observable raised when the influence changes
  25689. */
  25690. onInfluenceChanged: Observable<boolean>;
  25691. /** @hidden */
  25692. _onDataLayoutChanged: Observable<void>;
  25693. /**
  25694. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25695. */
  25696. get influence(): number;
  25697. set influence(influence: number);
  25698. /**
  25699. * Gets or sets the id of the morph Target
  25700. */
  25701. id: string;
  25702. private _animationPropertiesOverride;
  25703. /**
  25704. * Gets or sets the animation properties override
  25705. */
  25706. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25707. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25708. /**
  25709. * Creates a new MorphTarget
  25710. * @param name defines the name of the target
  25711. * @param influence defines the influence to use
  25712. * @param scene defines the scene the morphtarget belongs to
  25713. */
  25714. constructor(
  25715. /** defines the name of the target */
  25716. name: string, influence?: number, scene?: Nullable<Scene>);
  25717. /**
  25718. * Gets the unique ID of this manager
  25719. */
  25720. get uniqueId(): number;
  25721. /**
  25722. * Gets a boolean defining if the target contains position data
  25723. */
  25724. get hasPositions(): boolean;
  25725. /**
  25726. * Gets a boolean defining if the target contains normal data
  25727. */
  25728. get hasNormals(): boolean;
  25729. /**
  25730. * Gets a boolean defining if the target contains tangent data
  25731. */
  25732. get hasTangents(): boolean;
  25733. /**
  25734. * Gets a boolean defining if the target contains texture coordinates data
  25735. */
  25736. get hasUVs(): boolean;
  25737. /**
  25738. * Affects position data to this target
  25739. * @param data defines the position data to use
  25740. */
  25741. setPositions(data: Nullable<FloatArray>): void;
  25742. /**
  25743. * Gets the position data stored in this target
  25744. * @returns a FloatArray containing the position data (or null if not present)
  25745. */
  25746. getPositions(): Nullable<FloatArray>;
  25747. /**
  25748. * Affects normal data to this target
  25749. * @param data defines the normal data to use
  25750. */
  25751. setNormals(data: Nullable<FloatArray>): void;
  25752. /**
  25753. * Gets the normal data stored in this target
  25754. * @returns a FloatArray containing the normal data (or null if not present)
  25755. */
  25756. getNormals(): Nullable<FloatArray>;
  25757. /**
  25758. * Affects tangent data to this target
  25759. * @param data defines the tangent data to use
  25760. */
  25761. setTangents(data: Nullable<FloatArray>): void;
  25762. /**
  25763. * Gets the tangent data stored in this target
  25764. * @returns a FloatArray containing the tangent data (or null if not present)
  25765. */
  25766. getTangents(): Nullable<FloatArray>;
  25767. /**
  25768. * Affects texture coordinates data to this target
  25769. * @param data defines the texture coordinates data to use
  25770. */
  25771. setUVs(data: Nullable<FloatArray>): void;
  25772. /**
  25773. * Gets the texture coordinates data stored in this target
  25774. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25775. */
  25776. getUVs(): Nullable<FloatArray>;
  25777. /**
  25778. * Clone the current target
  25779. * @returns a new MorphTarget
  25780. */
  25781. clone(): MorphTarget;
  25782. /**
  25783. * Serializes the current target into a Serialization object
  25784. * @returns the serialized object
  25785. */
  25786. serialize(): any;
  25787. /**
  25788. * Returns the string "MorphTarget"
  25789. * @returns "MorphTarget"
  25790. */
  25791. getClassName(): string;
  25792. /**
  25793. * Creates a new target from serialized data
  25794. * @param serializationObject defines the serialized data to use
  25795. * @returns a new MorphTarget
  25796. */
  25797. static Parse(serializationObject: any): MorphTarget;
  25798. /**
  25799. * Creates a MorphTarget from mesh data
  25800. * @param mesh defines the source mesh
  25801. * @param name defines the name to use for the new target
  25802. * @param influence defines the influence to attach to the target
  25803. * @returns a new MorphTarget
  25804. */
  25805. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25806. }
  25807. }
  25808. declare module BABYLON {
  25809. /**
  25810. * This class is used to deform meshes using morphing between different targets
  25811. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25812. */
  25813. export class MorphTargetManager {
  25814. private _targets;
  25815. private _targetInfluenceChangedObservers;
  25816. private _targetDataLayoutChangedObservers;
  25817. private _activeTargets;
  25818. private _scene;
  25819. private _influences;
  25820. private _supportsNormals;
  25821. private _supportsTangents;
  25822. private _supportsUVs;
  25823. private _vertexCount;
  25824. private _uniqueId;
  25825. private _tempInfluences;
  25826. /**
  25827. * Gets or sets a boolean indicating if normals must be morphed
  25828. */
  25829. enableNormalMorphing: boolean;
  25830. /**
  25831. * Gets or sets a boolean indicating if tangents must be morphed
  25832. */
  25833. enableTangentMorphing: boolean;
  25834. /**
  25835. * Gets or sets a boolean indicating if UV must be morphed
  25836. */
  25837. enableUVMorphing: boolean;
  25838. /**
  25839. * Creates a new MorphTargetManager
  25840. * @param scene defines the current scene
  25841. */
  25842. constructor(scene?: Nullable<Scene>);
  25843. /**
  25844. * Gets the unique ID of this manager
  25845. */
  25846. get uniqueId(): number;
  25847. /**
  25848. * Gets the number of vertices handled by this manager
  25849. */
  25850. get vertexCount(): number;
  25851. /**
  25852. * Gets a boolean indicating if this manager supports morphing of normals
  25853. */
  25854. get supportsNormals(): boolean;
  25855. /**
  25856. * Gets a boolean indicating if this manager supports morphing of tangents
  25857. */
  25858. get supportsTangents(): boolean;
  25859. /**
  25860. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25861. */
  25862. get supportsUVs(): boolean;
  25863. /**
  25864. * Gets the number of targets stored in this manager
  25865. */
  25866. get numTargets(): number;
  25867. /**
  25868. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25869. */
  25870. get numInfluencers(): number;
  25871. /**
  25872. * Gets the list of influences (one per target)
  25873. */
  25874. get influences(): Float32Array;
  25875. /**
  25876. * Gets the active target at specified index. An active target is a target with an influence > 0
  25877. * @param index defines the index to check
  25878. * @returns the requested target
  25879. */
  25880. getActiveTarget(index: number): MorphTarget;
  25881. /**
  25882. * Gets the target at specified index
  25883. * @param index defines the index to check
  25884. * @returns the requested target
  25885. */
  25886. getTarget(index: number): MorphTarget;
  25887. /**
  25888. * Add a new target to this manager
  25889. * @param target defines the target to add
  25890. */
  25891. addTarget(target: MorphTarget): void;
  25892. /**
  25893. * Removes a target from the manager
  25894. * @param target defines the target to remove
  25895. */
  25896. removeTarget(target: MorphTarget): void;
  25897. /**
  25898. * Clone the current manager
  25899. * @returns a new MorphTargetManager
  25900. */
  25901. clone(): MorphTargetManager;
  25902. /**
  25903. * Serializes the current manager into a Serialization object
  25904. * @returns the serialized object
  25905. */
  25906. serialize(): any;
  25907. private _syncActiveTargets;
  25908. /**
  25909. * Syncrhonize the targets with all the meshes using this morph target manager
  25910. */
  25911. synchronize(): void;
  25912. /**
  25913. * Creates a new MorphTargetManager from serialized data
  25914. * @param serializationObject defines the serialized data
  25915. * @param scene defines the hosting scene
  25916. * @returns the new MorphTargetManager
  25917. */
  25918. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25919. }
  25920. }
  25921. declare module BABYLON {
  25922. /**
  25923. * Class used to represent a specific level of detail of a mesh
  25924. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25925. */
  25926. export class MeshLODLevel {
  25927. /** Defines the distance where this level should start being displayed */
  25928. distance: number;
  25929. /** Defines the mesh to use to render this level */
  25930. mesh: Nullable<Mesh>;
  25931. /**
  25932. * Creates a new LOD level
  25933. * @param distance defines the distance where this level should star being displayed
  25934. * @param mesh defines the mesh to use to render this level
  25935. */
  25936. constructor(
  25937. /** Defines the distance where this level should start being displayed */
  25938. distance: number,
  25939. /** Defines the mesh to use to render this level */
  25940. mesh: Nullable<Mesh>);
  25941. }
  25942. }
  25943. declare module BABYLON {
  25944. /**
  25945. * Mesh representing the gorund
  25946. */
  25947. export class GroundMesh extends Mesh {
  25948. /** If octree should be generated */
  25949. generateOctree: boolean;
  25950. private _heightQuads;
  25951. /** @hidden */
  25952. _subdivisionsX: number;
  25953. /** @hidden */
  25954. _subdivisionsY: number;
  25955. /** @hidden */
  25956. _width: number;
  25957. /** @hidden */
  25958. _height: number;
  25959. /** @hidden */
  25960. _minX: number;
  25961. /** @hidden */
  25962. _maxX: number;
  25963. /** @hidden */
  25964. _minZ: number;
  25965. /** @hidden */
  25966. _maxZ: number;
  25967. constructor(name: string, scene: Scene);
  25968. /**
  25969. * "GroundMesh"
  25970. * @returns "GroundMesh"
  25971. */
  25972. getClassName(): string;
  25973. /**
  25974. * The minimum of x and y subdivisions
  25975. */
  25976. get subdivisions(): number;
  25977. /**
  25978. * X subdivisions
  25979. */
  25980. get subdivisionsX(): number;
  25981. /**
  25982. * Y subdivisions
  25983. */
  25984. get subdivisionsY(): number;
  25985. /**
  25986. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25987. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25988. * @param chunksCount the number of subdivisions for x and y
  25989. * @param octreeBlocksSize (Default: 32)
  25990. */
  25991. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25992. /**
  25993. * Returns a height (y) value in the Worl system :
  25994. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25995. * @param x x coordinate
  25996. * @param z z coordinate
  25997. * @returns the ground y position if (x, z) are outside the ground surface.
  25998. */
  25999. getHeightAtCoordinates(x: number, z: number): number;
  26000. /**
  26001. * Returns a normalized vector (Vector3) orthogonal to the ground
  26002. * at the ground coordinates (x, z) expressed in the World system.
  26003. * @param x x coordinate
  26004. * @param z z coordinate
  26005. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26006. */
  26007. getNormalAtCoordinates(x: number, z: number): Vector3;
  26008. /**
  26009. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26010. * at the ground coordinates (x, z) expressed in the World system.
  26011. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26012. * @param x x coordinate
  26013. * @param z z coordinate
  26014. * @param ref vector to store the result
  26015. * @returns the GroundMesh.
  26016. */
  26017. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26018. /**
  26019. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26020. * if the ground has been updated.
  26021. * This can be used in the render loop.
  26022. * @returns the GroundMesh.
  26023. */
  26024. updateCoordinateHeights(): GroundMesh;
  26025. private _getFacetAt;
  26026. private _initHeightQuads;
  26027. private _computeHeightQuads;
  26028. /**
  26029. * Serializes this ground mesh
  26030. * @param serializationObject object to write serialization to
  26031. */
  26032. serialize(serializationObject: any): void;
  26033. /**
  26034. * Parses a serialized ground mesh
  26035. * @param parsedMesh the serialized mesh
  26036. * @param scene the scene to create the ground mesh in
  26037. * @returns the created ground mesh
  26038. */
  26039. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26040. }
  26041. }
  26042. declare module BABYLON {
  26043. /**
  26044. * Interface for Physics-Joint data
  26045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26046. */
  26047. export interface PhysicsJointData {
  26048. /**
  26049. * The main pivot of the joint
  26050. */
  26051. mainPivot?: Vector3;
  26052. /**
  26053. * The connected pivot of the joint
  26054. */
  26055. connectedPivot?: Vector3;
  26056. /**
  26057. * The main axis of the joint
  26058. */
  26059. mainAxis?: Vector3;
  26060. /**
  26061. * The connected axis of the joint
  26062. */
  26063. connectedAxis?: Vector3;
  26064. /**
  26065. * The collision of the joint
  26066. */
  26067. collision?: boolean;
  26068. /**
  26069. * Native Oimo/Cannon/Energy data
  26070. */
  26071. nativeParams?: any;
  26072. }
  26073. /**
  26074. * This is a holder class for the physics joint created by the physics plugin
  26075. * It holds a set of functions to control the underlying joint
  26076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26077. */
  26078. export class PhysicsJoint {
  26079. /**
  26080. * The type of the physics joint
  26081. */
  26082. type: number;
  26083. /**
  26084. * The data for the physics joint
  26085. */
  26086. jointData: PhysicsJointData;
  26087. private _physicsJoint;
  26088. protected _physicsPlugin: IPhysicsEnginePlugin;
  26089. /**
  26090. * Initializes the physics joint
  26091. * @param type The type of the physics joint
  26092. * @param jointData The data for the physics joint
  26093. */
  26094. constructor(
  26095. /**
  26096. * The type of the physics joint
  26097. */
  26098. type: number,
  26099. /**
  26100. * The data for the physics joint
  26101. */
  26102. jointData: PhysicsJointData);
  26103. /**
  26104. * Gets the physics joint
  26105. */
  26106. get physicsJoint(): any;
  26107. /**
  26108. * Sets the physics joint
  26109. */
  26110. set physicsJoint(newJoint: any);
  26111. /**
  26112. * Sets the physics plugin
  26113. */
  26114. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26115. /**
  26116. * Execute a function that is physics-plugin specific.
  26117. * @param {Function} func the function that will be executed.
  26118. * It accepts two parameters: the physics world and the physics joint
  26119. */
  26120. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26121. /**
  26122. * Distance-Joint type
  26123. */
  26124. static DistanceJoint: number;
  26125. /**
  26126. * Hinge-Joint type
  26127. */
  26128. static HingeJoint: number;
  26129. /**
  26130. * Ball-and-Socket joint type
  26131. */
  26132. static BallAndSocketJoint: number;
  26133. /**
  26134. * Wheel-Joint type
  26135. */
  26136. static WheelJoint: number;
  26137. /**
  26138. * Slider-Joint type
  26139. */
  26140. static SliderJoint: number;
  26141. /**
  26142. * Prismatic-Joint type
  26143. */
  26144. static PrismaticJoint: number;
  26145. /**
  26146. * Universal-Joint type
  26147. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26148. */
  26149. static UniversalJoint: number;
  26150. /**
  26151. * Hinge-Joint 2 type
  26152. */
  26153. static Hinge2Joint: number;
  26154. /**
  26155. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26156. */
  26157. static PointToPointJoint: number;
  26158. /**
  26159. * Spring-Joint type
  26160. */
  26161. static SpringJoint: number;
  26162. /**
  26163. * Lock-Joint type
  26164. */
  26165. static LockJoint: number;
  26166. }
  26167. /**
  26168. * A class representing a physics distance joint
  26169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26170. */
  26171. export class DistanceJoint extends PhysicsJoint {
  26172. /**
  26173. *
  26174. * @param jointData The data for the Distance-Joint
  26175. */
  26176. constructor(jointData: DistanceJointData);
  26177. /**
  26178. * Update the predefined distance.
  26179. * @param maxDistance The maximum preferred distance
  26180. * @param minDistance The minimum preferred distance
  26181. */
  26182. updateDistance(maxDistance: number, minDistance?: number): void;
  26183. }
  26184. /**
  26185. * Represents a Motor-Enabled Joint
  26186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26187. */
  26188. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26189. /**
  26190. * Initializes the Motor-Enabled Joint
  26191. * @param type The type of the joint
  26192. * @param jointData The physica joint data for the joint
  26193. */
  26194. constructor(type: number, jointData: PhysicsJointData);
  26195. /**
  26196. * Set the motor values.
  26197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26198. * @param force the force to apply
  26199. * @param maxForce max force for this motor.
  26200. */
  26201. setMotor(force?: number, maxForce?: number): void;
  26202. /**
  26203. * Set the motor's limits.
  26204. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26205. * @param upperLimit The upper limit of the motor
  26206. * @param lowerLimit The lower limit of the motor
  26207. */
  26208. setLimit(upperLimit: number, lowerLimit?: number): void;
  26209. }
  26210. /**
  26211. * This class represents a single physics Hinge-Joint
  26212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26213. */
  26214. export class HingeJoint extends MotorEnabledJoint {
  26215. /**
  26216. * Initializes the Hinge-Joint
  26217. * @param jointData The joint data for the Hinge-Joint
  26218. */
  26219. constructor(jointData: PhysicsJointData);
  26220. /**
  26221. * Set the motor values.
  26222. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26223. * @param {number} force the force to apply
  26224. * @param {number} maxForce max force for this motor.
  26225. */
  26226. setMotor(force?: number, maxForce?: number): void;
  26227. /**
  26228. * Set the motor's limits.
  26229. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26230. * @param upperLimit The upper limit of the motor
  26231. * @param lowerLimit The lower limit of the motor
  26232. */
  26233. setLimit(upperLimit: number, lowerLimit?: number): void;
  26234. }
  26235. /**
  26236. * This class represents a dual hinge physics joint (same as wheel joint)
  26237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26238. */
  26239. export class Hinge2Joint extends MotorEnabledJoint {
  26240. /**
  26241. * Initializes the Hinge2-Joint
  26242. * @param jointData The joint data for the Hinge2-Joint
  26243. */
  26244. constructor(jointData: PhysicsJointData);
  26245. /**
  26246. * Set the motor values.
  26247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26248. * @param {number} targetSpeed the speed the motor is to reach
  26249. * @param {number} maxForce max force for this motor.
  26250. * @param {motorIndex} the motor's index, 0 or 1.
  26251. */
  26252. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26253. /**
  26254. * Set the motor limits.
  26255. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26256. * @param {number} upperLimit the upper limit
  26257. * @param {number} lowerLimit lower limit
  26258. * @param {motorIndex} the motor's index, 0 or 1.
  26259. */
  26260. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26261. }
  26262. /**
  26263. * Interface for a motor enabled joint
  26264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26265. */
  26266. export interface IMotorEnabledJoint {
  26267. /**
  26268. * Physics joint
  26269. */
  26270. physicsJoint: any;
  26271. /**
  26272. * Sets the motor of the motor-enabled joint
  26273. * @param force The force of the motor
  26274. * @param maxForce The maximum force of the motor
  26275. * @param motorIndex The index of the motor
  26276. */
  26277. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26278. /**
  26279. * Sets the limit of the motor
  26280. * @param upperLimit The upper limit of the motor
  26281. * @param lowerLimit The lower limit of the motor
  26282. * @param motorIndex The index of the motor
  26283. */
  26284. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26285. }
  26286. /**
  26287. * Joint data for a Distance-Joint
  26288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26289. */
  26290. export interface DistanceJointData extends PhysicsJointData {
  26291. /**
  26292. * Max distance the 2 joint objects can be apart
  26293. */
  26294. maxDistance: number;
  26295. }
  26296. /**
  26297. * Joint data from a spring joint
  26298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26299. */
  26300. export interface SpringJointData extends PhysicsJointData {
  26301. /**
  26302. * Length of the spring
  26303. */
  26304. length: number;
  26305. /**
  26306. * Stiffness of the spring
  26307. */
  26308. stiffness: number;
  26309. /**
  26310. * Damping of the spring
  26311. */
  26312. damping: number;
  26313. /** this callback will be called when applying the force to the impostors. */
  26314. forceApplicationCallback: () => void;
  26315. }
  26316. }
  26317. declare module BABYLON {
  26318. /**
  26319. * Holds the data for the raycast result
  26320. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26321. */
  26322. export class PhysicsRaycastResult {
  26323. private _hasHit;
  26324. private _hitDistance;
  26325. private _hitNormalWorld;
  26326. private _hitPointWorld;
  26327. private _rayFromWorld;
  26328. private _rayToWorld;
  26329. /**
  26330. * Gets if there was a hit
  26331. */
  26332. get hasHit(): boolean;
  26333. /**
  26334. * Gets the distance from the hit
  26335. */
  26336. get hitDistance(): number;
  26337. /**
  26338. * Gets the hit normal/direction in the world
  26339. */
  26340. get hitNormalWorld(): Vector3;
  26341. /**
  26342. * Gets the hit point in the world
  26343. */
  26344. get hitPointWorld(): Vector3;
  26345. /**
  26346. * Gets the ray "start point" of the ray in the world
  26347. */
  26348. get rayFromWorld(): Vector3;
  26349. /**
  26350. * Gets the ray "end point" of the ray in the world
  26351. */
  26352. get rayToWorld(): Vector3;
  26353. /**
  26354. * Sets the hit data (normal & point in world space)
  26355. * @param hitNormalWorld defines the normal in world space
  26356. * @param hitPointWorld defines the point in world space
  26357. */
  26358. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26359. /**
  26360. * Sets the distance from the start point to the hit point
  26361. * @param distance
  26362. */
  26363. setHitDistance(distance: number): void;
  26364. /**
  26365. * Calculates the distance manually
  26366. */
  26367. calculateHitDistance(): void;
  26368. /**
  26369. * Resets all the values to default
  26370. * @param from The from point on world space
  26371. * @param to The to point on world space
  26372. */
  26373. reset(from?: Vector3, to?: Vector3): void;
  26374. }
  26375. /**
  26376. * Interface for the size containing width and height
  26377. */
  26378. interface IXYZ {
  26379. /**
  26380. * X
  26381. */
  26382. x: number;
  26383. /**
  26384. * Y
  26385. */
  26386. y: number;
  26387. /**
  26388. * Z
  26389. */
  26390. z: number;
  26391. }
  26392. }
  26393. declare module BABYLON {
  26394. /**
  26395. * Interface used to describe a physics joint
  26396. */
  26397. export interface PhysicsImpostorJoint {
  26398. /** Defines the main impostor to which the joint is linked */
  26399. mainImpostor: PhysicsImpostor;
  26400. /** Defines the impostor that is connected to the main impostor using this joint */
  26401. connectedImpostor: PhysicsImpostor;
  26402. /** Defines the joint itself */
  26403. joint: PhysicsJoint;
  26404. }
  26405. /** @hidden */
  26406. export interface IPhysicsEnginePlugin {
  26407. world: any;
  26408. name: string;
  26409. setGravity(gravity: Vector3): void;
  26410. setTimeStep(timeStep: number): void;
  26411. getTimeStep(): number;
  26412. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26416. removePhysicsBody(impostor: PhysicsImpostor): void;
  26417. generateJoint(joint: PhysicsImpostorJoint): void;
  26418. removeJoint(joint: PhysicsImpostorJoint): void;
  26419. isSupported(): boolean;
  26420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26427. getBodyMass(impostor: PhysicsImpostor): number;
  26428. getBodyFriction(impostor: PhysicsImpostor): number;
  26429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26430. getBodyRestitution(impostor: PhysicsImpostor): number;
  26431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26432. getBodyPressure?(impostor: PhysicsImpostor): number;
  26433. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26434. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26435. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26436. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26437. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26438. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26439. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26440. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26441. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26442. sleepBody(impostor: PhysicsImpostor): void;
  26443. wakeUpBody(impostor: PhysicsImpostor): void;
  26444. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26446. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26447. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26448. getRadius(impostor: PhysicsImpostor): number;
  26449. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26450. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26451. dispose(): void;
  26452. }
  26453. /**
  26454. * Interface used to define a physics engine
  26455. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26456. */
  26457. export interface IPhysicsEngine {
  26458. /**
  26459. * Gets the gravity vector used by the simulation
  26460. */
  26461. gravity: Vector3;
  26462. /**
  26463. * Sets the gravity vector used by the simulation
  26464. * @param gravity defines the gravity vector to use
  26465. */
  26466. setGravity(gravity: Vector3): void;
  26467. /**
  26468. * Set the time step of the physics engine.
  26469. * Default is 1/60.
  26470. * To slow it down, enter 1/600 for example.
  26471. * To speed it up, 1/30
  26472. * @param newTimeStep the new timestep to apply to this world.
  26473. */
  26474. setTimeStep(newTimeStep: number): void;
  26475. /**
  26476. * Get the time step of the physics engine.
  26477. * @returns the current time step
  26478. */
  26479. getTimeStep(): number;
  26480. /**
  26481. * Set the sub time step of the physics engine.
  26482. * Default is 0 meaning there is no sub steps
  26483. * To increase physics resolution precision, set a small value (like 1 ms)
  26484. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26485. */
  26486. setSubTimeStep(subTimeStep: number): void;
  26487. /**
  26488. * Get the sub time step of the physics engine.
  26489. * @returns the current sub time step
  26490. */
  26491. getSubTimeStep(): number;
  26492. /**
  26493. * Release all resources
  26494. */
  26495. dispose(): void;
  26496. /**
  26497. * Gets the name of the current physics plugin
  26498. * @returns the name of the plugin
  26499. */
  26500. getPhysicsPluginName(): string;
  26501. /**
  26502. * Adding a new impostor for the impostor tracking.
  26503. * This will be done by the impostor itself.
  26504. * @param impostor the impostor to add
  26505. */
  26506. addImpostor(impostor: PhysicsImpostor): void;
  26507. /**
  26508. * Remove an impostor from the engine.
  26509. * This impostor and its mesh will not longer be updated by the physics engine.
  26510. * @param impostor the impostor to remove
  26511. */
  26512. removeImpostor(impostor: PhysicsImpostor): void;
  26513. /**
  26514. * Add a joint to the physics engine
  26515. * @param mainImpostor defines the main impostor to which the joint is added.
  26516. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26517. * @param joint defines the joint that will connect both impostors.
  26518. */
  26519. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26520. /**
  26521. * Removes a joint from the simulation
  26522. * @param mainImpostor defines the impostor used with the joint
  26523. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26524. * @param joint defines the joint to remove
  26525. */
  26526. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26527. /**
  26528. * Gets the current plugin used to run the simulation
  26529. * @returns current plugin
  26530. */
  26531. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26532. /**
  26533. * Gets the list of physic impostors
  26534. * @returns an array of PhysicsImpostor
  26535. */
  26536. getImpostors(): Array<PhysicsImpostor>;
  26537. /**
  26538. * Gets the impostor for a physics enabled object
  26539. * @param object defines the object impersonated by the impostor
  26540. * @returns the PhysicsImpostor or null if not found
  26541. */
  26542. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26543. /**
  26544. * Gets the impostor for a physics body object
  26545. * @param body defines physics body used by the impostor
  26546. * @returns the PhysicsImpostor or null if not found
  26547. */
  26548. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26549. /**
  26550. * Does a raycast in the physics world
  26551. * @param from when should the ray start?
  26552. * @param to when should the ray end?
  26553. * @returns PhysicsRaycastResult
  26554. */
  26555. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26556. /**
  26557. * Called by the scene. No need to call it.
  26558. * @param delta defines the timespam between frames
  26559. */
  26560. _step(delta: number): void;
  26561. }
  26562. }
  26563. declare module BABYLON {
  26564. /**
  26565. * The interface for the physics imposter parameters
  26566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26567. */
  26568. export interface PhysicsImpostorParameters {
  26569. /**
  26570. * The mass of the physics imposter
  26571. */
  26572. mass: number;
  26573. /**
  26574. * The friction of the physics imposter
  26575. */
  26576. friction?: number;
  26577. /**
  26578. * The coefficient of restitution of the physics imposter
  26579. */
  26580. restitution?: number;
  26581. /**
  26582. * The native options of the physics imposter
  26583. */
  26584. nativeOptions?: any;
  26585. /**
  26586. * Specifies if the parent should be ignored
  26587. */
  26588. ignoreParent?: boolean;
  26589. /**
  26590. * Specifies if bi-directional transformations should be disabled
  26591. */
  26592. disableBidirectionalTransformation?: boolean;
  26593. /**
  26594. * The pressure inside the physics imposter, soft object only
  26595. */
  26596. pressure?: number;
  26597. /**
  26598. * The stiffness the physics imposter, soft object only
  26599. */
  26600. stiffness?: number;
  26601. /**
  26602. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26603. */
  26604. velocityIterations?: number;
  26605. /**
  26606. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26607. */
  26608. positionIterations?: number;
  26609. /**
  26610. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26611. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26612. * Add to fix multiple points
  26613. */
  26614. fixedPoints?: number;
  26615. /**
  26616. * The collision margin around a soft object
  26617. */
  26618. margin?: number;
  26619. /**
  26620. * The collision margin around a soft object
  26621. */
  26622. damping?: number;
  26623. /**
  26624. * The path for a rope based on an extrusion
  26625. */
  26626. path?: any;
  26627. /**
  26628. * The shape of an extrusion used for a rope based on an extrusion
  26629. */
  26630. shape?: any;
  26631. }
  26632. /**
  26633. * Interface for a physics-enabled object
  26634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26635. */
  26636. export interface IPhysicsEnabledObject {
  26637. /**
  26638. * The position of the physics-enabled object
  26639. */
  26640. position: Vector3;
  26641. /**
  26642. * The rotation of the physics-enabled object
  26643. */
  26644. rotationQuaternion: Nullable<Quaternion>;
  26645. /**
  26646. * The scale of the physics-enabled object
  26647. */
  26648. scaling: Vector3;
  26649. /**
  26650. * The rotation of the physics-enabled object
  26651. */
  26652. rotation?: Vector3;
  26653. /**
  26654. * The parent of the physics-enabled object
  26655. */
  26656. parent?: any;
  26657. /**
  26658. * The bounding info of the physics-enabled object
  26659. * @returns The bounding info of the physics-enabled object
  26660. */
  26661. getBoundingInfo(): BoundingInfo;
  26662. /**
  26663. * Computes the world matrix
  26664. * @param force Specifies if the world matrix should be computed by force
  26665. * @returns A world matrix
  26666. */
  26667. computeWorldMatrix(force: boolean): Matrix;
  26668. /**
  26669. * Gets the world matrix
  26670. * @returns A world matrix
  26671. */
  26672. getWorldMatrix?(): Matrix;
  26673. /**
  26674. * Gets the child meshes
  26675. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26676. * @returns An array of abstract meshes
  26677. */
  26678. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26679. /**
  26680. * Gets the vertex data
  26681. * @param kind The type of vertex data
  26682. * @returns A nullable array of numbers, or a float32 array
  26683. */
  26684. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26685. /**
  26686. * Gets the indices from the mesh
  26687. * @returns A nullable array of index arrays
  26688. */
  26689. getIndices?(): Nullable<IndicesArray>;
  26690. /**
  26691. * Gets the scene from the mesh
  26692. * @returns the indices array or null
  26693. */
  26694. getScene?(): Scene;
  26695. /**
  26696. * Gets the absolute position from the mesh
  26697. * @returns the absolute position
  26698. */
  26699. getAbsolutePosition(): Vector3;
  26700. /**
  26701. * Gets the absolute pivot point from the mesh
  26702. * @returns the absolute pivot point
  26703. */
  26704. getAbsolutePivotPoint(): Vector3;
  26705. /**
  26706. * Rotates the mesh
  26707. * @param axis The axis of rotation
  26708. * @param amount The amount of rotation
  26709. * @param space The space of the rotation
  26710. * @returns The rotation transform node
  26711. */
  26712. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26713. /**
  26714. * Translates the mesh
  26715. * @param axis The axis of translation
  26716. * @param distance The distance of translation
  26717. * @param space The space of the translation
  26718. * @returns The transform node
  26719. */
  26720. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26721. /**
  26722. * Sets the absolute position of the mesh
  26723. * @param absolutePosition The absolute position of the mesh
  26724. * @returns The transform node
  26725. */
  26726. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26727. /**
  26728. * Gets the class name of the mesh
  26729. * @returns The class name
  26730. */
  26731. getClassName(): string;
  26732. }
  26733. /**
  26734. * Represents a physics imposter
  26735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26736. */
  26737. export class PhysicsImpostor {
  26738. /**
  26739. * The physics-enabled object used as the physics imposter
  26740. */
  26741. object: IPhysicsEnabledObject;
  26742. /**
  26743. * The type of the physics imposter
  26744. */
  26745. type: number;
  26746. private _options;
  26747. private _scene?;
  26748. /**
  26749. * The default object size of the imposter
  26750. */
  26751. static DEFAULT_OBJECT_SIZE: Vector3;
  26752. /**
  26753. * The identity quaternion of the imposter
  26754. */
  26755. static IDENTITY_QUATERNION: Quaternion;
  26756. /** @hidden */
  26757. _pluginData: any;
  26758. private _physicsEngine;
  26759. private _physicsBody;
  26760. private _bodyUpdateRequired;
  26761. private _onBeforePhysicsStepCallbacks;
  26762. private _onAfterPhysicsStepCallbacks;
  26763. /** @hidden */
  26764. _onPhysicsCollideCallbacks: Array<{
  26765. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26766. otherImpostors: Array<PhysicsImpostor>;
  26767. }>;
  26768. private _deltaPosition;
  26769. private _deltaRotation;
  26770. private _deltaRotationConjugated;
  26771. /** @hidden */
  26772. _isFromLine: boolean;
  26773. private _parent;
  26774. private _isDisposed;
  26775. private static _tmpVecs;
  26776. private static _tmpQuat;
  26777. /**
  26778. * Specifies if the physics imposter is disposed
  26779. */
  26780. get isDisposed(): boolean;
  26781. /**
  26782. * Gets the mass of the physics imposter
  26783. */
  26784. get mass(): number;
  26785. set mass(value: number);
  26786. /**
  26787. * Gets the coefficient of friction
  26788. */
  26789. get friction(): number;
  26790. /**
  26791. * Sets the coefficient of friction
  26792. */
  26793. set friction(value: number);
  26794. /**
  26795. * Gets the coefficient of restitution
  26796. */
  26797. get restitution(): number;
  26798. /**
  26799. * Sets the coefficient of restitution
  26800. */
  26801. set restitution(value: number);
  26802. /**
  26803. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26804. */
  26805. get pressure(): number;
  26806. /**
  26807. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26808. */
  26809. set pressure(value: number);
  26810. /**
  26811. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26812. */
  26813. get stiffness(): number;
  26814. /**
  26815. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26816. */
  26817. set stiffness(value: number);
  26818. /**
  26819. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26820. */
  26821. get velocityIterations(): number;
  26822. /**
  26823. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26824. */
  26825. set velocityIterations(value: number);
  26826. /**
  26827. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26828. */
  26829. get positionIterations(): number;
  26830. /**
  26831. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26832. */
  26833. set positionIterations(value: number);
  26834. /**
  26835. * The unique id of the physics imposter
  26836. * set by the physics engine when adding this impostor to the array
  26837. */
  26838. uniqueId: number;
  26839. /**
  26840. * @hidden
  26841. */
  26842. soft: boolean;
  26843. /**
  26844. * @hidden
  26845. */
  26846. segments: number;
  26847. private _joints;
  26848. /**
  26849. * Initializes the physics imposter
  26850. * @param object The physics-enabled object used as the physics imposter
  26851. * @param type The type of the physics imposter
  26852. * @param _options The options for the physics imposter
  26853. * @param _scene The Babylon scene
  26854. */
  26855. constructor(
  26856. /**
  26857. * The physics-enabled object used as the physics imposter
  26858. */
  26859. object: IPhysicsEnabledObject,
  26860. /**
  26861. * The type of the physics imposter
  26862. */
  26863. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26864. /**
  26865. * This function will completly initialize this impostor.
  26866. * It will create a new body - but only if this mesh has no parent.
  26867. * If it has, this impostor will not be used other than to define the impostor
  26868. * of the child mesh.
  26869. * @hidden
  26870. */
  26871. _init(): void;
  26872. private _getPhysicsParent;
  26873. /**
  26874. * Should a new body be generated.
  26875. * @returns boolean specifying if body initialization is required
  26876. */
  26877. isBodyInitRequired(): boolean;
  26878. /**
  26879. * Sets the updated scaling
  26880. * @param updated Specifies if the scaling is updated
  26881. */
  26882. setScalingUpdated(): void;
  26883. /**
  26884. * Force a regeneration of this or the parent's impostor's body.
  26885. * Use under cautious - This will remove all joints already implemented.
  26886. */
  26887. forceUpdate(): void;
  26888. /**
  26889. * Gets the body that holds this impostor. Either its own, or its parent.
  26890. */
  26891. get physicsBody(): any;
  26892. /**
  26893. * Get the parent of the physics imposter
  26894. * @returns Physics imposter or null
  26895. */
  26896. get parent(): Nullable<PhysicsImpostor>;
  26897. /**
  26898. * Sets the parent of the physics imposter
  26899. */
  26900. set parent(value: Nullable<PhysicsImpostor>);
  26901. /**
  26902. * Set the physics body. Used mainly by the physics engine/plugin
  26903. */
  26904. set physicsBody(physicsBody: any);
  26905. /**
  26906. * Resets the update flags
  26907. */
  26908. resetUpdateFlags(): void;
  26909. /**
  26910. * Gets the object extend size
  26911. * @returns the object extend size
  26912. */
  26913. getObjectExtendSize(): Vector3;
  26914. /**
  26915. * Gets the object center
  26916. * @returns The object center
  26917. */
  26918. getObjectCenter(): Vector3;
  26919. /**
  26920. * Get a specific parameter from the options parameters
  26921. * @param paramName The object parameter name
  26922. * @returns The object parameter
  26923. */
  26924. getParam(paramName: string): any;
  26925. /**
  26926. * Sets a specific parameter in the options given to the physics plugin
  26927. * @param paramName The parameter name
  26928. * @param value The value of the parameter
  26929. */
  26930. setParam(paramName: string, value: number): void;
  26931. /**
  26932. * Specifically change the body's mass option. Won't recreate the physics body object
  26933. * @param mass The mass of the physics imposter
  26934. */
  26935. setMass(mass: number): void;
  26936. /**
  26937. * Gets the linear velocity
  26938. * @returns linear velocity or null
  26939. */
  26940. getLinearVelocity(): Nullable<Vector3>;
  26941. /**
  26942. * Sets the linear velocity
  26943. * @param velocity linear velocity or null
  26944. */
  26945. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26946. /**
  26947. * Gets the angular velocity
  26948. * @returns angular velocity or null
  26949. */
  26950. getAngularVelocity(): Nullable<Vector3>;
  26951. /**
  26952. * Sets the angular velocity
  26953. * @param velocity The velocity or null
  26954. */
  26955. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26956. /**
  26957. * Execute a function with the physics plugin native code
  26958. * Provide a function the will have two variables - the world object and the physics body object
  26959. * @param func The function to execute with the physics plugin native code
  26960. */
  26961. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26962. /**
  26963. * Register a function that will be executed before the physics world is stepping forward
  26964. * @param func The function to execute before the physics world is stepped forward
  26965. */
  26966. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26967. /**
  26968. * Unregister a function that will be executed before the physics world is stepping forward
  26969. * @param func The function to execute before the physics world is stepped forward
  26970. */
  26971. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26972. /**
  26973. * Register a function that will be executed after the physics step
  26974. * @param func The function to execute after physics step
  26975. */
  26976. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26977. /**
  26978. * Unregisters a function that will be executed after the physics step
  26979. * @param func The function to execute after physics step
  26980. */
  26981. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26982. /**
  26983. * register a function that will be executed when this impostor collides against a different body
  26984. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26985. * @param func Callback that is executed on collision
  26986. */
  26987. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26988. /**
  26989. * Unregisters the physics imposter on contact
  26990. * @param collideAgainst The physics object to collide against
  26991. * @param func Callback to execute on collision
  26992. */
  26993. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26994. private _tmpQuat;
  26995. private _tmpQuat2;
  26996. /**
  26997. * Get the parent rotation
  26998. * @returns The parent rotation
  26999. */
  27000. getParentsRotation(): Quaternion;
  27001. /**
  27002. * this function is executed by the physics engine.
  27003. */
  27004. beforeStep: () => void;
  27005. /**
  27006. * this function is executed by the physics engine
  27007. */
  27008. afterStep: () => void;
  27009. /**
  27010. * Legacy collision detection event support
  27011. */
  27012. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27013. /**
  27014. * event and body object due to cannon's event-based architecture.
  27015. */
  27016. onCollide: (e: {
  27017. body: any;
  27018. }) => void;
  27019. /**
  27020. * Apply a force
  27021. * @param force The force to apply
  27022. * @param contactPoint The contact point for the force
  27023. * @returns The physics imposter
  27024. */
  27025. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27026. /**
  27027. * Apply an impulse
  27028. * @param force The impulse force
  27029. * @param contactPoint The contact point for the impulse force
  27030. * @returns The physics imposter
  27031. */
  27032. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27033. /**
  27034. * A help function to create a joint
  27035. * @param otherImpostor A physics imposter used to create a joint
  27036. * @param jointType The type of joint
  27037. * @param jointData The data for the joint
  27038. * @returns The physics imposter
  27039. */
  27040. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27041. /**
  27042. * Add a joint to this impostor with a different impostor
  27043. * @param otherImpostor A physics imposter used to add a joint
  27044. * @param joint The joint to add
  27045. * @returns The physics imposter
  27046. */
  27047. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27048. /**
  27049. * Add an anchor to a cloth impostor
  27050. * @param otherImpostor rigid impostor to anchor to
  27051. * @param width ratio across width from 0 to 1
  27052. * @param height ratio up height from 0 to 1
  27053. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27054. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27055. * @returns impostor the soft imposter
  27056. */
  27057. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27058. /**
  27059. * Add a hook to a rope impostor
  27060. * @param otherImpostor rigid impostor to anchor to
  27061. * @param length ratio across rope from 0 to 1
  27062. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27063. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27064. * @returns impostor the rope imposter
  27065. */
  27066. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27067. /**
  27068. * Will keep this body still, in a sleep mode.
  27069. * @returns the physics imposter
  27070. */
  27071. sleep(): PhysicsImpostor;
  27072. /**
  27073. * Wake the body up.
  27074. * @returns The physics imposter
  27075. */
  27076. wakeUp(): PhysicsImpostor;
  27077. /**
  27078. * Clones the physics imposter
  27079. * @param newObject The physics imposter clones to this physics-enabled object
  27080. * @returns A nullable physics imposter
  27081. */
  27082. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27083. /**
  27084. * Disposes the physics imposter
  27085. */
  27086. dispose(): void;
  27087. /**
  27088. * Sets the delta position
  27089. * @param position The delta position amount
  27090. */
  27091. setDeltaPosition(position: Vector3): void;
  27092. /**
  27093. * Sets the delta rotation
  27094. * @param rotation The delta rotation amount
  27095. */
  27096. setDeltaRotation(rotation: Quaternion): void;
  27097. /**
  27098. * Gets the box size of the physics imposter and stores the result in the input parameter
  27099. * @param result Stores the box size
  27100. * @returns The physics imposter
  27101. */
  27102. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27103. /**
  27104. * Gets the radius of the physics imposter
  27105. * @returns Radius of the physics imposter
  27106. */
  27107. getRadius(): number;
  27108. /**
  27109. * Sync a bone with this impostor
  27110. * @param bone The bone to sync to the impostor.
  27111. * @param boneMesh The mesh that the bone is influencing.
  27112. * @param jointPivot The pivot of the joint / bone in local space.
  27113. * @param distToJoint Optional distance from the impostor to the joint.
  27114. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27115. */
  27116. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27117. /**
  27118. * Sync impostor to a bone
  27119. * @param bone The bone that the impostor will be synced to.
  27120. * @param boneMesh The mesh that the bone is influencing.
  27121. * @param jointPivot The pivot of the joint / bone in local space.
  27122. * @param distToJoint Optional distance from the impostor to the joint.
  27123. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27124. * @param boneAxis Optional vector3 axis the bone is aligned with
  27125. */
  27126. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27127. /**
  27128. * No-Imposter type
  27129. */
  27130. static NoImpostor: number;
  27131. /**
  27132. * Sphere-Imposter type
  27133. */
  27134. static SphereImpostor: number;
  27135. /**
  27136. * Box-Imposter type
  27137. */
  27138. static BoxImpostor: number;
  27139. /**
  27140. * Plane-Imposter type
  27141. */
  27142. static PlaneImpostor: number;
  27143. /**
  27144. * Mesh-imposter type
  27145. */
  27146. static MeshImpostor: number;
  27147. /**
  27148. * Capsule-Impostor type (Ammo.js plugin only)
  27149. */
  27150. static CapsuleImpostor: number;
  27151. /**
  27152. * Cylinder-Imposter type
  27153. */
  27154. static CylinderImpostor: number;
  27155. /**
  27156. * Particle-Imposter type
  27157. */
  27158. static ParticleImpostor: number;
  27159. /**
  27160. * Heightmap-Imposter type
  27161. */
  27162. static HeightmapImpostor: number;
  27163. /**
  27164. * ConvexHull-Impostor type (Ammo.js plugin only)
  27165. */
  27166. static ConvexHullImpostor: number;
  27167. /**
  27168. * Custom-Imposter type (Ammo.js plugin only)
  27169. */
  27170. static CustomImpostor: number;
  27171. /**
  27172. * Rope-Imposter type
  27173. */
  27174. static RopeImpostor: number;
  27175. /**
  27176. * Cloth-Imposter type
  27177. */
  27178. static ClothImpostor: number;
  27179. /**
  27180. * Softbody-Imposter type
  27181. */
  27182. static SoftbodyImpostor: number;
  27183. }
  27184. }
  27185. declare module BABYLON {
  27186. /**
  27187. * @hidden
  27188. **/
  27189. export class _CreationDataStorage {
  27190. closePath?: boolean;
  27191. closeArray?: boolean;
  27192. idx: number[];
  27193. dashSize: number;
  27194. gapSize: number;
  27195. path3D: Path3D;
  27196. pathArray: Vector3[][];
  27197. arc: number;
  27198. radius: number;
  27199. cap: number;
  27200. tessellation: number;
  27201. }
  27202. /**
  27203. * @hidden
  27204. **/
  27205. class _InstanceDataStorage {
  27206. visibleInstances: any;
  27207. batchCache: _InstancesBatch;
  27208. instancesBufferSize: number;
  27209. instancesBuffer: Nullable<Buffer>;
  27210. instancesData: Float32Array;
  27211. overridenInstanceCount: number;
  27212. isFrozen: boolean;
  27213. previousBatch: Nullable<_InstancesBatch>;
  27214. hardwareInstancedRendering: boolean;
  27215. sideOrientation: number;
  27216. manualUpdate: boolean;
  27217. }
  27218. /**
  27219. * @hidden
  27220. **/
  27221. export class _InstancesBatch {
  27222. mustReturn: boolean;
  27223. visibleInstances: Nullable<InstancedMesh[]>[];
  27224. renderSelf: boolean[];
  27225. hardwareInstancedRendering: boolean[];
  27226. }
  27227. /**
  27228. * @hidden
  27229. **/
  27230. class _ThinInstanceDataStorage {
  27231. instancesCount: number;
  27232. matrixBuffer: Nullable<Buffer>;
  27233. matrixBufferSize: number;
  27234. matrixData: Nullable<Float32Array>;
  27235. boundingVectors: Array<Vector3>;
  27236. }
  27237. /**
  27238. * Class used to represent renderable models
  27239. */
  27240. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27241. /**
  27242. * Mesh side orientation : usually the external or front surface
  27243. */
  27244. static readonly FRONTSIDE: number;
  27245. /**
  27246. * Mesh side orientation : usually the internal or back surface
  27247. */
  27248. static readonly BACKSIDE: number;
  27249. /**
  27250. * Mesh side orientation : both internal and external or front and back surfaces
  27251. */
  27252. static readonly DOUBLESIDE: number;
  27253. /**
  27254. * Mesh side orientation : by default, `FRONTSIDE`
  27255. */
  27256. static readonly DEFAULTSIDE: number;
  27257. /**
  27258. * Mesh cap setting : no cap
  27259. */
  27260. static readonly NO_CAP: number;
  27261. /**
  27262. * Mesh cap setting : one cap at the beginning of the mesh
  27263. */
  27264. static readonly CAP_START: number;
  27265. /**
  27266. * Mesh cap setting : one cap at the end of the mesh
  27267. */
  27268. static readonly CAP_END: number;
  27269. /**
  27270. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27271. */
  27272. static readonly CAP_ALL: number;
  27273. /**
  27274. * Mesh pattern setting : no flip or rotate
  27275. */
  27276. static readonly NO_FLIP: number;
  27277. /**
  27278. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27279. */
  27280. static readonly FLIP_TILE: number;
  27281. /**
  27282. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27283. */
  27284. static readonly ROTATE_TILE: number;
  27285. /**
  27286. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27287. */
  27288. static readonly FLIP_ROW: number;
  27289. /**
  27290. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27291. */
  27292. static readonly ROTATE_ROW: number;
  27293. /**
  27294. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27295. */
  27296. static readonly FLIP_N_ROTATE_TILE: number;
  27297. /**
  27298. * Mesh pattern setting : rotate pattern and rotate
  27299. */
  27300. static readonly FLIP_N_ROTATE_ROW: number;
  27301. /**
  27302. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27303. */
  27304. static readonly CENTER: number;
  27305. /**
  27306. * Mesh tile positioning : part tiles on left
  27307. */
  27308. static readonly LEFT: number;
  27309. /**
  27310. * Mesh tile positioning : part tiles on right
  27311. */
  27312. static readonly RIGHT: number;
  27313. /**
  27314. * Mesh tile positioning : part tiles on top
  27315. */
  27316. static readonly TOP: number;
  27317. /**
  27318. * Mesh tile positioning : part tiles on bottom
  27319. */
  27320. static readonly BOTTOM: number;
  27321. /**
  27322. * Gets the default side orientation.
  27323. * @param orientation the orientation to value to attempt to get
  27324. * @returns the default orientation
  27325. * @hidden
  27326. */
  27327. static _GetDefaultSideOrientation(orientation?: number): number;
  27328. private _internalMeshDataInfo;
  27329. /**
  27330. * An event triggered before rendering the mesh
  27331. */
  27332. get onBeforeRenderObservable(): Observable<Mesh>;
  27333. /**
  27334. * An event triggered before binding the mesh
  27335. */
  27336. get onBeforeBindObservable(): Observable<Mesh>;
  27337. /**
  27338. * An event triggered after rendering the mesh
  27339. */
  27340. get onAfterRenderObservable(): Observable<Mesh>;
  27341. /**
  27342. * An event triggered before drawing the mesh
  27343. */
  27344. get onBeforeDrawObservable(): Observable<Mesh>;
  27345. private _onBeforeDrawObserver;
  27346. /**
  27347. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27348. */
  27349. set onBeforeDraw(callback: () => void);
  27350. get hasInstances(): boolean;
  27351. get hasThinInstances(): boolean;
  27352. /**
  27353. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27354. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27355. */
  27356. delayLoadState: number;
  27357. /**
  27358. * Gets the list of instances created from this mesh
  27359. * it is not supposed to be modified manually.
  27360. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27361. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27362. */
  27363. instances: InstancedMesh[];
  27364. /**
  27365. * Gets the file containing delay loading data for this mesh
  27366. */
  27367. delayLoadingFile: string;
  27368. /** @hidden */
  27369. _binaryInfo: any;
  27370. /**
  27371. * User defined function used to change how LOD level selection is done
  27372. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27373. */
  27374. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27375. /**
  27376. * Gets or sets the morph target manager
  27377. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27378. */
  27379. get morphTargetManager(): Nullable<MorphTargetManager>;
  27380. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27381. /** @hidden */
  27382. _creationDataStorage: Nullable<_CreationDataStorage>;
  27383. /** @hidden */
  27384. _geometry: Nullable<Geometry>;
  27385. /** @hidden */
  27386. _delayInfo: Array<string>;
  27387. /** @hidden */
  27388. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27389. /** @hidden */
  27390. _instanceDataStorage: _InstanceDataStorage;
  27391. /** @hidden */
  27392. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27393. private _effectiveMaterial;
  27394. /** @hidden */
  27395. _shouldGenerateFlatShading: boolean;
  27396. /** @hidden */
  27397. _originalBuilderSideOrientation: number;
  27398. /**
  27399. * Use this property to change the original side orientation defined at construction time
  27400. */
  27401. overrideMaterialSideOrientation: Nullable<number>;
  27402. /**
  27403. * Gets the source mesh (the one used to clone this one from)
  27404. */
  27405. get source(): Nullable<Mesh>;
  27406. /**
  27407. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27408. */
  27409. get isUnIndexed(): boolean;
  27410. set isUnIndexed(value: boolean);
  27411. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27412. get worldMatrixInstancedBuffer(): Float32Array;
  27413. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27414. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27415. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27416. /**
  27417. * @constructor
  27418. * @param name The value used by scene.getMeshByName() to do a lookup.
  27419. * @param scene The scene to add this mesh to.
  27420. * @param parent The parent of this mesh, if it has one
  27421. * @param source An optional Mesh from which geometry is shared, cloned.
  27422. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27423. * When false, achieved by calling a clone(), also passing False.
  27424. * This will make creation of children, recursive.
  27425. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27426. */
  27427. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27428. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27429. doNotInstantiate: boolean;
  27430. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27431. /**
  27432. * Gets the class name
  27433. * @returns the string "Mesh".
  27434. */
  27435. getClassName(): string;
  27436. /** @hidden */
  27437. get _isMesh(): boolean;
  27438. /**
  27439. * Returns a description of this mesh
  27440. * @param fullDetails define if full details about this mesh must be used
  27441. * @returns a descriptive string representing this mesh
  27442. */
  27443. toString(fullDetails?: boolean): string;
  27444. /** @hidden */
  27445. _unBindEffect(): void;
  27446. /**
  27447. * Gets a boolean indicating if this mesh has LOD
  27448. */
  27449. get hasLODLevels(): boolean;
  27450. /**
  27451. * Gets the list of MeshLODLevel associated with the current mesh
  27452. * @returns an array of MeshLODLevel
  27453. */
  27454. getLODLevels(): MeshLODLevel[];
  27455. private _sortLODLevels;
  27456. /**
  27457. * Add a mesh as LOD level triggered at the given distance.
  27458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27459. * @param distance The distance from the center of the object to show this level
  27460. * @param mesh The mesh to be added as LOD level (can be null)
  27461. * @return This mesh (for chaining)
  27462. */
  27463. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27464. /**
  27465. * Returns the LOD level mesh at the passed distance or null if not found.
  27466. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27467. * @param distance The distance from the center of the object to show this level
  27468. * @returns a Mesh or `null`
  27469. */
  27470. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27471. /**
  27472. * Remove a mesh from the LOD array
  27473. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27474. * @param mesh defines the mesh to be removed
  27475. * @return This mesh (for chaining)
  27476. */
  27477. removeLODLevel(mesh: Mesh): Mesh;
  27478. /**
  27479. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27480. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27481. * @param camera defines the camera to use to compute distance
  27482. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27483. * @return This mesh (for chaining)
  27484. */
  27485. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27486. /**
  27487. * Gets the mesh internal Geometry object
  27488. */
  27489. get geometry(): Nullable<Geometry>;
  27490. /**
  27491. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27492. * @returns the total number of vertices
  27493. */
  27494. getTotalVertices(): number;
  27495. /**
  27496. * Returns the content of an associated vertex buffer
  27497. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27498. * - VertexBuffer.PositionKind
  27499. * - VertexBuffer.UVKind
  27500. * - VertexBuffer.UV2Kind
  27501. * - VertexBuffer.UV3Kind
  27502. * - VertexBuffer.UV4Kind
  27503. * - VertexBuffer.UV5Kind
  27504. * - VertexBuffer.UV6Kind
  27505. * - VertexBuffer.ColorKind
  27506. * - VertexBuffer.MatricesIndicesKind
  27507. * - VertexBuffer.MatricesIndicesExtraKind
  27508. * - VertexBuffer.MatricesWeightsKind
  27509. * - VertexBuffer.MatricesWeightsExtraKind
  27510. * @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
  27511. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27512. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27513. */
  27514. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27515. /**
  27516. * Returns the mesh VertexBuffer object from the requested `kind`
  27517. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27518. * - VertexBuffer.PositionKind
  27519. * - VertexBuffer.NormalKind
  27520. * - VertexBuffer.UVKind
  27521. * - VertexBuffer.UV2Kind
  27522. * - VertexBuffer.UV3Kind
  27523. * - VertexBuffer.UV4Kind
  27524. * - VertexBuffer.UV5Kind
  27525. * - VertexBuffer.UV6Kind
  27526. * - VertexBuffer.ColorKind
  27527. * - VertexBuffer.MatricesIndicesKind
  27528. * - VertexBuffer.MatricesIndicesExtraKind
  27529. * - VertexBuffer.MatricesWeightsKind
  27530. * - VertexBuffer.MatricesWeightsExtraKind
  27531. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27532. */
  27533. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27534. /**
  27535. * Tests if a specific vertex buffer is associated with this mesh
  27536. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27537. * - VertexBuffer.PositionKind
  27538. * - VertexBuffer.NormalKind
  27539. * - VertexBuffer.UVKind
  27540. * - VertexBuffer.UV2Kind
  27541. * - VertexBuffer.UV3Kind
  27542. * - VertexBuffer.UV4Kind
  27543. * - VertexBuffer.UV5Kind
  27544. * - VertexBuffer.UV6Kind
  27545. * - VertexBuffer.ColorKind
  27546. * - VertexBuffer.MatricesIndicesKind
  27547. * - VertexBuffer.MatricesIndicesExtraKind
  27548. * - VertexBuffer.MatricesWeightsKind
  27549. * - VertexBuffer.MatricesWeightsExtraKind
  27550. * @returns a boolean
  27551. */
  27552. isVerticesDataPresent(kind: string): boolean;
  27553. /**
  27554. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27555. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27556. * - VertexBuffer.PositionKind
  27557. * - VertexBuffer.UVKind
  27558. * - VertexBuffer.UV2Kind
  27559. * - VertexBuffer.UV3Kind
  27560. * - VertexBuffer.UV4Kind
  27561. * - VertexBuffer.UV5Kind
  27562. * - VertexBuffer.UV6Kind
  27563. * - VertexBuffer.ColorKind
  27564. * - VertexBuffer.MatricesIndicesKind
  27565. * - VertexBuffer.MatricesIndicesExtraKind
  27566. * - VertexBuffer.MatricesWeightsKind
  27567. * - VertexBuffer.MatricesWeightsExtraKind
  27568. * @returns a boolean
  27569. */
  27570. isVertexBufferUpdatable(kind: string): boolean;
  27571. /**
  27572. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27573. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27574. * - VertexBuffer.PositionKind
  27575. * - VertexBuffer.NormalKind
  27576. * - VertexBuffer.UVKind
  27577. * - VertexBuffer.UV2Kind
  27578. * - VertexBuffer.UV3Kind
  27579. * - VertexBuffer.UV4Kind
  27580. * - VertexBuffer.UV5Kind
  27581. * - VertexBuffer.UV6Kind
  27582. * - VertexBuffer.ColorKind
  27583. * - VertexBuffer.MatricesIndicesKind
  27584. * - VertexBuffer.MatricesIndicesExtraKind
  27585. * - VertexBuffer.MatricesWeightsKind
  27586. * - VertexBuffer.MatricesWeightsExtraKind
  27587. * @returns an array of strings
  27588. */
  27589. getVerticesDataKinds(): string[];
  27590. /**
  27591. * Returns a positive integer : the total number of indices in this mesh geometry.
  27592. * @returns the numner of indices or zero if the mesh has no geometry.
  27593. */
  27594. getTotalIndices(): number;
  27595. /**
  27596. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27597. * @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.
  27598. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27599. * @returns the indices array or an empty array if the mesh has no geometry
  27600. */
  27601. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27602. get isBlocked(): boolean;
  27603. /**
  27604. * Determine if the current mesh is ready to be rendered
  27605. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27606. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27607. * @returns true if all associated assets are ready (material, textures, shaders)
  27608. */
  27609. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27610. /**
  27611. * 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.
  27612. */
  27613. get areNormalsFrozen(): boolean;
  27614. /**
  27615. * 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.
  27616. * @returns the current mesh
  27617. */
  27618. freezeNormals(): Mesh;
  27619. /**
  27620. * 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
  27621. * @returns the current mesh
  27622. */
  27623. unfreezeNormals(): Mesh;
  27624. /**
  27625. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27626. */
  27627. set overridenInstanceCount(count: number);
  27628. /** @hidden */
  27629. _preActivate(): Mesh;
  27630. /** @hidden */
  27631. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27632. /** @hidden */
  27633. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27634. protected _afterComputeWorldMatrix(): void;
  27635. /** @hidden */
  27636. _postActivate(): void;
  27637. /**
  27638. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27639. * This means the mesh underlying bounding box and sphere are recomputed.
  27640. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27641. * @returns the current mesh
  27642. */
  27643. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27644. /** @hidden */
  27645. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27646. /**
  27647. * This function will subdivide the mesh into multiple submeshes
  27648. * @param count defines the expected number of submeshes
  27649. */
  27650. subdivide(count: number): void;
  27651. /**
  27652. * Copy a FloatArray into a specific associated vertex buffer
  27653. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27654. * - VertexBuffer.PositionKind
  27655. * - VertexBuffer.UVKind
  27656. * - VertexBuffer.UV2Kind
  27657. * - VertexBuffer.UV3Kind
  27658. * - VertexBuffer.UV4Kind
  27659. * - VertexBuffer.UV5Kind
  27660. * - VertexBuffer.UV6Kind
  27661. * - VertexBuffer.ColorKind
  27662. * - VertexBuffer.MatricesIndicesKind
  27663. * - VertexBuffer.MatricesIndicesExtraKind
  27664. * - VertexBuffer.MatricesWeightsKind
  27665. * - VertexBuffer.MatricesWeightsExtraKind
  27666. * @param data defines the data source
  27667. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27668. * @param stride defines the data stride size (can be null)
  27669. * @returns the current mesh
  27670. */
  27671. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27672. /**
  27673. * Delete a vertex buffer associated with this mesh
  27674. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27675. * - VertexBuffer.PositionKind
  27676. * - VertexBuffer.UVKind
  27677. * - VertexBuffer.UV2Kind
  27678. * - VertexBuffer.UV3Kind
  27679. * - VertexBuffer.UV4Kind
  27680. * - VertexBuffer.UV5Kind
  27681. * - VertexBuffer.UV6Kind
  27682. * - VertexBuffer.ColorKind
  27683. * - VertexBuffer.MatricesIndicesKind
  27684. * - VertexBuffer.MatricesIndicesExtraKind
  27685. * - VertexBuffer.MatricesWeightsKind
  27686. * - VertexBuffer.MatricesWeightsExtraKind
  27687. */
  27688. removeVerticesData(kind: string): void;
  27689. /**
  27690. * Flags an associated vertex buffer as updatable
  27691. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27692. * - VertexBuffer.PositionKind
  27693. * - VertexBuffer.UVKind
  27694. * - VertexBuffer.UV2Kind
  27695. * - VertexBuffer.UV3Kind
  27696. * - VertexBuffer.UV4Kind
  27697. * - VertexBuffer.UV5Kind
  27698. * - VertexBuffer.UV6Kind
  27699. * - VertexBuffer.ColorKind
  27700. * - VertexBuffer.MatricesIndicesKind
  27701. * - VertexBuffer.MatricesIndicesExtraKind
  27702. * - VertexBuffer.MatricesWeightsKind
  27703. * - VertexBuffer.MatricesWeightsExtraKind
  27704. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27705. */
  27706. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27707. /**
  27708. * Sets the mesh global Vertex Buffer
  27709. * @param buffer defines the buffer to use
  27710. * @returns the current mesh
  27711. */
  27712. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27713. /**
  27714. * Update a specific associated vertex buffer
  27715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27716. * - VertexBuffer.PositionKind
  27717. * - VertexBuffer.UVKind
  27718. * - VertexBuffer.UV2Kind
  27719. * - VertexBuffer.UV3Kind
  27720. * - VertexBuffer.UV4Kind
  27721. * - VertexBuffer.UV5Kind
  27722. * - VertexBuffer.UV6Kind
  27723. * - VertexBuffer.ColorKind
  27724. * - VertexBuffer.MatricesIndicesKind
  27725. * - VertexBuffer.MatricesIndicesExtraKind
  27726. * - VertexBuffer.MatricesWeightsKind
  27727. * - VertexBuffer.MatricesWeightsExtraKind
  27728. * @param data defines the data source
  27729. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27730. * @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)
  27731. * @returns the current mesh
  27732. */
  27733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27734. /**
  27735. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27737. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27738. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27739. * @returns the current mesh
  27740. */
  27741. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27742. /**
  27743. * Creates a un-shared specific occurence of the geometry for the mesh.
  27744. * @returns the current mesh
  27745. */
  27746. makeGeometryUnique(): Mesh;
  27747. /**
  27748. * Set the index buffer of this mesh
  27749. * @param indices defines the source data
  27750. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27751. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27752. * @returns the current mesh
  27753. */
  27754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27755. /**
  27756. * Update the current index buffer
  27757. * @param indices defines the source data
  27758. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27759. * @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)
  27760. * @returns the current mesh
  27761. */
  27762. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27763. /**
  27764. * Invert the geometry to move from a right handed system to a left handed one.
  27765. * @returns the current mesh
  27766. */
  27767. toLeftHanded(): Mesh;
  27768. /** @hidden */
  27769. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27770. /** @hidden */
  27771. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27772. /**
  27773. * Registers for this mesh a javascript function called just before the rendering process
  27774. * @param func defines the function to call before rendering this mesh
  27775. * @returns the current mesh
  27776. */
  27777. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27778. /**
  27779. * Disposes a previously registered javascript function called before the rendering
  27780. * @param func defines the function to remove
  27781. * @returns the current mesh
  27782. */
  27783. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27784. /**
  27785. * Registers for this mesh a javascript function called just after the rendering is complete
  27786. * @param func defines the function to call after rendering this mesh
  27787. * @returns the current mesh
  27788. */
  27789. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27790. /**
  27791. * Disposes a previously registered javascript function called after the rendering.
  27792. * @param func defines the function to remove
  27793. * @returns the current mesh
  27794. */
  27795. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27796. /** @hidden */
  27797. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27798. /** @hidden */
  27799. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27800. /** @hidden */
  27801. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27802. /** @hidden */
  27803. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27804. /** @hidden */
  27805. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27806. /** @hidden */
  27807. _rebuild(): void;
  27808. /** @hidden */
  27809. _freeze(): void;
  27810. /** @hidden */
  27811. _unFreeze(): void;
  27812. /**
  27813. * 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
  27814. * @param subMesh defines the subMesh to render
  27815. * @param enableAlphaMode defines if alpha mode can be changed
  27816. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27817. * @returns the current mesh
  27818. */
  27819. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27820. private _onBeforeDraw;
  27821. /**
  27822. * Renormalize the mesh and patch it up if there are no weights
  27823. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27824. * However in the case of zero weights then we set just a single influence to 1.
  27825. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27826. */
  27827. cleanMatrixWeights(): void;
  27828. private normalizeSkinFourWeights;
  27829. private normalizeSkinWeightsAndExtra;
  27830. /**
  27831. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27832. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27833. * the user know there was an issue with importing the mesh
  27834. * @returns a validation object with skinned, valid and report string
  27835. */
  27836. validateSkinning(): {
  27837. skinned: boolean;
  27838. valid: boolean;
  27839. report: string;
  27840. };
  27841. /** @hidden */
  27842. _checkDelayState(): Mesh;
  27843. private _queueLoad;
  27844. /**
  27845. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27846. * A mesh is in the frustum if its bounding box intersects the frustum
  27847. * @param frustumPlanes defines the frustum to test
  27848. * @returns true if the mesh is in the frustum planes
  27849. */
  27850. isInFrustum(frustumPlanes: Plane[]): boolean;
  27851. /**
  27852. * Sets the mesh material by the material or multiMaterial `id` property
  27853. * @param id is a string identifying the material or the multiMaterial
  27854. * @returns the current mesh
  27855. */
  27856. setMaterialByID(id: string): Mesh;
  27857. /**
  27858. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27859. * @returns an array of IAnimatable
  27860. */
  27861. getAnimatables(): IAnimatable[];
  27862. /**
  27863. * Modifies the mesh geometry according to the passed transformation matrix.
  27864. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27865. * The mesh normals are modified using the same transformation.
  27866. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27867. * @param transform defines the transform matrix to use
  27868. * @see http://doc.babylonjs.com/resources/baking_transformations
  27869. * @returns the current mesh
  27870. */
  27871. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27872. /**
  27873. * Modifies the mesh geometry according to its own current World Matrix.
  27874. * The mesh World Matrix is then reset.
  27875. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27876. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27877. * @see http://doc.babylonjs.com/resources/baking_transformations
  27878. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27879. * @returns the current mesh
  27880. */
  27881. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27882. /** @hidden */
  27883. get _positions(): Nullable<Vector3[]>;
  27884. /** @hidden */
  27885. _resetPointsArrayCache(): Mesh;
  27886. /** @hidden */
  27887. _generatePointsArray(): boolean;
  27888. /**
  27889. * Returns a new Mesh object generated from the current mesh properties.
  27890. * This method must not get confused with createInstance()
  27891. * @param name is a string, the name given to the new mesh
  27892. * @param newParent can be any Node object (default `null`)
  27893. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27894. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27895. * @returns a new mesh
  27896. */
  27897. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27898. /**
  27899. * Releases resources associated with this mesh.
  27900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27902. */
  27903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27904. /** @hidden */
  27905. _disposeInstanceSpecificData(): void;
  27906. /** @hidden */
  27907. _disposeThinInstanceSpecificData(): void;
  27908. /**
  27909. * Modifies the mesh geometry according to a displacement map.
  27910. * 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.
  27911. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27912. * @param url is a string, the URL from the image file is to be downloaded.
  27913. * @param minHeight is the lower limit of the displacement.
  27914. * @param maxHeight is the upper limit of the displacement.
  27915. * @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.
  27916. * @param uvOffset is an optional vector2 used to offset UV.
  27917. * @param uvScale is an optional vector2 used to scale UV.
  27918. * @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.
  27919. * @returns the Mesh.
  27920. */
  27921. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27922. /**
  27923. * Modifies the mesh geometry according to a displacementMap buffer.
  27924. * 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.
  27925. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27926. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27927. * @param heightMapWidth is the width of the buffer image.
  27928. * @param heightMapHeight is the height of the buffer image.
  27929. * @param minHeight is the lower limit of the displacement.
  27930. * @param maxHeight is the upper limit of the displacement.
  27931. * @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.
  27932. * @param uvOffset is an optional vector2 used to offset UV.
  27933. * @param uvScale is an optional vector2 used to scale UV.
  27934. * @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.
  27935. * @returns the Mesh.
  27936. */
  27937. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27938. /**
  27939. * Modify the mesh to get a flat shading rendering.
  27940. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27941. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27942. * @returns current mesh
  27943. */
  27944. convertToFlatShadedMesh(): Mesh;
  27945. /**
  27946. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27947. * In other words, more vertices, no more indices and a single bigger VBO.
  27948. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27949. * @returns current mesh
  27950. */
  27951. convertToUnIndexedMesh(): Mesh;
  27952. /**
  27953. * Inverses facet orientations.
  27954. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27955. * @param flipNormals will also inverts the normals
  27956. * @returns current mesh
  27957. */
  27958. flipFaces(flipNormals?: boolean): Mesh;
  27959. /**
  27960. * Increase the number of facets and hence vertices in a mesh
  27961. * Vertex normals are interpolated from existing vertex normals
  27962. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27963. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27964. */
  27965. increaseVertices(numberPerEdge: number): void;
  27966. /**
  27967. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27968. * This will undo any application of covertToFlatShadedMesh
  27969. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27970. */
  27971. forceSharedVertices(): void;
  27972. /** @hidden */
  27973. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27974. /** @hidden */
  27975. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27976. /**
  27977. * Creates a new InstancedMesh object from the mesh model.
  27978. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27979. * @param name defines the name of the new instance
  27980. * @returns a new InstancedMesh
  27981. */
  27982. createInstance(name: string): InstancedMesh;
  27983. /**
  27984. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27985. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27986. * @returns the current mesh
  27987. */
  27988. synchronizeInstances(): Mesh;
  27989. /**
  27990. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27991. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27992. * This should be used together with the simplification to avoid disappearing triangles.
  27993. * @param successCallback an optional success callback to be called after the optimization finished.
  27994. * @returns the current mesh
  27995. */
  27996. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27997. /**
  27998. * Serialize current mesh
  27999. * @param serializationObject defines the object which will receive the serialization data
  28000. */
  28001. serialize(serializationObject: any): void;
  28002. /** @hidden */
  28003. _syncGeometryWithMorphTargetManager(): void;
  28004. /** @hidden */
  28005. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28006. /**
  28007. * Returns a new Mesh object parsed from the source provided.
  28008. * @param parsedMesh is the source
  28009. * @param scene defines the hosting scene
  28010. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28011. * @returns a new Mesh
  28012. */
  28013. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28014. /**
  28015. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28016. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28017. * @param name defines the name of the mesh to create
  28018. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28019. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28020. * @param closePath creates a seam between the first and the last points of each path of the path array
  28021. * @param offset is taken in account only if the `pathArray` is containing a single path
  28022. * @param scene defines the hosting scene
  28023. * @param updatable defines if the mesh must be flagged as updatable
  28024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28025. * @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)
  28026. * @returns a new Mesh
  28027. */
  28028. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28029. /**
  28030. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28031. * @param name defines the name of the mesh to create
  28032. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28033. * @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
  28034. * @param scene defines the hosting scene
  28035. * @param updatable defines if the mesh must be flagged as updatable
  28036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28037. * @returns a new Mesh
  28038. */
  28039. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28040. /**
  28041. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28042. * @param name defines the name of the mesh to create
  28043. * @param size sets the size (float) of each box side (default 1)
  28044. * @param scene defines the hosting scene
  28045. * @param updatable defines if the mesh must be flagged as updatable
  28046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28047. * @returns a new Mesh
  28048. */
  28049. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28050. /**
  28051. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28052. * @param name defines the name of the mesh to create
  28053. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28054. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28055. * @param scene defines the hosting scene
  28056. * @param updatable defines if the mesh must be flagged as updatable
  28057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28058. * @returns a new Mesh
  28059. */
  28060. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28061. /**
  28062. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28063. * @param name defines the name of the mesh to create
  28064. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28065. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28066. * @param scene defines the hosting scene
  28067. * @returns a new Mesh
  28068. */
  28069. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28070. /**
  28071. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28072. * @param name defines the name of the mesh to create
  28073. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28074. * @param diameterTop set the top cap diameter (floats, default 1)
  28075. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28076. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28077. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28078. * @param scene defines the hosting scene
  28079. * @param updatable defines if the mesh must be flagged as updatable
  28080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28081. * @returns a new Mesh
  28082. */
  28083. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28084. /**
  28085. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28086. * @param name defines the name of the mesh to create
  28087. * @param diameter sets the diameter size (float) of the torus (default 1)
  28088. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28089. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28090. * @param scene defines the hosting scene
  28091. * @param updatable defines if the mesh must be flagged as updatable
  28092. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28093. * @returns a new Mesh
  28094. */
  28095. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28096. /**
  28097. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28098. * @param name defines the name of the mesh to create
  28099. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28100. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28101. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28102. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28103. * @param p the number of windings on X axis (positive integers, default 2)
  28104. * @param q the number of windings on Y axis (positive integers, default 3)
  28105. * @param scene defines the hosting scene
  28106. * @param updatable defines if the mesh must be flagged as updatable
  28107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28108. * @returns a new Mesh
  28109. */
  28110. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28111. /**
  28112. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28113. * @param name defines the name of the mesh to create
  28114. * @param points is an array successive Vector3
  28115. * @param scene defines the hosting scene
  28116. * @param updatable defines if the mesh must be flagged as updatable
  28117. * @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).
  28118. * @returns a new Mesh
  28119. */
  28120. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28121. /**
  28122. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28123. * @param name defines the name of the mesh to create
  28124. * @param points is an array successive Vector3
  28125. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28126. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28127. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28128. * @param scene defines the hosting scene
  28129. * @param updatable defines if the mesh must be flagged as updatable
  28130. * @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)
  28131. * @returns a new Mesh
  28132. */
  28133. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28134. /**
  28135. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28136. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28137. * 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.
  28138. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28139. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28140. * Remember you can only change the shape positions, not their number when updating a polygon.
  28141. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28142. * @param name defines the name of the mesh to create
  28143. * @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
  28144. * @param scene defines the hosting scene
  28145. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28146. * @param updatable defines if the mesh must be flagged as updatable
  28147. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28148. * @param earcutInjection can be used to inject your own earcut reference
  28149. * @returns a new Mesh
  28150. */
  28151. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28152. /**
  28153. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28154. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28155. * @param name defines the name of the mesh to create
  28156. * @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
  28157. * @param depth defines the height of extrusion
  28158. * @param scene defines the hosting scene
  28159. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28160. * @param updatable defines if the mesh must be flagged as updatable
  28161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28162. * @param earcutInjection can be used to inject your own earcut reference
  28163. * @returns a new Mesh
  28164. */
  28165. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28166. /**
  28167. * Creates an extruded shape mesh.
  28168. * 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
  28169. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28170. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28171. * @param name defines the name of the mesh to create
  28172. * @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
  28173. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28174. * @param scale is the value to scale the shape
  28175. * @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
  28176. * @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
  28177. * @param scene defines the hosting scene
  28178. * @param updatable defines if the mesh must be flagged as updatable
  28179. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28180. * @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)
  28181. * @returns a new Mesh
  28182. */
  28183. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28184. /**
  28185. * Creates an custom extruded shape mesh.
  28186. * The custom extrusion is a parametric shape.
  28187. * It has no predefined shape. Its final shape will depend on the input parameters.
  28188. * Please consider using the same method from the MeshBuilder class instead
  28189. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28190. * @param name defines the name of the mesh to create
  28191. * @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
  28192. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28193. * @param scaleFunction is a custom Javascript function called on each path point
  28194. * @param rotationFunction is a custom Javascript function called on each path point
  28195. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28196. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28197. * @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
  28198. * @param scene defines the hosting scene
  28199. * @param updatable defines if the mesh must be flagged as updatable
  28200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28201. * @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)
  28202. * @returns a new Mesh
  28203. */
  28204. 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;
  28205. /**
  28206. * Creates lathe mesh.
  28207. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28208. * Please consider using the same method from the MeshBuilder class instead
  28209. * @param name defines the name of the mesh to create
  28210. * @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
  28211. * @param radius is the radius value of the lathe
  28212. * @param tessellation is the side number of the lathe.
  28213. * @param scene defines the hosting scene
  28214. * @param updatable defines if the mesh must be flagged as updatable
  28215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28216. * @returns a new Mesh
  28217. */
  28218. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28219. /**
  28220. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28221. * @param name defines the name of the mesh to create
  28222. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28223. * @param scene defines the hosting scene
  28224. * @param updatable defines if the mesh must be flagged as updatable
  28225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28226. * @returns a new Mesh
  28227. */
  28228. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28229. /**
  28230. * Creates a ground mesh.
  28231. * Please consider using the same method from the MeshBuilder class instead
  28232. * @param name defines the name of the mesh to create
  28233. * @param width set the width of the ground
  28234. * @param height set the height of the ground
  28235. * @param subdivisions sets the number of subdivisions per side
  28236. * @param scene defines the hosting scene
  28237. * @param updatable defines if the mesh must be flagged as updatable
  28238. * @returns a new Mesh
  28239. */
  28240. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28241. /**
  28242. * Creates a tiled ground mesh.
  28243. * Please consider using the same method from the MeshBuilder class instead
  28244. * @param name defines the name of the mesh to create
  28245. * @param xmin set the ground minimum X coordinate
  28246. * @param zmin set the ground minimum Y coordinate
  28247. * @param xmax set the ground maximum X coordinate
  28248. * @param zmax set the ground maximum Z coordinate
  28249. * @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
  28250. * @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
  28251. * @param scene defines the hosting scene
  28252. * @param updatable defines if the mesh must be flagged as updatable
  28253. * @returns a new Mesh
  28254. */
  28255. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28256. w: number;
  28257. h: number;
  28258. }, precision: {
  28259. w: number;
  28260. h: number;
  28261. }, scene: Scene, updatable?: boolean): Mesh;
  28262. /**
  28263. * Creates a ground mesh from a height map.
  28264. * Please consider using the same method from the MeshBuilder class instead
  28265. * @see http://doc.babylonjs.com/babylon101/height_map
  28266. * @param name defines the name of the mesh to create
  28267. * @param url sets the URL of the height map image resource
  28268. * @param width set the ground width size
  28269. * @param height set the ground height size
  28270. * @param subdivisions sets the number of subdivision per side
  28271. * @param minHeight is the minimum altitude on the ground
  28272. * @param maxHeight is the maximum altitude on the ground
  28273. * @param scene defines the hosting scene
  28274. * @param updatable defines if the mesh must be flagged as updatable
  28275. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28276. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28277. * @returns a new Mesh
  28278. */
  28279. 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;
  28280. /**
  28281. * Creates a tube mesh.
  28282. * The tube is a parametric shape.
  28283. * It has no predefined shape. Its final shape will depend on the input parameters.
  28284. * Please consider using the same method from the MeshBuilder class instead
  28285. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28286. * @param name defines the name of the mesh to create
  28287. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28288. * @param radius sets the tube radius size
  28289. * @param tessellation is the number of sides on the tubular surface
  28290. * @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
  28291. * @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
  28292. * @param scene defines the hosting scene
  28293. * @param updatable defines if the mesh must be flagged as updatable
  28294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28295. * @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)
  28296. * @returns a new Mesh
  28297. */
  28298. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28299. (i: number, distance: number): number;
  28300. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28301. /**
  28302. * Creates a polyhedron mesh.
  28303. * Please consider using the same method from the MeshBuilder class instead.
  28304. * * 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
  28305. * * The parameter `size` (positive float, default 1) sets the polygon size
  28306. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28307. * * 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`
  28308. * * 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
  28309. * * 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)`)
  28310. * * 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
  28311. * * 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
  28312. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28313. * * 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
  28314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28315. * @param name defines the name of the mesh to create
  28316. * @param options defines the options used to create the mesh
  28317. * @param scene defines the hosting scene
  28318. * @returns a new Mesh
  28319. */
  28320. static CreatePolyhedron(name: string, options: {
  28321. type?: number;
  28322. size?: number;
  28323. sizeX?: number;
  28324. sizeY?: number;
  28325. sizeZ?: number;
  28326. custom?: any;
  28327. faceUV?: Vector4[];
  28328. faceColors?: Color4[];
  28329. updatable?: boolean;
  28330. sideOrientation?: number;
  28331. }, scene: Scene): Mesh;
  28332. /**
  28333. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28334. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28335. * * 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`)
  28336. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28337. * * 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
  28338. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28339. * * 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
  28340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28341. * @param name defines the name of the mesh
  28342. * @param options defines the options used to create the mesh
  28343. * @param scene defines the hosting scene
  28344. * @returns a new Mesh
  28345. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28346. */
  28347. static CreateIcoSphere(name: string, options: {
  28348. radius?: number;
  28349. flat?: boolean;
  28350. subdivisions?: number;
  28351. sideOrientation?: number;
  28352. updatable?: boolean;
  28353. }, scene: Scene): Mesh;
  28354. /**
  28355. * Creates a decal mesh.
  28356. * Please consider using the same method from the MeshBuilder class instead.
  28357. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28358. * @param name defines the name of the mesh
  28359. * @param sourceMesh defines the mesh receiving the decal
  28360. * @param position sets the position of the decal in world coordinates
  28361. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28362. * @param size sets the decal scaling
  28363. * @param angle sets the angle to rotate the decal
  28364. * @returns a new Mesh
  28365. */
  28366. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28367. /**
  28368. * Prepare internal position array for software CPU skinning
  28369. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28370. */
  28371. setPositionsForCPUSkinning(): Float32Array;
  28372. /**
  28373. * Prepare internal normal array for software CPU skinning
  28374. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28375. */
  28376. setNormalsForCPUSkinning(): Float32Array;
  28377. /**
  28378. * Updates the vertex buffer by applying transformation from the bones
  28379. * @param skeleton defines the skeleton to apply to current mesh
  28380. * @returns the current mesh
  28381. */
  28382. applySkeleton(skeleton: Skeleton): Mesh;
  28383. /**
  28384. * 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
  28385. * @param meshes defines the list of meshes to scan
  28386. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28387. */
  28388. static MinMax(meshes: AbstractMesh[]): {
  28389. min: Vector3;
  28390. max: Vector3;
  28391. };
  28392. /**
  28393. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28394. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28395. * @returns a vector3
  28396. */
  28397. static Center(meshesOrMinMaxVector: {
  28398. min: Vector3;
  28399. max: Vector3;
  28400. } | AbstractMesh[]): Vector3;
  28401. /**
  28402. * Merge the array of meshes into a single mesh for performance reasons.
  28403. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28404. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28405. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28406. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28407. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28408. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28409. * @returns a new mesh
  28410. */
  28411. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28412. /** @hidden */
  28413. addInstance(instance: InstancedMesh): void;
  28414. /** @hidden */
  28415. removeInstance(instance: InstancedMesh): void;
  28416. }
  28417. }
  28418. declare module BABYLON {
  28419. /**
  28420. * This is the base class of all the camera used in the application.
  28421. * @see http://doc.babylonjs.com/features/cameras
  28422. */
  28423. export class Camera extends Node {
  28424. /** @hidden */
  28425. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28426. /**
  28427. * This is the default projection mode used by the cameras.
  28428. * It helps recreating a feeling of perspective and better appreciate depth.
  28429. * This is the best way to simulate real life cameras.
  28430. */
  28431. static readonly PERSPECTIVE_CAMERA: number;
  28432. /**
  28433. * This helps creating camera with an orthographic mode.
  28434. * 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.
  28435. */
  28436. static readonly ORTHOGRAPHIC_CAMERA: number;
  28437. /**
  28438. * This is the default FOV mode for perspective cameras.
  28439. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28440. */
  28441. static readonly FOVMODE_VERTICAL_FIXED: number;
  28442. /**
  28443. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28444. */
  28445. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28446. /**
  28447. * This specifies ther is no need for a camera rig.
  28448. * Basically only one eye is rendered corresponding to the camera.
  28449. */
  28450. static readonly RIG_MODE_NONE: number;
  28451. /**
  28452. * Simulates a camera Rig with one blue eye and one red eye.
  28453. * This can be use with 3d blue and red glasses.
  28454. */
  28455. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28456. /**
  28457. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28458. */
  28459. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28460. /**
  28461. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28462. */
  28463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28464. /**
  28465. * Defines that both eyes of the camera will be rendered over under each other.
  28466. */
  28467. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28468. /**
  28469. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28470. */
  28471. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28472. /**
  28473. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28474. */
  28475. static readonly RIG_MODE_VR: number;
  28476. /**
  28477. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28478. */
  28479. static readonly RIG_MODE_WEBVR: number;
  28480. /**
  28481. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28482. */
  28483. static readonly RIG_MODE_CUSTOM: number;
  28484. /**
  28485. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28486. */
  28487. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28488. /**
  28489. * Define the input manager associated with the camera.
  28490. */
  28491. inputs: CameraInputsManager<Camera>;
  28492. /** @hidden */
  28493. _position: Vector3;
  28494. /**
  28495. * Define the current local position of the camera in the scene
  28496. */
  28497. get position(): Vector3;
  28498. set position(newPosition: Vector3);
  28499. /**
  28500. * The vector the camera should consider as up.
  28501. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28502. */
  28503. upVector: Vector3;
  28504. /**
  28505. * Define the current limit on the left side for an orthographic camera
  28506. * In scene unit
  28507. */
  28508. orthoLeft: Nullable<number>;
  28509. /**
  28510. * Define the current limit on the right side for an orthographic camera
  28511. * In scene unit
  28512. */
  28513. orthoRight: Nullable<number>;
  28514. /**
  28515. * Define the current limit on the bottom side for an orthographic camera
  28516. * In scene unit
  28517. */
  28518. orthoBottom: Nullable<number>;
  28519. /**
  28520. * Define the current limit on the top side for an orthographic camera
  28521. * In scene unit
  28522. */
  28523. orthoTop: Nullable<number>;
  28524. /**
  28525. * Field Of View is set in Radians. (default is 0.8)
  28526. */
  28527. fov: number;
  28528. /**
  28529. * Define the minimum distance the camera can see from.
  28530. * This is important to note that the depth buffer are not infinite and the closer it starts
  28531. * the more your scene might encounter depth fighting issue.
  28532. */
  28533. minZ: number;
  28534. /**
  28535. * Define the maximum distance the camera can see to.
  28536. * This is important to note that the depth buffer are not infinite and the further it end
  28537. * the more your scene might encounter depth fighting issue.
  28538. */
  28539. maxZ: number;
  28540. /**
  28541. * Define the default inertia of the camera.
  28542. * This helps giving a smooth feeling to the camera movement.
  28543. */
  28544. inertia: number;
  28545. /**
  28546. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28547. */
  28548. mode: number;
  28549. /**
  28550. * Define whether the camera is intermediate.
  28551. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28552. */
  28553. isIntermediate: boolean;
  28554. /**
  28555. * Define the viewport of the camera.
  28556. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28557. */
  28558. viewport: Viewport;
  28559. /**
  28560. * Restricts the camera to viewing objects with the same layerMask.
  28561. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28562. */
  28563. layerMask: number;
  28564. /**
  28565. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28566. */
  28567. fovMode: number;
  28568. /**
  28569. * Rig mode of the camera.
  28570. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28571. * This is normally controlled byt the camera themselves as internal use.
  28572. */
  28573. cameraRigMode: number;
  28574. /**
  28575. * Defines the distance between both "eyes" in case of a RIG
  28576. */
  28577. interaxialDistance: number;
  28578. /**
  28579. * Defines if stereoscopic rendering is done side by side or over under.
  28580. */
  28581. isStereoscopicSideBySide: boolean;
  28582. /**
  28583. * 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
  28584. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28585. * else in the scene. (Eg. security camera)
  28586. *
  28587. * 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)
  28588. */
  28589. customRenderTargets: RenderTargetTexture[];
  28590. /**
  28591. * When set, the camera will render to this render target instead of the default canvas
  28592. *
  28593. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28594. */
  28595. outputRenderTarget: Nullable<RenderTargetTexture>;
  28596. /**
  28597. * Observable triggered when the camera view matrix has changed.
  28598. */
  28599. onViewMatrixChangedObservable: Observable<Camera>;
  28600. /**
  28601. * Observable triggered when the camera Projection matrix has changed.
  28602. */
  28603. onProjectionMatrixChangedObservable: Observable<Camera>;
  28604. /**
  28605. * Observable triggered when the inputs have been processed.
  28606. */
  28607. onAfterCheckInputsObservable: Observable<Camera>;
  28608. /**
  28609. * Observable triggered when reset has been called and applied to the camera.
  28610. */
  28611. onRestoreStateObservable: Observable<Camera>;
  28612. /**
  28613. * Is this camera a part of a rig system?
  28614. */
  28615. isRigCamera: boolean;
  28616. /**
  28617. * If isRigCamera set to true this will be set with the parent camera.
  28618. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28619. */
  28620. rigParent?: Camera;
  28621. /** @hidden */
  28622. _cameraRigParams: any;
  28623. /** @hidden */
  28624. _rigCameras: Camera[];
  28625. /** @hidden */
  28626. _rigPostProcess: Nullable<PostProcess>;
  28627. protected _webvrViewMatrix: Matrix;
  28628. /** @hidden */
  28629. _skipRendering: boolean;
  28630. /** @hidden */
  28631. _projectionMatrix: Matrix;
  28632. /** @hidden */
  28633. _postProcesses: Nullable<PostProcess>[];
  28634. /** @hidden */
  28635. _activeMeshes: SmartArray<AbstractMesh>;
  28636. protected _globalPosition: Vector3;
  28637. /** @hidden */
  28638. _computedViewMatrix: Matrix;
  28639. private _doNotComputeProjectionMatrix;
  28640. private _transformMatrix;
  28641. private _frustumPlanes;
  28642. private _refreshFrustumPlanes;
  28643. private _storedFov;
  28644. private _stateStored;
  28645. /**
  28646. * Instantiates a new camera object.
  28647. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28648. * @see http://doc.babylonjs.com/features/cameras
  28649. * @param name Defines the name of the camera in the scene
  28650. * @param position Defines the position of the camera
  28651. * @param scene Defines the scene the camera belongs too
  28652. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28653. */
  28654. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28655. /**
  28656. * Store current camera state (fov, position, etc..)
  28657. * @returns the camera
  28658. */
  28659. storeState(): Camera;
  28660. /**
  28661. * Restores the camera state values if it has been stored. You must call storeState() first
  28662. */
  28663. protected _restoreStateValues(): boolean;
  28664. /**
  28665. * Restored camera state. You must call storeState() first.
  28666. * @returns true if restored and false otherwise
  28667. */
  28668. restoreState(): boolean;
  28669. /**
  28670. * Gets the class name of the camera.
  28671. * @returns the class name
  28672. */
  28673. getClassName(): string;
  28674. /** @hidden */
  28675. readonly _isCamera: boolean;
  28676. /**
  28677. * Gets a string representation of the camera useful for debug purpose.
  28678. * @param fullDetails Defines that a more verboe level of logging is required
  28679. * @returns the string representation
  28680. */
  28681. toString(fullDetails?: boolean): string;
  28682. /**
  28683. * Gets the current world space position of the camera.
  28684. */
  28685. get globalPosition(): Vector3;
  28686. /**
  28687. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28688. * @returns the active meshe list
  28689. */
  28690. getActiveMeshes(): SmartArray<AbstractMesh>;
  28691. /**
  28692. * Check whether a mesh is part of the current active mesh list of the camera
  28693. * @param mesh Defines the mesh to check
  28694. * @returns true if active, false otherwise
  28695. */
  28696. isActiveMesh(mesh: Mesh): boolean;
  28697. /**
  28698. * Is this camera ready to be used/rendered
  28699. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28700. * @return true if the camera is ready
  28701. */
  28702. isReady(completeCheck?: boolean): boolean;
  28703. /** @hidden */
  28704. _initCache(): void;
  28705. /** @hidden */
  28706. _updateCache(ignoreParentClass?: boolean): void;
  28707. /** @hidden */
  28708. _isSynchronized(): boolean;
  28709. /** @hidden */
  28710. _isSynchronizedViewMatrix(): boolean;
  28711. /** @hidden */
  28712. _isSynchronizedProjectionMatrix(): boolean;
  28713. /**
  28714. * Attach the input controls to a specific dom element to get the input from.
  28715. * @param element Defines the element the controls should be listened from
  28716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28717. */
  28718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28719. /**
  28720. * Detach the current controls from the specified dom element.
  28721. * @param element Defines the element to stop listening the inputs from
  28722. */
  28723. detachControl(element: HTMLElement): void;
  28724. /**
  28725. * Update the camera state according to the different inputs gathered during the frame.
  28726. */
  28727. update(): void;
  28728. /** @hidden */
  28729. _checkInputs(): void;
  28730. /** @hidden */
  28731. get rigCameras(): Camera[];
  28732. /**
  28733. * Gets the post process used by the rig cameras
  28734. */
  28735. get rigPostProcess(): Nullable<PostProcess>;
  28736. /**
  28737. * Internal, gets the first post proces.
  28738. * @returns the first post process to be run on this camera.
  28739. */
  28740. _getFirstPostProcess(): Nullable<PostProcess>;
  28741. private _cascadePostProcessesToRigCams;
  28742. /**
  28743. * Attach a post process to the camera.
  28744. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28745. * @param postProcess The post process to attach to the camera
  28746. * @param insertAt The position of the post process in case several of them are in use in the scene
  28747. * @returns the position the post process has been inserted at
  28748. */
  28749. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28750. /**
  28751. * Detach a post process to the camera.
  28752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28753. * @param postProcess The post process to detach from the camera
  28754. */
  28755. detachPostProcess(postProcess: PostProcess): void;
  28756. /**
  28757. * Gets the current world matrix of the camera
  28758. */
  28759. getWorldMatrix(): Matrix;
  28760. /** @hidden */
  28761. _getViewMatrix(): Matrix;
  28762. /**
  28763. * Gets the current view matrix of the camera.
  28764. * @param force forces the camera to recompute the matrix without looking at the cached state
  28765. * @returns the view matrix
  28766. */
  28767. getViewMatrix(force?: boolean): Matrix;
  28768. /**
  28769. * Freeze the projection matrix.
  28770. * It will prevent the cache check of the camera projection compute and can speed up perf
  28771. * if no parameter of the camera are meant to change
  28772. * @param projection Defines manually a projection if necessary
  28773. */
  28774. freezeProjectionMatrix(projection?: Matrix): void;
  28775. /**
  28776. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28777. */
  28778. unfreezeProjectionMatrix(): void;
  28779. /**
  28780. * Gets the current projection matrix of the camera.
  28781. * @param force forces the camera to recompute the matrix without looking at the cached state
  28782. * @returns the projection matrix
  28783. */
  28784. getProjectionMatrix(force?: boolean): Matrix;
  28785. /**
  28786. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28787. * @returns a Matrix
  28788. */
  28789. getTransformationMatrix(): Matrix;
  28790. private _updateFrustumPlanes;
  28791. /**
  28792. * Checks if a cullable object (mesh...) is in the camera frustum
  28793. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28794. * @param target The object to check
  28795. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28796. * @returns true if the object is in frustum otherwise false
  28797. */
  28798. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28799. /**
  28800. * Checks if a cullable object (mesh...) is in the camera frustum
  28801. * Unlike isInFrustum this cheks the full bounding box
  28802. * @param target The object to check
  28803. * @returns true if the object is in frustum otherwise false
  28804. */
  28805. isCompletelyInFrustum(target: ICullable): boolean;
  28806. /**
  28807. * Gets a ray in the forward direction from the camera.
  28808. * @param length Defines the length of the ray to create
  28809. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28810. * @param origin Defines the start point of the ray which defaults to the camera position
  28811. * @returns the forward ray
  28812. */
  28813. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28814. /**
  28815. * Releases resources associated with this node.
  28816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28818. */
  28819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28820. /** @hidden */
  28821. _isLeftCamera: boolean;
  28822. /**
  28823. * Gets the left camera of a rig setup in case of Rigged Camera
  28824. */
  28825. get isLeftCamera(): boolean;
  28826. /** @hidden */
  28827. _isRightCamera: boolean;
  28828. /**
  28829. * Gets the right camera of a rig setup in case of Rigged Camera
  28830. */
  28831. get isRightCamera(): boolean;
  28832. /**
  28833. * Gets the left camera of a rig setup in case of Rigged Camera
  28834. */
  28835. get leftCamera(): Nullable<FreeCamera>;
  28836. /**
  28837. * Gets the right camera of a rig setup in case of Rigged Camera
  28838. */
  28839. get rightCamera(): Nullable<FreeCamera>;
  28840. /**
  28841. * Gets the left camera target of a rig setup in case of Rigged Camera
  28842. * @returns the target position
  28843. */
  28844. getLeftTarget(): Nullable<Vector3>;
  28845. /**
  28846. * Gets the right camera target of a rig setup in case of Rigged Camera
  28847. * @returns the target position
  28848. */
  28849. getRightTarget(): Nullable<Vector3>;
  28850. /**
  28851. * @hidden
  28852. */
  28853. setCameraRigMode(mode: number, rigParams: any): void;
  28854. /** @hidden */
  28855. static _setStereoscopicRigMode(camera: Camera): void;
  28856. /** @hidden */
  28857. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28858. /** @hidden */
  28859. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28860. /** @hidden */
  28861. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28862. /** @hidden */
  28863. _getVRProjectionMatrix(): Matrix;
  28864. protected _updateCameraRotationMatrix(): void;
  28865. protected _updateWebVRCameraRotationMatrix(): void;
  28866. /**
  28867. * This function MUST be overwritten by the different WebVR cameras available.
  28868. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28869. * @hidden
  28870. */
  28871. _getWebVRProjectionMatrix(): Matrix;
  28872. /**
  28873. * This function MUST be overwritten by the different WebVR cameras available.
  28874. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28875. * @hidden
  28876. */
  28877. _getWebVRViewMatrix(): Matrix;
  28878. /** @hidden */
  28879. setCameraRigParameter(name: string, value: any): void;
  28880. /**
  28881. * needs to be overridden by children so sub has required properties to be copied
  28882. * @hidden
  28883. */
  28884. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28885. /**
  28886. * May need to be overridden by children
  28887. * @hidden
  28888. */
  28889. _updateRigCameras(): void;
  28890. /** @hidden */
  28891. _setupInputs(): void;
  28892. /**
  28893. * Serialiaze the camera setup to a json represention
  28894. * @returns the JSON representation
  28895. */
  28896. serialize(): any;
  28897. /**
  28898. * Clones the current camera.
  28899. * @param name The cloned camera name
  28900. * @returns the cloned camera
  28901. */
  28902. clone(name: string): Camera;
  28903. /**
  28904. * Gets the direction of the camera relative to a given local axis.
  28905. * @param localAxis Defines the reference axis to provide a relative direction.
  28906. * @return the direction
  28907. */
  28908. getDirection(localAxis: Vector3): Vector3;
  28909. /**
  28910. * Returns the current camera absolute rotation
  28911. */
  28912. get absoluteRotation(): Quaternion;
  28913. /**
  28914. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28915. * @param localAxis Defines the reference axis to provide a relative direction.
  28916. * @param result Defines the vector to store the result in
  28917. */
  28918. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28919. /**
  28920. * Gets a camera constructor for a given camera type
  28921. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28922. * @param name The name of the camera the result will be able to instantiate
  28923. * @param scene The scene the result will construct the camera in
  28924. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28925. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28926. * @returns a factory method to construc the camera
  28927. */
  28928. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28929. /**
  28930. * Compute the world matrix of the camera.
  28931. * @returns the camera world matrix
  28932. */
  28933. computeWorldMatrix(): Matrix;
  28934. /**
  28935. * Parse a JSON and creates the camera from the parsed information
  28936. * @param parsedCamera The JSON to parse
  28937. * @param scene The scene to instantiate the camera in
  28938. * @returns the newly constructed camera
  28939. */
  28940. static Parse(parsedCamera: any, scene: Scene): Camera;
  28941. }
  28942. }
  28943. declare module BABYLON {
  28944. /**
  28945. * Class containing static functions to help procedurally build meshes
  28946. */
  28947. export class DiscBuilder {
  28948. /**
  28949. * Creates a plane polygonal mesh. By default, this is a disc
  28950. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28951. * * 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
  28952. * * 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
  28953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28954. * * 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
  28955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28956. * @param name defines the name of the mesh
  28957. * @param options defines the options used to create the mesh
  28958. * @param scene defines the hosting scene
  28959. * @returns the plane polygonal mesh
  28960. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28961. */
  28962. static CreateDisc(name: string, options: {
  28963. radius?: number;
  28964. tessellation?: number;
  28965. arc?: number;
  28966. updatable?: boolean;
  28967. sideOrientation?: number;
  28968. frontUVs?: Vector4;
  28969. backUVs?: Vector4;
  28970. }, scene?: Nullable<Scene>): Mesh;
  28971. }
  28972. }
  28973. declare module BABYLON {
  28974. /**
  28975. * Options to be used when creating a FresnelParameters.
  28976. */
  28977. export type IFresnelParametersCreationOptions = {
  28978. /**
  28979. * Define the color used on edges (grazing angle)
  28980. */
  28981. leftColor?: Color3;
  28982. /**
  28983. * Define the color used on center
  28984. */
  28985. rightColor?: Color3;
  28986. /**
  28987. * Define bias applied to computed fresnel term
  28988. */
  28989. bias?: number;
  28990. /**
  28991. * Defined the power exponent applied to fresnel term
  28992. */
  28993. power?: number;
  28994. /**
  28995. * Define if the fresnel effect is enable or not.
  28996. */
  28997. isEnabled?: boolean;
  28998. };
  28999. /**
  29000. * Serialized format for FresnelParameters.
  29001. */
  29002. export type IFresnelParametersSerialized = {
  29003. /**
  29004. * Define the color used on edges (grazing angle) [as an array]
  29005. */
  29006. leftColor: number[];
  29007. /**
  29008. * Define the color used on center [as an array]
  29009. */
  29010. rightColor: number[];
  29011. /**
  29012. * Define bias applied to computed fresnel term
  29013. */
  29014. bias: number;
  29015. /**
  29016. * Defined the power exponent applied to fresnel term
  29017. */
  29018. power?: number;
  29019. /**
  29020. * Define if the fresnel effect is enable or not.
  29021. */
  29022. isEnabled: boolean;
  29023. };
  29024. /**
  29025. * This represents all the required information to add a fresnel effect on a material:
  29026. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29027. */
  29028. export class FresnelParameters {
  29029. private _isEnabled;
  29030. /**
  29031. * Define if the fresnel effect is enable or not.
  29032. */
  29033. get isEnabled(): boolean;
  29034. set isEnabled(value: boolean);
  29035. /**
  29036. * Define the color used on edges (grazing angle)
  29037. */
  29038. leftColor: Color3;
  29039. /**
  29040. * Define the color used on center
  29041. */
  29042. rightColor: Color3;
  29043. /**
  29044. * Define bias applied to computed fresnel term
  29045. */
  29046. bias: number;
  29047. /**
  29048. * Defined the power exponent applied to fresnel term
  29049. */
  29050. power: number;
  29051. /**
  29052. * Creates a new FresnelParameters object.
  29053. *
  29054. * @param options provide your own settings to optionally to override defaults
  29055. */
  29056. constructor(options?: IFresnelParametersCreationOptions);
  29057. /**
  29058. * Clones the current fresnel and its valuues
  29059. * @returns a clone fresnel configuration
  29060. */
  29061. clone(): FresnelParameters;
  29062. /**
  29063. * Determines equality between FresnelParameters objects
  29064. * @param otherFresnelParameters defines the second operand
  29065. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29066. */
  29067. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29068. /**
  29069. * Serializes the current fresnel parameters to a JSON representation.
  29070. * @return the JSON serialization
  29071. */
  29072. serialize(): IFresnelParametersSerialized;
  29073. /**
  29074. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29075. * @param parsedFresnelParameters Define the JSON representation
  29076. * @returns the parsed parameters
  29077. */
  29078. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29079. }
  29080. }
  29081. declare module BABYLON {
  29082. /**
  29083. * This groups all the flags used to control the materials channel.
  29084. */
  29085. export class MaterialFlags {
  29086. private static _DiffuseTextureEnabled;
  29087. /**
  29088. * Are diffuse textures enabled in the application.
  29089. */
  29090. static get DiffuseTextureEnabled(): boolean;
  29091. static set DiffuseTextureEnabled(value: boolean);
  29092. private static _AmbientTextureEnabled;
  29093. /**
  29094. * Are ambient textures enabled in the application.
  29095. */
  29096. static get AmbientTextureEnabled(): boolean;
  29097. static set AmbientTextureEnabled(value: boolean);
  29098. private static _OpacityTextureEnabled;
  29099. /**
  29100. * Are opacity textures enabled in the application.
  29101. */
  29102. static get OpacityTextureEnabled(): boolean;
  29103. static set OpacityTextureEnabled(value: boolean);
  29104. private static _ReflectionTextureEnabled;
  29105. /**
  29106. * Are reflection textures enabled in the application.
  29107. */
  29108. static get ReflectionTextureEnabled(): boolean;
  29109. static set ReflectionTextureEnabled(value: boolean);
  29110. private static _EmissiveTextureEnabled;
  29111. /**
  29112. * Are emissive textures enabled in the application.
  29113. */
  29114. static get EmissiveTextureEnabled(): boolean;
  29115. static set EmissiveTextureEnabled(value: boolean);
  29116. private static _SpecularTextureEnabled;
  29117. /**
  29118. * Are specular textures enabled in the application.
  29119. */
  29120. static get SpecularTextureEnabled(): boolean;
  29121. static set SpecularTextureEnabled(value: boolean);
  29122. private static _BumpTextureEnabled;
  29123. /**
  29124. * Are bump textures enabled in the application.
  29125. */
  29126. static get BumpTextureEnabled(): boolean;
  29127. static set BumpTextureEnabled(value: boolean);
  29128. private static _LightmapTextureEnabled;
  29129. /**
  29130. * Are lightmap textures enabled in the application.
  29131. */
  29132. static get LightmapTextureEnabled(): boolean;
  29133. static set LightmapTextureEnabled(value: boolean);
  29134. private static _RefractionTextureEnabled;
  29135. /**
  29136. * Are refraction textures enabled in the application.
  29137. */
  29138. static get RefractionTextureEnabled(): boolean;
  29139. static set RefractionTextureEnabled(value: boolean);
  29140. private static _ColorGradingTextureEnabled;
  29141. /**
  29142. * Are color grading textures enabled in the application.
  29143. */
  29144. static get ColorGradingTextureEnabled(): boolean;
  29145. static set ColorGradingTextureEnabled(value: boolean);
  29146. private static _FresnelEnabled;
  29147. /**
  29148. * Are fresnels enabled in the application.
  29149. */
  29150. static get FresnelEnabled(): boolean;
  29151. static set FresnelEnabled(value: boolean);
  29152. private static _ClearCoatTextureEnabled;
  29153. /**
  29154. * Are clear coat textures enabled in the application.
  29155. */
  29156. static get ClearCoatTextureEnabled(): boolean;
  29157. static set ClearCoatTextureEnabled(value: boolean);
  29158. private static _ClearCoatBumpTextureEnabled;
  29159. /**
  29160. * Are clear coat bump textures enabled in the application.
  29161. */
  29162. static get ClearCoatBumpTextureEnabled(): boolean;
  29163. static set ClearCoatBumpTextureEnabled(value: boolean);
  29164. private static _ClearCoatTintTextureEnabled;
  29165. /**
  29166. * Are clear coat tint textures enabled in the application.
  29167. */
  29168. static get ClearCoatTintTextureEnabled(): boolean;
  29169. static set ClearCoatTintTextureEnabled(value: boolean);
  29170. private static _SheenTextureEnabled;
  29171. /**
  29172. * Are sheen textures enabled in the application.
  29173. */
  29174. static get SheenTextureEnabled(): boolean;
  29175. static set SheenTextureEnabled(value: boolean);
  29176. private static _AnisotropicTextureEnabled;
  29177. /**
  29178. * Are anisotropic textures enabled in the application.
  29179. */
  29180. static get AnisotropicTextureEnabled(): boolean;
  29181. static set AnisotropicTextureEnabled(value: boolean);
  29182. private static _ThicknessTextureEnabled;
  29183. /**
  29184. * Are thickness textures enabled in the application.
  29185. */
  29186. static get ThicknessTextureEnabled(): boolean;
  29187. static set ThicknessTextureEnabled(value: boolean);
  29188. }
  29189. }
  29190. declare module BABYLON {
  29191. /** @hidden */
  29192. export var defaultFragmentDeclaration: {
  29193. name: string;
  29194. shader: string;
  29195. };
  29196. }
  29197. declare module BABYLON {
  29198. /** @hidden */
  29199. export var defaultUboDeclaration: {
  29200. name: string;
  29201. shader: string;
  29202. };
  29203. }
  29204. declare module BABYLON {
  29205. /** @hidden */
  29206. export var lightFragmentDeclaration: {
  29207. name: string;
  29208. shader: string;
  29209. };
  29210. }
  29211. declare module BABYLON {
  29212. /** @hidden */
  29213. export var lightUboDeclaration: {
  29214. name: string;
  29215. shader: string;
  29216. };
  29217. }
  29218. declare module BABYLON {
  29219. /** @hidden */
  29220. export var lightsFragmentFunctions: {
  29221. name: string;
  29222. shader: string;
  29223. };
  29224. }
  29225. declare module BABYLON {
  29226. /** @hidden */
  29227. export var shadowsFragmentFunctions: {
  29228. name: string;
  29229. shader: string;
  29230. };
  29231. }
  29232. declare module BABYLON {
  29233. /** @hidden */
  29234. export var fresnelFunction: {
  29235. name: string;
  29236. shader: string;
  29237. };
  29238. }
  29239. declare module BABYLON {
  29240. /** @hidden */
  29241. export var bumpFragmentMainFunctions: {
  29242. name: string;
  29243. shader: string;
  29244. };
  29245. }
  29246. declare module BABYLON {
  29247. /** @hidden */
  29248. export var bumpFragmentFunctions: {
  29249. name: string;
  29250. shader: string;
  29251. };
  29252. }
  29253. declare module BABYLON {
  29254. /** @hidden */
  29255. export var logDepthDeclaration: {
  29256. name: string;
  29257. shader: string;
  29258. };
  29259. }
  29260. declare module BABYLON {
  29261. /** @hidden */
  29262. export var bumpFragment: {
  29263. name: string;
  29264. shader: string;
  29265. };
  29266. }
  29267. declare module BABYLON {
  29268. /** @hidden */
  29269. export var depthPrePass: {
  29270. name: string;
  29271. shader: string;
  29272. };
  29273. }
  29274. declare module BABYLON {
  29275. /** @hidden */
  29276. export var lightFragment: {
  29277. name: string;
  29278. shader: string;
  29279. };
  29280. }
  29281. declare module BABYLON {
  29282. /** @hidden */
  29283. export var logDepthFragment: {
  29284. name: string;
  29285. shader: string;
  29286. };
  29287. }
  29288. declare module BABYLON {
  29289. /** @hidden */
  29290. export var defaultPixelShader: {
  29291. name: string;
  29292. shader: string;
  29293. };
  29294. }
  29295. declare module BABYLON {
  29296. /** @hidden */
  29297. export var defaultVertexDeclaration: {
  29298. name: string;
  29299. shader: string;
  29300. };
  29301. }
  29302. declare module BABYLON {
  29303. /** @hidden */
  29304. export var bumpVertexDeclaration: {
  29305. name: string;
  29306. shader: string;
  29307. };
  29308. }
  29309. declare module BABYLON {
  29310. /** @hidden */
  29311. export var bumpVertex: {
  29312. name: string;
  29313. shader: string;
  29314. };
  29315. }
  29316. declare module BABYLON {
  29317. /** @hidden */
  29318. export var fogVertex: {
  29319. name: string;
  29320. shader: string;
  29321. };
  29322. }
  29323. declare module BABYLON {
  29324. /** @hidden */
  29325. export var shadowsVertex: {
  29326. name: string;
  29327. shader: string;
  29328. };
  29329. }
  29330. declare module BABYLON {
  29331. /** @hidden */
  29332. export var pointCloudVertex: {
  29333. name: string;
  29334. shader: string;
  29335. };
  29336. }
  29337. declare module BABYLON {
  29338. /** @hidden */
  29339. export var logDepthVertex: {
  29340. name: string;
  29341. shader: string;
  29342. };
  29343. }
  29344. declare module BABYLON {
  29345. /** @hidden */
  29346. export var defaultVertexShader: {
  29347. name: string;
  29348. shader: string;
  29349. };
  29350. }
  29351. declare module BABYLON {
  29352. /** @hidden */
  29353. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29354. MAINUV1: boolean;
  29355. MAINUV2: boolean;
  29356. DIFFUSE: boolean;
  29357. DIFFUSEDIRECTUV: number;
  29358. AMBIENT: boolean;
  29359. AMBIENTDIRECTUV: number;
  29360. OPACITY: boolean;
  29361. OPACITYDIRECTUV: number;
  29362. OPACITYRGB: boolean;
  29363. REFLECTION: boolean;
  29364. EMISSIVE: boolean;
  29365. EMISSIVEDIRECTUV: number;
  29366. SPECULAR: boolean;
  29367. SPECULARDIRECTUV: number;
  29368. BUMP: boolean;
  29369. BUMPDIRECTUV: number;
  29370. PARALLAX: boolean;
  29371. PARALLAXOCCLUSION: boolean;
  29372. SPECULAROVERALPHA: boolean;
  29373. CLIPPLANE: boolean;
  29374. CLIPPLANE2: boolean;
  29375. CLIPPLANE3: boolean;
  29376. CLIPPLANE4: boolean;
  29377. CLIPPLANE5: boolean;
  29378. CLIPPLANE6: boolean;
  29379. ALPHATEST: boolean;
  29380. DEPTHPREPASS: boolean;
  29381. ALPHAFROMDIFFUSE: boolean;
  29382. POINTSIZE: boolean;
  29383. FOG: boolean;
  29384. SPECULARTERM: boolean;
  29385. DIFFUSEFRESNEL: boolean;
  29386. OPACITYFRESNEL: boolean;
  29387. REFLECTIONFRESNEL: boolean;
  29388. REFRACTIONFRESNEL: boolean;
  29389. EMISSIVEFRESNEL: boolean;
  29390. FRESNEL: boolean;
  29391. NORMAL: boolean;
  29392. UV1: boolean;
  29393. UV2: boolean;
  29394. VERTEXCOLOR: boolean;
  29395. VERTEXALPHA: boolean;
  29396. NUM_BONE_INFLUENCERS: number;
  29397. BonesPerMesh: number;
  29398. BONETEXTURE: boolean;
  29399. INSTANCES: boolean;
  29400. THIN_INSTANCES: boolean;
  29401. GLOSSINESS: boolean;
  29402. ROUGHNESS: boolean;
  29403. EMISSIVEASILLUMINATION: boolean;
  29404. LINKEMISSIVEWITHDIFFUSE: boolean;
  29405. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29406. LIGHTMAP: boolean;
  29407. LIGHTMAPDIRECTUV: number;
  29408. OBJECTSPACE_NORMALMAP: boolean;
  29409. USELIGHTMAPASSHADOWMAP: boolean;
  29410. REFLECTIONMAP_3D: boolean;
  29411. REFLECTIONMAP_SPHERICAL: boolean;
  29412. REFLECTIONMAP_PLANAR: boolean;
  29413. REFLECTIONMAP_CUBIC: boolean;
  29414. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29415. REFLECTIONMAP_PROJECTION: boolean;
  29416. REFLECTIONMAP_SKYBOX: boolean;
  29417. REFLECTIONMAP_EXPLICIT: boolean;
  29418. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29419. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29420. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29421. INVERTCUBICMAP: boolean;
  29422. LOGARITHMICDEPTH: boolean;
  29423. REFRACTION: boolean;
  29424. REFRACTIONMAP_3D: boolean;
  29425. REFLECTIONOVERALPHA: boolean;
  29426. TWOSIDEDLIGHTING: boolean;
  29427. SHADOWFLOAT: boolean;
  29428. MORPHTARGETS: boolean;
  29429. MORPHTARGETS_NORMAL: boolean;
  29430. MORPHTARGETS_TANGENT: boolean;
  29431. MORPHTARGETS_UV: boolean;
  29432. NUM_MORPH_INFLUENCERS: number;
  29433. NONUNIFORMSCALING: boolean;
  29434. PREMULTIPLYALPHA: boolean;
  29435. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29436. ALPHABLEND: boolean;
  29437. RGBDLIGHTMAP: boolean;
  29438. RGBDREFLECTION: boolean;
  29439. RGBDREFRACTION: boolean;
  29440. IMAGEPROCESSING: boolean;
  29441. VIGNETTE: boolean;
  29442. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29443. VIGNETTEBLENDMODEOPAQUE: boolean;
  29444. TONEMAPPING: boolean;
  29445. TONEMAPPING_ACES: boolean;
  29446. CONTRAST: boolean;
  29447. COLORCURVES: boolean;
  29448. COLORGRADING: boolean;
  29449. COLORGRADING3D: boolean;
  29450. SAMPLER3DGREENDEPTH: boolean;
  29451. SAMPLER3DBGRMAP: boolean;
  29452. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29453. MULTIVIEW: boolean;
  29454. /**
  29455. * If the reflection texture on this material is in linear color space
  29456. * @hidden
  29457. */
  29458. IS_REFLECTION_LINEAR: boolean;
  29459. /**
  29460. * If the refraction texture on this material is in linear color space
  29461. * @hidden
  29462. */
  29463. IS_REFRACTION_LINEAR: boolean;
  29464. EXPOSURE: boolean;
  29465. constructor();
  29466. setReflectionMode(modeToEnable: string): void;
  29467. }
  29468. /**
  29469. * This is the default material used in Babylon. It is the best trade off between quality
  29470. * and performances.
  29471. * @see http://doc.babylonjs.com/babylon101/materials
  29472. */
  29473. export class StandardMaterial extends PushMaterial {
  29474. private _diffuseTexture;
  29475. /**
  29476. * The basic texture of the material as viewed under a light.
  29477. */
  29478. diffuseTexture: Nullable<BaseTexture>;
  29479. private _ambientTexture;
  29480. /**
  29481. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29482. */
  29483. ambientTexture: Nullable<BaseTexture>;
  29484. private _opacityTexture;
  29485. /**
  29486. * Define the transparency of the material from a texture.
  29487. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29488. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29489. */
  29490. opacityTexture: Nullable<BaseTexture>;
  29491. private _reflectionTexture;
  29492. /**
  29493. * Define the texture used to display the reflection.
  29494. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29495. */
  29496. reflectionTexture: Nullable<BaseTexture>;
  29497. private _emissiveTexture;
  29498. /**
  29499. * Define texture of the material as if self lit.
  29500. * This will be mixed in the final result even in the absence of light.
  29501. */
  29502. emissiveTexture: Nullable<BaseTexture>;
  29503. private _specularTexture;
  29504. /**
  29505. * Define how the color and intensity of the highlight given by the light in the material.
  29506. */
  29507. specularTexture: Nullable<BaseTexture>;
  29508. private _bumpTexture;
  29509. /**
  29510. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29511. * 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.
  29512. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29513. */
  29514. bumpTexture: Nullable<BaseTexture>;
  29515. private _lightmapTexture;
  29516. /**
  29517. * Complex lighting can be computationally expensive to compute at runtime.
  29518. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29519. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29520. */
  29521. lightmapTexture: Nullable<BaseTexture>;
  29522. private _refractionTexture;
  29523. /**
  29524. * Define the texture used to display the refraction.
  29525. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29526. */
  29527. refractionTexture: Nullable<BaseTexture>;
  29528. /**
  29529. * The color of the material lit by the environmental background lighting.
  29530. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29531. */
  29532. ambientColor: Color3;
  29533. /**
  29534. * The basic color of the material as viewed under a light.
  29535. */
  29536. diffuseColor: Color3;
  29537. /**
  29538. * Define how the color and intensity of the highlight given by the light in the material.
  29539. */
  29540. specularColor: Color3;
  29541. /**
  29542. * Define the color of the material as if self lit.
  29543. * This will be mixed in the final result even in the absence of light.
  29544. */
  29545. emissiveColor: Color3;
  29546. /**
  29547. * Defines how sharp are the highlights in the material.
  29548. * The bigger the value the sharper giving a more glossy feeling to the result.
  29549. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29550. */
  29551. specularPower: number;
  29552. private _useAlphaFromDiffuseTexture;
  29553. /**
  29554. * Does the transparency come from the diffuse texture alpha channel.
  29555. */
  29556. useAlphaFromDiffuseTexture: boolean;
  29557. private _useEmissiveAsIllumination;
  29558. /**
  29559. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29560. */
  29561. useEmissiveAsIllumination: boolean;
  29562. private _linkEmissiveWithDiffuse;
  29563. /**
  29564. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29565. * the emissive level when the final color is close to one.
  29566. */
  29567. linkEmissiveWithDiffuse: boolean;
  29568. private _useSpecularOverAlpha;
  29569. /**
  29570. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29571. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29572. */
  29573. useSpecularOverAlpha: boolean;
  29574. private _useReflectionOverAlpha;
  29575. /**
  29576. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29577. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29578. */
  29579. useReflectionOverAlpha: boolean;
  29580. private _disableLighting;
  29581. /**
  29582. * Does lights from the scene impacts this material.
  29583. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29584. */
  29585. disableLighting: boolean;
  29586. private _useObjectSpaceNormalMap;
  29587. /**
  29588. * Allows using an object space normal map (instead of tangent space).
  29589. */
  29590. useObjectSpaceNormalMap: boolean;
  29591. private _useParallax;
  29592. /**
  29593. * Is parallax enabled or not.
  29594. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29595. */
  29596. useParallax: boolean;
  29597. private _useParallaxOcclusion;
  29598. /**
  29599. * Is parallax occlusion enabled or not.
  29600. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29601. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29602. */
  29603. useParallaxOcclusion: boolean;
  29604. /**
  29605. * 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.
  29606. */
  29607. parallaxScaleBias: number;
  29608. private _roughness;
  29609. /**
  29610. * Helps to define how blurry the reflections should appears in the material.
  29611. */
  29612. roughness: number;
  29613. /**
  29614. * In case of refraction, define the value of the index of refraction.
  29615. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29616. */
  29617. indexOfRefraction: number;
  29618. /**
  29619. * Invert the refraction texture alongside the y axis.
  29620. * It can be useful with procedural textures or probe for instance.
  29621. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29622. */
  29623. invertRefractionY: boolean;
  29624. /**
  29625. * Defines the alpha limits in alpha test mode.
  29626. */
  29627. alphaCutOff: number;
  29628. private _useLightmapAsShadowmap;
  29629. /**
  29630. * In case of light mapping, define whether the map contains light or shadow informations.
  29631. */
  29632. useLightmapAsShadowmap: boolean;
  29633. private _diffuseFresnelParameters;
  29634. /**
  29635. * Define the diffuse fresnel parameters of the material.
  29636. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29637. */
  29638. diffuseFresnelParameters: FresnelParameters;
  29639. private _opacityFresnelParameters;
  29640. /**
  29641. * Define the opacity fresnel parameters of the material.
  29642. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29643. */
  29644. opacityFresnelParameters: FresnelParameters;
  29645. private _reflectionFresnelParameters;
  29646. /**
  29647. * Define the reflection fresnel parameters of the material.
  29648. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29649. */
  29650. reflectionFresnelParameters: FresnelParameters;
  29651. private _refractionFresnelParameters;
  29652. /**
  29653. * Define the refraction fresnel parameters of the material.
  29654. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29655. */
  29656. refractionFresnelParameters: FresnelParameters;
  29657. private _emissiveFresnelParameters;
  29658. /**
  29659. * Define the emissive fresnel parameters of the material.
  29660. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29661. */
  29662. emissiveFresnelParameters: FresnelParameters;
  29663. private _useReflectionFresnelFromSpecular;
  29664. /**
  29665. * If true automatically deducts the fresnels values from the material specularity.
  29666. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29667. */
  29668. useReflectionFresnelFromSpecular: boolean;
  29669. private _useGlossinessFromSpecularMapAlpha;
  29670. /**
  29671. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29672. */
  29673. useGlossinessFromSpecularMapAlpha: boolean;
  29674. private _maxSimultaneousLights;
  29675. /**
  29676. * Defines the maximum number of lights that can be used in the material
  29677. */
  29678. maxSimultaneousLights: number;
  29679. private _invertNormalMapX;
  29680. /**
  29681. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29682. */
  29683. invertNormalMapX: boolean;
  29684. private _invertNormalMapY;
  29685. /**
  29686. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29687. */
  29688. invertNormalMapY: boolean;
  29689. private _twoSidedLighting;
  29690. /**
  29691. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29692. */
  29693. twoSidedLighting: boolean;
  29694. /**
  29695. * Default configuration related to image processing available in the standard Material.
  29696. */
  29697. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29698. /**
  29699. * Gets the image processing configuration used either in this material.
  29700. */
  29701. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29702. /**
  29703. * Sets the Default image processing configuration used either in the this material.
  29704. *
  29705. * If sets to null, the scene one is in use.
  29706. */
  29707. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29708. /**
  29709. * Keep track of the image processing observer to allow dispose and replace.
  29710. */
  29711. private _imageProcessingObserver;
  29712. /**
  29713. * Attaches a new image processing configuration to the Standard Material.
  29714. * @param configuration
  29715. */
  29716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29717. /**
  29718. * Gets wether the color curves effect is enabled.
  29719. */
  29720. get cameraColorCurvesEnabled(): boolean;
  29721. /**
  29722. * Sets wether the color curves effect is enabled.
  29723. */
  29724. set cameraColorCurvesEnabled(value: boolean);
  29725. /**
  29726. * Gets wether the color grading effect is enabled.
  29727. */
  29728. get cameraColorGradingEnabled(): boolean;
  29729. /**
  29730. * Gets wether the color grading effect is enabled.
  29731. */
  29732. set cameraColorGradingEnabled(value: boolean);
  29733. /**
  29734. * Gets wether tonemapping is enabled or not.
  29735. */
  29736. get cameraToneMappingEnabled(): boolean;
  29737. /**
  29738. * Sets wether tonemapping is enabled or not
  29739. */
  29740. set cameraToneMappingEnabled(value: boolean);
  29741. /**
  29742. * The camera exposure used on this material.
  29743. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29744. * This corresponds to a photographic exposure.
  29745. */
  29746. get cameraExposure(): number;
  29747. /**
  29748. * The camera exposure used on this material.
  29749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29750. * This corresponds to a photographic exposure.
  29751. */
  29752. set cameraExposure(value: number);
  29753. /**
  29754. * Gets The camera contrast used on this material.
  29755. */
  29756. get cameraContrast(): number;
  29757. /**
  29758. * Sets The camera contrast used on this material.
  29759. */
  29760. set cameraContrast(value: number);
  29761. /**
  29762. * Gets the Color Grading 2D Lookup Texture.
  29763. */
  29764. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29765. /**
  29766. * Sets the Color Grading 2D Lookup Texture.
  29767. */
  29768. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29769. /**
  29770. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29771. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29772. * 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;
  29773. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29774. */
  29775. get cameraColorCurves(): Nullable<ColorCurves>;
  29776. /**
  29777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29779. * 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;
  29780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29781. */
  29782. set cameraColorCurves(value: Nullable<ColorCurves>);
  29783. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29784. protected _worldViewProjectionMatrix: Matrix;
  29785. protected _globalAmbientColor: Color3;
  29786. protected _useLogarithmicDepth: boolean;
  29787. protected _rebuildInParallel: boolean;
  29788. /**
  29789. * Instantiates a new standard material.
  29790. * This is the default material used in Babylon. It is the best trade off between quality
  29791. * and performances.
  29792. * @see http://doc.babylonjs.com/babylon101/materials
  29793. * @param name Define the name of the material in the scene
  29794. * @param scene Define the scene the material belong to
  29795. */
  29796. constructor(name: string, scene: Scene);
  29797. /**
  29798. * Gets a boolean indicating that current material needs to register RTT
  29799. */
  29800. get hasRenderTargetTextures(): boolean;
  29801. /**
  29802. * Gets the current class name of the material e.g. "StandardMaterial"
  29803. * Mainly use in serialization.
  29804. * @returns the class name
  29805. */
  29806. getClassName(): string;
  29807. /**
  29808. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29809. * You can try switching to logarithmic depth.
  29810. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29811. */
  29812. get useLogarithmicDepth(): boolean;
  29813. set useLogarithmicDepth(value: boolean);
  29814. /**
  29815. * Specifies if the material will require alpha blending
  29816. * @returns a boolean specifying if alpha blending is needed
  29817. */
  29818. needAlphaBlending(): boolean;
  29819. /**
  29820. * Specifies if this material should be rendered in alpha test mode
  29821. * @returns a boolean specifying if an alpha test is needed.
  29822. */
  29823. needAlphaTesting(): boolean;
  29824. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29825. /**
  29826. * Get the texture used for alpha test purpose.
  29827. * @returns the diffuse texture in case of the standard material.
  29828. */
  29829. getAlphaTestTexture(): Nullable<BaseTexture>;
  29830. /**
  29831. * Get if the submesh is ready to be used and all its information available.
  29832. * Child classes can use it to update shaders
  29833. * @param mesh defines the mesh to check
  29834. * @param subMesh defines which submesh to check
  29835. * @param useInstances specifies that instances should be used
  29836. * @returns a boolean indicating that the submesh is ready or not
  29837. */
  29838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29839. /**
  29840. * Builds the material UBO layouts.
  29841. * Used internally during the effect preparation.
  29842. */
  29843. buildUniformLayout(): void;
  29844. /**
  29845. * Unbinds the material from the mesh
  29846. */
  29847. unbind(): void;
  29848. /**
  29849. * Binds the submesh to this material by preparing the effect and shader to draw
  29850. * @param world defines the world transformation matrix
  29851. * @param mesh defines the mesh containing the submesh
  29852. * @param subMesh defines the submesh to bind the material to
  29853. */
  29854. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29855. /**
  29856. * Get the list of animatables in the material.
  29857. * @returns the list of animatables object used in the material
  29858. */
  29859. getAnimatables(): IAnimatable[];
  29860. /**
  29861. * Gets the active textures from the material
  29862. * @returns an array of textures
  29863. */
  29864. getActiveTextures(): BaseTexture[];
  29865. /**
  29866. * Specifies if the material uses a texture
  29867. * @param texture defines the texture to check against the material
  29868. * @returns a boolean specifying if the material uses the texture
  29869. */
  29870. hasTexture(texture: BaseTexture): boolean;
  29871. /**
  29872. * Disposes the material
  29873. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29874. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29875. */
  29876. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29877. /**
  29878. * Makes a duplicate of the material, and gives it a new name
  29879. * @param name defines the new name for the duplicated material
  29880. * @returns the cloned material
  29881. */
  29882. clone(name: string): StandardMaterial;
  29883. /**
  29884. * Serializes this material in a JSON representation
  29885. * @returns the serialized material object
  29886. */
  29887. serialize(): any;
  29888. /**
  29889. * Creates a standard material from parsed material data
  29890. * @param source defines the JSON representation of the material
  29891. * @param scene defines the hosting scene
  29892. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29893. * @returns a new standard material
  29894. */
  29895. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29896. /**
  29897. * Are diffuse textures enabled in the application.
  29898. */
  29899. static get DiffuseTextureEnabled(): boolean;
  29900. static set DiffuseTextureEnabled(value: boolean);
  29901. /**
  29902. * Are ambient textures enabled in the application.
  29903. */
  29904. static get AmbientTextureEnabled(): boolean;
  29905. static set AmbientTextureEnabled(value: boolean);
  29906. /**
  29907. * Are opacity textures enabled in the application.
  29908. */
  29909. static get OpacityTextureEnabled(): boolean;
  29910. static set OpacityTextureEnabled(value: boolean);
  29911. /**
  29912. * Are reflection textures enabled in the application.
  29913. */
  29914. static get ReflectionTextureEnabled(): boolean;
  29915. static set ReflectionTextureEnabled(value: boolean);
  29916. /**
  29917. * Are emissive textures enabled in the application.
  29918. */
  29919. static get EmissiveTextureEnabled(): boolean;
  29920. static set EmissiveTextureEnabled(value: boolean);
  29921. /**
  29922. * Are specular textures enabled in the application.
  29923. */
  29924. static get SpecularTextureEnabled(): boolean;
  29925. static set SpecularTextureEnabled(value: boolean);
  29926. /**
  29927. * Are bump textures enabled in the application.
  29928. */
  29929. static get BumpTextureEnabled(): boolean;
  29930. static set BumpTextureEnabled(value: boolean);
  29931. /**
  29932. * Are lightmap textures enabled in the application.
  29933. */
  29934. static get LightmapTextureEnabled(): boolean;
  29935. static set LightmapTextureEnabled(value: boolean);
  29936. /**
  29937. * Are refraction textures enabled in the application.
  29938. */
  29939. static get RefractionTextureEnabled(): boolean;
  29940. static set RefractionTextureEnabled(value: boolean);
  29941. /**
  29942. * Are color grading textures enabled in the application.
  29943. */
  29944. static get ColorGradingTextureEnabled(): boolean;
  29945. static set ColorGradingTextureEnabled(value: boolean);
  29946. /**
  29947. * Are fresnels enabled in the application.
  29948. */
  29949. static get FresnelEnabled(): boolean;
  29950. static set FresnelEnabled(value: boolean);
  29951. }
  29952. }
  29953. declare module BABYLON {
  29954. /**
  29955. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29956. *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.
  29957. * The SPS is also a particle system. It provides some methods to manage the particles.
  29958. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29959. *
  29960. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29961. */
  29962. export class SolidParticleSystem implements IDisposable {
  29963. /**
  29964. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29965. * Example : var p = SPS.particles[i];
  29966. */
  29967. particles: SolidParticle[];
  29968. /**
  29969. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29970. */
  29971. nbParticles: number;
  29972. /**
  29973. * If the particles must ever face the camera (default false). Useful for planar particles.
  29974. */
  29975. billboard: boolean;
  29976. /**
  29977. * Recompute normals when adding a shape
  29978. */
  29979. recomputeNormals: boolean;
  29980. /**
  29981. * This a counter ofr your own usage. It's not set by any SPS functions.
  29982. */
  29983. counter: number;
  29984. /**
  29985. * The SPS name. This name is also given to the underlying mesh.
  29986. */
  29987. name: string;
  29988. /**
  29989. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29990. */
  29991. mesh: Mesh;
  29992. /**
  29993. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29994. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29995. */
  29996. vars: any;
  29997. /**
  29998. * This array is populated when the SPS is set as 'pickable'.
  29999. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30000. * Each element of this array is an object `{idx: int, faceId: int}`.
  30001. * `idx` is the picked particle index in the `SPS.particles` array
  30002. * `faceId` is the picked face index counted within this particle.
  30003. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30004. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30005. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30006. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30007. */
  30008. pickedParticles: {
  30009. idx: number;
  30010. faceId: number;
  30011. }[];
  30012. /**
  30013. * This array is populated when the SPS is set as 'pickable'
  30014. * Each key of this array is a submesh index.
  30015. * Each element of this array is a second array defined like this :
  30016. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30017. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30018. * `idx` is the picked particle index in the `SPS.particles` array
  30019. * `faceId` is the picked face index counted within this particle.
  30020. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30021. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30022. */
  30023. pickedBySubMesh: {
  30024. idx: number;
  30025. faceId: number;
  30026. }[][];
  30027. /**
  30028. * This array is populated when `enableDepthSort` is set to true.
  30029. * Each element of this array is an instance of the class DepthSortedParticle.
  30030. */
  30031. depthSortedParticles: DepthSortedParticle[];
  30032. /**
  30033. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30034. * @hidden
  30035. */
  30036. _bSphereOnly: boolean;
  30037. /**
  30038. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30039. * @hidden
  30040. */
  30041. _bSphereRadiusFactor: number;
  30042. private _scene;
  30043. private _positions;
  30044. private _indices;
  30045. private _normals;
  30046. private _colors;
  30047. private _uvs;
  30048. private _indices32;
  30049. private _positions32;
  30050. private _normals32;
  30051. private _fixedNormal32;
  30052. private _colors32;
  30053. private _uvs32;
  30054. private _index;
  30055. private _updatable;
  30056. private _pickable;
  30057. private _isVisibilityBoxLocked;
  30058. private _alwaysVisible;
  30059. private _depthSort;
  30060. private _expandable;
  30061. private _shapeCounter;
  30062. private _copy;
  30063. private _color;
  30064. private _computeParticleColor;
  30065. private _computeParticleTexture;
  30066. private _computeParticleRotation;
  30067. private _computeParticleVertex;
  30068. private _computeBoundingBox;
  30069. private _depthSortParticles;
  30070. private _camera;
  30071. private _mustUnrotateFixedNormals;
  30072. private _particlesIntersect;
  30073. private _needs32Bits;
  30074. private _isNotBuilt;
  30075. private _lastParticleId;
  30076. private _idxOfId;
  30077. private _multimaterialEnabled;
  30078. private _useModelMaterial;
  30079. private _indicesByMaterial;
  30080. private _materialIndexes;
  30081. private _depthSortFunction;
  30082. private _materialSortFunction;
  30083. private _materials;
  30084. private _multimaterial;
  30085. private _materialIndexesById;
  30086. private _defaultMaterial;
  30087. private _autoUpdateSubMeshes;
  30088. private _tmpVertex;
  30089. /**
  30090. * Creates a SPS (Solid Particle System) object.
  30091. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30092. * @param scene (Scene) is the scene in which the SPS is added.
  30093. * @param options defines the options of the sps e.g.
  30094. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30095. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30096. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30097. * * 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.
  30098. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30099. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30100. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30101. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30102. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30103. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30104. */
  30105. constructor(name: string, scene: Scene, options?: {
  30106. updatable?: boolean;
  30107. isPickable?: boolean;
  30108. enableDepthSort?: boolean;
  30109. particleIntersection?: boolean;
  30110. boundingSphereOnly?: boolean;
  30111. bSphereRadiusFactor?: number;
  30112. expandable?: boolean;
  30113. useModelMaterial?: boolean;
  30114. enableMultiMaterial?: boolean;
  30115. });
  30116. /**
  30117. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30118. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30119. * @returns the created mesh
  30120. */
  30121. buildMesh(): Mesh;
  30122. /**
  30123. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30124. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30125. * Thus the particles generated from `digest()` have their property `position` set yet.
  30126. * @param mesh ( Mesh ) is the mesh to be digested
  30127. * @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
  30128. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30129. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30130. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30131. * @returns the current SPS
  30132. */
  30133. digest(mesh: Mesh, options?: {
  30134. facetNb?: number;
  30135. number?: number;
  30136. delta?: number;
  30137. storage?: [];
  30138. }): SolidParticleSystem;
  30139. /**
  30140. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30141. * @hidden
  30142. */
  30143. private _unrotateFixedNormals;
  30144. /**
  30145. * Resets the temporary working copy particle
  30146. * @hidden
  30147. */
  30148. private _resetCopy;
  30149. /**
  30150. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30151. * @param p the current index in the positions array to be updated
  30152. * @param ind the current index in the indices array
  30153. * @param shape a Vector3 array, the shape geometry
  30154. * @param positions the positions array to be updated
  30155. * @param meshInd the shape indices array
  30156. * @param indices the indices array to be updated
  30157. * @param meshUV the shape uv array
  30158. * @param uvs the uv array to be updated
  30159. * @param meshCol the shape color array
  30160. * @param colors the color array to be updated
  30161. * @param meshNor the shape normals array
  30162. * @param normals the normals array to be updated
  30163. * @param idx the particle index
  30164. * @param idxInShape the particle index in its shape
  30165. * @param options the addShape() method passed options
  30166. * @model the particle model
  30167. * @hidden
  30168. */
  30169. private _meshBuilder;
  30170. /**
  30171. * Returns a shape Vector3 array from positions float array
  30172. * @param positions float array
  30173. * @returns a vector3 array
  30174. * @hidden
  30175. */
  30176. private _posToShape;
  30177. /**
  30178. * Returns a shapeUV array from a float uvs (array deep copy)
  30179. * @param uvs as a float array
  30180. * @returns a shapeUV array
  30181. * @hidden
  30182. */
  30183. private _uvsToShapeUV;
  30184. /**
  30185. * Adds a new particle object in the particles array
  30186. * @param idx particle index in particles array
  30187. * @param id particle id
  30188. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30189. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30190. * @param model particle ModelShape object
  30191. * @param shapeId model shape identifier
  30192. * @param idxInShape index of the particle in the current model
  30193. * @param bInfo model bounding info object
  30194. * @param storage target storage array, if any
  30195. * @hidden
  30196. */
  30197. private _addParticle;
  30198. /**
  30199. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30200. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30201. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30202. * @param nb (positive integer) the number of particles to be created from this model
  30203. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30204. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30205. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30206. * @returns the number of shapes in the system
  30207. */
  30208. addShape(mesh: Mesh, nb: number, options?: {
  30209. positionFunction?: any;
  30210. vertexFunction?: any;
  30211. storage?: [];
  30212. }): number;
  30213. /**
  30214. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30215. * @hidden
  30216. */
  30217. private _rebuildParticle;
  30218. /**
  30219. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30220. * @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.
  30221. * @returns the SPS.
  30222. */
  30223. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30224. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30225. * Returns an array with the removed particles.
  30226. * 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.
  30227. * The SPS can't be empty so at least one particle needs to remain in place.
  30228. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30229. * @param start index of the first particle to remove
  30230. * @param end index of the last particle to remove (included)
  30231. * @returns an array populated with the removed particles
  30232. */
  30233. removeParticles(start: number, end: number): SolidParticle[];
  30234. /**
  30235. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30236. * @param solidParticleArray an array populated with Solid Particles objects
  30237. * @returns the SPS
  30238. */
  30239. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30240. /**
  30241. * Creates a new particle and modifies the SPS mesh geometry :
  30242. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30243. * - calls _addParticle() to populate the particle array
  30244. * factorized code from addShape() and insertParticlesFromArray()
  30245. * @param idx particle index in the particles array
  30246. * @param i particle index in its shape
  30247. * @param modelShape particle ModelShape object
  30248. * @param shape shape vertex array
  30249. * @param meshInd shape indices array
  30250. * @param meshUV shape uv array
  30251. * @param meshCol shape color array
  30252. * @param meshNor shape normals array
  30253. * @param bbInfo shape bounding info
  30254. * @param storage target particle storage
  30255. * @options addShape() passed options
  30256. * @hidden
  30257. */
  30258. private _insertNewParticle;
  30259. /**
  30260. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30261. * This method calls `updateParticle()` for each particle of the SPS.
  30262. * For an animated SPS, it is usually called within the render loop.
  30263. * 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.
  30264. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30265. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30266. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30267. * @returns the SPS.
  30268. */
  30269. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30270. /**
  30271. * Disposes the SPS.
  30272. */
  30273. dispose(): void;
  30274. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30275. * idx is the particle index in the SPS
  30276. * faceId is the picked face index counted within this particle.
  30277. * Returns null if the pickInfo can't identify a picked particle.
  30278. * @param pickingInfo (PickingInfo object)
  30279. * @returns {idx: number, faceId: number} or null
  30280. */
  30281. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30282. idx: number;
  30283. faceId: number;
  30284. }>;
  30285. /**
  30286. * Returns a SolidParticle object from its identifier : particle.id
  30287. * @param id (integer) the particle Id
  30288. * @returns the searched particle or null if not found in the SPS.
  30289. */
  30290. getParticleById(id: number): Nullable<SolidParticle>;
  30291. /**
  30292. * Returns a new array populated with the particles having the passed shapeId.
  30293. * @param shapeId (integer) the shape identifier
  30294. * @returns a new solid particle array
  30295. */
  30296. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30297. /**
  30298. * Populates the passed array "ref" with the particles having the passed shapeId.
  30299. * @param shapeId the shape identifier
  30300. * @returns the SPS
  30301. * @param ref
  30302. */
  30303. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30304. /**
  30305. * Computes the required SubMeshes according the materials assigned to the particles.
  30306. * @returns the solid particle system.
  30307. * Does nothing if called before the SPS mesh is built.
  30308. */
  30309. computeSubMeshes(): SolidParticleSystem;
  30310. /**
  30311. * Sorts the solid particles by material when MultiMaterial is enabled.
  30312. * Updates the indices32 array.
  30313. * Updates the indicesByMaterial array.
  30314. * Updates the mesh indices array.
  30315. * @returns the SPS
  30316. * @hidden
  30317. */
  30318. private _sortParticlesByMaterial;
  30319. /**
  30320. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30321. * @hidden
  30322. */
  30323. private _setMaterialIndexesById;
  30324. /**
  30325. * Returns an array with unique values of Materials from the passed array
  30326. * @param array the material array to be checked and filtered
  30327. * @hidden
  30328. */
  30329. private _filterUniqueMaterialId;
  30330. /**
  30331. * Sets a new Standard Material as _defaultMaterial if not already set.
  30332. * @hidden
  30333. */
  30334. private _setDefaultMaterial;
  30335. /**
  30336. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30337. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30338. * @returns the SPS.
  30339. */
  30340. refreshVisibleSize(): SolidParticleSystem;
  30341. /**
  30342. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30343. * @param size the size (float) of the visibility box
  30344. * note : this doesn't lock the SPS mesh bounding box.
  30345. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30346. */
  30347. setVisibilityBox(size: number): void;
  30348. /**
  30349. * Gets whether the SPS as always visible or not
  30350. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30351. */
  30352. get isAlwaysVisible(): boolean;
  30353. /**
  30354. * Sets the SPS as always visible or not
  30355. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30356. */
  30357. set isAlwaysVisible(val: boolean);
  30358. /**
  30359. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30360. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30361. */
  30362. set isVisibilityBoxLocked(val: boolean);
  30363. /**
  30364. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30365. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30366. */
  30367. get isVisibilityBoxLocked(): boolean;
  30368. /**
  30369. * Tells to `setParticles()` to compute the particle rotations or not.
  30370. * Default value : true. The SPS is faster when it's set to false.
  30371. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30372. */
  30373. set computeParticleRotation(val: boolean);
  30374. /**
  30375. * Tells to `setParticles()` to compute the particle colors or not.
  30376. * Default value : true. The SPS is faster when it's set to false.
  30377. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30378. */
  30379. set computeParticleColor(val: boolean);
  30380. set computeParticleTexture(val: boolean);
  30381. /**
  30382. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30383. * Default value : false. The SPS is faster when it's set to false.
  30384. * Note : the particle custom vertex positions aren't stored values.
  30385. */
  30386. set computeParticleVertex(val: boolean);
  30387. /**
  30388. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30389. */
  30390. set computeBoundingBox(val: boolean);
  30391. /**
  30392. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30393. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30394. * Default : `true`
  30395. */
  30396. set depthSortParticles(val: boolean);
  30397. /**
  30398. * Gets if `setParticles()` computes the particle rotations or not.
  30399. * Default value : true. The SPS is faster when it's set to false.
  30400. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30401. */
  30402. get computeParticleRotation(): boolean;
  30403. /**
  30404. * Gets if `setParticles()` computes the particle colors or not.
  30405. * Default value : true. The SPS is faster when it's set to false.
  30406. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30407. */
  30408. get computeParticleColor(): boolean;
  30409. /**
  30410. * Gets if `setParticles()` computes the particle textures or not.
  30411. * Default value : true. The SPS is faster when it's set to false.
  30412. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30413. */
  30414. get computeParticleTexture(): boolean;
  30415. /**
  30416. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30417. * Default value : false. The SPS is faster when it's set to false.
  30418. * Note : the particle custom vertex positions aren't stored values.
  30419. */
  30420. get computeParticleVertex(): boolean;
  30421. /**
  30422. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30423. */
  30424. get computeBoundingBox(): boolean;
  30425. /**
  30426. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30427. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30428. * Default : `true`
  30429. */
  30430. get depthSortParticles(): boolean;
  30431. /**
  30432. * Gets if the SPS is created as expandable at construction time.
  30433. * Default : `false`
  30434. */
  30435. get expandable(): boolean;
  30436. /**
  30437. * Gets if the SPS supports the Multi Materials
  30438. */
  30439. get multimaterialEnabled(): boolean;
  30440. /**
  30441. * Gets if the SPS uses the model materials for its own multimaterial.
  30442. */
  30443. get useModelMaterial(): boolean;
  30444. /**
  30445. * The SPS used material array.
  30446. */
  30447. get materials(): Material[];
  30448. /**
  30449. * Sets the SPS MultiMaterial from the passed materials.
  30450. * Note : the passed array is internally copied and not used then by reference.
  30451. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30452. */
  30453. setMultiMaterial(materials: Material[]): void;
  30454. /**
  30455. * The SPS computed multimaterial object
  30456. */
  30457. get multimaterial(): MultiMaterial;
  30458. set multimaterial(mm: MultiMaterial);
  30459. /**
  30460. * If the subMeshes must be updated on the next call to setParticles()
  30461. */
  30462. get autoUpdateSubMeshes(): boolean;
  30463. set autoUpdateSubMeshes(val: boolean);
  30464. /**
  30465. * This function does nothing. It may be overwritten to set all the particle first values.
  30466. * The SPS doesn't call this function, you may have to call it by your own.
  30467. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30468. */
  30469. initParticles(): void;
  30470. /**
  30471. * This function does nothing. It may be overwritten to recycle a particle.
  30472. * The SPS doesn't call this function, you may have to call it by your own.
  30473. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30474. * @param particle The particle to recycle
  30475. * @returns the recycled particle
  30476. */
  30477. recycleParticle(particle: SolidParticle): SolidParticle;
  30478. /**
  30479. * Updates a particle : this function should be overwritten by the user.
  30480. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30481. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30482. * @example : just set a particle position or velocity and recycle conditions
  30483. * @param particle The particle to update
  30484. * @returns the updated particle
  30485. */
  30486. updateParticle(particle: SolidParticle): SolidParticle;
  30487. /**
  30488. * Updates a vertex of a particle : it can be overwritten by the user.
  30489. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30490. * @param particle the current particle
  30491. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30492. * @param pt the index of the current vertex in the particle shape
  30493. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30494. * @example : just set a vertex particle position or color
  30495. * @returns the sps
  30496. */
  30497. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30498. /**
  30499. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30500. * This does nothing and may be overwritten by the user.
  30501. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30502. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30503. * @param update the boolean update value actually passed to setParticles()
  30504. */
  30505. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30506. /**
  30507. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30508. * This will be passed three parameters.
  30509. * This does nothing and may be overwritten by the user.
  30510. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30511. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30512. * @param update the boolean update value actually passed to setParticles()
  30513. */
  30514. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30515. }
  30516. }
  30517. declare module BABYLON {
  30518. /**
  30519. * Represents one particle of a solid particle system.
  30520. */
  30521. export class SolidParticle {
  30522. /**
  30523. * particle global index
  30524. */
  30525. idx: number;
  30526. /**
  30527. * particle identifier
  30528. */
  30529. id: number;
  30530. /**
  30531. * The color of the particle
  30532. */
  30533. color: Nullable<Color4>;
  30534. /**
  30535. * The world space position of the particle.
  30536. */
  30537. position: Vector3;
  30538. /**
  30539. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30540. */
  30541. rotation: Vector3;
  30542. /**
  30543. * The world space rotation quaternion of the particle.
  30544. */
  30545. rotationQuaternion: Nullable<Quaternion>;
  30546. /**
  30547. * The scaling of the particle.
  30548. */
  30549. scaling: Vector3;
  30550. /**
  30551. * The uvs of the particle.
  30552. */
  30553. uvs: Vector4;
  30554. /**
  30555. * The current speed of the particle.
  30556. */
  30557. velocity: Vector3;
  30558. /**
  30559. * The pivot point in the particle local space.
  30560. */
  30561. pivot: Vector3;
  30562. /**
  30563. * Must the particle be translated from its pivot point in its local space ?
  30564. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30565. * Default : false
  30566. */
  30567. translateFromPivot: boolean;
  30568. /**
  30569. * Is the particle active or not ?
  30570. */
  30571. alive: boolean;
  30572. /**
  30573. * Is the particle visible or not ?
  30574. */
  30575. isVisible: boolean;
  30576. /**
  30577. * Index of this particle in the global "positions" array (Internal use)
  30578. * @hidden
  30579. */
  30580. _pos: number;
  30581. /**
  30582. * @hidden Index of this particle in the global "indices" array (Internal use)
  30583. */
  30584. _ind: number;
  30585. /**
  30586. * @hidden ModelShape of this particle (Internal use)
  30587. */
  30588. _model: ModelShape;
  30589. /**
  30590. * ModelShape id of this particle
  30591. */
  30592. shapeId: number;
  30593. /**
  30594. * Index of the particle in its shape id
  30595. */
  30596. idxInShape: number;
  30597. /**
  30598. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30599. */
  30600. _modelBoundingInfo: BoundingInfo;
  30601. /**
  30602. * @hidden Particle BoundingInfo object (Internal use)
  30603. */
  30604. _boundingInfo: BoundingInfo;
  30605. /**
  30606. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30607. */
  30608. _sps: SolidParticleSystem;
  30609. /**
  30610. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30611. */
  30612. _stillInvisible: boolean;
  30613. /**
  30614. * @hidden Last computed particle rotation matrix
  30615. */
  30616. _rotationMatrix: number[];
  30617. /**
  30618. * Parent particle Id, if any.
  30619. * Default null.
  30620. */
  30621. parentId: Nullable<number>;
  30622. /**
  30623. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30624. */
  30625. materialIndex: Nullable<number>;
  30626. /**
  30627. * Custom object or properties.
  30628. */
  30629. props: Nullable<any>;
  30630. /**
  30631. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30632. * The possible values are :
  30633. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30634. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30635. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30636. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30637. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30638. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30639. * */
  30640. cullingStrategy: number;
  30641. /**
  30642. * @hidden Internal global position in the SPS.
  30643. */
  30644. _globalPosition: Vector3;
  30645. /**
  30646. * Creates a Solid Particle object.
  30647. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30648. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30649. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30650. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30651. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30652. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30653. * @param shapeId (integer) is the model shape identifier in the SPS.
  30654. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30655. * @param sps defines the sps it is associated to
  30656. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30657. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30658. */
  30659. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30660. /**
  30661. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30662. * @param target the particle target
  30663. * @returns the current particle
  30664. */
  30665. copyToRef(target: SolidParticle): SolidParticle;
  30666. /**
  30667. * Legacy support, changed scale to scaling
  30668. */
  30669. get scale(): Vector3;
  30670. /**
  30671. * Legacy support, changed scale to scaling
  30672. */
  30673. set scale(scale: Vector3);
  30674. /**
  30675. * Legacy support, changed quaternion to rotationQuaternion
  30676. */
  30677. get quaternion(): Nullable<Quaternion>;
  30678. /**
  30679. * Legacy support, changed quaternion to rotationQuaternion
  30680. */
  30681. set quaternion(q: Nullable<Quaternion>);
  30682. /**
  30683. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30684. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30685. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30686. * @returns true if it intersects
  30687. */
  30688. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30689. /**
  30690. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30691. * A particle is in the frustum if its bounding box intersects the frustum
  30692. * @param frustumPlanes defines the frustum to test
  30693. * @returns true if the particle is in the frustum planes
  30694. */
  30695. isInFrustum(frustumPlanes: Plane[]): boolean;
  30696. /**
  30697. * get the rotation matrix of the particle
  30698. * @hidden
  30699. */
  30700. getRotationMatrix(m: Matrix): void;
  30701. }
  30702. /**
  30703. * Represents the shape of the model used by one particle of a solid particle system.
  30704. * SPS internal tool, don't use it manually.
  30705. */
  30706. export class ModelShape {
  30707. /**
  30708. * The shape id
  30709. * @hidden
  30710. */
  30711. shapeID: number;
  30712. /**
  30713. * flat array of model positions (internal use)
  30714. * @hidden
  30715. */
  30716. _shape: Vector3[];
  30717. /**
  30718. * flat array of model UVs (internal use)
  30719. * @hidden
  30720. */
  30721. _shapeUV: number[];
  30722. /**
  30723. * color array of the model
  30724. * @hidden
  30725. */
  30726. _shapeColors: number[];
  30727. /**
  30728. * indices array of the model
  30729. * @hidden
  30730. */
  30731. _indices: number[];
  30732. /**
  30733. * normals array of the model
  30734. * @hidden
  30735. */
  30736. _normals: number[];
  30737. /**
  30738. * length of the shape in the model indices array (internal use)
  30739. * @hidden
  30740. */
  30741. _indicesLength: number;
  30742. /**
  30743. * Custom position function (internal use)
  30744. * @hidden
  30745. */
  30746. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30747. /**
  30748. * Custom vertex function (internal use)
  30749. * @hidden
  30750. */
  30751. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30752. /**
  30753. * Model material (internal use)
  30754. * @hidden
  30755. */
  30756. _material: Nullable<Material>;
  30757. /**
  30758. * 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.
  30759. * SPS internal tool, don't use it manually.
  30760. * @hidden
  30761. */
  30762. 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>);
  30763. }
  30764. /**
  30765. * Represents a Depth Sorted Particle in the solid particle system.
  30766. * @hidden
  30767. */
  30768. export class DepthSortedParticle {
  30769. /**
  30770. * Particle index
  30771. */
  30772. idx: number;
  30773. /**
  30774. * Index of the particle in the "indices" array
  30775. */
  30776. ind: number;
  30777. /**
  30778. * Length of the particle shape in the "indices" array
  30779. */
  30780. indicesLength: number;
  30781. /**
  30782. * Squared distance from the particle to the camera
  30783. */
  30784. sqDistance: number;
  30785. /**
  30786. * Material index when used with MultiMaterials
  30787. */
  30788. materialIndex: number;
  30789. /**
  30790. * Creates a new sorted particle
  30791. * @param materialIndex
  30792. */
  30793. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30794. }
  30795. /**
  30796. * Represents a solid particle vertex
  30797. */
  30798. export class SolidParticleVertex {
  30799. /**
  30800. * Vertex position
  30801. */
  30802. position: Vector3;
  30803. /**
  30804. * Vertex color
  30805. */
  30806. color: Color4;
  30807. /**
  30808. * Vertex UV
  30809. */
  30810. uv: Vector2;
  30811. /**
  30812. * Creates a new solid particle vertex
  30813. */
  30814. constructor();
  30815. /** Vertex x coordinate */
  30816. get x(): number;
  30817. set x(val: number);
  30818. /** Vertex y coordinate */
  30819. get y(): number;
  30820. set y(val: number);
  30821. /** Vertex z coordinate */
  30822. get z(): number;
  30823. set z(val: number);
  30824. }
  30825. }
  30826. declare module BABYLON {
  30827. /**
  30828. * @hidden
  30829. */
  30830. export class _MeshCollisionData {
  30831. _checkCollisions: boolean;
  30832. _collisionMask: number;
  30833. _collisionGroup: number;
  30834. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30835. _collider: Nullable<Collider>;
  30836. _oldPositionForCollisions: Vector3;
  30837. _diffPositionForCollisions: Vector3;
  30838. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30839. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30840. }
  30841. }
  30842. declare module BABYLON {
  30843. /** @hidden */
  30844. class _FacetDataStorage {
  30845. facetPositions: Vector3[];
  30846. facetNormals: Vector3[];
  30847. facetPartitioning: number[][];
  30848. facetNb: number;
  30849. partitioningSubdivisions: number;
  30850. partitioningBBoxRatio: number;
  30851. facetDataEnabled: boolean;
  30852. facetParameters: any;
  30853. bbSize: Vector3;
  30854. subDiv: {
  30855. max: number;
  30856. X: number;
  30857. Y: number;
  30858. Z: number;
  30859. };
  30860. facetDepthSort: boolean;
  30861. facetDepthSortEnabled: boolean;
  30862. depthSortedIndices: IndicesArray;
  30863. depthSortedFacets: {
  30864. ind: number;
  30865. sqDistance: number;
  30866. }[];
  30867. facetDepthSortFunction: (f1: {
  30868. ind: number;
  30869. sqDistance: number;
  30870. }, f2: {
  30871. ind: number;
  30872. sqDistance: number;
  30873. }) => number;
  30874. facetDepthSortFrom: Vector3;
  30875. facetDepthSortOrigin: Vector3;
  30876. invertedMatrix: Matrix;
  30877. }
  30878. /**
  30879. * @hidden
  30880. **/
  30881. class _InternalAbstractMeshDataInfo {
  30882. _hasVertexAlpha: boolean;
  30883. _useVertexColors: boolean;
  30884. _numBoneInfluencers: number;
  30885. _applyFog: boolean;
  30886. _receiveShadows: boolean;
  30887. _facetData: _FacetDataStorage;
  30888. _visibility: number;
  30889. _skeleton: Nullable<Skeleton>;
  30890. _layerMask: number;
  30891. _computeBonesUsingShaders: boolean;
  30892. _isActive: boolean;
  30893. _onlyForInstances: boolean;
  30894. _isActiveIntermediate: boolean;
  30895. _onlyForInstancesIntermediate: boolean;
  30896. _actAsRegularMesh: boolean;
  30897. }
  30898. /**
  30899. * Class used to store all common mesh properties
  30900. */
  30901. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30902. /** No occlusion */
  30903. static OCCLUSION_TYPE_NONE: number;
  30904. /** Occlusion set to optimisitic */
  30905. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30906. /** Occlusion set to strict */
  30907. static OCCLUSION_TYPE_STRICT: number;
  30908. /** Use an accurante occlusion algorithm */
  30909. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30910. /** Use a conservative occlusion algorithm */
  30911. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30912. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30913. * Test order :
  30914. * Is the bounding sphere outside the frustum ?
  30915. * If not, are the bounding box vertices outside the frustum ?
  30916. * It not, then the cullable object is in the frustum.
  30917. */
  30918. static readonly CULLINGSTRATEGY_STANDARD: number;
  30919. /** Culling strategy : Bounding Sphere Only.
  30920. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30921. * It's also less accurate than the standard because some not visible objects can still be selected.
  30922. * Test : is the bounding sphere outside the frustum ?
  30923. * If not, then the cullable object is in the frustum.
  30924. */
  30925. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30926. /** Culling strategy : Optimistic Inclusion.
  30927. * This in an inclusion test first, then the standard exclusion test.
  30928. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30929. * 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.
  30930. * Anyway, it's as accurate as the standard strategy.
  30931. * Test :
  30932. * Is the cullable object bounding sphere center in the frustum ?
  30933. * If not, apply the default culling strategy.
  30934. */
  30935. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30936. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30937. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30938. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30939. * 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.
  30940. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30941. * Test :
  30942. * Is the cullable object bounding sphere center in the frustum ?
  30943. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30944. */
  30945. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30946. /**
  30947. * No billboard
  30948. */
  30949. static get BILLBOARDMODE_NONE(): number;
  30950. /** Billboard on X axis */
  30951. static get BILLBOARDMODE_X(): number;
  30952. /** Billboard on Y axis */
  30953. static get BILLBOARDMODE_Y(): number;
  30954. /** Billboard on Z axis */
  30955. static get BILLBOARDMODE_Z(): number;
  30956. /** Billboard on all axes */
  30957. static get BILLBOARDMODE_ALL(): number;
  30958. /** Billboard on using position instead of orientation */
  30959. static get BILLBOARDMODE_USE_POSITION(): number;
  30960. /** @hidden */
  30961. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30962. /**
  30963. * The culling strategy to use to check whether the mesh must be rendered or not.
  30964. * This value can be changed at any time and will be used on the next render mesh selection.
  30965. * The possible values are :
  30966. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30967. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30968. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30969. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30970. * Please read each static variable documentation to get details about the culling process.
  30971. * */
  30972. cullingStrategy: number;
  30973. /**
  30974. * Gets the number of facets in the mesh
  30975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30976. */
  30977. get facetNb(): number;
  30978. /**
  30979. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30981. */
  30982. get partitioningSubdivisions(): number;
  30983. set partitioningSubdivisions(nb: number);
  30984. /**
  30985. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30986. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30987. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30988. */
  30989. get partitioningBBoxRatio(): number;
  30990. set partitioningBBoxRatio(ratio: number);
  30991. /**
  30992. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30993. * Works only for updatable meshes.
  30994. * Doesn't work with multi-materials
  30995. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30996. */
  30997. get mustDepthSortFacets(): boolean;
  30998. set mustDepthSortFacets(sort: boolean);
  30999. /**
  31000. * The location (Vector3) where the facet depth sort must be computed from.
  31001. * By default, the active camera position.
  31002. * Used only when facet depth sort is enabled
  31003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31004. */
  31005. get facetDepthSortFrom(): Vector3;
  31006. set facetDepthSortFrom(location: Vector3);
  31007. /**
  31008. * gets a boolean indicating if facetData is enabled
  31009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31010. */
  31011. get isFacetDataEnabled(): boolean;
  31012. /** @hidden */
  31013. _updateNonUniformScalingState(value: boolean): boolean;
  31014. /**
  31015. * An event triggered when this mesh collides with another one
  31016. */
  31017. onCollideObservable: Observable<AbstractMesh>;
  31018. /** Set a function to call when this mesh collides with another one */
  31019. set onCollide(callback: () => void);
  31020. /**
  31021. * An event triggered when the collision's position changes
  31022. */
  31023. onCollisionPositionChangeObservable: Observable<Vector3>;
  31024. /** Set a function to call when the collision's position changes */
  31025. set onCollisionPositionChange(callback: () => void);
  31026. /**
  31027. * An event triggered when material is changed
  31028. */
  31029. onMaterialChangedObservable: Observable<AbstractMesh>;
  31030. /**
  31031. * Gets or sets the orientation for POV movement & rotation
  31032. */
  31033. definedFacingForward: boolean;
  31034. /** @hidden */
  31035. _occlusionQuery: Nullable<WebGLQuery>;
  31036. /** @hidden */
  31037. _renderingGroup: Nullable<RenderingGroup>;
  31038. /**
  31039. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31040. */
  31041. get visibility(): number;
  31042. /**
  31043. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31044. */
  31045. set visibility(value: number);
  31046. /** Gets or sets the alpha index used to sort transparent meshes
  31047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31048. */
  31049. alphaIndex: number;
  31050. /**
  31051. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31052. */
  31053. isVisible: boolean;
  31054. /**
  31055. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31056. */
  31057. isPickable: boolean;
  31058. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31059. showSubMeshesBoundingBox: boolean;
  31060. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31062. */
  31063. isBlocker: boolean;
  31064. /**
  31065. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31066. */
  31067. enablePointerMoveEvents: boolean;
  31068. /**
  31069. * Specifies the rendering group id for this mesh (0 by default)
  31070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31071. */
  31072. renderingGroupId: number;
  31073. private _material;
  31074. /** Gets or sets current material */
  31075. get material(): Nullable<Material>;
  31076. set material(value: Nullable<Material>);
  31077. /**
  31078. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31079. * @see http://doc.babylonjs.com/babylon101/shadows
  31080. */
  31081. get receiveShadows(): boolean;
  31082. set receiveShadows(value: boolean);
  31083. /** Defines color to use when rendering outline */
  31084. outlineColor: Color3;
  31085. /** Define width to use when rendering outline */
  31086. outlineWidth: number;
  31087. /** Defines color to use when rendering overlay */
  31088. overlayColor: Color3;
  31089. /** Defines alpha to use when rendering overlay */
  31090. overlayAlpha: number;
  31091. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31092. get hasVertexAlpha(): boolean;
  31093. set hasVertexAlpha(value: boolean);
  31094. /** 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) */
  31095. get useVertexColors(): boolean;
  31096. set useVertexColors(value: boolean);
  31097. /**
  31098. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31099. */
  31100. get computeBonesUsingShaders(): boolean;
  31101. set computeBonesUsingShaders(value: boolean);
  31102. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31103. get numBoneInfluencers(): number;
  31104. set numBoneInfluencers(value: number);
  31105. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31106. get applyFog(): boolean;
  31107. set applyFog(value: boolean);
  31108. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31109. useOctreeForRenderingSelection: boolean;
  31110. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31111. useOctreeForPicking: boolean;
  31112. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31113. useOctreeForCollisions: boolean;
  31114. /**
  31115. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31116. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31117. */
  31118. get layerMask(): number;
  31119. set layerMask(value: number);
  31120. /**
  31121. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31122. */
  31123. alwaysSelectAsActiveMesh: boolean;
  31124. /**
  31125. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31126. */
  31127. doNotSyncBoundingInfo: boolean;
  31128. /**
  31129. * Gets or sets the current action manager
  31130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31131. */
  31132. actionManager: Nullable<AbstractActionManager>;
  31133. private _meshCollisionData;
  31134. /**
  31135. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31136. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31137. */
  31138. ellipsoid: Vector3;
  31139. /**
  31140. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31141. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31142. */
  31143. ellipsoidOffset: Vector3;
  31144. /**
  31145. * Gets or sets a collision mask used to mask collisions (default is -1).
  31146. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31147. */
  31148. get collisionMask(): number;
  31149. set collisionMask(mask: number);
  31150. /**
  31151. * Gets or sets the current collision group mask (-1 by default).
  31152. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31153. */
  31154. get collisionGroup(): number;
  31155. set collisionGroup(mask: number);
  31156. /**
  31157. * Gets or sets current surrounding meshes (null by default).
  31158. *
  31159. * By default collision detection is tested against every mesh in the scene.
  31160. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31161. * meshes will be tested for the collision.
  31162. *
  31163. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31164. */
  31165. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31166. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31167. /**
  31168. * Defines edge width used when edgesRenderer is enabled
  31169. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31170. */
  31171. edgesWidth: number;
  31172. /**
  31173. * Defines edge color used when edgesRenderer is enabled
  31174. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31175. */
  31176. edgesColor: Color4;
  31177. /** @hidden */
  31178. _edgesRenderer: Nullable<IEdgesRenderer>;
  31179. /** @hidden */
  31180. _masterMesh: Nullable<AbstractMesh>;
  31181. /** @hidden */
  31182. _boundingInfo: Nullable<BoundingInfo>;
  31183. /** @hidden */
  31184. _renderId: number;
  31185. /**
  31186. * Gets or sets the list of subMeshes
  31187. * @see http://doc.babylonjs.com/how_to/multi_materials
  31188. */
  31189. subMeshes: SubMesh[];
  31190. /** @hidden */
  31191. _intersectionsInProgress: AbstractMesh[];
  31192. /** @hidden */
  31193. _unIndexed: boolean;
  31194. /** @hidden */
  31195. _lightSources: Light[];
  31196. /** Gets the list of lights affecting that mesh */
  31197. get lightSources(): Light[];
  31198. /** @hidden */
  31199. get _positions(): Nullable<Vector3[]>;
  31200. /** @hidden */
  31201. _waitingData: {
  31202. lods: Nullable<any>;
  31203. actions: Nullable<any>;
  31204. freezeWorldMatrix: Nullable<boolean>;
  31205. };
  31206. /** @hidden */
  31207. _bonesTransformMatrices: Nullable<Float32Array>;
  31208. /** @hidden */
  31209. _transformMatrixTexture: Nullable<RawTexture>;
  31210. /**
  31211. * Gets or sets a skeleton to apply skining transformations
  31212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31213. */
  31214. set skeleton(value: Nullable<Skeleton>);
  31215. get skeleton(): Nullable<Skeleton>;
  31216. /**
  31217. * An event triggered when the mesh is rebuilt.
  31218. */
  31219. onRebuildObservable: Observable<AbstractMesh>;
  31220. /**
  31221. * Creates a new AbstractMesh
  31222. * @param name defines the name of the mesh
  31223. * @param scene defines the hosting scene
  31224. */
  31225. constructor(name: string, scene?: Nullable<Scene>);
  31226. /**
  31227. * Returns the string "AbstractMesh"
  31228. * @returns "AbstractMesh"
  31229. */
  31230. getClassName(): string;
  31231. /**
  31232. * Gets a string representation of the current mesh
  31233. * @param fullDetails defines a boolean indicating if full details must be included
  31234. * @returns a string representation of the current mesh
  31235. */
  31236. toString(fullDetails?: boolean): string;
  31237. /**
  31238. * @hidden
  31239. */
  31240. protected _getEffectiveParent(): Nullable<Node>;
  31241. /** @hidden */
  31242. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31243. /** @hidden */
  31244. _rebuild(): void;
  31245. /** @hidden */
  31246. _resyncLightSources(): void;
  31247. /** @hidden */
  31248. _resyncLightSource(light: Light): void;
  31249. /** @hidden */
  31250. _unBindEffect(): void;
  31251. /** @hidden */
  31252. _removeLightSource(light: Light, dispose: boolean): void;
  31253. private _markSubMeshesAsDirty;
  31254. /** @hidden */
  31255. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31256. /** @hidden */
  31257. _markSubMeshesAsAttributesDirty(): void;
  31258. /** @hidden */
  31259. _markSubMeshesAsMiscDirty(): void;
  31260. /**
  31261. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31262. */
  31263. get scaling(): Vector3;
  31264. set scaling(newScaling: Vector3);
  31265. /**
  31266. * Returns true if the mesh is blocked. Implemented by child classes
  31267. */
  31268. get isBlocked(): boolean;
  31269. /**
  31270. * Returns the mesh itself by default. Implemented by child classes
  31271. * @param camera defines the camera to use to pick the right LOD level
  31272. * @returns the currentAbstractMesh
  31273. */
  31274. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31275. /**
  31276. * Returns 0 by default. Implemented by child classes
  31277. * @returns an integer
  31278. */
  31279. getTotalVertices(): number;
  31280. /**
  31281. * Returns a positive integer : the total number of indices in this mesh geometry.
  31282. * @returns the numner of indices or zero if the mesh has no geometry.
  31283. */
  31284. getTotalIndices(): number;
  31285. /**
  31286. * Returns null by default. Implemented by child classes
  31287. * @returns null
  31288. */
  31289. getIndices(): Nullable<IndicesArray>;
  31290. /**
  31291. * Returns the array of the requested vertex data kind. Implemented by child classes
  31292. * @param kind defines the vertex data kind to use
  31293. * @returns null
  31294. */
  31295. getVerticesData(kind: string): Nullable<FloatArray>;
  31296. /**
  31297. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31298. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31299. * Note that a new underlying VertexBuffer object is created each call.
  31300. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31301. * @param kind defines vertex data kind:
  31302. * * VertexBuffer.PositionKind
  31303. * * VertexBuffer.UVKind
  31304. * * VertexBuffer.UV2Kind
  31305. * * VertexBuffer.UV3Kind
  31306. * * VertexBuffer.UV4Kind
  31307. * * VertexBuffer.UV5Kind
  31308. * * VertexBuffer.UV6Kind
  31309. * * VertexBuffer.ColorKind
  31310. * * VertexBuffer.MatricesIndicesKind
  31311. * * VertexBuffer.MatricesIndicesExtraKind
  31312. * * VertexBuffer.MatricesWeightsKind
  31313. * * VertexBuffer.MatricesWeightsExtraKind
  31314. * @param data defines the data source
  31315. * @param updatable defines if the data must be flagged as updatable (or static)
  31316. * @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
  31317. * @returns the current mesh
  31318. */
  31319. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31320. /**
  31321. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31322. * If the mesh has no geometry, it is simply returned as it is.
  31323. * @param kind defines vertex data kind:
  31324. * * VertexBuffer.PositionKind
  31325. * * VertexBuffer.UVKind
  31326. * * VertexBuffer.UV2Kind
  31327. * * VertexBuffer.UV3Kind
  31328. * * VertexBuffer.UV4Kind
  31329. * * VertexBuffer.UV5Kind
  31330. * * VertexBuffer.UV6Kind
  31331. * * VertexBuffer.ColorKind
  31332. * * VertexBuffer.MatricesIndicesKind
  31333. * * VertexBuffer.MatricesIndicesExtraKind
  31334. * * VertexBuffer.MatricesWeightsKind
  31335. * * VertexBuffer.MatricesWeightsExtraKind
  31336. * @param data defines the data source
  31337. * @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
  31338. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31339. * @returns the current mesh
  31340. */
  31341. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31342. /**
  31343. * Sets the mesh indices,
  31344. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31345. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31346. * @param totalVertices Defines the total number of vertices
  31347. * @returns the current mesh
  31348. */
  31349. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31350. /**
  31351. * Gets a boolean indicating if specific vertex data is present
  31352. * @param kind defines the vertex data kind to use
  31353. * @returns true is data kind is present
  31354. */
  31355. isVerticesDataPresent(kind: string): boolean;
  31356. /**
  31357. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31358. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31359. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31360. * @returns a BoundingInfo
  31361. */
  31362. getBoundingInfo(): BoundingInfo;
  31363. /**
  31364. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31365. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31366. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31367. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31368. * @returns the current mesh
  31369. */
  31370. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31371. /**
  31372. * Overwrite the current bounding info
  31373. * @param boundingInfo defines the new bounding info
  31374. * @returns the current mesh
  31375. */
  31376. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31377. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31378. get useBones(): boolean;
  31379. /** @hidden */
  31380. _preActivate(): void;
  31381. /** @hidden */
  31382. _preActivateForIntermediateRendering(renderId: number): void;
  31383. /** @hidden */
  31384. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31385. /** @hidden */
  31386. _postActivate(): void;
  31387. /** @hidden */
  31388. _freeze(): void;
  31389. /** @hidden */
  31390. _unFreeze(): void;
  31391. /**
  31392. * Gets the current world matrix
  31393. * @returns a Matrix
  31394. */
  31395. getWorldMatrix(): Matrix;
  31396. /** @hidden */
  31397. _getWorldMatrixDeterminant(): number;
  31398. /**
  31399. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31400. */
  31401. get isAnInstance(): boolean;
  31402. /**
  31403. * Gets a boolean indicating if this mesh has instances
  31404. */
  31405. get hasInstances(): boolean;
  31406. /**
  31407. * Gets a boolean indicating if this mesh has thin instances
  31408. */
  31409. get hasThinInstances(): boolean;
  31410. /**
  31411. * Perform relative position change from the point of view of behind the front of the mesh.
  31412. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31413. * Supports definition of mesh facing forward or backward
  31414. * @param amountRight defines the distance on the right axis
  31415. * @param amountUp defines the distance on the up axis
  31416. * @param amountForward defines the distance on the forward axis
  31417. * @returns the current mesh
  31418. */
  31419. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31420. /**
  31421. * Calculate relative position change from the point of view of behind the front of the mesh.
  31422. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31423. * Supports definition of mesh facing forward or backward
  31424. * @param amountRight defines the distance on the right axis
  31425. * @param amountUp defines the distance on the up axis
  31426. * @param amountForward defines the distance on the forward axis
  31427. * @returns the new displacement vector
  31428. */
  31429. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31430. /**
  31431. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31432. * Supports definition of mesh facing forward or backward
  31433. * @param flipBack defines the flip
  31434. * @param twirlClockwise defines the twirl
  31435. * @param tiltRight defines the tilt
  31436. * @returns the current mesh
  31437. */
  31438. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31439. /**
  31440. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31441. * Supports definition of mesh facing forward or backward.
  31442. * @param flipBack defines the flip
  31443. * @param twirlClockwise defines the twirl
  31444. * @param tiltRight defines the tilt
  31445. * @returns the new rotation vector
  31446. */
  31447. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31448. /**
  31449. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31450. * This means the mesh underlying bounding box and sphere are recomputed.
  31451. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31452. * @returns the current mesh
  31453. */
  31454. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31455. /** @hidden */
  31456. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31457. /** @hidden */
  31458. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31459. /** @hidden */
  31460. _updateBoundingInfo(): AbstractMesh;
  31461. /** @hidden */
  31462. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31463. /** @hidden */
  31464. protected _afterComputeWorldMatrix(): void;
  31465. /** @hidden */
  31466. get _effectiveMesh(): AbstractMesh;
  31467. /**
  31468. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31469. * A mesh is in the frustum if its bounding box intersects the frustum
  31470. * @param frustumPlanes defines the frustum to test
  31471. * @returns true if the mesh is in the frustum planes
  31472. */
  31473. isInFrustum(frustumPlanes: Plane[]): boolean;
  31474. /**
  31475. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31476. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31477. * @param frustumPlanes defines the frustum to test
  31478. * @returns true if the mesh is completely in the frustum planes
  31479. */
  31480. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31481. /**
  31482. * True if the mesh intersects another mesh or a SolidParticle object
  31483. * @param mesh defines a target mesh or SolidParticle to test
  31484. * @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)
  31485. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31486. * @returns true if there is an intersection
  31487. */
  31488. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31489. /**
  31490. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31491. * @param point defines the point to test
  31492. * @returns true if there is an intersection
  31493. */
  31494. intersectsPoint(point: Vector3): boolean;
  31495. /**
  31496. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31498. */
  31499. get checkCollisions(): boolean;
  31500. set checkCollisions(collisionEnabled: boolean);
  31501. /**
  31502. * Gets Collider object used to compute collisions (not physics)
  31503. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31504. */
  31505. get collider(): Nullable<Collider>;
  31506. /**
  31507. * Move the mesh using collision engine
  31508. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31509. * @param displacement defines the requested displacement vector
  31510. * @returns the current mesh
  31511. */
  31512. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31513. private _onCollisionPositionChange;
  31514. /** @hidden */
  31515. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31516. /** @hidden */
  31517. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31518. /** @hidden */
  31519. _checkCollision(collider: Collider): AbstractMesh;
  31520. /** @hidden */
  31521. _generatePointsArray(): boolean;
  31522. /**
  31523. * Checks if the passed Ray intersects with the mesh
  31524. * @param ray defines the ray to use
  31525. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31526. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31527. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31528. * @returns the picking info
  31529. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31530. */
  31531. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31532. /**
  31533. * Clones the current mesh
  31534. * @param name defines the mesh name
  31535. * @param newParent defines the new mesh parent
  31536. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31537. * @returns the new mesh
  31538. */
  31539. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31540. /**
  31541. * Disposes all the submeshes of the current meshnp
  31542. * @returns the current mesh
  31543. */
  31544. releaseSubMeshes(): AbstractMesh;
  31545. /**
  31546. * Releases resources associated with this abstract mesh.
  31547. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31548. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31549. */
  31550. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31551. /**
  31552. * Adds the passed mesh as a child to the current mesh
  31553. * @param mesh defines the child mesh
  31554. * @returns the current mesh
  31555. */
  31556. addChild(mesh: AbstractMesh): AbstractMesh;
  31557. /**
  31558. * Removes the passed mesh from the current mesh children list
  31559. * @param mesh defines the child mesh
  31560. * @returns the current mesh
  31561. */
  31562. removeChild(mesh: AbstractMesh): AbstractMesh;
  31563. /** @hidden */
  31564. private _initFacetData;
  31565. /**
  31566. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31567. * This method can be called within the render loop.
  31568. * 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
  31569. * @returns the current mesh
  31570. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31571. */
  31572. updateFacetData(): AbstractMesh;
  31573. /**
  31574. * Returns the facetLocalNormals array.
  31575. * The normals are expressed in the mesh local spac
  31576. * @returns an array of Vector3
  31577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31578. */
  31579. getFacetLocalNormals(): Vector3[];
  31580. /**
  31581. * Returns the facetLocalPositions array.
  31582. * The facet positions are expressed in the mesh local space
  31583. * @returns an array of Vector3
  31584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31585. */
  31586. getFacetLocalPositions(): Vector3[];
  31587. /**
  31588. * Returns the facetLocalPartioning array
  31589. * @returns an array of array of numbers
  31590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31591. */
  31592. getFacetLocalPartitioning(): number[][];
  31593. /**
  31594. * Returns the i-th facet position in the world system.
  31595. * This method allocates a new Vector3 per call
  31596. * @param i defines the facet index
  31597. * @returns a new Vector3
  31598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31599. */
  31600. getFacetPosition(i: number): Vector3;
  31601. /**
  31602. * Sets the reference Vector3 with the i-th facet position in the world system
  31603. * @param i defines the facet index
  31604. * @param ref defines the target vector
  31605. * @returns the current mesh
  31606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31607. */
  31608. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31609. /**
  31610. * Returns the i-th facet normal in the world system.
  31611. * This method allocates a new Vector3 per call
  31612. * @param i defines the facet index
  31613. * @returns a new Vector3
  31614. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31615. */
  31616. getFacetNormal(i: number): Vector3;
  31617. /**
  31618. * Sets the reference Vector3 with the i-th facet normal in the world system
  31619. * @param i defines the facet index
  31620. * @param ref defines the target vector
  31621. * @returns the current mesh
  31622. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31623. */
  31624. getFacetNormalToRef(i: number, ref: Vector3): this;
  31625. /**
  31626. * 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)
  31627. * @param x defines x coordinate
  31628. * @param y defines y coordinate
  31629. * @param z defines z coordinate
  31630. * @returns the array of facet indexes
  31631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31632. */
  31633. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31634. /**
  31635. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31636. * @param projected sets as the (x,y,z) world projection on the facet
  31637. * @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
  31638. * @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
  31639. * @param x defines x coordinate
  31640. * @param y defines y coordinate
  31641. * @param z defines z coordinate
  31642. * @returns the face index if found (or null instead)
  31643. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31644. */
  31645. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31646. /**
  31647. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31648. * @param projected sets as the (x,y,z) local projection on the facet
  31649. * @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
  31650. * @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
  31651. * @param x defines x coordinate
  31652. * @param y defines y coordinate
  31653. * @param z defines z coordinate
  31654. * @returns the face index if found (or null instead)
  31655. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31656. */
  31657. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31658. /**
  31659. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31660. * @returns the parameters
  31661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31662. */
  31663. getFacetDataParameters(): any;
  31664. /**
  31665. * Disables the feature FacetData and frees the related memory
  31666. * @returns the current mesh
  31667. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31668. */
  31669. disableFacetData(): AbstractMesh;
  31670. /**
  31671. * Updates the AbstractMesh indices array
  31672. * @param indices defines the data source
  31673. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31674. * @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)
  31675. * @returns the current mesh
  31676. */
  31677. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31678. /**
  31679. * Creates new normals data for the mesh
  31680. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31681. * @returns the current mesh
  31682. */
  31683. createNormals(updatable: boolean): AbstractMesh;
  31684. /**
  31685. * Align the mesh with a normal
  31686. * @param normal defines the normal to use
  31687. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31688. * @returns the current mesh
  31689. */
  31690. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31691. /** @hidden */
  31692. _checkOcclusionQuery(): boolean;
  31693. /**
  31694. * Disables the mesh edge rendering mode
  31695. * @returns the currentAbstractMesh
  31696. */
  31697. disableEdgesRendering(): AbstractMesh;
  31698. /**
  31699. * Enables the edge rendering mode on the mesh.
  31700. * This mode makes the mesh edges visible
  31701. * @param epsilon defines the maximal distance between two angles to detect a face
  31702. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31703. * @returns the currentAbstractMesh
  31704. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31705. */
  31706. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31707. }
  31708. }
  31709. declare module BABYLON {
  31710. /**
  31711. * Interface used to define ActionEvent
  31712. */
  31713. export interface IActionEvent {
  31714. /** The mesh or sprite that triggered the action */
  31715. source: any;
  31716. /** The X mouse cursor position at the time of the event */
  31717. pointerX: number;
  31718. /** The Y mouse cursor position at the time of the event */
  31719. pointerY: number;
  31720. /** The mesh that is currently pointed at (can be null) */
  31721. meshUnderPointer: Nullable<AbstractMesh>;
  31722. /** the original (browser) event that triggered the ActionEvent */
  31723. sourceEvent?: any;
  31724. /** additional data for the event */
  31725. additionalData?: any;
  31726. }
  31727. /**
  31728. * ActionEvent is the event being sent when an action is triggered.
  31729. */
  31730. export class ActionEvent implements IActionEvent {
  31731. /** The mesh or sprite that triggered the action */
  31732. source: any;
  31733. /** The X mouse cursor position at the time of the event */
  31734. pointerX: number;
  31735. /** The Y mouse cursor position at the time of the event */
  31736. pointerY: number;
  31737. /** The mesh that is currently pointed at (can be null) */
  31738. meshUnderPointer: Nullable<AbstractMesh>;
  31739. /** the original (browser) event that triggered the ActionEvent */
  31740. sourceEvent?: any;
  31741. /** additional data for the event */
  31742. additionalData?: any;
  31743. /**
  31744. * Creates a new ActionEvent
  31745. * @param source The mesh or sprite that triggered the action
  31746. * @param pointerX The X mouse cursor position at the time of the event
  31747. * @param pointerY The Y mouse cursor position at the time of the event
  31748. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31749. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31750. * @param additionalData additional data for the event
  31751. */
  31752. constructor(
  31753. /** The mesh or sprite that triggered the action */
  31754. source: any,
  31755. /** The X mouse cursor position at the time of the event */
  31756. pointerX: number,
  31757. /** The Y mouse cursor position at the time of the event */
  31758. pointerY: number,
  31759. /** The mesh that is currently pointed at (can be null) */
  31760. meshUnderPointer: Nullable<AbstractMesh>,
  31761. /** the original (browser) event that triggered the ActionEvent */
  31762. sourceEvent?: any,
  31763. /** additional data for the event */
  31764. additionalData?: any);
  31765. /**
  31766. * Helper function to auto-create an ActionEvent from a source mesh.
  31767. * @param source The source mesh that triggered the event
  31768. * @param evt The original (browser) event
  31769. * @param additionalData additional data for the event
  31770. * @returns the new ActionEvent
  31771. */
  31772. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31773. /**
  31774. * Helper function to auto-create an ActionEvent from a source sprite
  31775. * @param source The source sprite that triggered the event
  31776. * @param scene Scene associated with the sprite
  31777. * @param evt The original (browser) event
  31778. * @param additionalData additional data for the event
  31779. * @returns the new ActionEvent
  31780. */
  31781. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31782. /**
  31783. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31784. * @param scene the scene where the event occurred
  31785. * @param evt The original (browser) event
  31786. * @returns the new ActionEvent
  31787. */
  31788. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31789. /**
  31790. * Helper function to auto-create an ActionEvent from a primitive
  31791. * @param prim defines the target primitive
  31792. * @param pointerPos defines the pointer position
  31793. * @param evt The original (browser) event
  31794. * @param additionalData additional data for the event
  31795. * @returns the new ActionEvent
  31796. */
  31797. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31798. }
  31799. }
  31800. declare module BABYLON {
  31801. /**
  31802. * Abstract class used to decouple action Manager from scene and meshes.
  31803. * Do not instantiate.
  31804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31805. */
  31806. export abstract class AbstractActionManager implements IDisposable {
  31807. /** Gets the list of active triggers */
  31808. static Triggers: {
  31809. [key: string]: number;
  31810. };
  31811. /** Gets the cursor to use when hovering items */
  31812. hoverCursor: string;
  31813. /** Gets the list of actions */
  31814. actions: IAction[];
  31815. /**
  31816. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31817. */
  31818. isRecursive: boolean;
  31819. /**
  31820. * Releases all associated resources
  31821. */
  31822. abstract dispose(): void;
  31823. /**
  31824. * Does this action manager has pointer triggers
  31825. */
  31826. abstract get hasPointerTriggers(): boolean;
  31827. /**
  31828. * Does this action manager has pick triggers
  31829. */
  31830. abstract get hasPickTriggers(): boolean;
  31831. /**
  31832. * Process a specific trigger
  31833. * @param trigger defines the trigger to process
  31834. * @param evt defines the event details to be processed
  31835. */
  31836. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31837. /**
  31838. * Does this action manager handles actions of any of the given triggers
  31839. * @param triggers defines the triggers to be tested
  31840. * @return a boolean indicating whether one (or more) of the triggers is handled
  31841. */
  31842. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31843. /**
  31844. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31845. * speed.
  31846. * @param triggerA defines the trigger to be tested
  31847. * @param triggerB defines the trigger to be tested
  31848. * @return a boolean indicating whether one (or more) of the triggers is handled
  31849. */
  31850. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31851. /**
  31852. * Does this action manager handles actions of a given trigger
  31853. * @param trigger defines the trigger to be tested
  31854. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31855. * @return whether the trigger is handled
  31856. */
  31857. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31858. /**
  31859. * Serialize this manager to a JSON object
  31860. * @param name defines the property name to store this manager
  31861. * @returns a JSON representation of this manager
  31862. */
  31863. abstract serialize(name: string): any;
  31864. /**
  31865. * Registers an action to this action manager
  31866. * @param action defines the action to be registered
  31867. * @return the action amended (prepared) after registration
  31868. */
  31869. abstract registerAction(action: IAction): Nullable<IAction>;
  31870. /**
  31871. * Unregisters an action to this action manager
  31872. * @param action defines the action to be unregistered
  31873. * @return a boolean indicating whether the action has been unregistered
  31874. */
  31875. abstract unregisterAction(action: IAction): Boolean;
  31876. /**
  31877. * Does exist one action manager with at least one trigger
  31878. **/
  31879. static get HasTriggers(): boolean;
  31880. /**
  31881. * Does exist one action manager with at least one pick trigger
  31882. **/
  31883. static get HasPickTriggers(): boolean;
  31884. /**
  31885. * Does exist one action manager that handles actions of a given trigger
  31886. * @param trigger defines the trigger to be tested
  31887. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31888. **/
  31889. static HasSpecificTrigger(trigger: number): boolean;
  31890. }
  31891. }
  31892. declare module BABYLON {
  31893. /**
  31894. * Defines how a node can be built from a string name.
  31895. */
  31896. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31897. /**
  31898. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31899. */
  31900. export class Node implements IBehaviorAware<Node> {
  31901. /** @hidden */
  31902. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31903. private static _NodeConstructors;
  31904. /**
  31905. * Add a new node constructor
  31906. * @param type defines the type name of the node to construct
  31907. * @param constructorFunc defines the constructor function
  31908. */
  31909. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31910. /**
  31911. * Returns a node constructor based on type name
  31912. * @param type defines the type name
  31913. * @param name defines the new node name
  31914. * @param scene defines the hosting scene
  31915. * @param options defines optional options to transmit to constructors
  31916. * @returns the new constructor or null
  31917. */
  31918. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31919. /**
  31920. * Gets or sets the name of the node
  31921. */
  31922. name: string;
  31923. /**
  31924. * Gets or sets the id of the node
  31925. */
  31926. id: string;
  31927. /**
  31928. * Gets or sets the unique id of the node
  31929. */
  31930. uniqueId: number;
  31931. /**
  31932. * Gets or sets a string used to store user defined state for the node
  31933. */
  31934. state: string;
  31935. /**
  31936. * Gets or sets an object used to store user defined information for the node
  31937. */
  31938. metadata: any;
  31939. /**
  31940. * For internal use only. Please do not use.
  31941. */
  31942. reservedDataStore: any;
  31943. /**
  31944. * List of inspectable custom properties (used by the Inspector)
  31945. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31946. */
  31947. inspectableCustomProperties: IInspectable[];
  31948. private _doNotSerialize;
  31949. /**
  31950. * Gets or sets a boolean used to define if the node must be serialized
  31951. */
  31952. get doNotSerialize(): boolean;
  31953. set doNotSerialize(value: boolean);
  31954. /** @hidden */
  31955. _isDisposed: boolean;
  31956. /**
  31957. * Gets a list of Animations associated with the node
  31958. */
  31959. animations: Animation[];
  31960. protected _ranges: {
  31961. [name: string]: Nullable<AnimationRange>;
  31962. };
  31963. /**
  31964. * Callback raised when the node is ready to be used
  31965. */
  31966. onReady: Nullable<(node: Node) => void>;
  31967. private _isEnabled;
  31968. private _isParentEnabled;
  31969. private _isReady;
  31970. /** @hidden */
  31971. _currentRenderId: number;
  31972. private _parentUpdateId;
  31973. /** @hidden */
  31974. _childUpdateId: number;
  31975. /** @hidden */
  31976. _waitingParentId: Nullable<string>;
  31977. /** @hidden */
  31978. _scene: Scene;
  31979. /** @hidden */
  31980. _cache: any;
  31981. private _parentNode;
  31982. private _children;
  31983. /** @hidden */
  31984. _worldMatrix: Matrix;
  31985. /** @hidden */
  31986. _worldMatrixDeterminant: number;
  31987. /** @hidden */
  31988. _worldMatrixDeterminantIsDirty: boolean;
  31989. /** @hidden */
  31990. private _sceneRootNodesIndex;
  31991. /**
  31992. * Gets a boolean indicating if the node has been disposed
  31993. * @returns true if the node was disposed
  31994. */
  31995. isDisposed(): boolean;
  31996. /**
  31997. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31998. * @see https://doc.babylonjs.com/how_to/parenting
  31999. */
  32000. set parent(parent: Nullable<Node>);
  32001. get parent(): Nullable<Node>;
  32002. /** @hidden */
  32003. _addToSceneRootNodes(): void;
  32004. /** @hidden */
  32005. _removeFromSceneRootNodes(): void;
  32006. private _animationPropertiesOverride;
  32007. /**
  32008. * Gets or sets the animation properties override
  32009. */
  32010. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32011. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32012. /**
  32013. * Gets a string idenfifying the name of the class
  32014. * @returns "Node" string
  32015. */
  32016. getClassName(): string;
  32017. /** @hidden */
  32018. readonly _isNode: boolean;
  32019. /**
  32020. * An event triggered when the mesh is disposed
  32021. */
  32022. onDisposeObservable: Observable<Node>;
  32023. private _onDisposeObserver;
  32024. /**
  32025. * Sets a callback that will be raised when the node will be disposed
  32026. */
  32027. set onDispose(callback: () => void);
  32028. /**
  32029. * Creates a new Node
  32030. * @param name the name and id to be given to this node
  32031. * @param scene the scene this node will be added to
  32032. */
  32033. constructor(name: string, scene?: Nullable<Scene>);
  32034. /**
  32035. * Gets the scene of the node
  32036. * @returns a scene
  32037. */
  32038. getScene(): Scene;
  32039. /**
  32040. * Gets the engine of the node
  32041. * @returns a Engine
  32042. */
  32043. getEngine(): Engine;
  32044. private _behaviors;
  32045. /**
  32046. * Attach a behavior to the node
  32047. * @see http://doc.babylonjs.com/features/behaviour
  32048. * @param behavior defines the behavior to attach
  32049. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32050. * @returns the current Node
  32051. */
  32052. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32053. /**
  32054. * Remove an attached behavior
  32055. * @see http://doc.babylonjs.com/features/behaviour
  32056. * @param behavior defines the behavior to attach
  32057. * @returns the current Node
  32058. */
  32059. removeBehavior(behavior: Behavior<Node>): Node;
  32060. /**
  32061. * Gets the list of attached behaviors
  32062. * @see http://doc.babylonjs.com/features/behaviour
  32063. */
  32064. get behaviors(): Behavior<Node>[];
  32065. /**
  32066. * Gets an attached behavior by name
  32067. * @param name defines the name of the behavior to look for
  32068. * @see http://doc.babylonjs.com/features/behaviour
  32069. * @returns null if behavior was not found else the requested behavior
  32070. */
  32071. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32072. /**
  32073. * Returns the latest update of the World matrix
  32074. * @returns a Matrix
  32075. */
  32076. getWorldMatrix(): Matrix;
  32077. /** @hidden */
  32078. _getWorldMatrixDeterminant(): number;
  32079. /**
  32080. * Returns directly the latest state of the mesh World matrix.
  32081. * A Matrix is returned.
  32082. */
  32083. get worldMatrixFromCache(): Matrix;
  32084. /** @hidden */
  32085. _initCache(): void;
  32086. /** @hidden */
  32087. updateCache(force?: boolean): void;
  32088. /** @hidden */
  32089. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32090. /** @hidden */
  32091. _updateCache(ignoreParentClass?: boolean): void;
  32092. /** @hidden */
  32093. _isSynchronized(): boolean;
  32094. /** @hidden */
  32095. _markSyncedWithParent(): void;
  32096. /** @hidden */
  32097. isSynchronizedWithParent(): boolean;
  32098. /** @hidden */
  32099. isSynchronized(): boolean;
  32100. /**
  32101. * Is this node ready to be used/rendered
  32102. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32103. * @return true if the node is ready
  32104. */
  32105. isReady(completeCheck?: boolean): boolean;
  32106. /**
  32107. * Is this node enabled?
  32108. * 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
  32109. * @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
  32110. * @return whether this node (and its parent) is enabled
  32111. */
  32112. isEnabled(checkAncestors?: boolean): boolean;
  32113. /** @hidden */
  32114. protected _syncParentEnabledState(): void;
  32115. /**
  32116. * Set the enabled state of this node
  32117. * @param value defines the new enabled state
  32118. */
  32119. setEnabled(value: boolean): void;
  32120. /**
  32121. * Is this node a descendant of the given node?
  32122. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32123. * @param ancestor defines the parent node to inspect
  32124. * @returns a boolean indicating if this node is a descendant of the given node
  32125. */
  32126. isDescendantOf(ancestor: Node): boolean;
  32127. /** @hidden */
  32128. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32129. /**
  32130. * Will return all nodes that have this node as ascendant
  32131. * @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
  32132. * @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
  32133. * @return all children nodes of all types
  32134. */
  32135. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32136. /**
  32137. * Get all child-meshes of this node
  32138. * @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)
  32139. * @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
  32140. * @returns an array of AbstractMesh
  32141. */
  32142. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32143. /**
  32144. * Get all direct children of this node
  32145. * @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
  32146. * @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)
  32147. * @returns an array of Node
  32148. */
  32149. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32150. /** @hidden */
  32151. _setReady(state: boolean): void;
  32152. /**
  32153. * Get an animation by name
  32154. * @param name defines the name of the animation to look for
  32155. * @returns null if not found else the requested animation
  32156. */
  32157. getAnimationByName(name: string): Nullable<Animation>;
  32158. /**
  32159. * Creates an animation range for this node
  32160. * @param name defines the name of the range
  32161. * @param from defines the starting key
  32162. * @param to defines the end key
  32163. */
  32164. createAnimationRange(name: string, from: number, to: number): void;
  32165. /**
  32166. * Delete a specific animation range
  32167. * @param name defines the name of the range to delete
  32168. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32169. */
  32170. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32171. /**
  32172. * Get an animation range by name
  32173. * @param name defines the name of the animation range to look for
  32174. * @returns null if not found else the requested animation range
  32175. */
  32176. getAnimationRange(name: string): Nullable<AnimationRange>;
  32177. /**
  32178. * Gets the list of all animation ranges defined on this node
  32179. * @returns an array
  32180. */
  32181. getAnimationRanges(): Nullable<AnimationRange>[];
  32182. /**
  32183. * Will start the animation sequence
  32184. * @param name defines the range frames for animation sequence
  32185. * @param loop defines if the animation should loop (false by default)
  32186. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32187. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32188. * @returns the object created for this animation. If range does not exist, it will return null
  32189. */
  32190. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32191. /**
  32192. * Serialize animation ranges into a JSON compatible object
  32193. * @returns serialization object
  32194. */
  32195. serializeAnimationRanges(): any;
  32196. /**
  32197. * Computes the world matrix of the node
  32198. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32199. * @returns the world matrix
  32200. */
  32201. computeWorldMatrix(force?: boolean): Matrix;
  32202. /**
  32203. * Releases resources associated with this node.
  32204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32206. */
  32207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32208. /**
  32209. * Parse animation range data from a serialization object and store them into a given node
  32210. * @param node defines where to store the animation ranges
  32211. * @param parsedNode defines the serialization object to read data from
  32212. * @param scene defines the hosting scene
  32213. */
  32214. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32215. /**
  32216. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32217. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32218. * @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
  32219. * @returns the new bounding vectors
  32220. */
  32221. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32222. min: Vector3;
  32223. max: Vector3;
  32224. };
  32225. }
  32226. }
  32227. declare module BABYLON {
  32228. /**
  32229. * @hidden
  32230. */
  32231. export class _IAnimationState {
  32232. key: number;
  32233. repeatCount: number;
  32234. workValue?: any;
  32235. loopMode?: number;
  32236. offsetValue?: any;
  32237. highLimitValue?: any;
  32238. }
  32239. /**
  32240. * Class used to store any kind of animation
  32241. */
  32242. export class Animation {
  32243. /**Name of the animation */
  32244. name: string;
  32245. /**Property to animate */
  32246. targetProperty: string;
  32247. /**The frames per second of the animation */
  32248. framePerSecond: number;
  32249. /**The data type of the animation */
  32250. dataType: number;
  32251. /**The loop mode of the animation */
  32252. loopMode?: number | undefined;
  32253. /**Specifies if blending should be enabled */
  32254. enableBlending?: boolean | undefined;
  32255. /**
  32256. * Use matrix interpolation instead of using direct key value when animating matrices
  32257. */
  32258. static AllowMatricesInterpolation: boolean;
  32259. /**
  32260. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32261. */
  32262. static AllowMatrixDecomposeForInterpolation: boolean;
  32263. /** Define the Url to load snippets */
  32264. static SnippetUrl: string;
  32265. /** Snippet ID if the animation was created from the snippet server */
  32266. snippetId: string;
  32267. /**
  32268. * Stores the key frames of the animation
  32269. */
  32270. private _keys;
  32271. /**
  32272. * Stores the easing function of the animation
  32273. */
  32274. private _easingFunction;
  32275. /**
  32276. * @hidden Internal use only
  32277. */
  32278. _runtimeAnimations: RuntimeAnimation[];
  32279. /**
  32280. * The set of event that will be linked to this animation
  32281. */
  32282. private _events;
  32283. /**
  32284. * Stores an array of target property paths
  32285. */
  32286. targetPropertyPath: string[];
  32287. /**
  32288. * Stores the blending speed of the animation
  32289. */
  32290. blendingSpeed: number;
  32291. /**
  32292. * Stores the animation ranges for the animation
  32293. */
  32294. private _ranges;
  32295. /**
  32296. * @hidden Internal use
  32297. */
  32298. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32299. /**
  32300. * Sets up an animation
  32301. * @param property The property to animate
  32302. * @param animationType The animation type to apply
  32303. * @param framePerSecond The frames per second of the animation
  32304. * @param easingFunction The easing function used in the animation
  32305. * @returns The created animation
  32306. */
  32307. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32308. /**
  32309. * Create and start an animation on a node
  32310. * @param name defines the name of the global animation that will be run on all nodes
  32311. * @param node defines the root node where the animation will take place
  32312. * @param targetProperty defines property to animate
  32313. * @param framePerSecond defines the number of frame per second yo use
  32314. * @param totalFrame defines the number of frames in total
  32315. * @param from defines the initial value
  32316. * @param to defines the final value
  32317. * @param loopMode defines which loop mode you want to use (off by default)
  32318. * @param easingFunction defines the easing function to use (linear by default)
  32319. * @param onAnimationEnd defines the callback to call when animation end
  32320. * @returns the animatable created for this animation
  32321. */
  32322. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32323. /**
  32324. * Create and start an animation on a node and its descendants
  32325. * @param name defines the name of the global animation that will be run on all nodes
  32326. * @param node defines the root node where the animation will take place
  32327. * @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
  32328. * @param targetProperty defines property to animate
  32329. * @param framePerSecond defines the number of frame per second to use
  32330. * @param totalFrame defines the number of frames in total
  32331. * @param from defines the initial value
  32332. * @param to defines the final value
  32333. * @param loopMode defines which loop mode you want to use (off by default)
  32334. * @param easingFunction defines the easing function to use (linear by default)
  32335. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32336. * @returns the list of animatables created for all nodes
  32337. * @example https://www.babylonjs-playground.com/#MH0VLI
  32338. */
  32339. 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[]>;
  32340. /**
  32341. * Creates a new animation, merges it with the existing animations and starts it
  32342. * @param name Name of the animation
  32343. * @param node Node which contains the scene that begins the animations
  32344. * @param targetProperty Specifies which property to animate
  32345. * @param framePerSecond The frames per second of the animation
  32346. * @param totalFrame The total number of frames
  32347. * @param from The frame at the beginning of the animation
  32348. * @param to The frame at the end of the animation
  32349. * @param loopMode Specifies the loop mode of the animation
  32350. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32351. * @param onAnimationEnd Callback to run once the animation is complete
  32352. * @returns Nullable animation
  32353. */
  32354. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32355. /**
  32356. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32357. * @param sourceAnimation defines the Animation containing keyframes to convert
  32358. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32359. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32360. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32361. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32362. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32363. */
  32364. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32365. /**
  32366. * Transition property of an host to the target Value
  32367. * @param property The property to transition
  32368. * @param targetValue The target Value of the property
  32369. * @param host The object where the property to animate belongs
  32370. * @param scene Scene used to run the animation
  32371. * @param frameRate Framerate (in frame/s) to use
  32372. * @param transition The transition type we want to use
  32373. * @param duration The duration of the animation, in milliseconds
  32374. * @param onAnimationEnd Callback trigger at the end of the animation
  32375. * @returns Nullable animation
  32376. */
  32377. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32378. /**
  32379. * Return the array of runtime animations currently using this animation
  32380. */
  32381. get runtimeAnimations(): RuntimeAnimation[];
  32382. /**
  32383. * Specifies if any of the runtime animations are currently running
  32384. */
  32385. get hasRunningRuntimeAnimations(): boolean;
  32386. /**
  32387. * Initializes the animation
  32388. * @param name Name of the animation
  32389. * @param targetProperty Property to animate
  32390. * @param framePerSecond The frames per second of the animation
  32391. * @param dataType The data type of the animation
  32392. * @param loopMode The loop mode of the animation
  32393. * @param enableBlending Specifies if blending should be enabled
  32394. */
  32395. constructor(
  32396. /**Name of the animation */
  32397. name: string,
  32398. /**Property to animate */
  32399. targetProperty: string,
  32400. /**The frames per second of the animation */
  32401. framePerSecond: number,
  32402. /**The data type of the animation */
  32403. dataType: number,
  32404. /**The loop mode of the animation */
  32405. loopMode?: number | undefined,
  32406. /**Specifies if blending should be enabled */
  32407. enableBlending?: boolean | undefined);
  32408. /**
  32409. * Converts the animation to a string
  32410. * @param fullDetails support for multiple levels of logging within scene loading
  32411. * @returns String form of the animation
  32412. */
  32413. toString(fullDetails?: boolean): string;
  32414. /**
  32415. * Add an event to this animation
  32416. * @param event Event to add
  32417. */
  32418. addEvent(event: AnimationEvent): void;
  32419. /**
  32420. * Remove all events found at the given frame
  32421. * @param frame The frame to remove events from
  32422. */
  32423. removeEvents(frame: number): void;
  32424. /**
  32425. * Retrieves all the events from the animation
  32426. * @returns Events from the animation
  32427. */
  32428. getEvents(): AnimationEvent[];
  32429. /**
  32430. * Creates an animation range
  32431. * @param name Name of the animation range
  32432. * @param from Starting frame of the animation range
  32433. * @param to Ending frame of the animation
  32434. */
  32435. createRange(name: string, from: number, to: number): void;
  32436. /**
  32437. * Deletes an animation range by name
  32438. * @param name Name of the animation range to delete
  32439. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32440. */
  32441. deleteRange(name: string, deleteFrames?: boolean): void;
  32442. /**
  32443. * Gets the animation range by name, or null if not defined
  32444. * @param name Name of the animation range
  32445. * @returns Nullable animation range
  32446. */
  32447. getRange(name: string): Nullable<AnimationRange>;
  32448. /**
  32449. * Gets the key frames from the animation
  32450. * @returns The key frames of the animation
  32451. */
  32452. getKeys(): Array<IAnimationKey>;
  32453. /**
  32454. * Gets the highest frame rate of the animation
  32455. * @returns Highest frame rate of the animation
  32456. */
  32457. getHighestFrame(): number;
  32458. /**
  32459. * Gets the easing function of the animation
  32460. * @returns Easing function of the animation
  32461. */
  32462. getEasingFunction(): IEasingFunction;
  32463. /**
  32464. * Sets the easing function of the animation
  32465. * @param easingFunction A custom mathematical formula for animation
  32466. */
  32467. setEasingFunction(easingFunction: EasingFunction): void;
  32468. /**
  32469. * Interpolates a scalar linearly
  32470. * @param startValue Start value of the animation curve
  32471. * @param endValue End value of the animation curve
  32472. * @param gradient Scalar amount to interpolate
  32473. * @returns Interpolated scalar value
  32474. */
  32475. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32476. /**
  32477. * Interpolates a scalar cubically
  32478. * @param startValue Start value of the animation curve
  32479. * @param outTangent End tangent of the animation
  32480. * @param endValue End value of the animation curve
  32481. * @param inTangent Start tangent of the animation curve
  32482. * @param gradient Scalar amount to interpolate
  32483. * @returns Interpolated scalar value
  32484. */
  32485. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32486. /**
  32487. * Interpolates a quaternion using a spherical linear interpolation
  32488. * @param startValue Start value of the animation curve
  32489. * @param endValue End value of the animation curve
  32490. * @param gradient Scalar amount to interpolate
  32491. * @returns Interpolated quaternion value
  32492. */
  32493. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32494. /**
  32495. * Interpolates a quaternion cubically
  32496. * @param startValue Start value of the animation curve
  32497. * @param outTangent End tangent of the animation curve
  32498. * @param endValue End value of the animation curve
  32499. * @param inTangent Start tangent of the animation curve
  32500. * @param gradient Scalar amount to interpolate
  32501. * @returns Interpolated quaternion value
  32502. */
  32503. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32504. /**
  32505. * Interpolates a Vector3 linearl
  32506. * @param startValue Start value of the animation curve
  32507. * @param endValue End value of the animation curve
  32508. * @param gradient Scalar amount to interpolate
  32509. * @returns Interpolated scalar value
  32510. */
  32511. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32512. /**
  32513. * Interpolates a Vector3 cubically
  32514. * @param startValue Start value of the animation curve
  32515. * @param outTangent End tangent of the animation
  32516. * @param endValue End value of the animation curve
  32517. * @param inTangent Start tangent of the animation curve
  32518. * @param gradient Scalar amount to interpolate
  32519. * @returns InterpolatedVector3 value
  32520. */
  32521. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32522. /**
  32523. * Interpolates a Vector2 linearly
  32524. * @param startValue Start value of the animation curve
  32525. * @param endValue End value of the animation curve
  32526. * @param gradient Scalar amount to interpolate
  32527. * @returns Interpolated Vector2 value
  32528. */
  32529. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32530. /**
  32531. * Interpolates a Vector2 cubically
  32532. * @param startValue Start value of the animation curve
  32533. * @param outTangent End tangent of the animation
  32534. * @param endValue End value of the animation curve
  32535. * @param inTangent Start tangent of the animation curve
  32536. * @param gradient Scalar amount to interpolate
  32537. * @returns Interpolated Vector2 value
  32538. */
  32539. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32540. /**
  32541. * Interpolates a size linearly
  32542. * @param startValue Start value of the animation curve
  32543. * @param endValue End value of the animation curve
  32544. * @param gradient Scalar amount to interpolate
  32545. * @returns Interpolated Size value
  32546. */
  32547. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32548. /**
  32549. * Interpolates a Color3 linearly
  32550. * @param startValue Start value of the animation curve
  32551. * @param endValue End value of the animation curve
  32552. * @param gradient Scalar amount to interpolate
  32553. * @returns Interpolated Color3 value
  32554. */
  32555. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32556. /**
  32557. * Interpolates a Color4 linearly
  32558. * @param startValue Start value of the animation curve
  32559. * @param endValue End value of the animation curve
  32560. * @param gradient Scalar amount to interpolate
  32561. * @returns Interpolated Color3 value
  32562. */
  32563. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32564. /**
  32565. * @hidden Internal use only
  32566. */
  32567. _getKeyValue(value: any): any;
  32568. /**
  32569. * @hidden Internal use only
  32570. */
  32571. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32572. /**
  32573. * Defines the function to use to interpolate matrices
  32574. * @param startValue defines the start matrix
  32575. * @param endValue defines the end matrix
  32576. * @param gradient defines the gradient between both matrices
  32577. * @param result defines an optional target matrix where to store the interpolation
  32578. * @returns the interpolated matrix
  32579. */
  32580. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32581. /**
  32582. * Makes a copy of the animation
  32583. * @returns Cloned animation
  32584. */
  32585. clone(): Animation;
  32586. /**
  32587. * Sets the key frames of the animation
  32588. * @param values The animation key frames to set
  32589. */
  32590. setKeys(values: Array<IAnimationKey>): void;
  32591. /**
  32592. * Serializes the animation to an object
  32593. * @returns Serialized object
  32594. */
  32595. serialize(): any;
  32596. /**
  32597. * Float animation type
  32598. */
  32599. static readonly ANIMATIONTYPE_FLOAT: number;
  32600. /**
  32601. * Vector3 animation type
  32602. */
  32603. static readonly ANIMATIONTYPE_VECTOR3: number;
  32604. /**
  32605. * Quaternion animation type
  32606. */
  32607. static readonly ANIMATIONTYPE_QUATERNION: number;
  32608. /**
  32609. * Matrix animation type
  32610. */
  32611. static readonly ANIMATIONTYPE_MATRIX: number;
  32612. /**
  32613. * Color3 animation type
  32614. */
  32615. static readonly ANIMATIONTYPE_COLOR3: number;
  32616. /**
  32617. * Color3 animation type
  32618. */
  32619. static readonly ANIMATIONTYPE_COLOR4: number;
  32620. /**
  32621. * Vector2 animation type
  32622. */
  32623. static readonly ANIMATIONTYPE_VECTOR2: number;
  32624. /**
  32625. * Size animation type
  32626. */
  32627. static readonly ANIMATIONTYPE_SIZE: number;
  32628. /**
  32629. * Relative Loop Mode
  32630. */
  32631. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32632. /**
  32633. * Cycle Loop Mode
  32634. */
  32635. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32636. /**
  32637. * Constant Loop Mode
  32638. */
  32639. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32640. /** @hidden */
  32641. static _UniversalLerp(left: any, right: any, amount: number): any;
  32642. /**
  32643. * Parses an animation object and creates an animation
  32644. * @param parsedAnimation Parsed animation object
  32645. * @returns Animation object
  32646. */
  32647. static Parse(parsedAnimation: any): Animation;
  32648. /**
  32649. * Appends the serialized animations from the source animations
  32650. * @param source Source containing the animations
  32651. * @param destination Target to store the animations
  32652. */
  32653. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32654. /**
  32655. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32656. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32657. * @param url defines the url to load from
  32658. * @returns a promise that will resolve to the new animation or an array of animations
  32659. */
  32660. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32661. /**
  32662. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32663. * @param snippetId defines the snippet to load
  32664. * @returns a promise that will resolve to the new animation or a new array of animations
  32665. */
  32666. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32667. }
  32668. }
  32669. declare module BABYLON {
  32670. /**
  32671. * Interface containing an array of animations
  32672. */
  32673. export interface IAnimatable {
  32674. /**
  32675. * Array of animations
  32676. */
  32677. animations: Nullable<Array<Animation>>;
  32678. }
  32679. }
  32680. declare module BABYLON {
  32681. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32682. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32683. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32684. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32685. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32686. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32687. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32688. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32689. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32690. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32691. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32692. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32693. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32694. /**
  32695. * Decorator used to define property that can be serialized as reference to a camera
  32696. * @param sourceName defines the name of the property to decorate
  32697. */
  32698. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32699. /**
  32700. * Class used to help serialization objects
  32701. */
  32702. export class SerializationHelper {
  32703. /** @hidden */
  32704. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32705. /** @hidden */
  32706. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32707. /** @hidden */
  32708. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32709. /** @hidden */
  32710. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32711. /**
  32712. * Appends the serialized animations from the source animations
  32713. * @param source Source containing the animations
  32714. * @param destination Target to store the animations
  32715. */
  32716. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32717. /**
  32718. * Static function used to serialized a specific entity
  32719. * @param entity defines the entity to serialize
  32720. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32721. * @returns a JSON compatible object representing the serialization of the entity
  32722. */
  32723. static Serialize<T>(entity: T, serializationObject?: any): any;
  32724. /**
  32725. * Creates a new entity from a serialization data object
  32726. * @param creationFunction defines a function used to instanciated the new entity
  32727. * @param source defines the source serialization data
  32728. * @param scene defines the hosting scene
  32729. * @param rootUrl defines the root url for resources
  32730. * @returns a new entity
  32731. */
  32732. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32733. /**
  32734. * Clones an object
  32735. * @param creationFunction defines the function used to instanciate the new object
  32736. * @param source defines the source object
  32737. * @returns the cloned object
  32738. */
  32739. static Clone<T>(creationFunction: () => T, source: T): T;
  32740. /**
  32741. * Instanciates a new object based on a source one (some data will be shared between both object)
  32742. * @param creationFunction defines the function used to instanciate the new object
  32743. * @param source defines the source object
  32744. * @returns the new object
  32745. */
  32746. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32747. }
  32748. }
  32749. declare module BABYLON {
  32750. /**
  32751. * Base class of all the textures in babylon.
  32752. * It groups all the common properties the materials, post process, lights... might need
  32753. * in order to make a correct use of the texture.
  32754. */
  32755. export class BaseTexture implements IAnimatable {
  32756. /**
  32757. * Default anisotropic filtering level for the application.
  32758. * It is set to 4 as a good tradeoff between perf and quality.
  32759. */
  32760. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32761. /**
  32762. * Gets or sets the unique id of the texture
  32763. */
  32764. uniqueId: number;
  32765. /**
  32766. * Define the name of the texture.
  32767. */
  32768. name: string;
  32769. /**
  32770. * Gets or sets an object used to store user defined information.
  32771. */
  32772. metadata: any;
  32773. /**
  32774. * For internal use only. Please do not use.
  32775. */
  32776. reservedDataStore: any;
  32777. private _hasAlpha;
  32778. /**
  32779. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32780. */
  32781. set hasAlpha(value: boolean);
  32782. get hasAlpha(): boolean;
  32783. /**
  32784. * Defines if the alpha value should be determined via the rgb values.
  32785. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32786. */
  32787. getAlphaFromRGB: boolean;
  32788. /**
  32789. * Intensity or strength of the texture.
  32790. * It is commonly used by materials to fine tune the intensity of the texture
  32791. */
  32792. level: number;
  32793. /**
  32794. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32795. * This is part of the texture as textures usually maps to one uv set.
  32796. */
  32797. coordinatesIndex: number;
  32798. private _coordinatesMode;
  32799. /**
  32800. * How a texture is mapped.
  32801. *
  32802. * | Value | Type | Description |
  32803. * | ----- | ----------------------------------- | ----------- |
  32804. * | 0 | EXPLICIT_MODE | |
  32805. * | 1 | SPHERICAL_MODE | |
  32806. * | 2 | PLANAR_MODE | |
  32807. * | 3 | CUBIC_MODE | |
  32808. * | 4 | PROJECTION_MODE | |
  32809. * | 5 | SKYBOX_MODE | |
  32810. * | 6 | INVCUBIC_MODE | |
  32811. * | 7 | EQUIRECTANGULAR_MODE | |
  32812. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32813. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32814. */
  32815. set coordinatesMode(value: number);
  32816. get coordinatesMode(): number;
  32817. /**
  32818. * | Value | Type | Description |
  32819. * | ----- | ------------------ | ----------- |
  32820. * | 0 | CLAMP_ADDRESSMODE | |
  32821. * | 1 | WRAP_ADDRESSMODE | |
  32822. * | 2 | MIRROR_ADDRESSMODE | |
  32823. */
  32824. wrapU: number;
  32825. /**
  32826. * | Value | Type | Description |
  32827. * | ----- | ------------------ | ----------- |
  32828. * | 0 | CLAMP_ADDRESSMODE | |
  32829. * | 1 | WRAP_ADDRESSMODE | |
  32830. * | 2 | MIRROR_ADDRESSMODE | |
  32831. */
  32832. wrapV: number;
  32833. /**
  32834. * | Value | Type | Description |
  32835. * | ----- | ------------------ | ----------- |
  32836. * | 0 | CLAMP_ADDRESSMODE | |
  32837. * | 1 | WRAP_ADDRESSMODE | |
  32838. * | 2 | MIRROR_ADDRESSMODE | |
  32839. */
  32840. wrapR: number;
  32841. /**
  32842. * With compliant hardware and browser (supporting anisotropic filtering)
  32843. * this defines the level of anisotropic filtering in the texture.
  32844. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32845. */
  32846. anisotropicFilteringLevel: number;
  32847. /**
  32848. * Define if the texture is a cube texture or if false a 2d texture.
  32849. */
  32850. get isCube(): boolean;
  32851. set isCube(value: boolean);
  32852. /**
  32853. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32854. */
  32855. get is3D(): boolean;
  32856. set is3D(value: boolean);
  32857. /**
  32858. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32859. */
  32860. get is2DArray(): boolean;
  32861. set is2DArray(value: boolean);
  32862. /**
  32863. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32864. * HDR texture are usually stored in linear space.
  32865. * This only impacts the PBR and Background materials
  32866. */
  32867. gammaSpace: boolean;
  32868. /**
  32869. * Gets or sets whether or not the texture contains RGBD data.
  32870. */
  32871. get isRGBD(): boolean;
  32872. set isRGBD(value: boolean);
  32873. /**
  32874. * Is Z inverted in the texture (useful in a cube texture).
  32875. */
  32876. invertZ: boolean;
  32877. /**
  32878. * Are mip maps generated for this texture or not.
  32879. */
  32880. get noMipmap(): boolean;
  32881. /**
  32882. * @hidden
  32883. */
  32884. lodLevelInAlpha: boolean;
  32885. /**
  32886. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32887. */
  32888. get lodGenerationOffset(): number;
  32889. set lodGenerationOffset(value: number);
  32890. /**
  32891. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32892. */
  32893. get lodGenerationScale(): number;
  32894. set lodGenerationScale(value: number);
  32895. /**
  32896. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32897. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32898. * average roughness values.
  32899. */
  32900. get linearSpecularLOD(): boolean;
  32901. set linearSpecularLOD(value: boolean);
  32902. /**
  32903. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32904. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32905. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32906. */
  32907. get irradianceTexture(): Nullable<BaseTexture>;
  32908. set irradianceTexture(value: Nullable<BaseTexture>);
  32909. /**
  32910. * Define if the texture is a render target.
  32911. */
  32912. isRenderTarget: boolean;
  32913. /**
  32914. * Define the unique id of the texture in the scene.
  32915. */
  32916. get uid(): string;
  32917. /** @hidden */
  32918. _prefiltered: boolean;
  32919. /**
  32920. * Return a string representation of the texture.
  32921. * @returns the texture as a string
  32922. */
  32923. toString(): string;
  32924. /**
  32925. * Get the class name of the texture.
  32926. * @returns "BaseTexture"
  32927. */
  32928. getClassName(): string;
  32929. /**
  32930. * Define the list of animation attached to the texture.
  32931. */
  32932. animations: Animation[];
  32933. /**
  32934. * An event triggered when the texture is disposed.
  32935. */
  32936. onDisposeObservable: Observable<BaseTexture>;
  32937. private _onDisposeObserver;
  32938. /**
  32939. * Callback triggered when the texture has been disposed.
  32940. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32941. */
  32942. set onDispose(callback: () => void);
  32943. /**
  32944. * Define the current state of the loading sequence when in delayed load mode.
  32945. */
  32946. delayLoadState: number;
  32947. private _scene;
  32948. private _engine;
  32949. /** @hidden */
  32950. _texture: Nullable<InternalTexture>;
  32951. private _uid;
  32952. /**
  32953. * Define if the texture is preventinga material to render or not.
  32954. * If not and the texture is not ready, the engine will use a default black texture instead.
  32955. */
  32956. get isBlocking(): boolean;
  32957. /**
  32958. * Instantiates a new BaseTexture.
  32959. * Base class of all the textures in babylon.
  32960. * It groups all the common properties the materials, post process, lights... might need
  32961. * in order to make a correct use of the texture.
  32962. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32963. */
  32964. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32965. /**
  32966. * Get the scene the texture belongs to.
  32967. * @returns the scene or null if undefined
  32968. */
  32969. getScene(): Nullable<Scene>;
  32970. /** @hidden */
  32971. protected _getEngine(): Nullable<ThinEngine>;
  32972. /**
  32973. * Get the texture transform matrix used to offset tile the texture for istance.
  32974. * @returns the transformation matrix
  32975. */
  32976. getTextureMatrix(): Matrix;
  32977. /**
  32978. * Get the texture reflection matrix used to rotate/transform the reflection.
  32979. * @returns the reflection matrix
  32980. */
  32981. getReflectionTextureMatrix(): Matrix;
  32982. /**
  32983. * Get the underlying lower level texture from Babylon.
  32984. * @returns the insternal texture
  32985. */
  32986. getInternalTexture(): Nullable<InternalTexture>;
  32987. /**
  32988. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32989. * @returns true if ready or not blocking
  32990. */
  32991. isReadyOrNotBlocking(): boolean;
  32992. /**
  32993. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32994. * @returns true if fully ready
  32995. */
  32996. isReady(): boolean;
  32997. private _cachedSize;
  32998. /**
  32999. * Get the size of the texture.
  33000. * @returns the texture size.
  33001. */
  33002. getSize(): ISize;
  33003. /**
  33004. * Get the base size of the texture.
  33005. * It can be different from the size if the texture has been resized for POT for instance
  33006. * @returns the base size
  33007. */
  33008. getBaseSize(): ISize;
  33009. /**
  33010. * Update the sampling mode of the texture.
  33011. * Default is Trilinear mode.
  33012. *
  33013. * | Value | Type | Description |
  33014. * | ----- | ------------------ | ----------- |
  33015. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33016. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33017. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33018. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33019. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33020. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33021. * | 7 | NEAREST_LINEAR | |
  33022. * | 8 | NEAREST_NEAREST | |
  33023. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33024. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33025. * | 11 | LINEAR_LINEAR | |
  33026. * | 12 | LINEAR_NEAREST | |
  33027. *
  33028. * > _mag_: magnification filter (close to the viewer)
  33029. * > _min_: minification filter (far from the viewer)
  33030. * > _mip_: filter used between mip map levels
  33031. *@param samplingMode Define the new sampling mode of the texture
  33032. */
  33033. updateSamplingMode(samplingMode: number): void;
  33034. /**
  33035. * Scales the texture if is `canRescale()`
  33036. * @param ratio the resize factor we want to use to rescale
  33037. */
  33038. scale(ratio: number): void;
  33039. /**
  33040. * Get if the texture can rescale.
  33041. */
  33042. get canRescale(): boolean;
  33043. /** @hidden */
  33044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33045. /** @hidden */
  33046. _rebuild(): void;
  33047. /**
  33048. * Triggers the load sequence in delayed load mode.
  33049. */
  33050. delayLoad(): void;
  33051. /**
  33052. * Clones the texture.
  33053. * @returns the cloned texture
  33054. */
  33055. clone(): Nullable<BaseTexture>;
  33056. /**
  33057. * Get the texture underlying type (INT, FLOAT...)
  33058. */
  33059. get textureType(): number;
  33060. /**
  33061. * Get the texture underlying format (RGB, RGBA...)
  33062. */
  33063. get textureFormat(): number;
  33064. /**
  33065. * Indicates that textures need to be re-calculated for all materials
  33066. */
  33067. protected _markAllSubMeshesAsTexturesDirty(): void;
  33068. /**
  33069. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33070. * This will returns an RGBA array buffer containing either in values (0-255) or
  33071. * float values (0-1) depending of the underlying buffer type.
  33072. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33073. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33074. * @param buffer defines a user defined buffer to fill with data (can be null)
  33075. * @returns The Array buffer containing the pixels data.
  33076. */
  33077. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33078. /**
  33079. * Release and destroy the underlying lower level texture aka internalTexture.
  33080. */
  33081. releaseInternalTexture(): void;
  33082. /** @hidden */
  33083. get _lodTextureHigh(): Nullable<BaseTexture>;
  33084. /** @hidden */
  33085. get _lodTextureMid(): Nullable<BaseTexture>;
  33086. /** @hidden */
  33087. get _lodTextureLow(): Nullable<BaseTexture>;
  33088. /**
  33089. * Dispose the texture and release its associated resources.
  33090. */
  33091. dispose(): void;
  33092. /**
  33093. * Serialize the texture into a JSON representation that can be parsed later on.
  33094. * @returns the JSON representation of the texture
  33095. */
  33096. serialize(): any;
  33097. /**
  33098. * Helper function to be called back once a list of texture contains only ready textures.
  33099. * @param textures Define the list of textures to wait for
  33100. * @param callback Define the callback triggered once the entire list will be ready
  33101. */
  33102. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33103. private static _isScene;
  33104. }
  33105. }
  33106. declare module BABYLON {
  33107. /**
  33108. * Options to be used when creating an effect.
  33109. */
  33110. export interface IEffectCreationOptions {
  33111. /**
  33112. * Atrributes that will be used in the shader.
  33113. */
  33114. attributes: string[];
  33115. /**
  33116. * Uniform varible names that will be set in the shader.
  33117. */
  33118. uniformsNames: string[];
  33119. /**
  33120. * Uniform buffer variable names that will be set in the shader.
  33121. */
  33122. uniformBuffersNames: string[];
  33123. /**
  33124. * Sampler texture variable names that will be set in the shader.
  33125. */
  33126. samplers: string[];
  33127. /**
  33128. * Define statements that will be set in the shader.
  33129. */
  33130. defines: any;
  33131. /**
  33132. * Possible fallbacks for this effect to improve performance when needed.
  33133. */
  33134. fallbacks: Nullable<IEffectFallbacks>;
  33135. /**
  33136. * Callback that will be called when the shader is compiled.
  33137. */
  33138. onCompiled: Nullable<(effect: Effect) => void>;
  33139. /**
  33140. * Callback that will be called if an error occurs during shader compilation.
  33141. */
  33142. onError: Nullable<(effect: Effect, errors: string) => void>;
  33143. /**
  33144. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33145. */
  33146. indexParameters?: any;
  33147. /**
  33148. * Max number of lights that can be used in the shader.
  33149. */
  33150. maxSimultaneousLights?: number;
  33151. /**
  33152. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33153. */
  33154. transformFeedbackVaryings?: Nullable<string[]>;
  33155. /**
  33156. * 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
  33157. */
  33158. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33159. }
  33160. /**
  33161. * Effect containing vertex and fragment shader that can be executed on an object.
  33162. */
  33163. export class Effect implements IDisposable {
  33164. /**
  33165. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33166. */
  33167. static ShadersRepository: string;
  33168. /**
  33169. * Enable logging of the shader code when a compilation error occurs
  33170. */
  33171. static LogShaderCodeOnCompilationError: boolean;
  33172. /**
  33173. * Name of the effect.
  33174. */
  33175. name: any;
  33176. /**
  33177. * String container all the define statements that should be set on the shader.
  33178. */
  33179. defines: string;
  33180. /**
  33181. * Callback that will be called when the shader is compiled.
  33182. */
  33183. onCompiled: Nullable<(effect: Effect) => void>;
  33184. /**
  33185. * Callback that will be called if an error occurs during shader compilation.
  33186. */
  33187. onError: Nullable<(effect: Effect, errors: string) => void>;
  33188. /**
  33189. * Callback that will be called when effect is bound.
  33190. */
  33191. onBind: Nullable<(effect: Effect) => void>;
  33192. /**
  33193. * Unique ID of the effect.
  33194. */
  33195. uniqueId: number;
  33196. /**
  33197. * Observable that will be called when the shader is compiled.
  33198. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33199. */
  33200. onCompileObservable: Observable<Effect>;
  33201. /**
  33202. * Observable that will be called if an error occurs during shader compilation.
  33203. */
  33204. onErrorObservable: Observable<Effect>;
  33205. /** @hidden */
  33206. _onBindObservable: Nullable<Observable<Effect>>;
  33207. /**
  33208. * @hidden
  33209. * Specifies if the effect was previously ready
  33210. */
  33211. _wasPreviouslyReady: boolean;
  33212. /**
  33213. * Observable that will be called when effect is bound.
  33214. */
  33215. get onBindObservable(): Observable<Effect>;
  33216. /** @hidden */
  33217. _bonesComputationForcedToCPU: boolean;
  33218. private static _uniqueIdSeed;
  33219. private _engine;
  33220. private _uniformBuffersNames;
  33221. private _uniformBuffersNamesList;
  33222. private _uniformsNames;
  33223. private _samplerList;
  33224. private _samplers;
  33225. private _isReady;
  33226. private _compilationError;
  33227. private _allFallbacksProcessed;
  33228. private _attributesNames;
  33229. private _attributes;
  33230. private _attributeLocationByName;
  33231. private _uniforms;
  33232. /**
  33233. * Key for the effect.
  33234. * @hidden
  33235. */
  33236. _key: string;
  33237. private _indexParameters;
  33238. private _fallbacks;
  33239. private _vertexSourceCode;
  33240. private _fragmentSourceCode;
  33241. private _vertexSourceCodeOverride;
  33242. private _fragmentSourceCodeOverride;
  33243. private _transformFeedbackVaryings;
  33244. /**
  33245. * Compiled shader to webGL program.
  33246. * @hidden
  33247. */
  33248. _pipelineContext: Nullable<IPipelineContext>;
  33249. private _valueCache;
  33250. private static _baseCache;
  33251. /**
  33252. * Instantiates an effect.
  33253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33254. * @param baseName Name of the effect.
  33255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33257. * @param samplers List of sampler variables that will be passed to the shader.
  33258. * @param engine Engine to be used to render the effect
  33259. * @param defines Define statements to be added to the shader.
  33260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33261. * @param onCompiled Callback that will be called when the shader is compiled.
  33262. * @param onError Callback that will be called if an error occurs during shader compilation.
  33263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33264. */
  33265. 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);
  33266. private _useFinalCode;
  33267. /**
  33268. * Unique key for this effect
  33269. */
  33270. get key(): string;
  33271. /**
  33272. * If the effect has been compiled and prepared.
  33273. * @returns if the effect is compiled and prepared.
  33274. */
  33275. isReady(): boolean;
  33276. private _isReadyInternal;
  33277. /**
  33278. * The engine the effect was initialized with.
  33279. * @returns the engine.
  33280. */
  33281. getEngine(): Engine;
  33282. /**
  33283. * The pipeline context for this effect
  33284. * @returns the associated pipeline context
  33285. */
  33286. getPipelineContext(): Nullable<IPipelineContext>;
  33287. /**
  33288. * The set of names of attribute variables for the shader.
  33289. * @returns An array of attribute names.
  33290. */
  33291. getAttributesNames(): string[];
  33292. /**
  33293. * Returns the attribute at the given index.
  33294. * @param index The index of the attribute.
  33295. * @returns The location of the attribute.
  33296. */
  33297. getAttributeLocation(index: number): number;
  33298. /**
  33299. * Returns the attribute based on the name of the variable.
  33300. * @param name of the attribute to look up.
  33301. * @returns the attribute location.
  33302. */
  33303. getAttributeLocationByName(name: string): number;
  33304. /**
  33305. * The number of attributes.
  33306. * @returns the numnber of attributes.
  33307. */
  33308. getAttributesCount(): number;
  33309. /**
  33310. * Gets the index of a uniform variable.
  33311. * @param uniformName of the uniform to look up.
  33312. * @returns the index.
  33313. */
  33314. getUniformIndex(uniformName: string): number;
  33315. /**
  33316. * Returns the attribute based on the name of the variable.
  33317. * @param uniformName of the uniform to look up.
  33318. * @returns the location of the uniform.
  33319. */
  33320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33321. /**
  33322. * Returns an array of sampler variable names
  33323. * @returns The array of sampler variable names.
  33324. */
  33325. getSamplers(): string[];
  33326. /**
  33327. * Returns an array of uniform variable names
  33328. * @returns The array of uniform variable names.
  33329. */
  33330. getUniformNames(): string[];
  33331. /**
  33332. * Returns an array of uniform buffer variable names
  33333. * @returns The array of uniform buffer variable names.
  33334. */
  33335. getUniformBuffersNames(): string[];
  33336. /**
  33337. * Returns the index parameters used to create the effect
  33338. * @returns The index parameters object
  33339. */
  33340. getIndexParameters(): any;
  33341. /**
  33342. * The error from the last compilation.
  33343. * @returns the error string.
  33344. */
  33345. getCompilationError(): string;
  33346. /**
  33347. * Gets a boolean indicating that all fallbacks were used during compilation
  33348. * @returns true if all fallbacks were used
  33349. */
  33350. allFallbacksProcessed(): boolean;
  33351. /**
  33352. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33353. * @param func The callback to be used.
  33354. */
  33355. executeWhenCompiled(func: (effect: Effect) => void): void;
  33356. private _checkIsReady;
  33357. private _loadShader;
  33358. /**
  33359. * Gets the vertex shader source code of this effect
  33360. */
  33361. get vertexSourceCode(): string;
  33362. /**
  33363. * Gets the fragment shader source code of this effect
  33364. */
  33365. get fragmentSourceCode(): string;
  33366. /**
  33367. * Recompiles the webGL program
  33368. * @param vertexSourceCode The source code for the vertex shader.
  33369. * @param fragmentSourceCode The source code for the fragment shader.
  33370. * @param onCompiled Callback called when completed.
  33371. * @param onError Callback called on error.
  33372. * @hidden
  33373. */
  33374. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33375. /**
  33376. * Prepares the effect
  33377. * @hidden
  33378. */
  33379. _prepareEffect(): void;
  33380. private _getShaderCodeAndErrorLine;
  33381. private _processCompilationErrors;
  33382. /**
  33383. * Checks if the effect is supported. (Must be called after compilation)
  33384. */
  33385. get isSupported(): boolean;
  33386. /**
  33387. * Binds a texture to the engine to be used as output of the shader.
  33388. * @param channel Name of the output variable.
  33389. * @param texture Texture to bind.
  33390. * @hidden
  33391. */
  33392. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33393. /**
  33394. * Sets a texture on the engine to be used in the shader.
  33395. * @param channel Name of the sampler variable.
  33396. * @param texture Texture to set.
  33397. */
  33398. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33399. /**
  33400. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33401. * @param channel Name of the sampler variable.
  33402. * @param texture Texture to set.
  33403. */
  33404. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33405. /**
  33406. * Sets an array of textures on the engine to be used in the shader.
  33407. * @param channel Name of the variable.
  33408. * @param textures Textures to set.
  33409. */
  33410. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33411. /**
  33412. * 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)
  33413. * @param channel Name of the sampler variable.
  33414. * @param postProcess Post process to get the input texture from.
  33415. */
  33416. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33417. /**
  33418. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33419. * 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)
  33420. * @param channel Name of the sampler variable.
  33421. * @param postProcess Post process to get the output texture from.
  33422. */
  33423. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33424. /** @hidden */
  33425. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33426. /** @hidden */
  33427. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33428. /** @hidden */
  33429. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33430. /** @hidden */
  33431. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33432. /**
  33433. * Binds a buffer to a uniform.
  33434. * @param buffer Buffer to bind.
  33435. * @param name Name of the uniform variable to bind to.
  33436. */
  33437. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33438. /**
  33439. * Binds block to a uniform.
  33440. * @param blockName Name of the block to bind.
  33441. * @param index Index to bind.
  33442. */
  33443. bindUniformBlock(blockName: string, index: number): void;
  33444. /**
  33445. * Sets an interger value on a uniform variable.
  33446. * @param uniformName Name of the variable.
  33447. * @param value Value to be set.
  33448. * @returns this effect.
  33449. */
  33450. setInt(uniformName: string, value: number): Effect;
  33451. /**
  33452. * Sets an int array on a uniform variable.
  33453. * @param uniformName Name of the variable.
  33454. * @param array array to be set.
  33455. * @returns this effect.
  33456. */
  33457. setIntArray(uniformName: string, array: Int32Array): Effect;
  33458. /**
  33459. * 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)
  33460. * @param uniformName Name of the variable.
  33461. * @param array array to be set.
  33462. * @returns this effect.
  33463. */
  33464. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33465. /**
  33466. * 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)
  33467. * @param uniformName Name of the variable.
  33468. * @param array array to be set.
  33469. * @returns this effect.
  33470. */
  33471. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33472. /**
  33473. * 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)
  33474. * @param uniformName Name of the variable.
  33475. * @param array array to be set.
  33476. * @returns this effect.
  33477. */
  33478. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33479. /**
  33480. * Sets an float array on a uniform variable.
  33481. * @param uniformName Name of the variable.
  33482. * @param array array to be set.
  33483. * @returns this effect.
  33484. */
  33485. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33486. /**
  33487. * 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)
  33488. * @param uniformName Name of the variable.
  33489. * @param array array to be set.
  33490. * @returns this effect.
  33491. */
  33492. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33493. /**
  33494. * 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)
  33495. * @param uniformName Name of the variable.
  33496. * @param array array to be set.
  33497. * @returns this effect.
  33498. */
  33499. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33500. /**
  33501. * 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)
  33502. * @param uniformName Name of the variable.
  33503. * @param array array to be set.
  33504. * @returns this effect.
  33505. */
  33506. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33507. /**
  33508. * Sets an array on a uniform variable.
  33509. * @param uniformName Name of the variable.
  33510. * @param array array to be set.
  33511. * @returns this effect.
  33512. */
  33513. setArray(uniformName: string, array: number[]): Effect;
  33514. /**
  33515. * 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)
  33516. * @param uniformName Name of the variable.
  33517. * @param array array to be set.
  33518. * @returns this effect.
  33519. */
  33520. setArray2(uniformName: string, array: number[]): Effect;
  33521. /**
  33522. * 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)
  33523. * @param uniformName Name of the variable.
  33524. * @param array array to be set.
  33525. * @returns this effect.
  33526. */
  33527. setArray3(uniformName: string, array: number[]): Effect;
  33528. /**
  33529. * 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)
  33530. * @param uniformName Name of the variable.
  33531. * @param array array to be set.
  33532. * @returns this effect.
  33533. */
  33534. setArray4(uniformName: string, array: number[]): Effect;
  33535. /**
  33536. * Sets matrices on a uniform variable.
  33537. * @param uniformName Name of the variable.
  33538. * @param matrices matrices to be set.
  33539. * @returns this effect.
  33540. */
  33541. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33542. /**
  33543. * Sets matrix on a uniform variable.
  33544. * @param uniformName Name of the variable.
  33545. * @param matrix matrix to be set.
  33546. * @returns this effect.
  33547. */
  33548. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33549. /**
  33550. * 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)
  33551. * @param uniformName Name of the variable.
  33552. * @param matrix matrix to be set.
  33553. * @returns this effect.
  33554. */
  33555. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33556. /**
  33557. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33558. * @param uniformName Name of the variable.
  33559. * @param matrix matrix to be set.
  33560. * @returns this effect.
  33561. */
  33562. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33563. /**
  33564. * Sets a float on a uniform variable.
  33565. * @param uniformName Name of the variable.
  33566. * @param value value to be set.
  33567. * @returns this effect.
  33568. */
  33569. setFloat(uniformName: string, value: number): Effect;
  33570. /**
  33571. * Sets a boolean on a uniform variable.
  33572. * @param uniformName Name of the variable.
  33573. * @param bool value to be set.
  33574. * @returns this effect.
  33575. */
  33576. setBool(uniformName: string, bool: boolean): Effect;
  33577. /**
  33578. * Sets a Vector2 on a uniform variable.
  33579. * @param uniformName Name of the variable.
  33580. * @param vector2 vector2 to be set.
  33581. * @returns this effect.
  33582. */
  33583. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33584. /**
  33585. * Sets a float2 on a uniform variable.
  33586. * @param uniformName Name of the variable.
  33587. * @param x First float in float2.
  33588. * @param y Second float in float2.
  33589. * @returns this effect.
  33590. */
  33591. setFloat2(uniformName: string, x: number, y: number): Effect;
  33592. /**
  33593. * Sets a Vector3 on a uniform variable.
  33594. * @param uniformName Name of the variable.
  33595. * @param vector3 Value to be set.
  33596. * @returns this effect.
  33597. */
  33598. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33599. /**
  33600. * Sets a float3 on a uniform variable.
  33601. * @param uniformName Name of the variable.
  33602. * @param x First float in float3.
  33603. * @param y Second float in float3.
  33604. * @param z Third float in float3.
  33605. * @returns this effect.
  33606. */
  33607. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33608. /**
  33609. * Sets a Vector4 on a uniform variable.
  33610. * @param uniformName Name of the variable.
  33611. * @param vector4 Value to be set.
  33612. * @returns this effect.
  33613. */
  33614. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33615. /**
  33616. * Sets a float4 on a uniform variable.
  33617. * @param uniformName Name of the variable.
  33618. * @param x First float in float4.
  33619. * @param y Second float in float4.
  33620. * @param z Third float in float4.
  33621. * @param w Fourth float in float4.
  33622. * @returns this effect.
  33623. */
  33624. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33625. /**
  33626. * Sets a Color3 on a uniform variable.
  33627. * @param uniformName Name of the variable.
  33628. * @param color3 Value to be set.
  33629. * @returns this effect.
  33630. */
  33631. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33632. /**
  33633. * Sets a Color4 on a uniform variable.
  33634. * @param uniformName Name of the variable.
  33635. * @param color3 Value to be set.
  33636. * @param alpha Alpha value to be set.
  33637. * @returns this effect.
  33638. */
  33639. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33640. /**
  33641. * Sets a Color4 on a uniform variable
  33642. * @param uniformName defines the name of the variable
  33643. * @param color4 defines the value to be set
  33644. * @returns this effect.
  33645. */
  33646. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33647. /** Release all associated resources */
  33648. dispose(): void;
  33649. /**
  33650. * This function will add a new shader to the shader store
  33651. * @param name the name of the shader
  33652. * @param pixelShader optional pixel shader content
  33653. * @param vertexShader optional vertex shader content
  33654. */
  33655. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33656. /**
  33657. * Store of each shader (The can be looked up using effect.key)
  33658. */
  33659. static ShadersStore: {
  33660. [key: string]: string;
  33661. };
  33662. /**
  33663. * Store of each included file for a shader (The can be looked up using effect.key)
  33664. */
  33665. static IncludesShadersStore: {
  33666. [key: string]: string;
  33667. };
  33668. /**
  33669. * Resets the cache of effects.
  33670. */
  33671. static ResetCache(): void;
  33672. }
  33673. }
  33674. declare module BABYLON {
  33675. /**
  33676. * Interface used to describe the capabilities of the engine relatively to the current browser
  33677. */
  33678. export interface EngineCapabilities {
  33679. /** Maximum textures units per fragment shader */
  33680. maxTexturesImageUnits: number;
  33681. /** Maximum texture units per vertex shader */
  33682. maxVertexTextureImageUnits: number;
  33683. /** Maximum textures units in the entire pipeline */
  33684. maxCombinedTexturesImageUnits: number;
  33685. /** Maximum texture size */
  33686. maxTextureSize: number;
  33687. /** Maximum texture samples */
  33688. maxSamples?: number;
  33689. /** Maximum cube texture size */
  33690. maxCubemapTextureSize: number;
  33691. /** Maximum render texture size */
  33692. maxRenderTextureSize: number;
  33693. /** Maximum number of vertex attributes */
  33694. maxVertexAttribs: number;
  33695. /** Maximum number of varyings */
  33696. maxVaryingVectors: number;
  33697. /** Maximum number of uniforms per vertex shader */
  33698. maxVertexUniformVectors: number;
  33699. /** Maximum number of uniforms per fragment shader */
  33700. maxFragmentUniformVectors: number;
  33701. /** Defines if standard derivates (dx/dy) are supported */
  33702. standardDerivatives: boolean;
  33703. /** Defines if s3tc texture compression is supported */
  33704. s3tc?: WEBGL_compressed_texture_s3tc;
  33705. /** Defines if pvrtc texture compression is supported */
  33706. pvrtc: any;
  33707. /** Defines if etc1 texture compression is supported */
  33708. etc1: any;
  33709. /** Defines if etc2 texture compression is supported */
  33710. etc2: any;
  33711. /** Defines if astc texture compression is supported */
  33712. astc: any;
  33713. /** Defines if float textures are supported */
  33714. textureFloat: boolean;
  33715. /** Defines if vertex array objects are supported */
  33716. vertexArrayObject: boolean;
  33717. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33718. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33719. /** Gets the maximum level of anisotropy supported */
  33720. maxAnisotropy: number;
  33721. /** Defines if instancing is supported */
  33722. instancedArrays: boolean;
  33723. /** Defines if 32 bits indices are supported */
  33724. uintIndices: boolean;
  33725. /** Defines if high precision shaders are supported */
  33726. highPrecisionShaderSupported: boolean;
  33727. /** Defines if depth reading in the fragment shader is supported */
  33728. fragmentDepthSupported: boolean;
  33729. /** Defines if float texture linear filtering is supported*/
  33730. textureFloatLinearFiltering: boolean;
  33731. /** Defines if rendering to float textures is supported */
  33732. textureFloatRender: boolean;
  33733. /** Defines if half float textures are supported*/
  33734. textureHalfFloat: boolean;
  33735. /** Defines if half float texture linear filtering is supported*/
  33736. textureHalfFloatLinearFiltering: boolean;
  33737. /** Defines if rendering to half float textures is supported */
  33738. textureHalfFloatRender: boolean;
  33739. /** Defines if textureLOD shader command is supported */
  33740. textureLOD: boolean;
  33741. /** Defines if draw buffers extension is supported */
  33742. drawBuffersExtension: boolean;
  33743. /** Defines if depth textures are supported */
  33744. depthTextureExtension: boolean;
  33745. /** Defines if float color buffer are supported */
  33746. colorBufferFloat: boolean;
  33747. /** Gets disjoint timer query extension (null if not supported) */
  33748. timerQuery?: EXT_disjoint_timer_query;
  33749. /** Defines if timestamp can be used with timer query */
  33750. canUseTimestampForTimerQuery: boolean;
  33751. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33752. multiview?: any;
  33753. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33754. oculusMultiview?: any;
  33755. /** Function used to let the system compiles shaders in background */
  33756. parallelShaderCompile?: {
  33757. COMPLETION_STATUS_KHR: number;
  33758. };
  33759. /** Max number of texture samples for MSAA */
  33760. maxMSAASamples: number;
  33761. /** Defines if the blend min max extension is supported */
  33762. blendMinMax: boolean;
  33763. }
  33764. }
  33765. declare module BABYLON {
  33766. /**
  33767. * @hidden
  33768. **/
  33769. export class DepthCullingState {
  33770. private _isDepthTestDirty;
  33771. private _isDepthMaskDirty;
  33772. private _isDepthFuncDirty;
  33773. private _isCullFaceDirty;
  33774. private _isCullDirty;
  33775. private _isZOffsetDirty;
  33776. private _isFrontFaceDirty;
  33777. private _depthTest;
  33778. private _depthMask;
  33779. private _depthFunc;
  33780. private _cull;
  33781. private _cullFace;
  33782. private _zOffset;
  33783. private _frontFace;
  33784. /**
  33785. * Initializes the state.
  33786. */
  33787. constructor();
  33788. get isDirty(): boolean;
  33789. get zOffset(): number;
  33790. set zOffset(value: number);
  33791. get cullFace(): Nullable<number>;
  33792. set cullFace(value: Nullable<number>);
  33793. get cull(): Nullable<boolean>;
  33794. set cull(value: Nullable<boolean>);
  33795. get depthFunc(): Nullable<number>;
  33796. set depthFunc(value: Nullable<number>);
  33797. get depthMask(): boolean;
  33798. set depthMask(value: boolean);
  33799. get depthTest(): boolean;
  33800. set depthTest(value: boolean);
  33801. get frontFace(): Nullable<number>;
  33802. set frontFace(value: Nullable<number>);
  33803. reset(): void;
  33804. apply(gl: WebGLRenderingContext): void;
  33805. }
  33806. }
  33807. declare module BABYLON {
  33808. /**
  33809. * @hidden
  33810. **/
  33811. export class StencilState {
  33812. /** 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 */
  33813. static readonly ALWAYS: number;
  33814. /** Passed to stencilOperation to specify that stencil value must be kept */
  33815. static readonly KEEP: number;
  33816. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33817. static readonly REPLACE: number;
  33818. private _isStencilTestDirty;
  33819. private _isStencilMaskDirty;
  33820. private _isStencilFuncDirty;
  33821. private _isStencilOpDirty;
  33822. private _stencilTest;
  33823. private _stencilMask;
  33824. private _stencilFunc;
  33825. private _stencilFuncRef;
  33826. private _stencilFuncMask;
  33827. private _stencilOpStencilFail;
  33828. private _stencilOpDepthFail;
  33829. private _stencilOpStencilDepthPass;
  33830. get isDirty(): boolean;
  33831. get stencilFunc(): number;
  33832. set stencilFunc(value: number);
  33833. get stencilFuncRef(): number;
  33834. set stencilFuncRef(value: number);
  33835. get stencilFuncMask(): number;
  33836. set stencilFuncMask(value: number);
  33837. get stencilOpStencilFail(): number;
  33838. set stencilOpStencilFail(value: number);
  33839. get stencilOpDepthFail(): number;
  33840. set stencilOpDepthFail(value: number);
  33841. get stencilOpStencilDepthPass(): number;
  33842. set stencilOpStencilDepthPass(value: number);
  33843. get stencilMask(): number;
  33844. set stencilMask(value: number);
  33845. get stencilTest(): boolean;
  33846. set stencilTest(value: boolean);
  33847. constructor();
  33848. reset(): void;
  33849. apply(gl: WebGLRenderingContext): void;
  33850. }
  33851. }
  33852. declare module BABYLON {
  33853. /**
  33854. * @hidden
  33855. **/
  33856. export class AlphaState {
  33857. private _isAlphaBlendDirty;
  33858. private _isBlendFunctionParametersDirty;
  33859. private _isBlendEquationParametersDirty;
  33860. private _isBlendConstantsDirty;
  33861. private _alphaBlend;
  33862. private _blendFunctionParameters;
  33863. private _blendEquationParameters;
  33864. private _blendConstants;
  33865. /**
  33866. * Initializes the state.
  33867. */
  33868. constructor();
  33869. get isDirty(): boolean;
  33870. get alphaBlend(): boolean;
  33871. set alphaBlend(value: boolean);
  33872. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33873. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33874. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33875. reset(): void;
  33876. apply(gl: WebGLRenderingContext): void;
  33877. }
  33878. }
  33879. declare module BABYLON {
  33880. /** @hidden */
  33881. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33882. attributeProcessor(attribute: string): string;
  33883. varyingProcessor(varying: string, isFragment: boolean): string;
  33884. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * Interface for attribute information associated with buffer instanciation
  33890. */
  33891. export interface InstancingAttributeInfo {
  33892. /**
  33893. * Name of the GLSL attribute
  33894. * if attribute index is not specified, this is used to retrieve the index from the effect
  33895. */
  33896. attributeName: string;
  33897. /**
  33898. * Index/offset of the attribute in the vertex shader
  33899. * if not specified, this will be computes from the name.
  33900. */
  33901. index?: number;
  33902. /**
  33903. * size of the attribute, 1, 2, 3 or 4
  33904. */
  33905. attributeSize: number;
  33906. /**
  33907. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33908. */
  33909. offset: number;
  33910. /**
  33911. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33912. * default to 1
  33913. */
  33914. divisor?: number;
  33915. /**
  33916. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33917. * default is FLOAT
  33918. */
  33919. attributeType?: number;
  33920. /**
  33921. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33922. */
  33923. normalized?: boolean;
  33924. }
  33925. }
  33926. declare module BABYLON {
  33927. interface ThinEngine {
  33928. /**
  33929. * Update a video texture
  33930. * @param texture defines the texture to update
  33931. * @param video defines the video element to use
  33932. * @param invertY defines if data must be stored with Y axis inverted
  33933. */
  33934. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33935. }
  33936. }
  33937. declare module BABYLON {
  33938. /**
  33939. * Settings for finer control over video usage
  33940. */
  33941. export interface VideoTextureSettings {
  33942. /**
  33943. * Applies `autoplay` to video, if specified
  33944. */
  33945. autoPlay?: boolean;
  33946. /**
  33947. * Applies `loop` to video, if specified
  33948. */
  33949. loop?: boolean;
  33950. /**
  33951. * Automatically updates internal texture from video at every frame in the render loop
  33952. */
  33953. autoUpdateTexture: boolean;
  33954. /**
  33955. * Image src displayed during the video loading or until the user interacts with the video.
  33956. */
  33957. poster?: string;
  33958. }
  33959. /**
  33960. * If you want to display a video in your scene, this is the special texture for that.
  33961. * This special texture works similar to other textures, with the exception of a few parameters.
  33962. * @see https://doc.babylonjs.com/how_to/video_texture
  33963. */
  33964. export class VideoTexture extends Texture {
  33965. /**
  33966. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33967. */
  33968. readonly autoUpdateTexture: boolean;
  33969. /**
  33970. * The video instance used by the texture internally
  33971. */
  33972. readonly video: HTMLVideoElement;
  33973. private _onUserActionRequestedObservable;
  33974. /**
  33975. * Event triggerd when a dom action is required by the user to play the video.
  33976. * This happens due to recent changes in browser policies preventing video to auto start.
  33977. */
  33978. get onUserActionRequestedObservable(): Observable<Texture>;
  33979. private _generateMipMaps;
  33980. private _stillImageCaptured;
  33981. private _displayingPosterTexture;
  33982. private _settings;
  33983. private _createInternalTextureOnEvent;
  33984. private _frameId;
  33985. private _currentSrc;
  33986. /**
  33987. * Creates a video texture.
  33988. * If you want to display a video in your scene, this is the special texture for that.
  33989. * This special texture works similar to other textures, with the exception of a few parameters.
  33990. * @see https://doc.babylonjs.com/how_to/video_texture
  33991. * @param name optional name, will detect from video source, if not defined
  33992. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33993. * @param scene is obviously the current scene.
  33994. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33995. * @param invertY is false by default but can be used to invert video on Y axis
  33996. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33997. * @param settings allows finer control over video usage
  33998. */
  33999. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34000. private _getName;
  34001. private _getVideo;
  34002. private _createInternalTexture;
  34003. private reset;
  34004. /**
  34005. * @hidden Internal method to initiate `update`.
  34006. */
  34007. _rebuild(): void;
  34008. /**
  34009. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34010. */
  34011. update(): void;
  34012. /**
  34013. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34014. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34015. */
  34016. updateTexture(isVisible: boolean): void;
  34017. protected _updateInternalTexture: () => void;
  34018. /**
  34019. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34020. * @param url New url.
  34021. */
  34022. updateURL(url: string): void;
  34023. /**
  34024. * Clones the texture.
  34025. * @returns the cloned texture
  34026. */
  34027. clone(): VideoTexture;
  34028. /**
  34029. * Dispose the texture and release its associated resources.
  34030. */
  34031. dispose(): void;
  34032. /**
  34033. * Creates a video texture straight from a stream.
  34034. * @param scene Define the scene the texture should be created in
  34035. * @param stream Define the stream the texture should be created from
  34036. * @returns The created video texture as a promise
  34037. */
  34038. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34039. /**
  34040. * Creates a video texture straight from your WebCam video feed.
  34041. * @param scene Define the scene the texture should be created in
  34042. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34043. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34044. * @returns The created video texture as a promise
  34045. */
  34046. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34047. minWidth: number;
  34048. maxWidth: number;
  34049. minHeight: number;
  34050. maxHeight: number;
  34051. deviceId: string;
  34052. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34053. /**
  34054. * Creates a video texture straight from your WebCam video feed.
  34055. * @param scene Define the scene the texture should be created in
  34056. * @param onReady Define a callback to triggered once the texture will be ready
  34057. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34058. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34059. */
  34060. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34061. minWidth: number;
  34062. maxWidth: number;
  34063. minHeight: number;
  34064. maxHeight: number;
  34065. deviceId: string;
  34066. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34067. }
  34068. }
  34069. declare module BABYLON {
  34070. /**
  34071. * Defines the interface used by objects working like Scene
  34072. * @hidden
  34073. */
  34074. export interface ISceneLike {
  34075. _addPendingData(data: any): void;
  34076. _removePendingData(data: any): void;
  34077. offlineProvider: IOfflineProvider;
  34078. }
  34079. /** Interface defining initialization parameters for Engine class */
  34080. export interface EngineOptions extends WebGLContextAttributes {
  34081. /**
  34082. * Defines if the engine should no exceed a specified device ratio
  34083. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34084. */
  34085. limitDeviceRatio?: number;
  34086. /**
  34087. * Defines if webvr should be enabled automatically
  34088. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34089. */
  34090. autoEnableWebVR?: boolean;
  34091. /**
  34092. * Defines if webgl2 should be turned off even if supported
  34093. * @see http://doc.babylonjs.com/features/webgl2
  34094. */
  34095. disableWebGL2Support?: boolean;
  34096. /**
  34097. * Defines if webaudio should be initialized as well
  34098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34099. */
  34100. audioEngine?: boolean;
  34101. /**
  34102. * Defines if animations should run using a deterministic lock step
  34103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34104. */
  34105. deterministicLockstep?: boolean;
  34106. /** Defines the maximum steps to use with deterministic lock step mode */
  34107. lockstepMaxSteps?: number;
  34108. /** Defines the seconds between each deterministic lock step */
  34109. timeStep?: number;
  34110. /**
  34111. * Defines that engine should ignore context lost events
  34112. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34113. */
  34114. doNotHandleContextLost?: boolean;
  34115. /**
  34116. * Defines that engine should ignore modifying touch action attribute and style
  34117. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34118. */
  34119. doNotHandleTouchAction?: boolean;
  34120. /**
  34121. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34122. */
  34123. useHighPrecisionFloats?: boolean;
  34124. /**
  34125. * Make the canvas XR Compatible for XR sessions
  34126. */
  34127. xrCompatible?: boolean;
  34128. }
  34129. /**
  34130. * The base engine class (root of all engines)
  34131. */
  34132. export class ThinEngine {
  34133. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34134. static ExceptionList: ({
  34135. key: string;
  34136. capture: string;
  34137. captureConstraint: number;
  34138. targets: string[];
  34139. } | {
  34140. key: string;
  34141. capture: null;
  34142. captureConstraint: null;
  34143. targets: string[];
  34144. })[];
  34145. /** @hidden */
  34146. static _TextureLoaders: IInternalTextureLoader[];
  34147. /**
  34148. * Returns the current npm package of the sdk
  34149. */
  34150. static get NpmPackage(): string;
  34151. /**
  34152. * Returns the current version of the framework
  34153. */
  34154. static get Version(): string;
  34155. /**
  34156. * Returns a string describing the current engine
  34157. */
  34158. get description(): string;
  34159. /**
  34160. * Gets or sets the epsilon value used by collision engine
  34161. */
  34162. static CollisionsEpsilon: number;
  34163. /**
  34164. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34165. */
  34166. static get ShadersRepository(): string;
  34167. static set ShadersRepository(value: string);
  34168. /** @hidden */
  34169. _shaderProcessor: IShaderProcessor;
  34170. /**
  34171. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34172. */
  34173. forcePOTTextures: boolean;
  34174. /**
  34175. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34176. */
  34177. isFullscreen: boolean;
  34178. /**
  34179. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34180. */
  34181. cullBackFaces: boolean;
  34182. /**
  34183. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34184. */
  34185. renderEvenInBackground: boolean;
  34186. /**
  34187. * Gets or sets a boolean indicating that cache can be kept between frames
  34188. */
  34189. preventCacheWipeBetweenFrames: boolean;
  34190. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34191. validateShaderPrograms: boolean;
  34192. /**
  34193. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34194. * This can provide greater z depth for distant objects.
  34195. */
  34196. useReverseDepthBuffer: boolean;
  34197. /**
  34198. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34199. */
  34200. disableUniformBuffers: boolean;
  34201. /** @hidden */
  34202. _uniformBuffers: UniformBuffer[];
  34203. /**
  34204. * Gets a boolean indicating that the engine supports uniform buffers
  34205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34206. */
  34207. get supportsUniformBuffers(): boolean;
  34208. /** @hidden */
  34209. _gl: WebGLRenderingContext;
  34210. /** @hidden */
  34211. _webGLVersion: number;
  34212. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34213. protected _windowIsBackground: boolean;
  34214. protected _creationOptions: EngineOptions;
  34215. protected _highPrecisionShadersAllowed: boolean;
  34216. /** @hidden */
  34217. get _shouldUseHighPrecisionShader(): boolean;
  34218. /**
  34219. * Gets a boolean indicating that only power of 2 textures are supported
  34220. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34221. */
  34222. get needPOTTextures(): boolean;
  34223. /** @hidden */
  34224. _badOS: boolean;
  34225. /** @hidden */
  34226. _badDesktopOS: boolean;
  34227. private _hardwareScalingLevel;
  34228. /** @hidden */
  34229. _caps: EngineCapabilities;
  34230. private _isStencilEnable;
  34231. private _glVersion;
  34232. private _glRenderer;
  34233. private _glVendor;
  34234. /** @hidden */
  34235. _videoTextureSupported: boolean;
  34236. protected _renderingQueueLaunched: boolean;
  34237. protected _activeRenderLoops: (() => void)[];
  34238. /**
  34239. * Observable signaled when a context lost event is raised
  34240. */
  34241. onContextLostObservable: Observable<ThinEngine>;
  34242. /**
  34243. * Observable signaled when a context restored event is raised
  34244. */
  34245. onContextRestoredObservable: Observable<ThinEngine>;
  34246. private _onContextLost;
  34247. private _onContextRestored;
  34248. protected _contextWasLost: boolean;
  34249. /** @hidden */
  34250. _doNotHandleContextLost: boolean;
  34251. /**
  34252. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34254. */
  34255. get doNotHandleContextLost(): boolean;
  34256. set doNotHandleContextLost(value: boolean);
  34257. /**
  34258. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34259. */
  34260. disableVertexArrayObjects: boolean;
  34261. /** @hidden */
  34262. protected _colorWrite: boolean;
  34263. /** @hidden */
  34264. protected _colorWriteChanged: boolean;
  34265. /** @hidden */
  34266. protected _depthCullingState: DepthCullingState;
  34267. /** @hidden */
  34268. protected _stencilState: StencilState;
  34269. /** @hidden */
  34270. _alphaState: AlphaState;
  34271. /** @hidden */
  34272. _alphaMode: number;
  34273. /** @hidden */
  34274. _alphaEquation: number;
  34275. /** @hidden */
  34276. _internalTexturesCache: InternalTexture[];
  34277. /** @hidden */
  34278. protected _activeChannel: number;
  34279. private _currentTextureChannel;
  34280. /** @hidden */
  34281. protected _boundTexturesCache: {
  34282. [key: string]: Nullable<InternalTexture>;
  34283. };
  34284. /** @hidden */
  34285. protected _currentEffect: Nullable<Effect>;
  34286. /** @hidden */
  34287. protected _currentProgram: Nullable<WebGLProgram>;
  34288. private _compiledEffects;
  34289. private _vertexAttribArraysEnabled;
  34290. /** @hidden */
  34291. protected _cachedViewport: Nullable<IViewportLike>;
  34292. private _cachedVertexArrayObject;
  34293. /** @hidden */
  34294. protected _cachedVertexBuffers: any;
  34295. /** @hidden */
  34296. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34297. /** @hidden */
  34298. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34299. /** @hidden */
  34300. _currentRenderTarget: Nullable<InternalTexture>;
  34301. private _uintIndicesCurrentlySet;
  34302. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34303. /** @hidden */
  34304. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34305. /** @hidden */
  34306. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34307. private _currentBufferPointers;
  34308. private _currentInstanceLocations;
  34309. private _currentInstanceBuffers;
  34310. private _textureUnits;
  34311. /** @hidden */
  34312. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34313. /** @hidden */
  34314. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34315. /** @hidden */
  34316. _boundRenderFunction: any;
  34317. private _vaoRecordInProgress;
  34318. private _mustWipeVertexAttributes;
  34319. private _emptyTexture;
  34320. private _emptyCubeTexture;
  34321. private _emptyTexture3D;
  34322. private _emptyTexture2DArray;
  34323. /** @hidden */
  34324. _frameHandler: number;
  34325. private _nextFreeTextureSlots;
  34326. private _maxSimultaneousTextures;
  34327. private _activeRequests;
  34328. /** @hidden */
  34329. _transformTextureUrl: Nullable<(url: string) => string>;
  34330. protected get _supportsHardwareTextureRescaling(): boolean;
  34331. private _framebufferDimensionsObject;
  34332. /**
  34333. * sets the object from which width and height will be taken from when getting render width and height
  34334. * Will fallback to the gl object
  34335. * @param dimensions the framebuffer width and height that will be used.
  34336. */
  34337. set framebufferDimensionsObject(dimensions: Nullable<{
  34338. framebufferWidth: number;
  34339. framebufferHeight: number;
  34340. }>);
  34341. /**
  34342. * Gets the current viewport
  34343. */
  34344. get currentViewport(): Nullable<IViewportLike>;
  34345. /**
  34346. * Gets the default empty texture
  34347. */
  34348. get emptyTexture(): InternalTexture;
  34349. /**
  34350. * Gets the default empty 3D texture
  34351. */
  34352. get emptyTexture3D(): InternalTexture;
  34353. /**
  34354. * Gets the default empty 2D array texture
  34355. */
  34356. get emptyTexture2DArray(): InternalTexture;
  34357. /**
  34358. * Gets the default empty cube texture
  34359. */
  34360. get emptyCubeTexture(): InternalTexture;
  34361. /**
  34362. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34363. */
  34364. readonly premultipliedAlpha: boolean;
  34365. /**
  34366. * Observable event triggered before each texture is initialized
  34367. */
  34368. onBeforeTextureInitObservable: Observable<Texture>;
  34369. /**
  34370. * Creates a new engine
  34371. * @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
  34372. * @param antialias defines enable antialiasing (default: false)
  34373. * @param options defines further options to be sent to the getContext() function
  34374. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34375. */
  34376. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34377. private _rebuildInternalTextures;
  34378. private _rebuildEffects;
  34379. /**
  34380. * Gets a boolean indicating if all created effects are ready
  34381. * @returns true if all effects are ready
  34382. */
  34383. areAllEffectsReady(): boolean;
  34384. protected _rebuildBuffers(): void;
  34385. protected _initGLContext(): void;
  34386. /**
  34387. * Gets version of the current webGL context
  34388. */
  34389. get webGLVersion(): number;
  34390. /**
  34391. * Gets a string idenfifying the name of the class
  34392. * @returns "Engine" string
  34393. */
  34394. getClassName(): string;
  34395. /**
  34396. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34397. */
  34398. get isStencilEnable(): boolean;
  34399. /** @hidden */
  34400. _prepareWorkingCanvas(): void;
  34401. /**
  34402. * Reset the texture cache to empty state
  34403. */
  34404. resetTextureCache(): void;
  34405. /**
  34406. * Gets an object containing information about the current webGL context
  34407. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34408. */
  34409. getGlInfo(): {
  34410. vendor: string;
  34411. renderer: string;
  34412. version: string;
  34413. };
  34414. /**
  34415. * Defines the hardware scaling level.
  34416. * By default the hardware scaling level is computed from the window device ratio.
  34417. * 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.
  34418. * @param level defines the level to use
  34419. */
  34420. setHardwareScalingLevel(level: number): void;
  34421. /**
  34422. * Gets the current hardware scaling level.
  34423. * By default the hardware scaling level is computed from the window device ratio.
  34424. * 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.
  34425. * @returns a number indicating the current hardware scaling level
  34426. */
  34427. getHardwareScalingLevel(): number;
  34428. /**
  34429. * Gets the list of loaded textures
  34430. * @returns an array containing all loaded textures
  34431. */
  34432. getLoadedTexturesCache(): InternalTexture[];
  34433. /**
  34434. * Gets the object containing all engine capabilities
  34435. * @returns the EngineCapabilities object
  34436. */
  34437. getCaps(): EngineCapabilities;
  34438. /**
  34439. * stop executing a render loop function and remove it from the execution array
  34440. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34441. */
  34442. stopRenderLoop(renderFunction?: () => void): void;
  34443. /** @hidden */
  34444. _renderLoop(): void;
  34445. /**
  34446. * Gets the HTML canvas attached with the current webGL context
  34447. * @returns a HTML canvas
  34448. */
  34449. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34450. /**
  34451. * Gets host window
  34452. * @returns the host window object
  34453. */
  34454. getHostWindow(): Nullable<Window>;
  34455. /**
  34456. * Gets the current render width
  34457. * @param useScreen defines if screen size must be used (or the current render target if any)
  34458. * @returns a number defining the current render width
  34459. */
  34460. getRenderWidth(useScreen?: boolean): number;
  34461. /**
  34462. * Gets the current render height
  34463. * @param useScreen defines if screen size must be used (or the current render target if any)
  34464. * @returns a number defining the current render height
  34465. */
  34466. getRenderHeight(useScreen?: boolean): number;
  34467. /**
  34468. * Can be used to override the current requestAnimationFrame requester.
  34469. * @hidden
  34470. */
  34471. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34472. /**
  34473. * Register and execute a render loop. The engine can have more than one render function
  34474. * @param renderFunction defines the function to continuously execute
  34475. */
  34476. runRenderLoop(renderFunction: () => void): void;
  34477. /**
  34478. * Clear the current render buffer or the current render target (if any is set up)
  34479. * @param color defines the color to use
  34480. * @param backBuffer defines if the back buffer must be cleared
  34481. * @param depth defines if the depth buffer must be cleared
  34482. * @param stencil defines if the stencil buffer must be cleared
  34483. */
  34484. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34485. private _viewportCached;
  34486. /** @hidden */
  34487. _viewport(x: number, y: number, width: number, height: number): void;
  34488. /**
  34489. * Set the WebGL's viewport
  34490. * @param viewport defines the viewport element to be used
  34491. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34492. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34493. */
  34494. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34495. /**
  34496. * Begin a new frame
  34497. */
  34498. beginFrame(): void;
  34499. /**
  34500. * Enf the current frame
  34501. */
  34502. endFrame(): void;
  34503. /**
  34504. * Resize the view according to the canvas' size
  34505. */
  34506. resize(): void;
  34507. /**
  34508. * Force a specific size of the canvas
  34509. * @param width defines the new canvas' width
  34510. * @param height defines the new canvas' height
  34511. */
  34512. setSize(width: number, height: number): void;
  34513. /**
  34514. * Binds the frame buffer to the specified texture.
  34515. * @param texture The texture to render to or null for the default canvas
  34516. * @param faceIndex The face of the texture to render to in case of cube texture
  34517. * @param requiredWidth The width of the target to render to
  34518. * @param requiredHeight The height of the target to render to
  34519. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34520. * @param lodLevel defines the lod level to bind to the frame buffer
  34521. * @param layer defines the 2d array index to bind to frame buffer to
  34522. */
  34523. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34524. /** @hidden */
  34525. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34526. /**
  34527. * Unbind the current render target texture from the webGL context
  34528. * @param texture defines the render target texture to unbind
  34529. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34530. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34531. */
  34532. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34533. /**
  34534. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34535. */
  34536. flushFramebuffer(): void;
  34537. /**
  34538. * Unbind the current render target and bind the default framebuffer
  34539. */
  34540. restoreDefaultFramebuffer(): void;
  34541. /** @hidden */
  34542. protected _resetVertexBufferBinding(): void;
  34543. /**
  34544. * Creates a vertex buffer
  34545. * @param data the data for the vertex buffer
  34546. * @returns the new WebGL static buffer
  34547. */
  34548. createVertexBuffer(data: DataArray): DataBuffer;
  34549. private _createVertexBuffer;
  34550. /**
  34551. * Creates a dynamic vertex buffer
  34552. * @param data the data for the dynamic vertex buffer
  34553. * @returns the new WebGL dynamic buffer
  34554. */
  34555. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34556. protected _resetIndexBufferBinding(): void;
  34557. /**
  34558. * Creates a new index buffer
  34559. * @param indices defines the content of the index buffer
  34560. * @param updatable defines if the index buffer must be updatable
  34561. * @returns a new webGL buffer
  34562. */
  34563. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34564. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34565. /**
  34566. * Bind a webGL buffer to the webGL context
  34567. * @param buffer defines the buffer to bind
  34568. */
  34569. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34570. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34571. private bindBuffer;
  34572. /**
  34573. * update the bound buffer with the given data
  34574. * @param data defines the data to update
  34575. */
  34576. updateArrayBuffer(data: Float32Array): void;
  34577. private _vertexAttribPointer;
  34578. /** @hidden */
  34579. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34580. private _bindVertexBuffersAttributes;
  34581. /**
  34582. * Records a vertex array object
  34583. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34584. * @param vertexBuffers defines the list of vertex buffers to store
  34585. * @param indexBuffer defines the index buffer to store
  34586. * @param effect defines the effect to store
  34587. * @returns the new vertex array object
  34588. */
  34589. recordVertexArrayObject(vertexBuffers: {
  34590. [key: string]: VertexBuffer;
  34591. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34592. /**
  34593. * Bind a specific vertex array object
  34594. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34595. * @param vertexArrayObject defines the vertex array object to bind
  34596. * @param indexBuffer defines the index buffer to bind
  34597. */
  34598. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34599. /**
  34600. * Bind webGl buffers directly to the webGL context
  34601. * @param vertexBuffer defines the vertex buffer to bind
  34602. * @param indexBuffer defines the index buffer to bind
  34603. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34604. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34605. * @param effect defines the effect associated with the vertex buffer
  34606. */
  34607. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34608. private _unbindVertexArrayObject;
  34609. /**
  34610. * Bind a list of vertex buffers to the webGL context
  34611. * @param vertexBuffers defines the list of vertex buffers to bind
  34612. * @param indexBuffer defines the index buffer to bind
  34613. * @param effect defines the effect associated with the vertex buffers
  34614. */
  34615. bindBuffers(vertexBuffers: {
  34616. [key: string]: Nullable<VertexBuffer>;
  34617. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34618. /**
  34619. * Unbind all instance attributes
  34620. */
  34621. unbindInstanceAttributes(): void;
  34622. /**
  34623. * Release and free the memory of a vertex array object
  34624. * @param vao defines the vertex array object to delete
  34625. */
  34626. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34627. /** @hidden */
  34628. _releaseBuffer(buffer: DataBuffer): boolean;
  34629. protected _deleteBuffer(buffer: DataBuffer): void;
  34630. /**
  34631. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34632. * @param instancesBuffer defines the webGL buffer to update and bind
  34633. * @param data defines the data to store in the buffer
  34634. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34635. */
  34636. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34637. /**
  34638. * Bind the content of a webGL buffer used with instantiation
  34639. * @param instancesBuffer defines the webGL buffer to bind
  34640. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34641. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34642. */
  34643. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34644. /**
  34645. * Disable the instance attribute corresponding to the name in parameter
  34646. * @param name defines the name of the attribute to disable
  34647. */
  34648. disableInstanceAttributeByName(name: string): void;
  34649. /**
  34650. * Disable the instance attribute corresponding to the location in parameter
  34651. * @param attributeLocation defines the attribute location of the attribute to disable
  34652. */
  34653. disableInstanceAttribute(attributeLocation: number): void;
  34654. /**
  34655. * Disable the attribute corresponding to the location in parameter
  34656. * @param attributeLocation defines the attribute location of the attribute to disable
  34657. */
  34658. disableAttributeByIndex(attributeLocation: number): void;
  34659. /**
  34660. * Send a draw order
  34661. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34662. * @param indexStart defines the starting index
  34663. * @param indexCount defines the number of index to draw
  34664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34665. */
  34666. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34667. /**
  34668. * Draw a list of points
  34669. * @param verticesStart defines the index of first vertex to draw
  34670. * @param verticesCount defines the count of vertices to draw
  34671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34672. */
  34673. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34674. /**
  34675. * Draw a list of unindexed primitives
  34676. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34677. * @param verticesStart defines the index of first vertex to draw
  34678. * @param verticesCount defines the count of vertices to draw
  34679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34680. */
  34681. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34682. /**
  34683. * Draw a list of indexed primitives
  34684. * @param fillMode defines the primitive to use
  34685. * @param indexStart defines the starting index
  34686. * @param indexCount defines the number of index to draw
  34687. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34688. */
  34689. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34690. /**
  34691. * Draw a list of unindexed primitives
  34692. * @param fillMode defines the primitive to use
  34693. * @param verticesStart defines the index of first vertex to draw
  34694. * @param verticesCount defines the count of vertices to draw
  34695. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34696. */
  34697. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34698. private _drawMode;
  34699. /** @hidden */
  34700. protected _reportDrawCall(): void;
  34701. /** @hidden */
  34702. _releaseEffect(effect: Effect): void;
  34703. /** @hidden */
  34704. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34705. /**
  34706. * Create a new effect (used to store vertex/fragment shaders)
  34707. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34708. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34709. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34710. * @param samplers defines an array of string used to represent textures
  34711. * @param defines defines the string containing the defines to use to compile the shaders
  34712. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34713. * @param onCompiled defines a function to call when the effect creation is successful
  34714. * @param onError defines a function to call when the effect creation has failed
  34715. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34716. * @returns the new Effect
  34717. */
  34718. 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;
  34719. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34720. private _compileShader;
  34721. private _compileRawShader;
  34722. /** @hidden */
  34723. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34724. /**
  34725. * Directly creates a webGL program
  34726. * @param pipelineContext defines the pipeline context to attach to
  34727. * @param vertexCode defines the vertex shader code to use
  34728. * @param fragmentCode defines the fragment shader code to use
  34729. * @param context defines the webGL context to use (if not set, the current one will be used)
  34730. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34731. * @returns the new webGL program
  34732. */
  34733. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34734. /**
  34735. * Creates a webGL program
  34736. * @param pipelineContext defines the pipeline context to attach to
  34737. * @param vertexCode defines the vertex shader code to use
  34738. * @param fragmentCode defines the fragment shader code to use
  34739. * @param defines defines the string containing the defines to use to compile the shaders
  34740. * @param context defines the webGL context to use (if not set, the current one will be used)
  34741. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34742. * @returns the new webGL program
  34743. */
  34744. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34745. /**
  34746. * Creates a new pipeline context
  34747. * @returns the new pipeline
  34748. */
  34749. createPipelineContext(): IPipelineContext;
  34750. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34751. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34752. /** @hidden */
  34753. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34754. /** @hidden */
  34755. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34756. /** @hidden */
  34757. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34758. /**
  34759. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34760. * @param pipelineContext defines the pipeline context to use
  34761. * @param uniformsNames defines the list of uniform names
  34762. * @returns an array of webGL uniform locations
  34763. */
  34764. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34765. /**
  34766. * Gets the lsit of active attributes for a given webGL program
  34767. * @param pipelineContext defines the pipeline context to use
  34768. * @param attributesNames defines the list of attribute names to get
  34769. * @returns an array of indices indicating the offset of each attribute
  34770. */
  34771. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34772. /**
  34773. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34774. * @param effect defines the effect to activate
  34775. */
  34776. enableEffect(effect: Nullable<Effect>): void;
  34777. /**
  34778. * Set the value of an uniform to a number (int)
  34779. * @param uniform defines the webGL uniform location where to store the value
  34780. * @param value defines the int number to store
  34781. */
  34782. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34783. /**
  34784. * Set the value of an uniform to an array of int32
  34785. * @param uniform defines the webGL uniform location where to store the value
  34786. * @param array defines the array of int32 to store
  34787. */
  34788. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34789. /**
  34790. * Set the value of an uniform to an array of int32 (stored as vec2)
  34791. * @param uniform defines the webGL uniform location where to store the value
  34792. * @param array defines the array of int32 to store
  34793. */
  34794. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34795. /**
  34796. * Set the value of an uniform to an array of int32 (stored as vec3)
  34797. * @param uniform defines the webGL uniform location where to store the value
  34798. * @param array defines the array of int32 to store
  34799. */
  34800. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34801. /**
  34802. * Set the value of an uniform to an array of int32 (stored as vec4)
  34803. * @param uniform defines the webGL uniform location where to store the value
  34804. * @param array defines the array of int32 to store
  34805. */
  34806. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34807. /**
  34808. * Set the value of an uniform to an array of number
  34809. * @param uniform defines the webGL uniform location where to store the value
  34810. * @param array defines the array of number to store
  34811. */
  34812. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34813. /**
  34814. * Set the value of an uniform to an array of number (stored as vec2)
  34815. * @param uniform defines the webGL uniform location where to store the value
  34816. * @param array defines the array of number to store
  34817. */
  34818. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34819. /**
  34820. * Set the value of an uniform to an array of number (stored as vec3)
  34821. * @param uniform defines the webGL uniform location where to store the value
  34822. * @param array defines the array of number to store
  34823. */
  34824. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34825. /**
  34826. * Set the value of an uniform to an array of number (stored as vec4)
  34827. * @param uniform defines the webGL uniform location where to store the value
  34828. * @param array defines the array of number to store
  34829. */
  34830. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34831. /**
  34832. * Set the value of an uniform to an array of float32 (stored as matrices)
  34833. * @param uniform defines the webGL uniform location where to store the value
  34834. * @param matrices defines the array of float32 to store
  34835. */
  34836. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34837. /**
  34838. * Set the value of an uniform to a matrix (3x3)
  34839. * @param uniform defines the webGL uniform location where to store the value
  34840. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34841. */
  34842. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34843. /**
  34844. * Set the value of an uniform to a matrix (2x2)
  34845. * @param uniform defines the webGL uniform location where to store the value
  34846. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34847. */
  34848. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34849. /**
  34850. * Set the value of an uniform to a number (float)
  34851. * @param uniform defines the webGL uniform location where to store the value
  34852. * @param value defines the float number to store
  34853. */
  34854. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34855. /**
  34856. * Set the value of an uniform to a vec2
  34857. * @param uniform defines the webGL uniform location where to store the value
  34858. * @param x defines the 1st component of the value
  34859. * @param y defines the 2nd component of the value
  34860. */
  34861. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34862. /**
  34863. * Set the value of an uniform to a vec3
  34864. * @param uniform defines the webGL uniform location where to store the value
  34865. * @param x defines the 1st component of the value
  34866. * @param y defines the 2nd component of the value
  34867. * @param z defines the 3rd component of the value
  34868. */
  34869. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34870. /**
  34871. * Set the value of an uniform to a vec4
  34872. * @param uniform defines the webGL uniform location where to store the value
  34873. * @param x defines the 1st component of the value
  34874. * @param y defines the 2nd component of the value
  34875. * @param z defines the 3rd component of the value
  34876. * @param w defines the 4th component of the value
  34877. */
  34878. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34879. /**
  34880. * Apply all cached states (depth, culling, stencil and alpha)
  34881. */
  34882. applyStates(): void;
  34883. /**
  34884. * Enable or disable color writing
  34885. * @param enable defines the state to set
  34886. */
  34887. setColorWrite(enable: boolean): void;
  34888. /**
  34889. * Gets a boolean indicating if color writing is enabled
  34890. * @returns the current color writing state
  34891. */
  34892. getColorWrite(): boolean;
  34893. /**
  34894. * Gets the depth culling state manager
  34895. */
  34896. get depthCullingState(): DepthCullingState;
  34897. /**
  34898. * Gets the alpha state manager
  34899. */
  34900. get alphaState(): AlphaState;
  34901. /**
  34902. * Gets the stencil state manager
  34903. */
  34904. get stencilState(): StencilState;
  34905. /**
  34906. * Clears the list of texture accessible through engine.
  34907. * This can help preventing texture load conflict due to name collision.
  34908. */
  34909. clearInternalTexturesCache(): void;
  34910. /**
  34911. * Force the entire cache to be cleared
  34912. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34913. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34914. */
  34915. wipeCaches(bruteForce?: boolean): void;
  34916. /** @hidden */
  34917. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34918. min: number;
  34919. mag: number;
  34920. };
  34921. /** @hidden */
  34922. _createTexture(): WebGLTexture;
  34923. /**
  34924. * Usually called from Texture.ts.
  34925. * Passed information to create a WebGLTexture
  34926. * @param url defines a value which contains one of the following:
  34927. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34928. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34929. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34931. * @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)
  34932. * @param scene needed for loading to the correct scene
  34933. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34934. * @param onLoad optional callback to be called upon successful completion
  34935. * @param onError optional callback to be called upon failure
  34936. * @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
  34937. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34938. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34939. * @param forcedExtension defines the extension to use to pick the right loader
  34940. * @param mimeType defines an optional mime type
  34941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34942. */
  34943. 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;
  34944. /**
  34945. * Loads an image as an HTMLImageElement.
  34946. * @param input url string, ArrayBuffer, or Blob to load
  34947. * @param onLoad callback called when the image successfully loads
  34948. * @param onError callback called when the image fails to load
  34949. * @param offlineProvider offline provider for caching
  34950. * @param mimeType optional mime type
  34951. * @returns the HTMLImageElement of the loaded image
  34952. * @hidden
  34953. */
  34954. 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>;
  34955. /**
  34956. * @hidden
  34957. */
  34958. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34959. private _unpackFlipYCached;
  34960. /**
  34961. * In case you are sharing the context with other applications, it might
  34962. * be interested to not cache the unpack flip y state to ensure a consistent
  34963. * value would be set.
  34964. */
  34965. enableUnpackFlipYCached: boolean;
  34966. /** @hidden */
  34967. _unpackFlipY(value: boolean): void;
  34968. /** @hidden */
  34969. _getUnpackAlignement(): number;
  34970. private _getTextureTarget;
  34971. /**
  34972. * Update the sampling mode of a given texture
  34973. * @param samplingMode defines the required sampling mode
  34974. * @param texture defines the texture to update
  34975. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34976. */
  34977. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34978. /**
  34979. * Update the sampling mode of a given texture
  34980. * @param texture defines the texture to update
  34981. * @param wrapU defines the texture wrap mode of the u coordinates
  34982. * @param wrapV defines the texture wrap mode of the v coordinates
  34983. * @param wrapR defines the texture wrap mode of the r coordinates
  34984. */
  34985. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34986. /** @hidden */
  34987. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34988. width: number;
  34989. height: number;
  34990. layers?: number;
  34991. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34992. /** @hidden */
  34993. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34994. /** @hidden */
  34995. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34996. /**
  34997. * Update a portion of an internal texture
  34998. * @param texture defines the texture to update
  34999. * @param imageData defines the data to store into the texture
  35000. * @param xOffset defines the x coordinates of the update rectangle
  35001. * @param yOffset defines the y coordinates of the update rectangle
  35002. * @param width defines the width of the update rectangle
  35003. * @param height defines the height of the update rectangle
  35004. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35005. * @param lod defines the lod level to update (0 by default)
  35006. */
  35007. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35008. /** @hidden */
  35009. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35010. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35011. private _prepareWebGLTexture;
  35012. /** @hidden */
  35013. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35014. private _getDepthStencilBuffer;
  35015. /** @hidden */
  35016. _releaseFramebufferObjects(texture: InternalTexture): void;
  35017. /** @hidden */
  35018. _releaseTexture(texture: InternalTexture): void;
  35019. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35020. protected _setProgram(program: WebGLProgram): void;
  35021. protected _boundUniforms: {
  35022. [key: number]: WebGLUniformLocation;
  35023. };
  35024. /**
  35025. * Binds an effect to the webGL context
  35026. * @param effect defines the effect to bind
  35027. */
  35028. bindSamplers(effect: Effect): void;
  35029. private _activateCurrentTexture;
  35030. /** @hidden */
  35031. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35032. /** @hidden */
  35033. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35034. /**
  35035. * Unbind all textures from the webGL context
  35036. */
  35037. unbindAllTextures(): void;
  35038. /**
  35039. * Sets a texture to the according uniform.
  35040. * @param channel The texture channel
  35041. * @param uniform The uniform to set
  35042. * @param texture The texture to apply
  35043. */
  35044. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35045. private _bindSamplerUniformToChannel;
  35046. private _getTextureWrapMode;
  35047. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35048. /**
  35049. * Sets an array of texture to the webGL context
  35050. * @param channel defines the channel where the texture array must be set
  35051. * @param uniform defines the associated uniform location
  35052. * @param textures defines the array of textures to bind
  35053. */
  35054. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35055. /** @hidden */
  35056. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35057. private _setTextureParameterFloat;
  35058. private _setTextureParameterInteger;
  35059. /**
  35060. * Unbind all vertex attributes from the webGL context
  35061. */
  35062. unbindAllAttributes(): void;
  35063. /**
  35064. * 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
  35065. */
  35066. releaseEffects(): void;
  35067. /**
  35068. * Dispose and release all associated resources
  35069. */
  35070. dispose(): void;
  35071. /**
  35072. * Attach a new callback raised when context lost event is fired
  35073. * @param callback defines the callback to call
  35074. */
  35075. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35076. /**
  35077. * Attach a new callback raised when context restored event is fired
  35078. * @param callback defines the callback to call
  35079. */
  35080. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35081. /**
  35082. * Get the current error code of the webGL context
  35083. * @returns the error code
  35084. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35085. */
  35086. getError(): number;
  35087. private _canRenderToFloatFramebuffer;
  35088. private _canRenderToHalfFloatFramebuffer;
  35089. private _canRenderToFramebuffer;
  35090. /** @hidden */
  35091. _getWebGLTextureType(type: number): number;
  35092. /** @hidden */
  35093. _getInternalFormat(format: number): number;
  35094. /** @hidden */
  35095. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35096. /** @hidden */
  35097. _getRGBAMultiSampleBufferFormat(type: number): number;
  35098. /** @hidden */
  35099. _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;
  35100. /**
  35101. * Loads a file from a url
  35102. * @param url url to load
  35103. * @param onSuccess callback called when the file successfully loads
  35104. * @param onProgress callback called while file is loading (if the server supports this mode)
  35105. * @param offlineProvider defines the offline provider for caching
  35106. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35107. * @param onError callback called when the file fails to load
  35108. * @returns a file request object
  35109. * @hidden
  35110. */
  35111. 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;
  35112. /**
  35113. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35114. * @param x defines the x coordinate of the rectangle where pixels must be read
  35115. * @param y defines the y coordinate of the rectangle where pixels must be read
  35116. * @param width defines the width of the rectangle where pixels must be read
  35117. * @param height defines the height of the rectangle where pixels must be read
  35118. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35119. * @returns a Uint8Array containing RGBA colors
  35120. */
  35121. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35122. private static _isSupported;
  35123. /**
  35124. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35125. * @returns true if the engine can be created
  35126. * @ignorenaming
  35127. */
  35128. static isSupported(): boolean;
  35129. /**
  35130. * Find the next highest power of two.
  35131. * @param x Number to start search from.
  35132. * @return Next highest power of two.
  35133. */
  35134. static CeilingPOT(x: number): number;
  35135. /**
  35136. * Find the next lowest power of two.
  35137. * @param x Number to start search from.
  35138. * @return Next lowest power of two.
  35139. */
  35140. static FloorPOT(x: number): number;
  35141. /**
  35142. * Find the nearest power of two.
  35143. * @param x Number to start search from.
  35144. * @return Next nearest power of two.
  35145. */
  35146. static NearestPOT(x: number): number;
  35147. /**
  35148. * Get the closest exponent of two
  35149. * @param value defines the value to approximate
  35150. * @param max defines the maximum value to return
  35151. * @param mode defines how to define the closest value
  35152. * @returns closest exponent of two of the given value
  35153. */
  35154. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35155. /**
  35156. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35157. * @param func - the function to be called
  35158. * @param requester - the object that will request the next frame. Falls back to window.
  35159. * @returns frame number
  35160. */
  35161. static QueueNewFrame(func: () => void, requester?: any): number;
  35162. /**
  35163. * Gets host document
  35164. * @returns the host document object
  35165. */
  35166. getHostDocument(): Nullable<Document>;
  35167. }
  35168. }
  35169. declare module BABYLON {
  35170. /**
  35171. * Class representing spherical harmonics coefficients to the 3rd degree
  35172. */
  35173. export class SphericalHarmonics {
  35174. /**
  35175. * Defines whether or not the harmonics have been prescaled for rendering.
  35176. */
  35177. preScaled: boolean;
  35178. /**
  35179. * The l0,0 coefficients of the spherical harmonics
  35180. */
  35181. l00: Vector3;
  35182. /**
  35183. * The l1,-1 coefficients of the spherical harmonics
  35184. */
  35185. l1_1: Vector3;
  35186. /**
  35187. * The l1,0 coefficients of the spherical harmonics
  35188. */
  35189. l10: Vector3;
  35190. /**
  35191. * The l1,1 coefficients of the spherical harmonics
  35192. */
  35193. l11: Vector3;
  35194. /**
  35195. * The l2,-2 coefficients of the spherical harmonics
  35196. */
  35197. l2_2: Vector3;
  35198. /**
  35199. * The l2,-1 coefficients of the spherical harmonics
  35200. */
  35201. l2_1: Vector3;
  35202. /**
  35203. * The l2,0 coefficients of the spherical harmonics
  35204. */
  35205. l20: Vector3;
  35206. /**
  35207. * The l2,1 coefficients of the spherical harmonics
  35208. */
  35209. l21: Vector3;
  35210. /**
  35211. * The l2,2 coefficients of the spherical harmonics
  35212. */
  35213. l22: Vector3;
  35214. /**
  35215. * Adds a light to the spherical harmonics
  35216. * @param direction the direction of the light
  35217. * @param color the color of the light
  35218. * @param deltaSolidAngle the delta solid angle of the light
  35219. */
  35220. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35221. /**
  35222. * Scales the spherical harmonics by the given amount
  35223. * @param scale the amount to scale
  35224. */
  35225. scaleInPlace(scale: number): void;
  35226. /**
  35227. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35228. *
  35229. * ```
  35230. * E_lm = A_l * L_lm
  35231. * ```
  35232. *
  35233. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35234. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35235. * the scaling factors are given in equation 9.
  35236. */
  35237. convertIncidentRadianceToIrradiance(): void;
  35238. /**
  35239. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35240. *
  35241. * ```
  35242. * L = (1/pi) * E * rho
  35243. * ```
  35244. *
  35245. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35246. */
  35247. convertIrradianceToLambertianRadiance(): void;
  35248. /**
  35249. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35250. * required operations at run time.
  35251. *
  35252. * This is simply done by scaling back the SH with Ylm constants parameter.
  35253. * The trigonometric part being applied by the shader at run time.
  35254. */
  35255. preScaleForRendering(): void;
  35256. /**
  35257. * Constructs a spherical harmonics from an array.
  35258. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35259. * @returns the spherical harmonics
  35260. */
  35261. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35262. /**
  35263. * Gets the spherical harmonics from polynomial
  35264. * @param polynomial the spherical polynomial
  35265. * @returns the spherical harmonics
  35266. */
  35267. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35268. }
  35269. /**
  35270. * Class representing spherical polynomial coefficients to the 3rd degree
  35271. */
  35272. export class SphericalPolynomial {
  35273. private _harmonics;
  35274. /**
  35275. * The spherical harmonics used to create the polynomials.
  35276. */
  35277. get preScaledHarmonics(): SphericalHarmonics;
  35278. /**
  35279. * The x coefficients of the spherical polynomial
  35280. */
  35281. x: Vector3;
  35282. /**
  35283. * The y coefficients of the spherical polynomial
  35284. */
  35285. y: Vector3;
  35286. /**
  35287. * The z coefficients of the spherical polynomial
  35288. */
  35289. z: Vector3;
  35290. /**
  35291. * The xx coefficients of the spherical polynomial
  35292. */
  35293. xx: Vector3;
  35294. /**
  35295. * The yy coefficients of the spherical polynomial
  35296. */
  35297. yy: Vector3;
  35298. /**
  35299. * The zz coefficients of the spherical polynomial
  35300. */
  35301. zz: Vector3;
  35302. /**
  35303. * The xy coefficients of the spherical polynomial
  35304. */
  35305. xy: Vector3;
  35306. /**
  35307. * The yz coefficients of the spherical polynomial
  35308. */
  35309. yz: Vector3;
  35310. /**
  35311. * The zx coefficients of the spherical polynomial
  35312. */
  35313. zx: Vector3;
  35314. /**
  35315. * Adds an ambient color to the spherical polynomial
  35316. * @param color the color to add
  35317. */
  35318. addAmbient(color: Color3): void;
  35319. /**
  35320. * Scales the spherical polynomial by the given amount
  35321. * @param scale the amount to scale
  35322. */
  35323. scaleInPlace(scale: number): void;
  35324. /**
  35325. * Gets the spherical polynomial from harmonics
  35326. * @param harmonics the spherical harmonics
  35327. * @returns the spherical polynomial
  35328. */
  35329. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35330. /**
  35331. * Constructs a spherical polynomial from an array.
  35332. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35333. * @returns the spherical polynomial
  35334. */
  35335. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35336. }
  35337. }
  35338. declare module BABYLON {
  35339. /**
  35340. * Defines the source of the internal texture
  35341. */
  35342. export enum InternalTextureSource {
  35343. /**
  35344. * The source of the texture data is unknown
  35345. */
  35346. Unknown = 0,
  35347. /**
  35348. * Texture data comes from an URL
  35349. */
  35350. Url = 1,
  35351. /**
  35352. * Texture data is only used for temporary storage
  35353. */
  35354. Temp = 2,
  35355. /**
  35356. * Texture data comes from raw data (ArrayBuffer)
  35357. */
  35358. Raw = 3,
  35359. /**
  35360. * Texture content is dynamic (video or dynamic texture)
  35361. */
  35362. Dynamic = 4,
  35363. /**
  35364. * Texture content is generated by rendering to it
  35365. */
  35366. RenderTarget = 5,
  35367. /**
  35368. * Texture content is part of a multi render target process
  35369. */
  35370. MultiRenderTarget = 6,
  35371. /**
  35372. * Texture data comes from a cube data file
  35373. */
  35374. Cube = 7,
  35375. /**
  35376. * Texture data comes from a raw cube data
  35377. */
  35378. CubeRaw = 8,
  35379. /**
  35380. * Texture data come from a prefiltered cube data file
  35381. */
  35382. CubePrefiltered = 9,
  35383. /**
  35384. * Texture content is raw 3D data
  35385. */
  35386. Raw3D = 10,
  35387. /**
  35388. * Texture content is raw 2D array data
  35389. */
  35390. Raw2DArray = 11,
  35391. /**
  35392. * Texture content is a depth texture
  35393. */
  35394. Depth = 12,
  35395. /**
  35396. * Texture data comes from a raw cube data encoded with RGBD
  35397. */
  35398. CubeRawRGBD = 13
  35399. }
  35400. /**
  35401. * Class used to store data associated with WebGL texture data for the engine
  35402. * This class should not be used directly
  35403. */
  35404. export class InternalTexture {
  35405. /** @hidden */
  35406. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35407. /**
  35408. * Defines if the texture is ready
  35409. */
  35410. isReady: boolean;
  35411. /**
  35412. * Defines if the texture is a cube texture
  35413. */
  35414. isCube: boolean;
  35415. /**
  35416. * Defines if the texture contains 3D data
  35417. */
  35418. is3D: boolean;
  35419. /**
  35420. * Defines if the texture contains 2D array data
  35421. */
  35422. is2DArray: boolean;
  35423. /**
  35424. * Defines if the texture contains multiview data
  35425. */
  35426. isMultiview: boolean;
  35427. /**
  35428. * Gets the URL used to load this texture
  35429. */
  35430. url: string;
  35431. /**
  35432. * Gets the sampling mode of the texture
  35433. */
  35434. samplingMode: number;
  35435. /**
  35436. * Gets a boolean indicating if the texture needs mipmaps generation
  35437. */
  35438. generateMipMaps: boolean;
  35439. /**
  35440. * Gets the number of samples used by the texture (WebGL2+ only)
  35441. */
  35442. samples: number;
  35443. /**
  35444. * Gets the type of the texture (int, float...)
  35445. */
  35446. type: number;
  35447. /**
  35448. * Gets the format of the texture (RGB, RGBA...)
  35449. */
  35450. format: number;
  35451. /**
  35452. * Observable called when the texture is loaded
  35453. */
  35454. onLoadedObservable: Observable<InternalTexture>;
  35455. /**
  35456. * Gets the width of the texture
  35457. */
  35458. width: number;
  35459. /**
  35460. * Gets the height of the texture
  35461. */
  35462. height: number;
  35463. /**
  35464. * Gets the depth of the texture
  35465. */
  35466. depth: number;
  35467. /**
  35468. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35469. */
  35470. baseWidth: number;
  35471. /**
  35472. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35473. */
  35474. baseHeight: number;
  35475. /**
  35476. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35477. */
  35478. baseDepth: number;
  35479. /**
  35480. * Gets a boolean indicating if the texture is inverted on Y axis
  35481. */
  35482. invertY: boolean;
  35483. /** @hidden */
  35484. _invertVScale: boolean;
  35485. /** @hidden */
  35486. _associatedChannel: number;
  35487. /** @hidden */
  35488. _source: InternalTextureSource;
  35489. /** @hidden */
  35490. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35491. /** @hidden */
  35492. _bufferView: Nullable<ArrayBufferView>;
  35493. /** @hidden */
  35494. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35495. /** @hidden */
  35496. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35497. /** @hidden */
  35498. _size: number;
  35499. /** @hidden */
  35500. _extension: string;
  35501. /** @hidden */
  35502. _files: Nullable<string[]>;
  35503. /** @hidden */
  35504. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35505. /** @hidden */
  35506. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35507. /** @hidden */
  35508. _framebuffer: Nullable<WebGLFramebuffer>;
  35509. /** @hidden */
  35510. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35511. /** @hidden */
  35512. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35513. /** @hidden */
  35514. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35515. /** @hidden */
  35516. _attachments: Nullable<number[]>;
  35517. /** @hidden */
  35518. _cachedCoordinatesMode: Nullable<number>;
  35519. /** @hidden */
  35520. _cachedWrapU: Nullable<number>;
  35521. /** @hidden */
  35522. _cachedWrapV: Nullable<number>;
  35523. /** @hidden */
  35524. _cachedWrapR: Nullable<number>;
  35525. /** @hidden */
  35526. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35527. /** @hidden */
  35528. _isDisabled: boolean;
  35529. /** @hidden */
  35530. _compression: Nullable<string>;
  35531. /** @hidden */
  35532. _generateStencilBuffer: boolean;
  35533. /** @hidden */
  35534. _generateDepthBuffer: boolean;
  35535. /** @hidden */
  35536. _comparisonFunction: number;
  35537. /** @hidden */
  35538. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35539. /** @hidden */
  35540. _lodGenerationScale: number;
  35541. /** @hidden */
  35542. _lodGenerationOffset: number;
  35543. /** @hidden */
  35544. _depthStencilTexture: Nullable<InternalTexture>;
  35545. /** @hidden */
  35546. _colorTextureArray: Nullable<WebGLTexture>;
  35547. /** @hidden */
  35548. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35549. /** @hidden */
  35550. _lodTextureHigh: Nullable<BaseTexture>;
  35551. /** @hidden */
  35552. _lodTextureMid: Nullable<BaseTexture>;
  35553. /** @hidden */
  35554. _lodTextureLow: Nullable<BaseTexture>;
  35555. /** @hidden */
  35556. _isRGBD: boolean;
  35557. /** @hidden */
  35558. _linearSpecularLOD: boolean;
  35559. /** @hidden */
  35560. _irradianceTexture: Nullable<BaseTexture>;
  35561. /** @hidden */
  35562. _webGLTexture: Nullable<WebGLTexture>;
  35563. /** @hidden */
  35564. _references: number;
  35565. private _engine;
  35566. /**
  35567. * Gets the Engine the texture belongs to.
  35568. * @returns The babylon engine
  35569. */
  35570. getEngine(): ThinEngine;
  35571. /**
  35572. * Gets the data source type of the texture
  35573. */
  35574. get source(): InternalTextureSource;
  35575. /**
  35576. * Creates a new InternalTexture
  35577. * @param engine defines the engine to use
  35578. * @param source defines the type of data that will be used
  35579. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35580. */
  35581. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35582. /**
  35583. * Increments the number of references (ie. the number of Texture that point to it)
  35584. */
  35585. incrementReferences(): void;
  35586. /**
  35587. * Change the size of the texture (not the size of the content)
  35588. * @param width defines the new width
  35589. * @param height defines the new height
  35590. * @param depth defines the new depth (1 by default)
  35591. */
  35592. updateSize(width: int, height: int, depth?: int): void;
  35593. /** @hidden */
  35594. _rebuild(): void;
  35595. /** @hidden */
  35596. _swapAndDie(target: InternalTexture): void;
  35597. /**
  35598. * Dispose the current allocated resources
  35599. */
  35600. dispose(): void;
  35601. }
  35602. }
  35603. declare module BABYLON {
  35604. /**
  35605. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35607. */
  35608. export class Analyser {
  35609. /**
  35610. * Gets or sets the smoothing
  35611. * @ignorenaming
  35612. */
  35613. SMOOTHING: number;
  35614. /**
  35615. * Gets or sets the FFT table size
  35616. * @ignorenaming
  35617. */
  35618. FFT_SIZE: number;
  35619. /**
  35620. * Gets or sets the bar graph amplitude
  35621. * @ignorenaming
  35622. */
  35623. BARGRAPHAMPLITUDE: number;
  35624. /**
  35625. * Gets or sets the position of the debug canvas
  35626. * @ignorenaming
  35627. */
  35628. DEBUGCANVASPOS: {
  35629. x: number;
  35630. y: number;
  35631. };
  35632. /**
  35633. * Gets or sets the debug canvas size
  35634. * @ignorenaming
  35635. */
  35636. DEBUGCANVASSIZE: {
  35637. width: number;
  35638. height: number;
  35639. };
  35640. private _byteFreqs;
  35641. private _byteTime;
  35642. private _floatFreqs;
  35643. private _webAudioAnalyser;
  35644. private _debugCanvas;
  35645. private _debugCanvasContext;
  35646. private _scene;
  35647. private _registerFunc;
  35648. private _audioEngine;
  35649. /**
  35650. * Creates a new analyser
  35651. * @param scene defines hosting scene
  35652. */
  35653. constructor(scene: Scene);
  35654. /**
  35655. * Get the number of data values you will have to play with for the visualization
  35656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35657. * @returns a number
  35658. */
  35659. getFrequencyBinCount(): number;
  35660. /**
  35661. * Gets the current frequency data as a byte array
  35662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35663. * @returns a Uint8Array
  35664. */
  35665. getByteFrequencyData(): Uint8Array;
  35666. /**
  35667. * Gets the current waveform as a byte array
  35668. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35669. * @returns a Uint8Array
  35670. */
  35671. getByteTimeDomainData(): Uint8Array;
  35672. /**
  35673. * Gets the current frequency data as a float array
  35674. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35675. * @returns a Float32Array
  35676. */
  35677. getFloatFrequencyData(): Float32Array;
  35678. /**
  35679. * Renders the debug canvas
  35680. */
  35681. drawDebugCanvas(): void;
  35682. /**
  35683. * Stops rendering the debug canvas and removes it
  35684. */
  35685. stopDebugCanvas(): void;
  35686. /**
  35687. * Connects two audio nodes
  35688. * @param inputAudioNode defines first node to connect
  35689. * @param outputAudioNode defines second node to connect
  35690. */
  35691. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35692. /**
  35693. * Releases all associated resources
  35694. */
  35695. dispose(): void;
  35696. }
  35697. }
  35698. declare module BABYLON {
  35699. /**
  35700. * This represents an audio engine and it is responsible
  35701. * to play, synchronize and analyse sounds throughout the application.
  35702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35703. */
  35704. export interface IAudioEngine extends IDisposable {
  35705. /**
  35706. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35707. */
  35708. readonly canUseWebAudio: boolean;
  35709. /**
  35710. * Gets the current AudioContext if available.
  35711. */
  35712. readonly audioContext: Nullable<AudioContext>;
  35713. /**
  35714. * The master gain node defines the global audio volume of your audio engine.
  35715. */
  35716. readonly masterGain: GainNode;
  35717. /**
  35718. * Gets whether or not mp3 are supported by your browser.
  35719. */
  35720. readonly isMP3supported: boolean;
  35721. /**
  35722. * Gets whether or not ogg are supported by your browser.
  35723. */
  35724. readonly isOGGsupported: boolean;
  35725. /**
  35726. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35727. * @ignoreNaming
  35728. */
  35729. WarnedWebAudioUnsupported: boolean;
  35730. /**
  35731. * Defines if the audio engine relies on a custom unlocked button.
  35732. * In this case, the embedded button will not be displayed.
  35733. */
  35734. useCustomUnlockedButton: boolean;
  35735. /**
  35736. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35737. */
  35738. readonly unlocked: boolean;
  35739. /**
  35740. * Event raised when audio has been unlocked on the browser.
  35741. */
  35742. onAudioUnlockedObservable: Observable<AudioEngine>;
  35743. /**
  35744. * Event raised when audio has been locked on the browser.
  35745. */
  35746. onAudioLockedObservable: Observable<AudioEngine>;
  35747. /**
  35748. * Flags the audio engine in Locked state.
  35749. * This happens due to new browser policies preventing audio to autoplay.
  35750. */
  35751. lock(): void;
  35752. /**
  35753. * Unlocks the audio engine once a user action has been done on the dom.
  35754. * This is helpful to resume play once browser policies have been satisfied.
  35755. */
  35756. unlock(): void;
  35757. /**
  35758. * Gets the global volume sets on the master gain.
  35759. * @returns the global volume if set or -1 otherwise
  35760. */
  35761. getGlobalVolume(): number;
  35762. /**
  35763. * Sets the global volume of your experience (sets on the master gain).
  35764. * @param newVolume Defines the new global volume of the application
  35765. */
  35766. setGlobalVolume(newVolume: number): void;
  35767. /**
  35768. * Connect the audio engine to an audio analyser allowing some amazing
  35769. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35771. * @param analyser The analyser to connect to the engine
  35772. */
  35773. connectToAnalyser(analyser: Analyser): void;
  35774. }
  35775. /**
  35776. * This represents the default audio engine used in babylon.
  35777. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35779. */
  35780. export class AudioEngine implements IAudioEngine {
  35781. private _audioContext;
  35782. private _audioContextInitialized;
  35783. private _muteButton;
  35784. private _hostElement;
  35785. /**
  35786. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35787. */
  35788. canUseWebAudio: boolean;
  35789. /**
  35790. * The master gain node defines the global audio volume of your audio engine.
  35791. */
  35792. masterGain: GainNode;
  35793. /**
  35794. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35795. * @ignoreNaming
  35796. */
  35797. WarnedWebAudioUnsupported: boolean;
  35798. /**
  35799. * Gets whether or not mp3 are supported by your browser.
  35800. */
  35801. isMP3supported: boolean;
  35802. /**
  35803. * Gets whether or not ogg are supported by your browser.
  35804. */
  35805. isOGGsupported: boolean;
  35806. /**
  35807. * Gets whether audio has been unlocked on the device.
  35808. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35809. * a user interaction has happened.
  35810. */
  35811. unlocked: boolean;
  35812. /**
  35813. * Defines if the audio engine relies on a custom unlocked button.
  35814. * In this case, the embedded button will not be displayed.
  35815. */
  35816. useCustomUnlockedButton: boolean;
  35817. /**
  35818. * Event raised when audio has been unlocked on the browser.
  35819. */
  35820. onAudioUnlockedObservable: Observable<AudioEngine>;
  35821. /**
  35822. * Event raised when audio has been locked on the browser.
  35823. */
  35824. onAudioLockedObservable: Observable<AudioEngine>;
  35825. /**
  35826. * Gets the current AudioContext if available.
  35827. */
  35828. get audioContext(): Nullable<AudioContext>;
  35829. private _connectedAnalyser;
  35830. /**
  35831. * Instantiates a new audio engine.
  35832. *
  35833. * There should be only one per page as some browsers restrict the number
  35834. * of audio contexts you can create.
  35835. * @param hostElement defines the host element where to display the mute icon if necessary
  35836. */
  35837. constructor(hostElement?: Nullable<HTMLElement>);
  35838. /**
  35839. * Flags the audio engine in Locked state.
  35840. * This happens due to new browser policies preventing audio to autoplay.
  35841. */
  35842. lock(): void;
  35843. /**
  35844. * Unlocks the audio engine once a user action has been done on the dom.
  35845. * This is helpful to resume play once browser policies have been satisfied.
  35846. */
  35847. unlock(): void;
  35848. private _resumeAudioContext;
  35849. private _initializeAudioContext;
  35850. private _tryToRun;
  35851. private _triggerRunningState;
  35852. private _triggerSuspendedState;
  35853. private _displayMuteButton;
  35854. private _moveButtonToTopLeft;
  35855. private _onResize;
  35856. private _hideMuteButton;
  35857. /**
  35858. * Destroy and release the resources associated with the audio ccontext.
  35859. */
  35860. dispose(): void;
  35861. /**
  35862. * Gets the global volume sets on the master gain.
  35863. * @returns the global volume if set or -1 otherwise
  35864. */
  35865. getGlobalVolume(): number;
  35866. /**
  35867. * Sets the global volume of your experience (sets on the master gain).
  35868. * @param newVolume Defines the new global volume of the application
  35869. */
  35870. setGlobalVolume(newVolume: number): void;
  35871. /**
  35872. * Connect the audio engine to an audio analyser allowing some amazing
  35873. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35875. * @param analyser The analyser to connect to the engine
  35876. */
  35877. connectToAnalyser(analyser: Analyser): void;
  35878. }
  35879. }
  35880. declare module BABYLON {
  35881. /**
  35882. * Interface used to present a loading screen while loading a scene
  35883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35884. */
  35885. export interface ILoadingScreen {
  35886. /**
  35887. * Function called to display the loading screen
  35888. */
  35889. displayLoadingUI: () => void;
  35890. /**
  35891. * Function called to hide the loading screen
  35892. */
  35893. hideLoadingUI: () => void;
  35894. /**
  35895. * Gets or sets the color to use for the background
  35896. */
  35897. loadingUIBackgroundColor: string;
  35898. /**
  35899. * Gets or sets the text to display while loading
  35900. */
  35901. loadingUIText: string;
  35902. }
  35903. /**
  35904. * Class used for the default loading screen
  35905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35906. */
  35907. export class DefaultLoadingScreen implements ILoadingScreen {
  35908. private _renderingCanvas;
  35909. private _loadingText;
  35910. private _loadingDivBackgroundColor;
  35911. private _loadingDiv;
  35912. private _loadingTextDiv;
  35913. /** Gets or sets the logo url to use for the default loading screen */
  35914. static DefaultLogoUrl: string;
  35915. /** Gets or sets the spinner url to use for the default loading screen */
  35916. static DefaultSpinnerUrl: string;
  35917. /**
  35918. * Creates a new default loading screen
  35919. * @param _renderingCanvas defines the canvas used to render the scene
  35920. * @param _loadingText defines the default text to display
  35921. * @param _loadingDivBackgroundColor defines the default background color
  35922. */
  35923. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35924. /**
  35925. * Function called to display the loading screen
  35926. */
  35927. displayLoadingUI(): void;
  35928. /**
  35929. * Function called to hide the loading screen
  35930. */
  35931. hideLoadingUI(): void;
  35932. /**
  35933. * Gets or sets the text to display while loading
  35934. */
  35935. set loadingUIText(text: string);
  35936. get loadingUIText(): string;
  35937. /**
  35938. * Gets or sets the color to use for the background
  35939. */
  35940. get loadingUIBackgroundColor(): string;
  35941. set loadingUIBackgroundColor(color: string);
  35942. private _resizeLoadingUI;
  35943. }
  35944. }
  35945. declare module BABYLON {
  35946. /**
  35947. * Interface for any object that can request an animation frame
  35948. */
  35949. export interface ICustomAnimationFrameRequester {
  35950. /**
  35951. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35952. */
  35953. renderFunction?: Function;
  35954. /**
  35955. * Called to request the next frame to render to
  35956. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35957. */
  35958. requestAnimationFrame: Function;
  35959. /**
  35960. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35961. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35962. */
  35963. requestID?: number;
  35964. }
  35965. }
  35966. declare module BABYLON {
  35967. /**
  35968. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35969. */
  35970. export class PerformanceMonitor {
  35971. private _enabled;
  35972. private _rollingFrameTime;
  35973. private _lastFrameTimeMs;
  35974. /**
  35975. * constructor
  35976. * @param frameSampleSize The number of samples required to saturate the sliding window
  35977. */
  35978. constructor(frameSampleSize?: number);
  35979. /**
  35980. * Samples current frame
  35981. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35982. */
  35983. sampleFrame(timeMs?: number): void;
  35984. /**
  35985. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35986. */
  35987. get averageFrameTime(): number;
  35988. /**
  35989. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35990. */
  35991. get averageFrameTimeVariance(): number;
  35992. /**
  35993. * Returns the frame time of the most recent frame
  35994. */
  35995. get instantaneousFrameTime(): number;
  35996. /**
  35997. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35998. */
  35999. get averageFPS(): number;
  36000. /**
  36001. * Returns the average framerate in frames per second using the most recent frame time
  36002. */
  36003. get instantaneousFPS(): number;
  36004. /**
  36005. * Returns true if enough samples have been taken to completely fill the sliding window
  36006. */
  36007. get isSaturated(): boolean;
  36008. /**
  36009. * Enables contributions to the sliding window sample set
  36010. */
  36011. enable(): void;
  36012. /**
  36013. * Disables contributions to the sliding window sample set
  36014. * Samples will not be interpolated over the disabled period
  36015. */
  36016. disable(): void;
  36017. /**
  36018. * Returns true if sampling is enabled
  36019. */
  36020. get isEnabled(): boolean;
  36021. /**
  36022. * Resets performance monitor
  36023. */
  36024. reset(): void;
  36025. }
  36026. /**
  36027. * RollingAverage
  36028. *
  36029. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36030. */
  36031. export class RollingAverage {
  36032. /**
  36033. * Current average
  36034. */
  36035. average: number;
  36036. /**
  36037. * Current variance
  36038. */
  36039. variance: number;
  36040. protected _samples: Array<number>;
  36041. protected _sampleCount: number;
  36042. protected _pos: number;
  36043. protected _m2: number;
  36044. /**
  36045. * constructor
  36046. * @param length The number of samples required to saturate the sliding window
  36047. */
  36048. constructor(length: number);
  36049. /**
  36050. * Adds a sample to the sample set
  36051. * @param v The sample value
  36052. */
  36053. add(v: number): void;
  36054. /**
  36055. * Returns previously added values or null if outside of history or outside the sliding window domain
  36056. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36057. * @return Value previously recorded with add() or null if outside of range
  36058. */
  36059. history(i: number): number;
  36060. /**
  36061. * Returns true if enough samples have been taken to completely fill the sliding window
  36062. * @return true if sample-set saturated
  36063. */
  36064. isSaturated(): boolean;
  36065. /**
  36066. * Resets the rolling average (equivalent to 0 samples taken so far)
  36067. */
  36068. reset(): void;
  36069. /**
  36070. * Wraps a value around the sample range boundaries
  36071. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36072. * @return Wrapped position in sample range
  36073. */
  36074. protected _wrapPosition(i: number): number;
  36075. }
  36076. }
  36077. declare module BABYLON {
  36078. /**
  36079. * This class is used to track a performance counter which is number based.
  36080. * The user has access to many properties which give statistics of different nature.
  36081. *
  36082. * The implementer can track two kinds of Performance Counter: time and count.
  36083. * 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.
  36084. * 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.
  36085. */
  36086. export class PerfCounter {
  36087. /**
  36088. * Gets or sets a global boolean to turn on and off all the counters
  36089. */
  36090. static Enabled: boolean;
  36091. /**
  36092. * Returns the smallest value ever
  36093. */
  36094. get min(): number;
  36095. /**
  36096. * Returns the biggest value ever
  36097. */
  36098. get max(): number;
  36099. /**
  36100. * Returns the average value since the performance counter is running
  36101. */
  36102. get average(): number;
  36103. /**
  36104. * Returns the average value of the last second the counter was monitored
  36105. */
  36106. get lastSecAverage(): number;
  36107. /**
  36108. * Returns the current value
  36109. */
  36110. get current(): number;
  36111. /**
  36112. * Gets the accumulated total
  36113. */
  36114. get total(): number;
  36115. /**
  36116. * Gets the total value count
  36117. */
  36118. get count(): number;
  36119. /**
  36120. * Creates a new counter
  36121. */
  36122. constructor();
  36123. /**
  36124. * Call this method to start monitoring a new frame.
  36125. * 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.
  36126. */
  36127. fetchNewFrame(): void;
  36128. /**
  36129. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36130. * @param newCount the count value to add to the monitored count
  36131. * @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.
  36132. */
  36133. addCount(newCount: number, fetchResult: boolean): void;
  36134. /**
  36135. * Start monitoring this performance counter
  36136. */
  36137. beginMonitoring(): void;
  36138. /**
  36139. * Compute the time lapsed since the previous beginMonitoring() call.
  36140. * @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
  36141. */
  36142. endMonitoring(newFrame?: boolean): void;
  36143. private _fetchResult;
  36144. private _startMonitoringTime;
  36145. private _min;
  36146. private _max;
  36147. private _average;
  36148. private _current;
  36149. private _totalValueCount;
  36150. private _totalAccumulated;
  36151. private _lastSecAverage;
  36152. private _lastSecAccumulated;
  36153. private _lastSecTime;
  36154. private _lastSecValueCount;
  36155. }
  36156. }
  36157. declare module BABYLON {
  36158. interface ThinEngine {
  36159. /**
  36160. * Sets alpha constants used by some alpha blending modes
  36161. * @param r defines the red component
  36162. * @param g defines the green component
  36163. * @param b defines the blue component
  36164. * @param a defines the alpha component
  36165. */
  36166. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36167. /**
  36168. * Sets the current alpha mode
  36169. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36170. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36172. */
  36173. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36174. /**
  36175. * Gets the current alpha mode
  36176. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36177. * @returns the current alpha mode
  36178. */
  36179. getAlphaMode(): number;
  36180. /**
  36181. * Sets the current alpha equation
  36182. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36183. */
  36184. setAlphaEquation(equation: number): void;
  36185. /**
  36186. * Gets the current alpha equation.
  36187. * @returns the current alpha equation
  36188. */
  36189. getAlphaEquation(): number;
  36190. }
  36191. }
  36192. declare module BABYLON {
  36193. interface ThinEngine {
  36194. /** @hidden */
  36195. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36196. }
  36197. }
  36198. declare module BABYLON {
  36199. /**
  36200. * Defines the interface used by display changed events
  36201. */
  36202. export interface IDisplayChangedEventArgs {
  36203. /** Gets the vrDisplay object (if any) */
  36204. vrDisplay: Nullable<any>;
  36205. /** Gets a boolean indicating if webVR is supported */
  36206. vrSupported: boolean;
  36207. }
  36208. /**
  36209. * Defines the interface used by objects containing a viewport (like a camera)
  36210. */
  36211. interface IViewportOwnerLike {
  36212. /**
  36213. * Gets or sets the viewport
  36214. */
  36215. viewport: IViewportLike;
  36216. }
  36217. /**
  36218. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36219. */
  36220. export class Engine extends ThinEngine {
  36221. /** Defines that alpha blending is disabled */
  36222. static readonly ALPHA_DISABLE: number;
  36223. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36224. static readonly ALPHA_ADD: number;
  36225. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36226. static readonly ALPHA_COMBINE: number;
  36227. /** Defines that alpha blending to DEST - SRC * DEST */
  36228. static readonly ALPHA_SUBTRACT: number;
  36229. /** Defines that alpha blending to SRC * DEST */
  36230. static readonly ALPHA_MULTIPLY: number;
  36231. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36232. static readonly ALPHA_MAXIMIZED: number;
  36233. /** Defines that alpha blending to SRC + DEST */
  36234. static readonly ALPHA_ONEONE: number;
  36235. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36236. static readonly ALPHA_PREMULTIPLIED: number;
  36237. /**
  36238. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36239. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36240. */
  36241. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36242. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36243. static readonly ALPHA_INTERPOLATE: number;
  36244. /**
  36245. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36246. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36247. */
  36248. static readonly ALPHA_SCREENMODE: number;
  36249. /** Defines that the ressource is not delayed*/
  36250. static readonly DELAYLOADSTATE_NONE: number;
  36251. /** Defines that the ressource was successfully delay loaded */
  36252. static readonly DELAYLOADSTATE_LOADED: number;
  36253. /** Defines that the ressource is currently delay loading */
  36254. static readonly DELAYLOADSTATE_LOADING: number;
  36255. /** Defines that the ressource is delayed and has not started loading */
  36256. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36257. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36258. static readonly NEVER: number;
  36259. /** 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 */
  36260. static readonly ALWAYS: number;
  36261. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36262. static readonly LESS: number;
  36263. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36264. static readonly EQUAL: number;
  36265. /** 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 */
  36266. static readonly LEQUAL: number;
  36267. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36268. static readonly GREATER: number;
  36269. /** 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 */
  36270. static readonly GEQUAL: number;
  36271. /** 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 */
  36272. static readonly NOTEQUAL: number;
  36273. /** Passed to stencilOperation to specify that stencil value must be kept */
  36274. static readonly KEEP: number;
  36275. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36276. static readonly REPLACE: number;
  36277. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36278. static readonly INCR: number;
  36279. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36280. static readonly DECR: number;
  36281. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36282. static readonly INVERT: number;
  36283. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36284. static readonly INCR_WRAP: number;
  36285. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36286. static readonly DECR_WRAP: number;
  36287. /** Texture is not repeating outside of 0..1 UVs */
  36288. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36289. /** Texture is repeating outside of 0..1 UVs */
  36290. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36291. /** Texture is repeating and mirrored */
  36292. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36293. /** ALPHA */
  36294. static readonly TEXTUREFORMAT_ALPHA: number;
  36295. /** LUMINANCE */
  36296. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36297. /** LUMINANCE_ALPHA */
  36298. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36299. /** RGB */
  36300. static readonly TEXTUREFORMAT_RGB: number;
  36301. /** RGBA */
  36302. static readonly TEXTUREFORMAT_RGBA: number;
  36303. /** RED */
  36304. static readonly TEXTUREFORMAT_RED: number;
  36305. /** RED (2nd reference) */
  36306. static readonly TEXTUREFORMAT_R: number;
  36307. /** RG */
  36308. static readonly TEXTUREFORMAT_RG: number;
  36309. /** RED_INTEGER */
  36310. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36311. /** RED_INTEGER (2nd reference) */
  36312. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36313. /** RG_INTEGER */
  36314. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36315. /** RGB_INTEGER */
  36316. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36317. /** RGBA_INTEGER */
  36318. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36319. /** UNSIGNED_BYTE */
  36320. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36321. /** UNSIGNED_BYTE (2nd reference) */
  36322. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36323. /** FLOAT */
  36324. static readonly TEXTURETYPE_FLOAT: number;
  36325. /** HALF_FLOAT */
  36326. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36327. /** BYTE */
  36328. static readonly TEXTURETYPE_BYTE: number;
  36329. /** SHORT */
  36330. static readonly TEXTURETYPE_SHORT: number;
  36331. /** UNSIGNED_SHORT */
  36332. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36333. /** INT */
  36334. static readonly TEXTURETYPE_INT: number;
  36335. /** UNSIGNED_INT */
  36336. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36337. /** UNSIGNED_SHORT_4_4_4_4 */
  36338. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36339. /** UNSIGNED_SHORT_5_5_5_1 */
  36340. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36341. /** UNSIGNED_SHORT_5_6_5 */
  36342. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36343. /** UNSIGNED_INT_2_10_10_10_REV */
  36344. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36345. /** UNSIGNED_INT_24_8 */
  36346. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36347. /** UNSIGNED_INT_10F_11F_11F_REV */
  36348. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36349. /** UNSIGNED_INT_5_9_9_9_REV */
  36350. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36351. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36352. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36353. /** nearest is mag = nearest and min = nearest and mip = linear */
  36354. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36355. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36356. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36357. /** Trilinear is mag = linear and min = linear and mip = linear */
  36358. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36359. /** nearest is mag = nearest and min = nearest and mip = linear */
  36360. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36361. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36362. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36363. /** Trilinear is mag = linear and min = linear and mip = linear */
  36364. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36365. /** mag = nearest and min = nearest and mip = nearest */
  36366. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36367. /** mag = nearest and min = linear and mip = nearest */
  36368. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36369. /** mag = nearest and min = linear and mip = linear */
  36370. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36371. /** mag = nearest and min = linear and mip = none */
  36372. static readonly TEXTURE_NEAREST_LINEAR: number;
  36373. /** mag = nearest and min = nearest and mip = none */
  36374. static readonly TEXTURE_NEAREST_NEAREST: number;
  36375. /** mag = linear and min = nearest and mip = nearest */
  36376. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36377. /** mag = linear and min = nearest and mip = linear */
  36378. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36379. /** mag = linear and min = linear and mip = none */
  36380. static readonly TEXTURE_LINEAR_LINEAR: number;
  36381. /** mag = linear and min = nearest and mip = none */
  36382. static readonly TEXTURE_LINEAR_NEAREST: number;
  36383. /** Explicit coordinates mode */
  36384. static readonly TEXTURE_EXPLICIT_MODE: number;
  36385. /** Spherical coordinates mode */
  36386. static readonly TEXTURE_SPHERICAL_MODE: number;
  36387. /** Planar coordinates mode */
  36388. static readonly TEXTURE_PLANAR_MODE: number;
  36389. /** Cubic coordinates mode */
  36390. static readonly TEXTURE_CUBIC_MODE: number;
  36391. /** Projection coordinates mode */
  36392. static readonly TEXTURE_PROJECTION_MODE: number;
  36393. /** Skybox coordinates mode */
  36394. static readonly TEXTURE_SKYBOX_MODE: number;
  36395. /** Inverse Cubic coordinates mode */
  36396. static readonly TEXTURE_INVCUBIC_MODE: number;
  36397. /** Equirectangular coordinates mode */
  36398. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36399. /** Equirectangular Fixed coordinates mode */
  36400. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36401. /** Equirectangular Fixed Mirrored coordinates mode */
  36402. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36403. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36404. static readonly SCALEMODE_FLOOR: number;
  36405. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36406. static readonly SCALEMODE_NEAREST: number;
  36407. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36408. static readonly SCALEMODE_CEILING: number;
  36409. /**
  36410. * Returns the current npm package of the sdk
  36411. */
  36412. static get NpmPackage(): string;
  36413. /**
  36414. * Returns the current version of the framework
  36415. */
  36416. static get Version(): string;
  36417. /** Gets the list of created engines */
  36418. static get Instances(): Engine[];
  36419. /**
  36420. * Gets the latest created engine
  36421. */
  36422. static get LastCreatedEngine(): Nullable<Engine>;
  36423. /**
  36424. * Gets the latest created scene
  36425. */
  36426. static get LastCreatedScene(): Nullable<Scene>;
  36427. /**
  36428. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36429. * @param flag defines which part of the materials must be marked as dirty
  36430. * @param predicate defines a predicate used to filter which materials should be affected
  36431. */
  36432. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36433. /**
  36434. * Method called to create the default loading screen.
  36435. * This can be overriden in your own app.
  36436. * @param canvas The rendering canvas element
  36437. * @returns The loading screen
  36438. */
  36439. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36440. /**
  36441. * Method called to create the default rescale post process on each engine.
  36442. */
  36443. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36444. /**
  36445. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36446. **/
  36447. enableOfflineSupport: boolean;
  36448. /**
  36449. * 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)
  36450. **/
  36451. disableManifestCheck: boolean;
  36452. /**
  36453. * Gets the list of created scenes
  36454. */
  36455. scenes: Scene[];
  36456. /**
  36457. * Event raised when a new scene is created
  36458. */
  36459. onNewSceneAddedObservable: Observable<Scene>;
  36460. /**
  36461. * Gets the list of created postprocesses
  36462. */
  36463. postProcesses: PostProcess[];
  36464. /**
  36465. * Gets a boolean indicating if the pointer is currently locked
  36466. */
  36467. isPointerLock: boolean;
  36468. /**
  36469. * Observable event triggered each time the rendering canvas is resized
  36470. */
  36471. onResizeObservable: Observable<Engine>;
  36472. /**
  36473. * Observable event triggered each time the canvas loses focus
  36474. */
  36475. onCanvasBlurObservable: Observable<Engine>;
  36476. /**
  36477. * Observable event triggered each time the canvas gains focus
  36478. */
  36479. onCanvasFocusObservable: Observable<Engine>;
  36480. /**
  36481. * Observable event triggered each time the canvas receives pointerout event
  36482. */
  36483. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36484. /**
  36485. * Observable raised when the engine begins a new frame
  36486. */
  36487. onBeginFrameObservable: Observable<Engine>;
  36488. /**
  36489. * If set, will be used to request the next animation frame for the render loop
  36490. */
  36491. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36492. /**
  36493. * Observable raised when the engine ends the current frame
  36494. */
  36495. onEndFrameObservable: Observable<Engine>;
  36496. /**
  36497. * Observable raised when the engine is about to compile a shader
  36498. */
  36499. onBeforeShaderCompilationObservable: Observable<Engine>;
  36500. /**
  36501. * Observable raised when the engine has jsut compiled a shader
  36502. */
  36503. onAfterShaderCompilationObservable: Observable<Engine>;
  36504. /**
  36505. * Gets the audio engine
  36506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36507. * @ignorenaming
  36508. */
  36509. static audioEngine: IAudioEngine;
  36510. /**
  36511. * Default AudioEngine factory responsible of creating the Audio Engine.
  36512. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36513. */
  36514. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36515. /**
  36516. * Default offline support factory responsible of creating a tool used to store data locally.
  36517. * By default, this will create a Database object if the workload has been embedded.
  36518. */
  36519. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36520. private _loadingScreen;
  36521. private _pointerLockRequested;
  36522. private _rescalePostProcess;
  36523. private _deterministicLockstep;
  36524. private _lockstepMaxSteps;
  36525. private _timeStep;
  36526. protected get _supportsHardwareTextureRescaling(): boolean;
  36527. private _fps;
  36528. private _deltaTime;
  36529. /** @hidden */
  36530. _drawCalls: PerfCounter;
  36531. /** 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 */
  36532. canvasTabIndex: number;
  36533. /**
  36534. * Turn this value on if you want to pause FPS computation when in background
  36535. */
  36536. disablePerformanceMonitorInBackground: boolean;
  36537. private _performanceMonitor;
  36538. /**
  36539. * Gets the performance monitor attached to this engine
  36540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36541. */
  36542. get performanceMonitor(): PerformanceMonitor;
  36543. private _onFocus;
  36544. private _onBlur;
  36545. private _onCanvasPointerOut;
  36546. private _onCanvasBlur;
  36547. private _onCanvasFocus;
  36548. private _onFullscreenChange;
  36549. private _onPointerLockChange;
  36550. /**
  36551. * Gets the HTML element used to attach event listeners
  36552. * @returns a HTML element
  36553. */
  36554. getInputElement(): Nullable<HTMLElement>;
  36555. /**
  36556. * Creates a new engine
  36557. * @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
  36558. * @param antialias defines enable antialiasing (default: false)
  36559. * @param options defines further options to be sent to the getContext() function
  36560. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36561. */
  36562. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36563. /**
  36564. * Gets current aspect ratio
  36565. * @param viewportOwner defines the camera to use to get the aspect ratio
  36566. * @param useScreen defines if screen size must be used (or the current render target if any)
  36567. * @returns a number defining the aspect ratio
  36568. */
  36569. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36570. /**
  36571. * Gets current screen aspect ratio
  36572. * @returns a number defining the aspect ratio
  36573. */
  36574. getScreenAspectRatio(): number;
  36575. /**
  36576. * Gets the client rect of the HTML canvas attached with the current webGL context
  36577. * @returns a client rectanglee
  36578. */
  36579. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36580. /**
  36581. * Gets the client rect of the HTML element used for events
  36582. * @returns a client rectanglee
  36583. */
  36584. getInputElementClientRect(): Nullable<ClientRect>;
  36585. /**
  36586. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36588. * @returns true if engine is in deterministic lock step mode
  36589. */
  36590. isDeterministicLockStep(): boolean;
  36591. /**
  36592. * Gets the max steps when engine is running in deterministic lock step
  36593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36594. * @returns the max steps
  36595. */
  36596. getLockstepMaxSteps(): number;
  36597. /**
  36598. * Returns the time in ms between steps when using deterministic lock step.
  36599. * @returns time step in (ms)
  36600. */
  36601. getTimeStep(): number;
  36602. /**
  36603. * Force the mipmap generation for the given render target texture
  36604. * @param texture defines the render target texture to use
  36605. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36606. */
  36607. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36608. /** States */
  36609. /**
  36610. * Set various states to the webGL context
  36611. * @param culling defines backface culling state
  36612. * @param zOffset defines the value to apply to zOffset (0 by default)
  36613. * @param force defines if states must be applied even if cache is up to date
  36614. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36615. */
  36616. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36617. /**
  36618. * Set the z offset to apply to current rendering
  36619. * @param value defines the offset to apply
  36620. */
  36621. setZOffset(value: number): void;
  36622. /**
  36623. * Gets the current value of the zOffset
  36624. * @returns the current zOffset state
  36625. */
  36626. getZOffset(): number;
  36627. /**
  36628. * Enable or disable depth buffering
  36629. * @param enable defines the state to set
  36630. */
  36631. setDepthBuffer(enable: boolean): void;
  36632. /**
  36633. * Gets a boolean indicating if depth writing is enabled
  36634. * @returns the current depth writing state
  36635. */
  36636. getDepthWrite(): boolean;
  36637. /**
  36638. * Enable or disable depth writing
  36639. * @param enable defines the state to set
  36640. */
  36641. setDepthWrite(enable: boolean): void;
  36642. /**
  36643. * Gets a boolean indicating if stencil buffer is enabled
  36644. * @returns the current stencil buffer state
  36645. */
  36646. getStencilBuffer(): boolean;
  36647. /**
  36648. * Enable or disable the stencil buffer
  36649. * @param enable defines if the stencil buffer must be enabled or disabled
  36650. */
  36651. setStencilBuffer(enable: boolean): void;
  36652. /**
  36653. * Gets the current stencil mask
  36654. * @returns a number defining the new stencil mask to use
  36655. */
  36656. getStencilMask(): number;
  36657. /**
  36658. * Sets the current stencil mask
  36659. * @param mask defines the new stencil mask to use
  36660. */
  36661. setStencilMask(mask: number): void;
  36662. /**
  36663. * Gets the current stencil function
  36664. * @returns a number defining the stencil function to use
  36665. */
  36666. getStencilFunction(): number;
  36667. /**
  36668. * Gets the current stencil reference value
  36669. * @returns a number defining the stencil reference value to use
  36670. */
  36671. getStencilFunctionReference(): number;
  36672. /**
  36673. * Gets the current stencil mask
  36674. * @returns a number defining the stencil mask to use
  36675. */
  36676. getStencilFunctionMask(): number;
  36677. /**
  36678. * Sets the current stencil function
  36679. * @param stencilFunc defines the new stencil function to use
  36680. */
  36681. setStencilFunction(stencilFunc: number): void;
  36682. /**
  36683. * Sets the current stencil reference
  36684. * @param reference defines the new stencil reference to use
  36685. */
  36686. setStencilFunctionReference(reference: number): void;
  36687. /**
  36688. * Sets the current stencil mask
  36689. * @param mask defines the new stencil mask to use
  36690. */
  36691. setStencilFunctionMask(mask: number): void;
  36692. /**
  36693. * Gets the current stencil operation when stencil fails
  36694. * @returns a number defining stencil operation to use when stencil fails
  36695. */
  36696. getStencilOperationFail(): number;
  36697. /**
  36698. * Gets the current stencil operation when depth fails
  36699. * @returns a number defining stencil operation to use when depth fails
  36700. */
  36701. getStencilOperationDepthFail(): number;
  36702. /**
  36703. * Gets the current stencil operation when stencil passes
  36704. * @returns a number defining stencil operation to use when stencil passes
  36705. */
  36706. getStencilOperationPass(): number;
  36707. /**
  36708. * Sets the stencil operation to use when stencil fails
  36709. * @param operation defines the stencil operation to use when stencil fails
  36710. */
  36711. setStencilOperationFail(operation: number): void;
  36712. /**
  36713. * Sets the stencil operation to use when depth fails
  36714. * @param operation defines the stencil operation to use when depth fails
  36715. */
  36716. setStencilOperationDepthFail(operation: number): void;
  36717. /**
  36718. * Sets the stencil operation to use when stencil passes
  36719. * @param operation defines the stencil operation to use when stencil passes
  36720. */
  36721. setStencilOperationPass(operation: number): void;
  36722. /**
  36723. * Sets a boolean indicating if the dithering state is enabled or disabled
  36724. * @param value defines the dithering state
  36725. */
  36726. setDitheringState(value: boolean): void;
  36727. /**
  36728. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36729. * @param value defines the rasterizer state
  36730. */
  36731. setRasterizerState(value: boolean): void;
  36732. /**
  36733. * Gets the current depth function
  36734. * @returns a number defining the depth function
  36735. */
  36736. getDepthFunction(): Nullable<number>;
  36737. /**
  36738. * Sets the current depth function
  36739. * @param depthFunc defines the function to use
  36740. */
  36741. setDepthFunction(depthFunc: number): void;
  36742. /**
  36743. * Sets the current depth function to GREATER
  36744. */
  36745. setDepthFunctionToGreater(): void;
  36746. /**
  36747. * Sets the current depth function to GEQUAL
  36748. */
  36749. setDepthFunctionToGreaterOrEqual(): void;
  36750. /**
  36751. * Sets the current depth function to LESS
  36752. */
  36753. setDepthFunctionToLess(): void;
  36754. /**
  36755. * Sets the current depth function to LEQUAL
  36756. */
  36757. setDepthFunctionToLessOrEqual(): void;
  36758. private _cachedStencilBuffer;
  36759. private _cachedStencilFunction;
  36760. private _cachedStencilMask;
  36761. private _cachedStencilOperationPass;
  36762. private _cachedStencilOperationFail;
  36763. private _cachedStencilOperationDepthFail;
  36764. private _cachedStencilReference;
  36765. /**
  36766. * Caches the the state of the stencil buffer
  36767. */
  36768. cacheStencilState(): void;
  36769. /**
  36770. * Restores the state of the stencil buffer
  36771. */
  36772. restoreStencilState(): void;
  36773. /**
  36774. * Directly set the WebGL Viewport
  36775. * @param x defines the x coordinate of the viewport (in screen space)
  36776. * @param y defines the y coordinate of the viewport (in screen space)
  36777. * @param width defines the width of the viewport (in screen space)
  36778. * @param height defines the height of the viewport (in screen space)
  36779. * @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
  36780. */
  36781. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36782. /**
  36783. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36784. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36785. * @param y defines the y-coordinate of the corner of the clear rectangle
  36786. * @param width defines the width of the clear rectangle
  36787. * @param height defines the height of the clear rectangle
  36788. * @param clearColor defines the clear color
  36789. */
  36790. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36791. /**
  36792. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36793. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36794. * @param y defines the y-coordinate of the corner of the clear rectangle
  36795. * @param width defines the width of the clear rectangle
  36796. * @param height defines the height of the clear rectangle
  36797. */
  36798. enableScissor(x: number, y: number, width: number, height: number): void;
  36799. /**
  36800. * Disable previously set scissor test rectangle
  36801. */
  36802. disableScissor(): void;
  36803. protected _reportDrawCall(): void;
  36804. /**
  36805. * Initializes a webVR display and starts listening to display change events
  36806. * The onVRDisplayChangedObservable will be notified upon these changes
  36807. * @returns The onVRDisplayChangedObservable
  36808. */
  36809. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36810. /** @hidden */
  36811. _prepareVRComponent(): void;
  36812. /** @hidden */
  36813. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36814. /** @hidden */
  36815. _submitVRFrame(): void;
  36816. /**
  36817. * Call this function to leave webVR mode
  36818. * Will do nothing if webVR is not supported or if there is no webVR device
  36819. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36820. */
  36821. disableVR(): void;
  36822. /**
  36823. * Gets a boolean indicating that the system is in VR mode and is presenting
  36824. * @returns true if VR mode is engaged
  36825. */
  36826. isVRPresenting(): boolean;
  36827. /** @hidden */
  36828. _requestVRFrame(): void;
  36829. /** @hidden */
  36830. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36831. /**
  36832. * Gets the source code of the vertex shader associated with a specific webGL program
  36833. * @param program defines the program to use
  36834. * @returns a string containing the source code of the vertex shader associated with the program
  36835. */
  36836. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36837. /**
  36838. * Gets the source code of the fragment shader associated with a specific webGL program
  36839. * @param program defines the program to use
  36840. * @returns a string containing the source code of the fragment shader associated with the program
  36841. */
  36842. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36843. /**
  36844. * Sets a depth stencil texture from a render target to the according uniform.
  36845. * @param channel The texture channel
  36846. * @param uniform The uniform to set
  36847. * @param texture The render target texture containing the depth stencil texture to apply
  36848. */
  36849. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36850. /**
  36851. * Sets a texture to the webGL context from a postprocess
  36852. * @param channel defines the channel to use
  36853. * @param postProcess defines the source postprocess
  36854. */
  36855. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36856. /**
  36857. * Binds the output of the passed in post process to the texture channel specified
  36858. * @param channel The channel the texture should be bound to
  36859. * @param postProcess The post process which's output should be bound
  36860. */
  36861. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36862. protected _rebuildBuffers(): void;
  36863. /** @hidden */
  36864. _renderFrame(): void;
  36865. _renderLoop(): void;
  36866. /** @hidden */
  36867. _renderViews(): boolean;
  36868. /**
  36869. * Toggle full screen mode
  36870. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36871. */
  36872. switchFullscreen(requestPointerLock: boolean): void;
  36873. /**
  36874. * Enters full screen mode
  36875. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36876. */
  36877. enterFullscreen(requestPointerLock: boolean): void;
  36878. /**
  36879. * Exits full screen mode
  36880. */
  36881. exitFullscreen(): void;
  36882. /**
  36883. * Enters Pointerlock mode
  36884. */
  36885. enterPointerlock(): void;
  36886. /**
  36887. * Exits Pointerlock mode
  36888. */
  36889. exitPointerlock(): void;
  36890. /**
  36891. * Begin a new frame
  36892. */
  36893. beginFrame(): void;
  36894. /**
  36895. * Enf the current frame
  36896. */
  36897. endFrame(): void;
  36898. resize(): void;
  36899. /**
  36900. * Force a specific size of the canvas
  36901. * @param width defines the new canvas' width
  36902. * @param height defines the new canvas' height
  36903. */
  36904. setSize(width: number, height: number): void;
  36905. /**
  36906. * Updates a dynamic vertex buffer.
  36907. * @param vertexBuffer the vertex buffer to update
  36908. * @param data the data used to update the vertex buffer
  36909. * @param byteOffset the byte offset of the data
  36910. * @param byteLength the byte length of the data
  36911. */
  36912. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36913. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36914. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36915. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36916. _releaseTexture(texture: InternalTexture): void;
  36917. /**
  36918. * @hidden
  36919. * Rescales a texture
  36920. * @param source input texutre
  36921. * @param destination destination texture
  36922. * @param scene scene to use to render the resize
  36923. * @param internalFormat format to use when resizing
  36924. * @param onComplete callback to be called when resize has completed
  36925. */
  36926. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36927. /**
  36928. * Gets the current framerate
  36929. * @returns a number representing the framerate
  36930. */
  36931. getFps(): number;
  36932. /**
  36933. * Gets the time spent between current and previous frame
  36934. * @returns a number representing the delta time in ms
  36935. */
  36936. getDeltaTime(): number;
  36937. private _measureFps;
  36938. /** @hidden */
  36939. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36940. /**
  36941. * Update a dynamic index buffer
  36942. * @param indexBuffer defines the target index buffer
  36943. * @param indices defines the data to update
  36944. * @param offset defines the offset in the target index buffer where update should start
  36945. */
  36946. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36947. /**
  36948. * Updates the sample count of a render target texture
  36949. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36950. * @param texture defines the texture to update
  36951. * @param samples defines the sample count to set
  36952. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36953. */
  36954. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36955. /**
  36956. * Updates a depth texture Comparison Mode and Function.
  36957. * If the comparison Function is equal to 0, the mode will be set to none.
  36958. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36959. * @param texture The texture to set the comparison function for
  36960. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36961. */
  36962. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36963. /**
  36964. * Creates a webGL buffer to use with instanciation
  36965. * @param capacity defines the size of the buffer
  36966. * @returns the webGL buffer
  36967. */
  36968. createInstancesBuffer(capacity: number): DataBuffer;
  36969. /**
  36970. * Delete a webGL buffer used with instanciation
  36971. * @param buffer defines the webGL buffer to delete
  36972. */
  36973. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36974. private _clientWaitAsync;
  36975. /** @hidden */
  36976. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36977. dispose(): void;
  36978. private _disableTouchAction;
  36979. /**
  36980. * Display the loading screen
  36981. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36982. */
  36983. displayLoadingUI(): void;
  36984. /**
  36985. * Hide the loading screen
  36986. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36987. */
  36988. hideLoadingUI(): void;
  36989. /**
  36990. * Gets the current loading screen object
  36991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36992. */
  36993. get loadingScreen(): ILoadingScreen;
  36994. /**
  36995. * Sets the current loading screen object
  36996. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36997. */
  36998. set loadingScreen(loadingScreen: ILoadingScreen);
  36999. /**
  37000. * Sets the current loading screen text
  37001. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37002. */
  37003. set loadingUIText(text: string);
  37004. /**
  37005. * Sets the current loading screen background color
  37006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37007. */
  37008. set loadingUIBackgroundColor(color: string);
  37009. /** Pointerlock and fullscreen */
  37010. /**
  37011. * Ask the browser to promote the current element to pointerlock mode
  37012. * @param element defines the DOM element to promote
  37013. */
  37014. static _RequestPointerlock(element: HTMLElement): void;
  37015. /**
  37016. * Asks the browser to exit pointerlock mode
  37017. */
  37018. static _ExitPointerlock(): void;
  37019. /**
  37020. * Ask the browser to promote the current element to fullscreen rendering mode
  37021. * @param element defines the DOM element to promote
  37022. */
  37023. static _RequestFullscreen(element: HTMLElement): void;
  37024. /**
  37025. * Asks the browser to exit fullscreen mode
  37026. */
  37027. static _ExitFullscreen(): void;
  37028. }
  37029. }
  37030. declare module BABYLON {
  37031. /**
  37032. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37033. * during the life time of the application.
  37034. */
  37035. export class EngineStore {
  37036. /** Gets the list of created engines */
  37037. static Instances: Engine[];
  37038. /** @hidden */
  37039. static _LastCreatedScene: Nullable<Scene>;
  37040. /**
  37041. * Gets the latest created engine
  37042. */
  37043. static get LastCreatedEngine(): Nullable<Engine>;
  37044. /**
  37045. * Gets the latest created scene
  37046. */
  37047. static get LastCreatedScene(): Nullable<Scene>;
  37048. /**
  37049. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37050. * @ignorenaming
  37051. */
  37052. static UseFallbackTexture: boolean;
  37053. /**
  37054. * Texture content used if a texture cannot loaded
  37055. * @ignorenaming
  37056. */
  37057. static FallbackTexture: string;
  37058. }
  37059. }
  37060. declare module BABYLON {
  37061. /**
  37062. * Helper class that provides a small promise polyfill
  37063. */
  37064. export class PromisePolyfill {
  37065. /**
  37066. * Static function used to check if the polyfill is required
  37067. * If this is the case then the function will inject the polyfill to window.Promise
  37068. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37069. */
  37070. static Apply(force?: boolean): void;
  37071. }
  37072. }
  37073. declare module BABYLON {
  37074. /**
  37075. * Interface for screenshot methods with describe argument called `size` as object with options
  37076. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37077. */
  37078. export interface IScreenshotSize {
  37079. /**
  37080. * number in pixels for canvas height
  37081. */
  37082. height?: number;
  37083. /**
  37084. * multiplier allowing render at a higher or lower resolution
  37085. * If value is defined then height and width will be ignored and taken from camera
  37086. */
  37087. precision?: number;
  37088. /**
  37089. * number in pixels for canvas width
  37090. */
  37091. width?: number;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. interface IColor4Like {
  37096. r: float;
  37097. g: float;
  37098. b: float;
  37099. a: float;
  37100. }
  37101. /**
  37102. * Class containing a set of static utilities functions
  37103. */
  37104. export class Tools {
  37105. /**
  37106. * Gets or sets the base URL to use to load assets
  37107. */
  37108. static get BaseUrl(): string;
  37109. static set BaseUrl(value: string);
  37110. /**
  37111. * Enable/Disable Custom HTTP Request Headers globally.
  37112. * default = false
  37113. * @see CustomRequestHeaders
  37114. */
  37115. static UseCustomRequestHeaders: boolean;
  37116. /**
  37117. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37118. * i.e. when loading files, where the server/service expects an Authorization header
  37119. */
  37120. static CustomRequestHeaders: {
  37121. [key: string]: string;
  37122. };
  37123. /**
  37124. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37125. */
  37126. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37127. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37128. /**
  37129. * Default behaviour for cors in the application.
  37130. * It can be a string if the expected behavior is identical in the entire app.
  37131. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37132. */
  37133. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37134. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37135. /**
  37136. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37137. * @ignorenaming
  37138. */
  37139. static get UseFallbackTexture(): boolean;
  37140. static set UseFallbackTexture(value: boolean);
  37141. /**
  37142. * Use this object to register external classes like custom textures or material
  37143. * to allow the laoders to instantiate them
  37144. */
  37145. static get RegisteredExternalClasses(): {
  37146. [key: string]: Object;
  37147. };
  37148. static set RegisteredExternalClasses(classes: {
  37149. [key: string]: Object;
  37150. });
  37151. /**
  37152. * Texture content used if a texture cannot loaded
  37153. * @ignorenaming
  37154. */
  37155. static get fallbackTexture(): string;
  37156. static set fallbackTexture(value: string);
  37157. /**
  37158. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37159. * @param u defines the coordinate on X axis
  37160. * @param v defines the coordinate on Y axis
  37161. * @param width defines the width of the source data
  37162. * @param height defines the height of the source data
  37163. * @param pixels defines the source byte array
  37164. * @param color defines the output color
  37165. */
  37166. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37167. /**
  37168. * Interpolates between a and b via alpha
  37169. * @param a The lower value (returned when alpha = 0)
  37170. * @param b The upper value (returned when alpha = 1)
  37171. * @param alpha The interpolation-factor
  37172. * @return The mixed value
  37173. */
  37174. static Mix(a: number, b: number, alpha: number): number;
  37175. /**
  37176. * Tries to instantiate a new object from a given class name
  37177. * @param className defines the class name to instantiate
  37178. * @returns the new object or null if the system was not able to do the instantiation
  37179. */
  37180. static Instantiate(className: string): any;
  37181. /**
  37182. * Provides a slice function that will work even on IE
  37183. * @param data defines the array to slice
  37184. * @param start defines the start of the data (optional)
  37185. * @param end defines the end of the data (optional)
  37186. * @returns the new sliced array
  37187. */
  37188. static Slice<T>(data: T, start?: number, end?: number): T;
  37189. /**
  37190. * Polyfill for setImmediate
  37191. * @param action defines the action to execute after the current execution block
  37192. */
  37193. static SetImmediate(action: () => void): void;
  37194. /**
  37195. * Function indicating if a number is an exponent of 2
  37196. * @param value defines the value to test
  37197. * @returns true if the value is an exponent of 2
  37198. */
  37199. static IsExponentOfTwo(value: number): boolean;
  37200. private static _tmpFloatArray;
  37201. /**
  37202. * Returns the nearest 32-bit single precision float representation of a Number
  37203. * @param value A Number. If the parameter is of a different type, it will get converted
  37204. * to a number or to NaN if it cannot be converted
  37205. * @returns number
  37206. */
  37207. static FloatRound(value: number): number;
  37208. /**
  37209. * Extracts the filename from a path
  37210. * @param path defines the path to use
  37211. * @returns the filename
  37212. */
  37213. static GetFilename(path: string): string;
  37214. /**
  37215. * Extracts the "folder" part of a path (everything before the filename).
  37216. * @param uri The URI to extract the info from
  37217. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37218. * @returns The "folder" part of the path
  37219. */
  37220. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37221. /**
  37222. * Extracts text content from a DOM element hierarchy
  37223. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37224. */
  37225. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37226. /**
  37227. * Convert an angle in radians to degrees
  37228. * @param angle defines the angle to convert
  37229. * @returns the angle in degrees
  37230. */
  37231. static ToDegrees(angle: number): number;
  37232. /**
  37233. * Convert an angle in degrees to radians
  37234. * @param angle defines the angle to convert
  37235. * @returns the angle in radians
  37236. */
  37237. static ToRadians(angle: number): number;
  37238. /**
  37239. * Returns an array if obj is not an array
  37240. * @param obj defines the object to evaluate as an array
  37241. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37242. * @returns either obj directly if obj is an array or a new array containing obj
  37243. */
  37244. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37245. /**
  37246. * Gets the pointer prefix to use
  37247. * @param engine defines the engine we are finding the prefix for
  37248. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37249. */
  37250. static GetPointerPrefix(engine: Engine): string;
  37251. /**
  37252. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37253. * @param url define the url we are trying
  37254. * @param element define the dom element where to configure the cors policy
  37255. */
  37256. static SetCorsBehavior(url: string | string[], element: {
  37257. crossOrigin: string | null;
  37258. }): void;
  37259. /**
  37260. * Removes unwanted characters from an url
  37261. * @param url defines the url to clean
  37262. * @returns the cleaned url
  37263. */
  37264. static CleanUrl(url: string): string;
  37265. /**
  37266. * Gets or sets a function used to pre-process url before using them to load assets
  37267. */
  37268. static get PreprocessUrl(): (url: string) => string;
  37269. static set PreprocessUrl(processor: (url: string) => string);
  37270. /**
  37271. * Loads an image as an HTMLImageElement.
  37272. * @param input url string, ArrayBuffer, or Blob to load
  37273. * @param onLoad callback called when the image successfully loads
  37274. * @param onError callback called when the image fails to load
  37275. * @param offlineProvider offline provider for caching
  37276. * @param mimeType optional mime type
  37277. * @returns the HTMLImageElement of the loaded image
  37278. */
  37279. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37280. /**
  37281. * Loads a file from a url
  37282. * @param url url string, ArrayBuffer, or Blob to load
  37283. * @param onSuccess callback called when the file successfully loads
  37284. * @param onProgress callback called while file is loading (if the server supports this mode)
  37285. * @param offlineProvider defines the offline provider for caching
  37286. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37287. * @param onError callback called when the file fails to load
  37288. * @returns a file request object
  37289. */
  37290. 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;
  37291. /**
  37292. * Loads a file from a url
  37293. * @param url the file url to load
  37294. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37295. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37296. */
  37297. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37298. /**
  37299. * Load a script (identified by an url). When the url returns, the
  37300. * content of this file is added into a new script element, attached to the DOM (body element)
  37301. * @param scriptUrl defines the url of the script to laod
  37302. * @param onSuccess defines the callback called when the script is loaded
  37303. * @param onError defines the callback to call if an error occurs
  37304. * @param scriptId defines the id of the script element
  37305. */
  37306. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37307. /**
  37308. * Load an asynchronous script (identified by an url). When the url returns, the
  37309. * content of this file is added into a new script element, attached to the DOM (body element)
  37310. * @param scriptUrl defines the url of the script to laod
  37311. * @param scriptId defines the id of the script element
  37312. * @returns a promise request object
  37313. */
  37314. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37315. /**
  37316. * Loads a file from a blob
  37317. * @param fileToLoad defines the blob to use
  37318. * @param callback defines the callback to call when data is loaded
  37319. * @param progressCallback defines the callback to call during loading process
  37320. * @returns a file request object
  37321. */
  37322. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37323. /**
  37324. * Reads a file from a File object
  37325. * @param file defines the file to load
  37326. * @param onSuccess defines the callback to call when data is loaded
  37327. * @param onProgress defines the callback to call during loading process
  37328. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37329. * @param onError defines the callback to call when an error occurs
  37330. * @returns a file request object
  37331. */
  37332. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37333. /**
  37334. * Creates a data url from a given string content
  37335. * @param content defines the content to convert
  37336. * @returns the new data url link
  37337. */
  37338. static FileAsURL(content: string): string;
  37339. /**
  37340. * Format the given number to a specific decimal format
  37341. * @param value defines the number to format
  37342. * @param decimals defines the number of decimals to use
  37343. * @returns the formatted string
  37344. */
  37345. static Format(value: number, decimals?: number): string;
  37346. /**
  37347. * Tries to copy an object by duplicating every property
  37348. * @param source defines the source object
  37349. * @param destination defines the target object
  37350. * @param doNotCopyList defines a list of properties to avoid
  37351. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37352. */
  37353. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37354. /**
  37355. * Gets a boolean indicating if the given object has no own property
  37356. * @param obj defines the object to test
  37357. * @returns true if object has no own property
  37358. */
  37359. static IsEmpty(obj: any): boolean;
  37360. /**
  37361. * Function used to register events at window level
  37362. * @param windowElement defines the Window object to use
  37363. * @param events defines the events to register
  37364. */
  37365. static RegisterTopRootEvents(windowElement: Window, events: {
  37366. name: string;
  37367. handler: Nullable<(e: FocusEvent) => any>;
  37368. }[]): void;
  37369. /**
  37370. * Function used to unregister events from window level
  37371. * @param windowElement defines the Window object to use
  37372. * @param events defines the events to unregister
  37373. */
  37374. static UnregisterTopRootEvents(windowElement: Window, events: {
  37375. name: string;
  37376. handler: Nullable<(e: FocusEvent) => any>;
  37377. }[]): void;
  37378. /**
  37379. * @ignore
  37380. */
  37381. static _ScreenshotCanvas: HTMLCanvasElement;
  37382. /**
  37383. * Dumps the current bound framebuffer
  37384. * @param width defines the rendering width
  37385. * @param height defines the rendering height
  37386. * @param engine defines the hosting engine
  37387. * @param successCallback defines the callback triggered once the data are available
  37388. * @param mimeType defines the mime type of the result
  37389. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37390. */
  37391. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37392. /**
  37393. * Converts the canvas data to blob.
  37394. * This acts as a polyfill for browsers not supporting the to blob function.
  37395. * @param canvas Defines the canvas to extract the data from
  37396. * @param successCallback Defines the callback triggered once the data are available
  37397. * @param mimeType Defines the mime type of the result
  37398. */
  37399. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37400. /**
  37401. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37402. * @param successCallback defines the callback triggered once the data are available
  37403. * @param mimeType defines the mime type of the result
  37404. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37405. */
  37406. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37407. /**
  37408. * Downloads a blob in the browser
  37409. * @param blob defines the blob to download
  37410. * @param fileName defines the name of the downloaded file
  37411. */
  37412. static Download(blob: Blob, fileName: string): void;
  37413. /**
  37414. * Captures a screenshot of the current rendering
  37415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37416. * @param engine defines the rendering engine
  37417. * @param camera defines the source camera
  37418. * @param size This parameter can be set to a single number or to an object with the
  37419. * following (optional) properties: precision, width, height. If a single number is passed,
  37420. * it will be used for both width and height. If an object is passed, the screenshot size
  37421. * will be derived from the parameters. The precision property is a multiplier allowing
  37422. * rendering at a higher or lower resolution
  37423. * @param successCallback defines the callback receives a single parameter which contains the
  37424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37425. * src parameter of an <img> to display it
  37426. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37427. * Check your browser for supported MIME types
  37428. */
  37429. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37430. /**
  37431. * Captures a screenshot of the current rendering
  37432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37433. * @param engine defines the rendering engine
  37434. * @param camera defines the source camera
  37435. * @param size This parameter can be set to a single number or to an object with the
  37436. * following (optional) properties: precision, width, height. If a single number is passed,
  37437. * it will be used for both width and height. If an object is passed, the screenshot size
  37438. * will be derived from the parameters. The precision property is a multiplier allowing
  37439. * rendering at a higher or lower resolution
  37440. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37441. * Check your browser for supported MIME types
  37442. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37443. * to the src parameter of an <img> to display it
  37444. */
  37445. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37446. /**
  37447. * Generates an image screenshot from the specified camera.
  37448. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37449. * @param engine The engine to use for rendering
  37450. * @param camera The camera to use for rendering
  37451. * @param size This parameter can be set to a single number or to an object with the
  37452. * following (optional) properties: precision, width, height. If a single number is passed,
  37453. * it will be used for both width and height. If an object is passed, the screenshot size
  37454. * will be derived from the parameters. The precision property is a multiplier allowing
  37455. * rendering at a higher or lower resolution
  37456. * @param successCallback The callback receives a single parameter which contains the
  37457. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37458. * src parameter of an <img> to display it
  37459. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37460. * Check your browser for supported MIME types
  37461. * @param samples Texture samples (default: 1)
  37462. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37463. * @param fileName A name for for the downloaded file.
  37464. */
  37465. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37466. /**
  37467. * Generates an image screenshot from the specified camera.
  37468. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37469. * @param engine The engine to use for rendering
  37470. * @param camera The camera to use for rendering
  37471. * @param size This parameter can be set to a single number or to an object with the
  37472. * following (optional) properties: precision, width, height. If a single number is passed,
  37473. * it will be used for both width and height. If an object is passed, the screenshot size
  37474. * will be derived from the parameters. The precision property is a multiplier allowing
  37475. * rendering at a higher or lower resolution
  37476. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37477. * Check your browser for supported MIME types
  37478. * @param samples Texture samples (default: 1)
  37479. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37480. * @param fileName A name for for the downloaded file.
  37481. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37482. * to the src parameter of an <img> to display it
  37483. */
  37484. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37485. /**
  37486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37487. * Be aware Math.random() could cause collisions, but:
  37488. * "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"
  37489. * @returns a pseudo random id
  37490. */
  37491. static RandomId(): string;
  37492. /**
  37493. * Test if the given uri is a base64 string
  37494. * @param uri The uri to test
  37495. * @return True if the uri is a base64 string or false otherwise
  37496. */
  37497. static IsBase64(uri: string): boolean;
  37498. /**
  37499. * Decode the given base64 uri.
  37500. * @param uri The uri to decode
  37501. * @return The decoded base64 data.
  37502. */
  37503. static DecodeBase64(uri: string): ArrayBuffer;
  37504. /**
  37505. * Gets the absolute url.
  37506. * @param url the input url
  37507. * @return the absolute url
  37508. */
  37509. static GetAbsoluteUrl(url: string): string;
  37510. /**
  37511. * No log
  37512. */
  37513. static readonly NoneLogLevel: number;
  37514. /**
  37515. * Only message logs
  37516. */
  37517. static readonly MessageLogLevel: number;
  37518. /**
  37519. * Only warning logs
  37520. */
  37521. static readonly WarningLogLevel: number;
  37522. /**
  37523. * Only error logs
  37524. */
  37525. static readonly ErrorLogLevel: number;
  37526. /**
  37527. * All logs
  37528. */
  37529. static readonly AllLogLevel: number;
  37530. /**
  37531. * Gets a value indicating the number of loading errors
  37532. * @ignorenaming
  37533. */
  37534. static get errorsCount(): number;
  37535. /**
  37536. * Callback called when a new log is added
  37537. */
  37538. static OnNewCacheEntry: (entry: string) => void;
  37539. /**
  37540. * Log a message to the console
  37541. * @param message defines the message to log
  37542. */
  37543. static Log(message: string): void;
  37544. /**
  37545. * Write a warning message to the console
  37546. * @param message defines the message to log
  37547. */
  37548. static Warn(message: string): void;
  37549. /**
  37550. * Write an error message to the console
  37551. * @param message defines the message to log
  37552. */
  37553. static Error(message: string): void;
  37554. /**
  37555. * Gets current log cache (list of logs)
  37556. */
  37557. static get LogCache(): string;
  37558. /**
  37559. * Clears the log cache
  37560. */
  37561. static ClearLogCache(): void;
  37562. /**
  37563. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37564. */
  37565. static set LogLevels(level: number);
  37566. /**
  37567. * Checks if the window object exists
  37568. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37569. */
  37570. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37571. /**
  37572. * No performance log
  37573. */
  37574. static readonly PerformanceNoneLogLevel: number;
  37575. /**
  37576. * Use user marks to log performance
  37577. */
  37578. static readonly PerformanceUserMarkLogLevel: number;
  37579. /**
  37580. * Log performance to the console
  37581. */
  37582. static readonly PerformanceConsoleLogLevel: number;
  37583. private static _performance;
  37584. /**
  37585. * Sets the current performance log level
  37586. */
  37587. static set PerformanceLogLevel(level: number);
  37588. private static _StartPerformanceCounterDisabled;
  37589. private static _EndPerformanceCounterDisabled;
  37590. private static _StartUserMark;
  37591. private static _EndUserMark;
  37592. private static _StartPerformanceConsole;
  37593. private static _EndPerformanceConsole;
  37594. /**
  37595. * Starts a performance counter
  37596. */
  37597. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37598. /**
  37599. * Ends a specific performance coutner
  37600. */
  37601. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37602. /**
  37603. * Gets either window.performance.now() if supported or Date.now() else
  37604. */
  37605. static get Now(): number;
  37606. /**
  37607. * This method will return the name of the class used to create the instance of the given object.
  37608. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37609. * @param object the object to get the class name from
  37610. * @param isType defines if the object is actually a type
  37611. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37612. */
  37613. static GetClassName(object: any, isType?: boolean): string;
  37614. /**
  37615. * Gets the first element of an array satisfying a given predicate
  37616. * @param array defines the array to browse
  37617. * @param predicate defines the predicate to use
  37618. * @returns null if not found or the element
  37619. */
  37620. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37621. /**
  37622. * This method will return the name of the full name of the class, including its owning module (if any).
  37623. * 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).
  37624. * @param object the object to get the class name from
  37625. * @param isType defines if the object is actually a type
  37626. * @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.
  37627. * @ignorenaming
  37628. */
  37629. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37630. /**
  37631. * Returns a promise that resolves after the given amount of time.
  37632. * @param delay Number of milliseconds to delay
  37633. * @returns Promise that resolves after the given amount of time
  37634. */
  37635. static DelayAsync(delay: number): Promise<void>;
  37636. /**
  37637. * Utility function to detect if the current user agent is Safari
  37638. * @returns whether or not the current user agent is safari
  37639. */
  37640. static IsSafari(): boolean;
  37641. }
  37642. /**
  37643. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37644. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37645. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37646. * @param name The name of the class, case should be preserved
  37647. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37648. */
  37649. export function className(name: string, module?: string): (target: Object) => void;
  37650. /**
  37651. * An implementation of a loop for asynchronous functions.
  37652. */
  37653. export class AsyncLoop {
  37654. /**
  37655. * Defines the number of iterations for the loop
  37656. */
  37657. iterations: number;
  37658. /**
  37659. * Defines the current index of the loop.
  37660. */
  37661. index: number;
  37662. private _done;
  37663. private _fn;
  37664. private _successCallback;
  37665. /**
  37666. * Constructor.
  37667. * @param iterations the number of iterations.
  37668. * @param func the function to run each iteration
  37669. * @param successCallback the callback that will be called upon succesful execution
  37670. * @param offset starting offset.
  37671. */
  37672. constructor(
  37673. /**
  37674. * Defines the number of iterations for the loop
  37675. */
  37676. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37677. /**
  37678. * Execute the next iteration. Must be called after the last iteration was finished.
  37679. */
  37680. executeNext(): void;
  37681. /**
  37682. * Break the loop and run the success callback.
  37683. */
  37684. breakLoop(): void;
  37685. /**
  37686. * Create and run an async loop.
  37687. * @param iterations the number of iterations.
  37688. * @param fn the function to run each iteration
  37689. * @param successCallback the callback that will be called upon succesful execution
  37690. * @param offset starting offset.
  37691. * @returns the created async loop object
  37692. */
  37693. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37694. /**
  37695. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37696. * @param iterations total number of iterations
  37697. * @param syncedIterations number of synchronous iterations in each async iteration.
  37698. * @param fn the function to call each iteration.
  37699. * @param callback a success call back that will be called when iterating stops.
  37700. * @param breakFunction a break condition (optional)
  37701. * @param timeout timeout settings for the setTimeout function. default - 0.
  37702. * @returns the created async loop object
  37703. */
  37704. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37705. }
  37706. }
  37707. declare module BABYLON {
  37708. /**
  37709. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37710. * The underlying implementation relies on an associative array to ensure the best performances.
  37711. * The value can be anything including 'null' but except 'undefined'
  37712. */
  37713. export class StringDictionary<T> {
  37714. /**
  37715. * This will clear this dictionary and copy the content from the 'source' one.
  37716. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37717. * @param source the dictionary to take the content from and copy to this dictionary
  37718. */
  37719. copyFrom(source: StringDictionary<T>): void;
  37720. /**
  37721. * Get a value based from its key
  37722. * @param key the given key to get the matching value from
  37723. * @return the value if found, otherwise undefined is returned
  37724. */
  37725. get(key: string): T | undefined;
  37726. /**
  37727. * Get a value from its key or add it if it doesn't exist.
  37728. * This method will ensure you that a given key/data will be present in the dictionary.
  37729. * @param key the given key to get the matching value from
  37730. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37731. * The factory will only be invoked if there's no data for the given key.
  37732. * @return the value corresponding to the key.
  37733. */
  37734. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37735. /**
  37736. * Get a value from its key if present in the dictionary otherwise add it
  37737. * @param key the key to get the value from
  37738. * @param val if there's no such key/value pair in the dictionary add it with this value
  37739. * @return the value corresponding to the key
  37740. */
  37741. getOrAdd(key: string, val: T): T;
  37742. /**
  37743. * Check if there's a given key in the dictionary
  37744. * @param key the key to check for
  37745. * @return true if the key is present, false otherwise
  37746. */
  37747. contains(key: string): boolean;
  37748. /**
  37749. * Add a new key and its corresponding value
  37750. * @param key the key to add
  37751. * @param value the value corresponding to the key
  37752. * @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
  37753. */
  37754. add(key: string, value: T): boolean;
  37755. /**
  37756. * Update a specific value associated to a key
  37757. * @param key defines the key to use
  37758. * @param value defines the value to store
  37759. * @returns true if the value was updated (or false if the key was not found)
  37760. */
  37761. set(key: string, value: T): boolean;
  37762. /**
  37763. * Get the element of the given key and remove it from the dictionary
  37764. * @param key defines the key to search
  37765. * @returns the value associated with the key or null if not found
  37766. */
  37767. getAndRemove(key: string): Nullable<T>;
  37768. /**
  37769. * Remove a key/value from the dictionary.
  37770. * @param key the key to remove
  37771. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37772. */
  37773. remove(key: string): boolean;
  37774. /**
  37775. * Clear the whole content of the dictionary
  37776. */
  37777. clear(): void;
  37778. /**
  37779. * Gets the current count
  37780. */
  37781. get count(): number;
  37782. /**
  37783. * Execute a callback on each key/val of the dictionary.
  37784. * Note that you can remove any element in this dictionary in the callback implementation
  37785. * @param callback the callback to execute on a given key/value pair
  37786. */
  37787. forEach(callback: (key: string, val: T) => void): void;
  37788. /**
  37789. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37790. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37791. * Note that you can remove any element in this dictionary in the callback implementation
  37792. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37793. * @returns the first item
  37794. */
  37795. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37796. private _count;
  37797. private _data;
  37798. }
  37799. }
  37800. declare module BABYLON {
  37801. /** @hidden */
  37802. export interface ICollisionCoordinator {
  37803. createCollider(): Collider;
  37804. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37805. init(scene: Scene): void;
  37806. }
  37807. /** @hidden */
  37808. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37809. private _scene;
  37810. private _scaledPosition;
  37811. private _scaledVelocity;
  37812. private _finalPosition;
  37813. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37814. createCollider(): Collider;
  37815. init(scene: Scene): void;
  37816. private _collideWithWorld;
  37817. }
  37818. }
  37819. declare module BABYLON {
  37820. /**
  37821. * Class used to manage all inputs for the scene.
  37822. */
  37823. export class InputManager {
  37824. /** The distance in pixel that you have to move to prevent some events */
  37825. static DragMovementThreshold: number;
  37826. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37827. static LongPressDelay: number;
  37828. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37829. static DoubleClickDelay: number;
  37830. /** If you need to check double click without raising a single click at first click, enable this flag */
  37831. static ExclusiveDoubleClickMode: boolean;
  37832. private _wheelEventName;
  37833. private _onPointerMove;
  37834. private _onPointerDown;
  37835. private _onPointerUp;
  37836. private _initClickEvent;
  37837. private _initActionManager;
  37838. private _delayedSimpleClick;
  37839. private _delayedSimpleClickTimeout;
  37840. private _previousDelayedSimpleClickTimeout;
  37841. private _meshPickProceed;
  37842. private _previousButtonPressed;
  37843. private _currentPickResult;
  37844. private _previousPickResult;
  37845. private _totalPointersPressed;
  37846. private _doubleClickOccured;
  37847. private _pointerOverMesh;
  37848. private _pickedDownMesh;
  37849. private _pickedUpMesh;
  37850. private _pointerX;
  37851. private _pointerY;
  37852. private _unTranslatedPointerX;
  37853. private _unTranslatedPointerY;
  37854. private _startingPointerPosition;
  37855. private _previousStartingPointerPosition;
  37856. private _startingPointerTime;
  37857. private _previousStartingPointerTime;
  37858. private _pointerCaptures;
  37859. private _onKeyDown;
  37860. private _onKeyUp;
  37861. private _onCanvasFocusObserver;
  37862. private _onCanvasBlurObserver;
  37863. private _scene;
  37864. /**
  37865. * Creates a new InputManager
  37866. * @param scene defines the hosting scene
  37867. */
  37868. constructor(scene: Scene);
  37869. /**
  37870. * Gets the mesh that is currently under the pointer
  37871. */
  37872. get meshUnderPointer(): Nullable<AbstractMesh>;
  37873. /**
  37874. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37875. */
  37876. get unTranslatedPointer(): Vector2;
  37877. /**
  37878. * Gets or sets the current on-screen X position of the pointer
  37879. */
  37880. get pointerX(): number;
  37881. set pointerX(value: number);
  37882. /**
  37883. * Gets or sets the current on-screen Y position of the pointer
  37884. */
  37885. get pointerY(): number;
  37886. set pointerY(value: number);
  37887. private _updatePointerPosition;
  37888. private _processPointerMove;
  37889. private _setRayOnPointerInfo;
  37890. private _checkPrePointerObservable;
  37891. /**
  37892. * Use this method to simulate a pointer move on a mesh
  37893. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37894. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37895. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37896. */
  37897. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37898. /**
  37899. * Use this method to simulate a pointer down on a mesh
  37900. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37901. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37902. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37903. */
  37904. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37905. private _processPointerDown;
  37906. /** @hidden */
  37907. _isPointerSwiping(): boolean;
  37908. /**
  37909. * Use this method to simulate a pointer up on a mesh
  37910. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37911. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37912. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37913. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37914. */
  37915. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37916. private _processPointerUp;
  37917. /**
  37918. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37919. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37920. * @returns true if the pointer was captured
  37921. */
  37922. isPointerCaptured(pointerId?: number): boolean;
  37923. /**
  37924. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37925. * @param attachUp defines if you want to attach events to pointerup
  37926. * @param attachDown defines if you want to attach events to pointerdown
  37927. * @param attachMove defines if you want to attach events to pointermove
  37928. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37929. */
  37930. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37931. /**
  37932. * Detaches all event handlers
  37933. */
  37934. detachControl(): void;
  37935. /**
  37936. * Force the value of meshUnderPointer
  37937. * @param mesh defines the mesh to use
  37938. */
  37939. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37940. /**
  37941. * Gets the mesh under the pointer
  37942. * @returns a Mesh or null if no mesh is under the pointer
  37943. */
  37944. getPointerOverMesh(): Nullable<AbstractMesh>;
  37945. }
  37946. }
  37947. declare module BABYLON {
  37948. /**
  37949. * This class defines the direct association between an animation and a target
  37950. */
  37951. export class TargetedAnimation {
  37952. /**
  37953. * Animation to perform
  37954. */
  37955. animation: Animation;
  37956. /**
  37957. * Target to animate
  37958. */
  37959. target: any;
  37960. /**
  37961. * Returns the string "TargetedAnimation"
  37962. * @returns "TargetedAnimation"
  37963. */
  37964. getClassName(): string;
  37965. /**
  37966. * Serialize the object
  37967. * @returns the JSON object representing the current entity
  37968. */
  37969. serialize(): any;
  37970. }
  37971. /**
  37972. * Use this class to create coordinated animations on multiple targets
  37973. */
  37974. export class AnimationGroup implements IDisposable {
  37975. /** The name of the animation group */
  37976. name: string;
  37977. private _scene;
  37978. private _targetedAnimations;
  37979. private _animatables;
  37980. private _from;
  37981. private _to;
  37982. private _isStarted;
  37983. private _isPaused;
  37984. private _speedRatio;
  37985. private _loopAnimation;
  37986. private _isAdditive;
  37987. /**
  37988. * Gets or sets the unique id of the node
  37989. */
  37990. uniqueId: number;
  37991. /**
  37992. * This observable will notify when one animation have ended
  37993. */
  37994. onAnimationEndObservable: Observable<TargetedAnimation>;
  37995. /**
  37996. * Observer raised when one animation loops
  37997. */
  37998. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37999. /**
  38000. * Observer raised when all animations have looped
  38001. */
  38002. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38003. /**
  38004. * This observable will notify when all animations have ended.
  38005. */
  38006. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38007. /**
  38008. * This observable will notify when all animations have paused.
  38009. */
  38010. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38011. /**
  38012. * This observable will notify when all animations are playing.
  38013. */
  38014. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38015. /**
  38016. * Gets the first frame
  38017. */
  38018. get from(): number;
  38019. /**
  38020. * Gets the last frame
  38021. */
  38022. get to(): number;
  38023. /**
  38024. * Define if the animations are started
  38025. */
  38026. get isStarted(): boolean;
  38027. /**
  38028. * Gets a value indicating that the current group is playing
  38029. */
  38030. get isPlaying(): boolean;
  38031. /**
  38032. * Gets or sets the speed ratio to use for all animations
  38033. */
  38034. get speedRatio(): number;
  38035. /**
  38036. * Gets or sets the speed ratio to use for all animations
  38037. */
  38038. set speedRatio(value: number);
  38039. /**
  38040. * Gets or sets if all animations should loop or not
  38041. */
  38042. get loopAnimation(): boolean;
  38043. set loopAnimation(value: boolean);
  38044. /**
  38045. * Gets or sets if all animations should be evaluated additively
  38046. */
  38047. get isAdditive(): boolean;
  38048. set isAdditive(value: boolean);
  38049. /**
  38050. * Gets the targeted animations for this animation group
  38051. */
  38052. get targetedAnimations(): Array<TargetedAnimation>;
  38053. /**
  38054. * returning the list of animatables controlled by this animation group.
  38055. */
  38056. get animatables(): Array<Animatable>;
  38057. /**
  38058. * Gets the list of target animations
  38059. */
  38060. get children(): TargetedAnimation[];
  38061. /**
  38062. * Instantiates a new Animation Group.
  38063. * This helps managing several animations at once.
  38064. * @see http://doc.babylonjs.com/how_to/group
  38065. * @param name Defines the name of the group
  38066. * @param scene Defines the scene the group belongs to
  38067. */
  38068. constructor(
  38069. /** The name of the animation group */
  38070. name: string, scene?: Nullable<Scene>);
  38071. /**
  38072. * Add an animation (with its target) in the group
  38073. * @param animation defines the animation we want to add
  38074. * @param target defines the target of the animation
  38075. * @returns the TargetedAnimation object
  38076. */
  38077. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38078. /**
  38079. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38080. * It can add constant keys at begin or end
  38081. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38082. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38083. * @returns the animation group
  38084. */
  38085. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38086. private _animationLoopCount;
  38087. private _animationLoopFlags;
  38088. private _processLoop;
  38089. /**
  38090. * Start all animations on given targets
  38091. * @param loop defines if animations must loop
  38092. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38093. * @param from defines the from key (optional)
  38094. * @param to defines the to key (optional)
  38095. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38096. * @returns the current animation group
  38097. */
  38098. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38099. /**
  38100. * Pause all animations
  38101. * @returns the animation group
  38102. */
  38103. pause(): AnimationGroup;
  38104. /**
  38105. * Play all animations to initial state
  38106. * This function will start() the animations if they were not started or will restart() them if they were paused
  38107. * @param loop defines if animations must loop
  38108. * @returns the animation group
  38109. */
  38110. play(loop?: boolean): AnimationGroup;
  38111. /**
  38112. * Reset all animations to initial state
  38113. * @returns the animation group
  38114. */
  38115. reset(): AnimationGroup;
  38116. /**
  38117. * Restart animations from key 0
  38118. * @returns the animation group
  38119. */
  38120. restart(): AnimationGroup;
  38121. /**
  38122. * Stop all animations
  38123. * @returns the animation group
  38124. */
  38125. stop(): AnimationGroup;
  38126. /**
  38127. * Set animation weight for all animatables
  38128. * @param weight defines the weight to use
  38129. * @return the animationGroup
  38130. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38131. */
  38132. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38133. /**
  38134. * Synchronize and normalize all animatables with a source animatable
  38135. * @param root defines the root animatable to synchronize with
  38136. * @return the animationGroup
  38137. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38138. */
  38139. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38140. /**
  38141. * Goes to a specific frame in this animation group
  38142. * @param frame the frame number to go to
  38143. * @return the animationGroup
  38144. */
  38145. goToFrame(frame: number): AnimationGroup;
  38146. /**
  38147. * Dispose all associated resources
  38148. */
  38149. dispose(): void;
  38150. private _checkAnimationGroupEnded;
  38151. /**
  38152. * Clone the current animation group and returns a copy
  38153. * @param newName defines the name of the new group
  38154. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38155. * @returns the new aniamtion group
  38156. */
  38157. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38158. /**
  38159. * Serializes the animationGroup to an object
  38160. * @returns Serialized object
  38161. */
  38162. serialize(): any;
  38163. /**
  38164. * Returns a new AnimationGroup object parsed from the source provided.
  38165. * @param parsedAnimationGroup defines the source
  38166. * @param scene defines the scene that will receive the animationGroup
  38167. * @returns a new AnimationGroup
  38168. */
  38169. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38170. /**
  38171. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38172. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38173. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38174. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38175. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38176. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38177. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38178. */
  38179. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38180. /**
  38181. * Returns the string "AnimationGroup"
  38182. * @returns "AnimationGroup"
  38183. */
  38184. getClassName(): string;
  38185. /**
  38186. * Creates a detailled string about the object
  38187. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38188. * @returns a string representing the object
  38189. */
  38190. toString(fullDetails?: boolean): string;
  38191. }
  38192. }
  38193. declare module BABYLON {
  38194. /**
  38195. * Define an interface for all classes that will hold resources
  38196. */
  38197. export interface IDisposable {
  38198. /**
  38199. * Releases all held resources
  38200. */
  38201. dispose(): void;
  38202. }
  38203. /** Interface defining initialization parameters for Scene class */
  38204. export interface SceneOptions {
  38205. /**
  38206. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38207. * It will improve performance when the number of geometries becomes important.
  38208. */
  38209. useGeometryUniqueIdsMap?: boolean;
  38210. /**
  38211. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38212. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38213. */
  38214. useMaterialMeshMap?: boolean;
  38215. /**
  38216. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38217. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38218. */
  38219. useClonedMeshMap?: boolean;
  38220. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38221. virtual?: boolean;
  38222. }
  38223. /**
  38224. * Represents a scene to be rendered by the engine.
  38225. * @see http://doc.babylonjs.com/features/scene
  38226. */
  38227. export class Scene extends AbstractScene implements IAnimatable {
  38228. /** The fog is deactivated */
  38229. static readonly FOGMODE_NONE: number;
  38230. /** The fog density is following an exponential function */
  38231. static readonly FOGMODE_EXP: number;
  38232. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38233. static readonly FOGMODE_EXP2: number;
  38234. /** The fog density is following a linear function. */
  38235. static readonly FOGMODE_LINEAR: number;
  38236. /**
  38237. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38239. */
  38240. static MinDeltaTime: number;
  38241. /**
  38242. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38244. */
  38245. static MaxDeltaTime: number;
  38246. /**
  38247. * Factory used to create the default material.
  38248. * @param name The name of the material to create
  38249. * @param scene The scene to create the material for
  38250. * @returns The default material
  38251. */
  38252. static DefaultMaterialFactory(scene: Scene): Material;
  38253. /**
  38254. * Factory used to create the a collision coordinator.
  38255. * @returns The collision coordinator
  38256. */
  38257. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38258. /** @hidden */
  38259. _inputManager: InputManager;
  38260. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38261. cameraToUseForPointers: Nullable<Camera>;
  38262. /** @hidden */
  38263. readonly _isScene: boolean;
  38264. /** @hidden */
  38265. _blockEntityCollection: boolean;
  38266. /**
  38267. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38268. */
  38269. autoClear: boolean;
  38270. /**
  38271. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38272. */
  38273. autoClearDepthAndStencil: boolean;
  38274. /**
  38275. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38276. */
  38277. clearColor: Color4;
  38278. /**
  38279. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38280. */
  38281. ambientColor: Color3;
  38282. /**
  38283. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38284. * It should only be one of the following (if not the default embedded one):
  38285. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38286. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38287. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38288. * The material properties need to be setup according to the type of texture in use.
  38289. */
  38290. environmentBRDFTexture: BaseTexture;
  38291. /** @hidden */
  38292. protected _environmentTexture: Nullable<BaseTexture>;
  38293. /**
  38294. * Texture used in all pbr material as the reflection texture.
  38295. * As in the majority of the scene they are the same (exception for multi room and so on),
  38296. * this is easier to reference from here than from all the materials.
  38297. */
  38298. get environmentTexture(): Nullable<BaseTexture>;
  38299. /**
  38300. * Texture used in all pbr material as the reflection texture.
  38301. * As in the majority of the scene they are the same (exception for multi room and so on),
  38302. * this is easier to set here than in all the materials.
  38303. */
  38304. set environmentTexture(value: Nullable<BaseTexture>);
  38305. /** @hidden */
  38306. protected _environmentIntensity: number;
  38307. /**
  38308. * Intensity of the environment in all pbr material.
  38309. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38310. * As in the majority of the scene they are the same (exception for multi room and so on),
  38311. * this is easier to reference from here than from all the materials.
  38312. */
  38313. get environmentIntensity(): number;
  38314. /**
  38315. * Intensity of the environment in all pbr material.
  38316. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38317. * As in the majority of the scene they are the same (exception for multi room and so on),
  38318. * this is easier to set here than in all the materials.
  38319. */
  38320. set environmentIntensity(value: number);
  38321. /** @hidden */
  38322. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38323. /**
  38324. * Default image processing configuration used either in the rendering
  38325. * Forward main pass or through the imageProcessingPostProcess if present.
  38326. * As in the majority of the scene they are the same (exception for multi camera),
  38327. * this is easier to reference from here than from all the materials and post process.
  38328. *
  38329. * No setter as we it is a shared configuration, you can set the values instead.
  38330. */
  38331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38332. private _forceWireframe;
  38333. /**
  38334. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38335. */
  38336. set forceWireframe(value: boolean);
  38337. get forceWireframe(): boolean;
  38338. private _skipFrustumClipping;
  38339. /**
  38340. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38341. */
  38342. set skipFrustumClipping(value: boolean);
  38343. get skipFrustumClipping(): boolean;
  38344. private _forcePointsCloud;
  38345. /**
  38346. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38347. */
  38348. set forcePointsCloud(value: boolean);
  38349. get forcePointsCloud(): boolean;
  38350. /**
  38351. * Gets or sets the active clipplane 1
  38352. */
  38353. clipPlane: Nullable<Plane>;
  38354. /**
  38355. * Gets or sets the active clipplane 2
  38356. */
  38357. clipPlane2: Nullable<Plane>;
  38358. /**
  38359. * Gets or sets the active clipplane 3
  38360. */
  38361. clipPlane3: Nullable<Plane>;
  38362. /**
  38363. * Gets or sets the active clipplane 4
  38364. */
  38365. clipPlane4: Nullable<Plane>;
  38366. /**
  38367. * Gets or sets the active clipplane 5
  38368. */
  38369. clipPlane5: Nullable<Plane>;
  38370. /**
  38371. * Gets or sets the active clipplane 6
  38372. */
  38373. clipPlane6: Nullable<Plane>;
  38374. /**
  38375. * Gets or sets a boolean indicating if animations are enabled
  38376. */
  38377. animationsEnabled: boolean;
  38378. private _animationPropertiesOverride;
  38379. /**
  38380. * Gets or sets the animation properties override
  38381. */
  38382. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38383. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38384. /**
  38385. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38386. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38387. */
  38388. useConstantAnimationDeltaTime: boolean;
  38389. /**
  38390. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38391. * Please note that it requires to run a ray cast through the scene on every frame
  38392. */
  38393. constantlyUpdateMeshUnderPointer: boolean;
  38394. /**
  38395. * Defines the HTML cursor to use when hovering over interactive elements
  38396. */
  38397. hoverCursor: string;
  38398. /**
  38399. * Defines the HTML default cursor to use (empty by default)
  38400. */
  38401. defaultCursor: string;
  38402. /**
  38403. * Defines whether cursors are handled by the scene.
  38404. */
  38405. doNotHandleCursors: boolean;
  38406. /**
  38407. * This is used to call preventDefault() on pointer down
  38408. * in order to block unwanted artifacts like system double clicks
  38409. */
  38410. preventDefaultOnPointerDown: boolean;
  38411. /**
  38412. * This is used to call preventDefault() on pointer up
  38413. * in order to block unwanted artifacts like system double clicks
  38414. */
  38415. preventDefaultOnPointerUp: boolean;
  38416. /**
  38417. * Gets or sets user defined metadata
  38418. */
  38419. metadata: any;
  38420. /**
  38421. * For internal use only. Please do not use.
  38422. */
  38423. reservedDataStore: any;
  38424. /**
  38425. * Gets the name of the plugin used to load this scene (null by default)
  38426. */
  38427. loadingPluginName: string;
  38428. /**
  38429. * Use this array to add regular expressions used to disable offline support for specific urls
  38430. */
  38431. disableOfflineSupportExceptionRules: RegExp[];
  38432. /**
  38433. * An event triggered when the scene is disposed.
  38434. */
  38435. onDisposeObservable: Observable<Scene>;
  38436. private _onDisposeObserver;
  38437. /** Sets a function to be executed when this scene is disposed. */
  38438. set onDispose(callback: () => void);
  38439. /**
  38440. * An event triggered before rendering the scene (right after animations and physics)
  38441. */
  38442. onBeforeRenderObservable: Observable<Scene>;
  38443. private _onBeforeRenderObserver;
  38444. /** Sets a function to be executed before rendering this scene */
  38445. set beforeRender(callback: Nullable<() => void>);
  38446. /**
  38447. * An event triggered after rendering the scene
  38448. */
  38449. onAfterRenderObservable: Observable<Scene>;
  38450. /**
  38451. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38452. */
  38453. onAfterRenderCameraObservable: Observable<Camera>;
  38454. private _onAfterRenderObserver;
  38455. /** Sets a function to be executed after rendering this scene */
  38456. set afterRender(callback: Nullable<() => void>);
  38457. /**
  38458. * An event triggered before animating the scene
  38459. */
  38460. onBeforeAnimationsObservable: Observable<Scene>;
  38461. /**
  38462. * An event triggered after animations processing
  38463. */
  38464. onAfterAnimationsObservable: Observable<Scene>;
  38465. /**
  38466. * An event triggered before draw calls are ready to be sent
  38467. */
  38468. onBeforeDrawPhaseObservable: Observable<Scene>;
  38469. /**
  38470. * An event triggered after draw calls have been sent
  38471. */
  38472. onAfterDrawPhaseObservable: Observable<Scene>;
  38473. /**
  38474. * An event triggered when the scene is ready
  38475. */
  38476. onReadyObservable: Observable<Scene>;
  38477. /**
  38478. * An event triggered before rendering a camera
  38479. */
  38480. onBeforeCameraRenderObservable: Observable<Camera>;
  38481. private _onBeforeCameraRenderObserver;
  38482. /** Sets a function to be executed before rendering a camera*/
  38483. set beforeCameraRender(callback: () => void);
  38484. /**
  38485. * An event triggered after rendering a camera
  38486. */
  38487. onAfterCameraRenderObservable: Observable<Camera>;
  38488. private _onAfterCameraRenderObserver;
  38489. /** Sets a function to be executed after rendering a camera*/
  38490. set afterCameraRender(callback: () => void);
  38491. /**
  38492. * An event triggered when active meshes evaluation is about to start
  38493. */
  38494. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38495. /**
  38496. * An event triggered when active meshes evaluation is done
  38497. */
  38498. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38499. /**
  38500. * An event triggered when particles rendering is about to start
  38501. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38502. */
  38503. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38504. /**
  38505. * An event triggered when particles rendering is done
  38506. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38507. */
  38508. onAfterParticlesRenderingObservable: Observable<Scene>;
  38509. /**
  38510. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38511. */
  38512. onDataLoadedObservable: Observable<Scene>;
  38513. /**
  38514. * An event triggered when a camera is created
  38515. */
  38516. onNewCameraAddedObservable: Observable<Camera>;
  38517. /**
  38518. * An event triggered when a camera is removed
  38519. */
  38520. onCameraRemovedObservable: Observable<Camera>;
  38521. /**
  38522. * An event triggered when a light is created
  38523. */
  38524. onNewLightAddedObservable: Observable<Light>;
  38525. /**
  38526. * An event triggered when a light is removed
  38527. */
  38528. onLightRemovedObservable: Observable<Light>;
  38529. /**
  38530. * An event triggered when a geometry is created
  38531. */
  38532. onNewGeometryAddedObservable: Observable<Geometry>;
  38533. /**
  38534. * An event triggered when a geometry is removed
  38535. */
  38536. onGeometryRemovedObservable: Observable<Geometry>;
  38537. /**
  38538. * An event triggered when a transform node is created
  38539. */
  38540. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38541. /**
  38542. * An event triggered when a transform node is removed
  38543. */
  38544. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38545. /**
  38546. * An event triggered when a mesh is created
  38547. */
  38548. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38549. /**
  38550. * An event triggered when a mesh is removed
  38551. */
  38552. onMeshRemovedObservable: Observable<AbstractMesh>;
  38553. /**
  38554. * An event triggered when a skeleton is created
  38555. */
  38556. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38557. /**
  38558. * An event triggered when a skeleton is removed
  38559. */
  38560. onSkeletonRemovedObservable: Observable<Skeleton>;
  38561. /**
  38562. * An event triggered when a material is created
  38563. */
  38564. onNewMaterialAddedObservable: Observable<Material>;
  38565. /**
  38566. * An event triggered when a material is removed
  38567. */
  38568. onMaterialRemovedObservable: Observable<Material>;
  38569. /**
  38570. * An event triggered when a texture is created
  38571. */
  38572. onNewTextureAddedObservable: Observable<BaseTexture>;
  38573. /**
  38574. * An event triggered when a texture is removed
  38575. */
  38576. onTextureRemovedObservable: Observable<BaseTexture>;
  38577. /**
  38578. * An event triggered when render targets are about to be rendered
  38579. * Can happen multiple times per frame.
  38580. */
  38581. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38582. /**
  38583. * An event triggered when render targets were rendered.
  38584. * Can happen multiple times per frame.
  38585. */
  38586. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38587. /**
  38588. * An event triggered before calculating deterministic simulation step
  38589. */
  38590. onBeforeStepObservable: Observable<Scene>;
  38591. /**
  38592. * An event triggered after calculating deterministic simulation step
  38593. */
  38594. onAfterStepObservable: Observable<Scene>;
  38595. /**
  38596. * An event triggered when the activeCamera property is updated
  38597. */
  38598. onActiveCameraChanged: Observable<Scene>;
  38599. /**
  38600. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38601. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38602. * 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)
  38603. */
  38604. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38605. /**
  38606. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38607. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38608. * 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)
  38609. */
  38610. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38611. /**
  38612. * This Observable will when a mesh has been imported into the scene.
  38613. */
  38614. onMeshImportedObservable: Observable<AbstractMesh>;
  38615. /**
  38616. * This Observable will when an animation file has been imported into the scene.
  38617. */
  38618. onAnimationFileImportedObservable: Observable<Scene>;
  38619. /**
  38620. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38621. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38622. */
  38623. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38624. /** @hidden */
  38625. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38626. /**
  38627. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38628. */
  38629. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38630. /**
  38631. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38632. */
  38633. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38634. /**
  38635. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38636. */
  38637. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38638. /** Callback called when a pointer move is detected */
  38639. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38640. /** Callback called when a pointer down is detected */
  38641. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38642. /** Callback called when a pointer up is detected */
  38643. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38644. /** Callback called when a pointer pick is detected */
  38645. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38646. /**
  38647. * 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).
  38648. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38649. */
  38650. onPrePointerObservable: Observable<PointerInfoPre>;
  38651. /**
  38652. * Observable event triggered each time an input event is received from the rendering canvas
  38653. */
  38654. onPointerObservable: Observable<PointerInfo>;
  38655. /**
  38656. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38657. */
  38658. get unTranslatedPointer(): Vector2;
  38659. /**
  38660. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38661. */
  38662. static get DragMovementThreshold(): number;
  38663. static set DragMovementThreshold(value: number);
  38664. /**
  38665. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38666. */
  38667. static get LongPressDelay(): number;
  38668. static set LongPressDelay(value: number);
  38669. /**
  38670. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38671. */
  38672. static get DoubleClickDelay(): number;
  38673. static set DoubleClickDelay(value: number);
  38674. /** If you need to check double click without raising a single click at first click, enable this flag */
  38675. static get ExclusiveDoubleClickMode(): boolean;
  38676. static set ExclusiveDoubleClickMode(value: boolean);
  38677. /** @hidden */
  38678. _mirroredCameraPosition: Nullable<Vector3>;
  38679. /**
  38680. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38681. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38682. */
  38683. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38684. /**
  38685. * Observable event triggered each time an keyboard event is received from the hosting window
  38686. */
  38687. onKeyboardObservable: Observable<KeyboardInfo>;
  38688. private _useRightHandedSystem;
  38689. /**
  38690. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38691. */
  38692. set useRightHandedSystem(value: boolean);
  38693. get useRightHandedSystem(): boolean;
  38694. private _timeAccumulator;
  38695. private _currentStepId;
  38696. private _currentInternalStep;
  38697. /**
  38698. * Sets the step Id used by deterministic lock step
  38699. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38700. * @param newStepId defines the step Id
  38701. */
  38702. setStepId(newStepId: number): void;
  38703. /**
  38704. * Gets the step Id used by deterministic lock step
  38705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38706. * @returns the step Id
  38707. */
  38708. getStepId(): number;
  38709. /**
  38710. * Gets the internal step used by deterministic lock step
  38711. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38712. * @returns the internal step
  38713. */
  38714. getInternalStep(): number;
  38715. private _fogEnabled;
  38716. /**
  38717. * Gets or sets a boolean indicating if fog is enabled on this scene
  38718. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38719. * (Default is true)
  38720. */
  38721. set fogEnabled(value: boolean);
  38722. get fogEnabled(): boolean;
  38723. private _fogMode;
  38724. /**
  38725. * Gets or sets the fog mode to use
  38726. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38727. * | mode | value |
  38728. * | --- | --- |
  38729. * | FOGMODE_NONE | 0 |
  38730. * | FOGMODE_EXP | 1 |
  38731. * | FOGMODE_EXP2 | 2 |
  38732. * | FOGMODE_LINEAR | 3 |
  38733. */
  38734. set fogMode(value: number);
  38735. get fogMode(): number;
  38736. /**
  38737. * Gets or sets the fog color to use
  38738. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38739. * (Default is Color3(0.2, 0.2, 0.3))
  38740. */
  38741. fogColor: Color3;
  38742. /**
  38743. * Gets or sets the fog density to use
  38744. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38745. * (Default is 0.1)
  38746. */
  38747. fogDensity: number;
  38748. /**
  38749. * Gets or sets the fog start distance to use
  38750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38751. * (Default is 0)
  38752. */
  38753. fogStart: number;
  38754. /**
  38755. * Gets or sets the fog end distance to use
  38756. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38757. * (Default is 1000)
  38758. */
  38759. fogEnd: number;
  38760. private _shadowsEnabled;
  38761. /**
  38762. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38763. */
  38764. set shadowsEnabled(value: boolean);
  38765. get shadowsEnabled(): boolean;
  38766. private _lightsEnabled;
  38767. /**
  38768. * Gets or sets a boolean indicating if lights are enabled on this scene
  38769. */
  38770. set lightsEnabled(value: boolean);
  38771. get lightsEnabled(): boolean;
  38772. /** All of the active cameras added to this scene. */
  38773. activeCameras: Camera[];
  38774. /** @hidden */
  38775. _activeCamera: Nullable<Camera>;
  38776. /** Gets or sets the current active camera */
  38777. get activeCamera(): Nullable<Camera>;
  38778. set activeCamera(value: Nullable<Camera>);
  38779. private _defaultMaterial;
  38780. /** The default material used on meshes when no material is affected */
  38781. get defaultMaterial(): Material;
  38782. /** The default material used on meshes when no material is affected */
  38783. set defaultMaterial(value: Material);
  38784. private _texturesEnabled;
  38785. /**
  38786. * Gets or sets a boolean indicating if textures are enabled on this scene
  38787. */
  38788. set texturesEnabled(value: boolean);
  38789. get texturesEnabled(): boolean;
  38790. /**
  38791. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38792. */
  38793. physicsEnabled: boolean;
  38794. /**
  38795. * Gets or sets a boolean indicating if particles are enabled on this scene
  38796. */
  38797. particlesEnabled: boolean;
  38798. /**
  38799. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38800. */
  38801. spritesEnabled: boolean;
  38802. private _skeletonsEnabled;
  38803. /**
  38804. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38805. */
  38806. set skeletonsEnabled(value: boolean);
  38807. get skeletonsEnabled(): boolean;
  38808. /**
  38809. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38810. */
  38811. lensFlaresEnabled: boolean;
  38812. /**
  38813. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38814. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38815. */
  38816. collisionsEnabled: boolean;
  38817. private _collisionCoordinator;
  38818. /** @hidden */
  38819. get collisionCoordinator(): ICollisionCoordinator;
  38820. /**
  38821. * Defines the gravity applied to this scene (used only for collisions)
  38822. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38823. */
  38824. gravity: Vector3;
  38825. /**
  38826. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38827. */
  38828. postProcessesEnabled: boolean;
  38829. /**
  38830. * The list of postprocesses added to the scene
  38831. */
  38832. postProcesses: PostProcess[];
  38833. /**
  38834. * Gets the current postprocess manager
  38835. */
  38836. postProcessManager: PostProcessManager;
  38837. /**
  38838. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38839. */
  38840. renderTargetsEnabled: boolean;
  38841. /**
  38842. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38843. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38844. */
  38845. dumpNextRenderTargets: boolean;
  38846. /**
  38847. * The list of user defined render targets added to the scene
  38848. */
  38849. customRenderTargets: RenderTargetTexture[];
  38850. /**
  38851. * Defines if texture loading must be delayed
  38852. * If true, textures will only be loaded when they need to be rendered
  38853. */
  38854. useDelayedTextureLoading: boolean;
  38855. /**
  38856. * Gets the list of meshes imported to the scene through SceneLoader
  38857. */
  38858. importedMeshesFiles: String[];
  38859. /**
  38860. * Gets or sets a boolean indicating if probes are enabled on this scene
  38861. */
  38862. probesEnabled: boolean;
  38863. /**
  38864. * Gets or sets the current offline provider to use to store scene data
  38865. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38866. */
  38867. offlineProvider: IOfflineProvider;
  38868. /**
  38869. * Gets or sets the action manager associated with the scene
  38870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38871. */
  38872. actionManager: AbstractActionManager;
  38873. private _meshesForIntersections;
  38874. /**
  38875. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38876. */
  38877. proceduralTexturesEnabled: boolean;
  38878. private _engine;
  38879. private _totalVertices;
  38880. /** @hidden */
  38881. _activeIndices: PerfCounter;
  38882. /** @hidden */
  38883. _activeParticles: PerfCounter;
  38884. /** @hidden */
  38885. _activeBones: PerfCounter;
  38886. private _animationRatio;
  38887. /** @hidden */
  38888. _animationTimeLast: number;
  38889. /** @hidden */
  38890. _animationTime: number;
  38891. /**
  38892. * Gets or sets a general scale for animation speed
  38893. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38894. */
  38895. animationTimeScale: number;
  38896. /** @hidden */
  38897. _cachedMaterial: Nullable<Material>;
  38898. /** @hidden */
  38899. _cachedEffect: Nullable<Effect>;
  38900. /** @hidden */
  38901. _cachedVisibility: Nullable<number>;
  38902. private _renderId;
  38903. private _frameId;
  38904. private _executeWhenReadyTimeoutId;
  38905. private _intermediateRendering;
  38906. private _viewUpdateFlag;
  38907. private _projectionUpdateFlag;
  38908. /** @hidden */
  38909. _toBeDisposed: Nullable<IDisposable>[];
  38910. private _activeRequests;
  38911. /** @hidden */
  38912. _pendingData: any[];
  38913. private _isDisposed;
  38914. /**
  38915. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38916. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38917. */
  38918. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38919. private _activeMeshes;
  38920. private _processedMaterials;
  38921. private _renderTargets;
  38922. /** @hidden */
  38923. _activeParticleSystems: SmartArray<IParticleSystem>;
  38924. private _activeSkeletons;
  38925. private _softwareSkinnedMeshes;
  38926. private _renderingManager;
  38927. /** @hidden */
  38928. _activeAnimatables: Animatable[];
  38929. private _transformMatrix;
  38930. private _sceneUbo;
  38931. /** @hidden */
  38932. _viewMatrix: Matrix;
  38933. private _projectionMatrix;
  38934. /** @hidden */
  38935. _forcedViewPosition: Nullable<Vector3>;
  38936. /** @hidden */
  38937. _frustumPlanes: Plane[];
  38938. /**
  38939. * Gets the list of frustum planes (built from the active camera)
  38940. */
  38941. get frustumPlanes(): Plane[];
  38942. /**
  38943. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38944. * This is useful if there are more lights that the maximum simulteanous authorized
  38945. */
  38946. requireLightSorting: boolean;
  38947. /** @hidden */
  38948. readonly useMaterialMeshMap: boolean;
  38949. /** @hidden */
  38950. readonly useClonedMeshMap: boolean;
  38951. private _externalData;
  38952. private _uid;
  38953. /**
  38954. * @hidden
  38955. * Backing store of defined scene components.
  38956. */
  38957. _components: ISceneComponent[];
  38958. /**
  38959. * @hidden
  38960. * Backing store of defined scene components.
  38961. */
  38962. _serializableComponents: ISceneSerializableComponent[];
  38963. /**
  38964. * List of components to register on the next registration step.
  38965. */
  38966. private _transientComponents;
  38967. /**
  38968. * Registers the transient components if needed.
  38969. */
  38970. private _registerTransientComponents;
  38971. /**
  38972. * @hidden
  38973. * Add a component to the scene.
  38974. * Note that the ccomponent could be registered on th next frame if this is called after
  38975. * the register component stage.
  38976. * @param component Defines the component to add to the scene
  38977. */
  38978. _addComponent(component: ISceneComponent): void;
  38979. /**
  38980. * @hidden
  38981. * Gets a component from the scene.
  38982. * @param name defines the name of the component to retrieve
  38983. * @returns the component or null if not present
  38984. */
  38985. _getComponent(name: string): Nullable<ISceneComponent>;
  38986. /**
  38987. * @hidden
  38988. * Defines the actions happening before camera updates.
  38989. */
  38990. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38991. /**
  38992. * @hidden
  38993. * Defines the actions happening before clear the canvas.
  38994. */
  38995. _beforeClearStage: Stage<SimpleStageAction>;
  38996. /**
  38997. * @hidden
  38998. * Defines the actions when collecting render targets for the frame.
  38999. */
  39000. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39001. /**
  39002. * @hidden
  39003. * Defines the actions happening for one camera in the frame.
  39004. */
  39005. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39006. /**
  39007. * @hidden
  39008. * Defines the actions happening during the per mesh ready checks.
  39009. */
  39010. _isReadyForMeshStage: Stage<MeshStageAction>;
  39011. /**
  39012. * @hidden
  39013. * Defines the actions happening before evaluate active mesh checks.
  39014. */
  39015. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39016. /**
  39017. * @hidden
  39018. * Defines the actions happening during the evaluate sub mesh checks.
  39019. */
  39020. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39021. /**
  39022. * @hidden
  39023. * Defines the actions happening during the active mesh stage.
  39024. */
  39025. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39026. /**
  39027. * @hidden
  39028. * Defines the actions happening during the per camera render target step.
  39029. */
  39030. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39031. /**
  39032. * @hidden
  39033. * Defines the actions happening just before the active camera is drawing.
  39034. */
  39035. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39036. /**
  39037. * @hidden
  39038. * Defines the actions happening just before a render target is drawing.
  39039. */
  39040. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39041. /**
  39042. * @hidden
  39043. * Defines the actions happening just before a rendering group is drawing.
  39044. */
  39045. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39046. /**
  39047. * @hidden
  39048. * Defines the actions happening just before a mesh is drawing.
  39049. */
  39050. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39051. /**
  39052. * @hidden
  39053. * Defines the actions happening just after a mesh has been drawn.
  39054. */
  39055. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39056. /**
  39057. * @hidden
  39058. * Defines the actions happening just after a rendering group has been drawn.
  39059. */
  39060. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39061. /**
  39062. * @hidden
  39063. * Defines the actions happening just after the active camera has been drawn.
  39064. */
  39065. _afterCameraDrawStage: Stage<CameraStageAction>;
  39066. /**
  39067. * @hidden
  39068. * Defines the actions happening just after a render target has been drawn.
  39069. */
  39070. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39071. /**
  39072. * @hidden
  39073. * Defines the actions happening just after rendering all cameras and computing intersections.
  39074. */
  39075. _afterRenderStage: Stage<SimpleStageAction>;
  39076. /**
  39077. * @hidden
  39078. * Defines the actions happening when a pointer move event happens.
  39079. */
  39080. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39081. /**
  39082. * @hidden
  39083. * Defines the actions happening when a pointer down event happens.
  39084. */
  39085. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39086. /**
  39087. * @hidden
  39088. * Defines the actions happening when a pointer up event happens.
  39089. */
  39090. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39091. /**
  39092. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39093. */
  39094. private geometriesByUniqueId;
  39095. /**
  39096. * Creates a new Scene
  39097. * @param engine defines the engine to use to render this scene
  39098. * @param options defines the scene options
  39099. */
  39100. constructor(engine: Engine, options?: SceneOptions);
  39101. /**
  39102. * Gets a string idenfifying the name of the class
  39103. * @returns "Scene" string
  39104. */
  39105. getClassName(): string;
  39106. private _defaultMeshCandidates;
  39107. /**
  39108. * @hidden
  39109. */
  39110. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39111. private _defaultSubMeshCandidates;
  39112. /**
  39113. * @hidden
  39114. */
  39115. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39116. /**
  39117. * Sets the default candidate providers for the scene.
  39118. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39119. * and getCollidingSubMeshCandidates to their default function
  39120. */
  39121. setDefaultCandidateProviders(): void;
  39122. /**
  39123. * Gets the mesh that is currently under the pointer
  39124. */
  39125. get meshUnderPointer(): Nullable<AbstractMesh>;
  39126. /**
  39127. * Gets or sets the current on-screen X position of the pointer
  39128. */
  39129. get pointerX(): number;
  39130. set pointerX(value: number);
  39131. /**
  39132. * Gets or sets the current on-screen Y position of the pointer
  39133. */
  39134. get pointerY(): number;
  39135. set pointerY(value: number);
  39136. /**
  39137. * Gets the cached material (ie. the latest rendered one)
  39138. * @returns the cached material
  39139. */
  39140. getCachedMaterial(): Nullable<Material>;
  39141. /**
  39142. * Gets the cached effect (ie. the latest rendered one)
  39143. * @returns the cached effect
  39144. */
  39145. getCachedEffect(): Nullable<Effect>;
  39146. /**
  39147. * Gets the cached visibility state (ie. the latest rendered one)
  39148. * @returns the cached visibility state
  39149. */
  39150. getCachedVisibility(): Nullable<number>;
  39151. /**
  39152. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39153. * @param material defines the current material
  39154. * @param effect defines the current effect
  39155. * @param visibility defines the current visibility state
  39156. * @returns true if one parameter is not cached
  39157. */
  39158. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39159. /**
  39160. * Gets the engine associated with the scene
  39161. * @returns an Engine
  39162. */
  39163. getEngine(): Engine;
  39164. /**
  39165. * Gets the total number of vertices rendered per frame
  39166. * @returns the total number of vertices rendered per frame
  39167. */
  39168. getTotalVertices(): number;
  39169. /**
  39170. * Gets the performance counter for total vertices
  39171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39172. */
  39173. get totalVerticesPerfCounter(): PerfCounter;
  39174. /**
  39175. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39176. * @returns the total number of active indices rendered per frame
  39177. */
  39178. getActiveIndices(): number;
  39179. /**
  39180. * Gets the performance counter for active indices
  39181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39182. */
  39183. get totalActiveIndicesPerfCounter(): PerfCounter;
  39184. /**
  39185. * Gets the total number of active particles rendered per frame
  39186. * @returns the total number of active particles rendered per frame
  39187. */
  39188. getActiveParticles(): number;
  39189. /**
  39190. * Gets the performance counter for active particles
  39191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39192. */
  39193. get activeParticlesPerfCounter(): PerfCounter;
  39194. /**
  39195. * Gets the total number of active bones rendered per frame
  39196. * @returns the total number of active bones rendered per frame
  39197. */
  39198. getActiveBones(): number;
  39199. /**
  39200. * Gets the performance counter for active bones
  39201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39202. */
  39203. get activeBonesPerfCounter(): PerfCounter;
  39204. /**
  39205. * Gets the array of active meshes
  39206. * @returns an array of AbstractMesh
  39207. */
  39208. getActiveMeshes(): SmartArray<AbstractMesh>;
  39209. /**
  39210. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39211. * @returns a number
  39212. */
  39213. getAnimationRatio(): number;
  39214. /**
  39215. * Gets an unique Id for the current render phase
  39216. * @returns a number
  39217. */
  39218. getRenderId(): number;
  39219. /**
  39220. * Gets an unique Id for the current frame
  39221. * @returns a number
  39222. */
  39223. getFrameId(): number;
  39224. /** Call this function if you want to manually increment the render Id*/
  39225. incrementRenderId(): void;
  39226. private _createUbo;
  39227. /**
  39228. * Use this method to simulate a pointer move on a mesh
  39229. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39230. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39231. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39232. * @returns the current scene
  39233. */
  39234. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39235. /**
  39236. * Use this method to simulate a pointer down on a mesh
  39237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39240. * @returns the current scene
  39241. */
  39242. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39243. /**
  39244. * Use this method to simulate a pointer up on a mesh
  39245. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39246. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39247. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39248. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39249. * @returns the current scene
  39250. */
  39251. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39252. /**
  39253. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39254. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39255. * @returns true if the pointer was captured
  39256. */
  39257. isPointerCaptured(pointerId?: number): boolean;
  39258. /**
  39259. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39260. * @param attachUp defines if you want to attach events to pointerup
  39261. * @param attachDown defines if you want to attach events to pointerdown
  39262. * @param attachMove defines if you want to attach events to pointermove
  39263. */
  39264. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39265. /** Detaches all event handlers*/
  39266. detachControl(): void;
  39267. /**
  39268. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39269. * Delay loaded resources are not taking in account
  39270. * @return true if all required resources are ready
  39271. */
  39272. isReady(): boolean;
  39273. /** Resets all cached information relative to material (including effect and visibility) */
  39274. resetCachedMaterial(): void;
  39275. /**
  39276. * Registers a function to be called before every frame render
  39277. * @param func defines the function to register
  39278. */
  39279. registerBeforeRender(func: () => void): void;
  39280. /**
  39281. * Unregisters a function called before every frame render
  39282. * @param func defines the function to unregister
  39283. */
  39284. unregisterBeforeRender(func: () => void): void;
  39285. /**
  39286. * Registers a function to be called after every frame render
  39287. * @param func defines the function to register
  39288. */
  39289. registerAfterRender(func: () => void): void;
  39290. /**
  39291. * Unregisters a function called after every frame render
  39292. * @param func defines the function to unregister
  39293. */
  39294. unregisterAfterRender(func: () => void): void;
  39295. private _executeOnceBeforeRender;
  39296. /**
  39297. * The provided function will run before render once and will be disposed afterwards.
  39298. * A timeout delay can be provided so that the function will be executed in N ms.
  39299. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39300. * @param func The function to be executed.
  39301. * @param timeout optional delay in ms
  39302. */
  39303. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39304. /** @hidden */
  39305. _addPendingData(data: any): void;
  39306. /** @hidden */
  39307. _removePendingData(data: any): void;
  39308. /**
  39309. * Returns the number of items waiting to be loaded
  39310. * @returns the number of items waiting to be loaded
  39311. */
  39312. getWaitingItemsCount(): number;
  39313. /**
  39314. * Returns a boolean indicating if the scene is still loading data
  39315. */
  39316. get isLoading(): boolean;
  39317. /**
  39318. * Registers a function to be executed when the scene is ready
  39319. * @param {Function} func - the function to be executed
  39320. */
  39321. executeWhenReady(func: () => void): void;
  39322. /**
  39323. * Returns a promise that resolves when the scene is ready
  39324. * @returns A promise that resolves when the scene is ready
  39325. */
  39326. whenReadyAsync(): Promise<void>;
  39327. /** @hidden */
  39328. _checkIsReady(): void;
  39329. /**
  39330. * Gets all animatable attached to the scene
  39331. */
  39332. get animatables(): Animatable[];
  39333. /**
  39334. * Resets the last animation time frame.
  39335. * Useful to override when animations start running when loading a scene for the first time.
  39336. */
  39337. resetLastAnimationTimeFrame(): void;
  39338. /**
  39339. * Gets the current view matrix
  39340. * @returns a Matrix
  39341. */
  39342. getViewMatrix(): Matrix;
  39343. /**
  39344. * Gets the current projection matrix
  39345. * @returns a Matrix
  39346. */
  39347. getProjectionMatrix(): Matrix;
  39348. /**
  39349. * Gets the current transform matrix
  39350. * @returns a Matrix made of View * Projection
  39351. */
  39352. getTransformMatrix(): Matrix;
  39353. /**
  39354. * Sets the current transform matrix
  39355. * @param viewL defines the View matrix to use
  39356. * @param projectionL defines the Projection matrix to use
  39357. * @param viewR defines the right View matrix to use (if provided)
  39358. * @param projectionR defines the right Projection matrix to use (if provided)
  39359. */
  39360. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39361. /**
  39362. * Gets the uniform buffer used to store scene data
  39363. * @returns a UniformBuffer
  39364. */
  39365. getSceneUniformBuffer(): UniformBuffer;
  39366. /**
  39367. * Gets an unique (relatively to the current scene) Id
  39368. * @returns an unique number for the scene
  39369. */
  39370. getUniqueId(): number;
  39371. /**
  39372. * Add a mesh to the list of scene's meshes
  39373. * @param newMesh defines the mesh to add
  39374. * @param recursive if all child meshes should also be added to the scene
  39375. */
  39376. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39377. /**
  39378. * Remove a mesh for the list of scene's meshes
  39379. * @param toRemove defines the mesh to remove
  39380. * @param recursive if all child meshes should also be removed from the scene
  39381. * @returns the index where the mesh was in the mesh list
  39382. */
  39383. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39384. /**
  39385. * Add a transform node to the list of scene's transform nodes
  39386. * @param newTransformNode defines the transform node to add
  39387. */
  39388. addTransformNode(newTransformNode: TransformNode): void;
  39389. /**
  39390. * Remove a transform node for the list of scene's transform nodes
  39391. * @param toRemove defines the transform node to remove
  39392. * @returns the index where the transform node was in the transform node list
  39393. */
  39394. removeTransformNode(toRemove: TransformNode): number;
  39395. /**
  39396. * Remove a skeleton for the list of scene's skeletons
  39397. * @param toRemove defines the skeleton to remove
  39398. * @returns the index where the skeleton was in the skeleton list
  39399. */
  39400. removeSkeleton(toRemove: Skeleton): number;
  39401. /**
  39402. * Remove a morph target for the list of scene's morph targets
  39403. * @param toRemove defines the morph target to remove
  39404. * @returns the index where the morph target was in the morph target list
  39405. */
  39406. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39407. /**
  39408. * Remove a light for the list of scene's lights
  39409. * @param toRemove defines the light to remove
  39410. * @returns the index where the light was in the light list
  39411. */
  39412. removeLight(toRemove: Light): number;
  39413. /**
  39414. * Remove a camera for the list of scene's cameras
  39415. * @param toRemove defines the camera to remove
  39416. * @returns the index where the camera was in the camera list
  39417. */
  39418. removeCamera(toRemove: Camera): number;
  39419. /**
  39420. * Remove a particle system for the list of scene's particle systems
  39421. * @param toRemove defines the particle system to remove
  39422. * @returns the index where the particle system was in the particle system list
  39423. */
  39424. removeParticleSystem(toRemove: IParticleSystem): number;
  39425. /**
  39426. * Remove a animation for the list of scene's animations
  39427. * @param toRemove defines the animation to remove
  39428. * @returns the index where the animation was in the animation list
  39429. */
  39430. removeAnimation(toRemove: Animation): number;
  39431. /**
  39432. * Will stop the animation of the given target
  39433. * @param target - the target
  39434. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39435. * @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)
  39436. */
  39437. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39438. /**
  39439. * Removes the given animation group from this scene.
  39440. * @param toRemove The animation group to remove
  39441. * @returns The index of the removed animation group
  39442. */
  39443. removeAnimationGroup(toRemove: AnimationGroup): number;
  39444. /**
  39445. * Removes the given multi-material from this scene.
  39446. * @param toRemove The multi-material to remove
  39447. * @returns The index of the removed multi-material
  39448. */
  39449. removeMultiMaterial(toRemove: MultiMaterial): number;
  39450. /**
  39451. * Removes the given material from this scene.
  39452. * @param toRemove The material to remove
  39453. * @returns The index of the removed material
  39454. */
  39455. removeMaterial(toRemove: Material): number;
  39456. /**
  39457. * Removes the given action manager from this scene.
  39458. * @param toRemove The action manager to remove
  39459. * @returns The index of the removed action manager
  39460. */
  39461. removeActionManager(toRemove: AbstractActionManager): number;
  39462. /**
  39463. * Removes the given texture from this scene.
  39464. * @param toRemove The texture to remove
  39465. * @returns The index of the removed texture
  39466. */
  39467. removeTexture(toRemove: BaseTexture): number;
  39468. /**
  39469. * Adds the given light to this scene
  39470. * @param newLight The light to add
  39471. */
  39472. addLight(newLight: Light): void;
  39473. /**
  39474. * Sorts the list list based on light priorities
  39475. */
  39476. sortLightsByPriority(): void;
  39477. /**
  39478. * Adds the given camera to this scene
  39479. * @param newCamera The camera to add
  39480. */
  39481. addCamera(newCamera: Camera): void;
  39482. /**
  39483. * Adds the given skeleton to this scene
  39484. * @param newSkeleton The skeleton to add
  39485. */
  39486. addSkeleton(newSkeleton: Skeleton): void;
  39487. /**
  39488. * Adds the given particle system to this scene
  39489. * @param newParticleSystem The particle system to add
  39490. */
  39491. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39492. /**
  39493. * Adds the given animation to this scene
  39494. * @param newAnimation The animation to add
  39495. */
  39496. addAnimation(newAnimation: Animation): void;
  39497. /**
  39498. * Adds the given animation group to this scene.
  39499. * @param newAnimationGroup The animation group to add
  39500. */
  39501. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39502. /**
  39503. * Adds the given multi-material to this scene
  39504. * @param newMultiMaterial The multi-material to add
  39505. */
  39506. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39507. /**
  39508. * Adds the given material to this scene
  39509. * @param newMaterial The material to add
  39510. */
  39511. addMaterial(newMaterial: Material): void;
  39512. /**
  39513. * Adds the given morph target to this scene
  39514. * @param newMorphTargetManager The morph target to add
  39515. */
  39516. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39517. /**
  39518. * Adds the given geometry to this scene
  39519. * @param newGeometry The geometry to add
  39520. */
  39521. addGeometry(newGeometry: Geometry): void;
  39522. /**
  39523. * Adds the given action manager to this scene
  39524. * @param newActionManager The action manager to add
  39525. */
  39526. addActionManager(newActionManager: AbstractActionManager): void;
  39527. /**
  39528. * Adds the given texture to this scene.
  39529. * @param newTexture The texture to add
  39530. */
  39531. addTexture(newTexture: BaseTexture): void;
  39532. /**
  39533. * Switch active camera
  39534. * @param newCamera defines the new active camera
  39535. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39536. */
  39537. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39538. /**
  39539. * sets the active camera of the scene using its ID
  39540. * @param id defines the camera's ID
  39541. * @return the new active camera or null if none found.
  39542. */
  39543. setActiveCameraByID(id: string): Nullable<Camera>;
  39544. /**
  39545. * sets the active camera of the scene using its name
  39546. * @param name defines the camera's name
  39547. * @returns the new active camera or null if none found.
  39548. */
  39549. setActiveCameraByName(name: string): Nullable<Camera>;
  39550. /**
  39551. * get an animation group using its name
  39552. * @param name defines the material's name
  39553. * @return the animation group or null if none found.
  39554. */
  39555. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39556. /**
  39557. * Get a material using its unique id
  39558. * @param uniqueId defines the material's unique id
  39559. * @return the material or null if none found.
  39560. */
  39561. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39562. /**
  39563. * get a material using its id
  39564. * @param id defines the material's ID
  39565. * @return the material or null if none found.
  39566. */
  39567. getMaterialByID(id: string): Nullable<Material>;
  39568. /**
  39569. * Gets a the last added material using a given id
  39570. * @param id defines the material's ID
  39571. * @return the last material with the given id or null if none found.
  39572. */
  39573. getLastMaterialByID(id: string): Nullable<Material>;
  39574. /**
  39575. * Gets a material using its name
  39576. * @param name defines the material's name
  39577. * @return the material or null if none found.
  39578. */
  39579. getMaterialByName(name: string): Nullable<Material>;
  39580. /**
  39581. * Get a texture using its unique id
  39582. * @param uniqueId defines the texture's unique id
  39583. * @return the texture or null if none found.
  39584. */
  39585. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39586. /**
  39587. * Gets a camera using its id
  39588. * @param id defines the id to look for
  39589. * @returns the camera or null if not found
  39590. */
  39591. getCameraByID(id: string): Nullable<Camera>;
  39592. /**
  39593. * Gets a camera using its unique id
  39594. * @param uniqueId defines the unique id to look for
  39595. * @returns the camera or null if not found
  39596. */
  39597. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39598. /**
  39599. * Gets a camera using its name
  39600. * @param name defines the camera's name
  39601. * @return the camera or null if none found.
  39602. */
  39603. getCameraByName(name: string): Nullable<Camera>;
  39604. /**
  39605. * Gets a bone using its id
  39606. * @param id defines the bone's id
  39607. * @return the bone or null if not found
  39608. */
  39609. getBoneByID(id: string): Nullable<Bone>;
  39610. /**
  39611. * Gets a bone using its id
  39612. * @param name defines the bone's name
  39613. * @return the bone or null if not found
  39614. */
  39615. getBoneByName(name: string): Nullable<Bone>;
  39616. /**
  39617. * Gets a light node using its name
  39618. * @param name defines the the light's name
  39619. * @return the light or null if none found.
  39620. */
  39621. getLightByName(name: string): Nullable<Light>;
  39622. /**
  39623. * Gets a light node using its id
  39624. * @param id defines the light's id
  39625. * @return the light or null if none found.
  39626. */
  39627. getLightByID(id: string): Nullable<Light>;
  39628. /**
  39629. * Gets a light node using its scene-generated unique ID
  39630. * @param uniqueId defines the light's unique id
  39631. * @return the light or null if none found.
  39632. */
  39633. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39634. /**
  39635. * Gets a particle system by id
  39636. * @param id defines the particle system id
  39637. * @return the corresponding system or null if none found
  39638. */
  39639. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39640. /**
  39641. * Gets a geometry using its ID
  39642. * @param id defines the geometry's id
  39643. * @return the geometry or null if none found.
  39644. */
  39645. getGeometryByID(id: string): Nullable<Geometry>;
  39646. private _getGeometryByUniqueID;
  39647. /**
  39648. * Add a new geometry to this scene
  39649. * @param geometry defines the geometry to be added to the scene.
  39650. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39651. * @return a boolean defining if the geometry was added or not
  39652. */
  39653. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39654. /**
  39655. * Removes an existing geometry
  39656. * @param geometry defines the geometry to be removed from the scene
  39657. * @return a boolean defining if the geometry was removed or not
  39658. */
  39659. removeGeometry(geometry: Geometry): boolean;
  39660. /**
  39661. * Gets the list of geometries attached to the scene
  39662. * @returns an array of Geometry
  39663. */
  39664. getGeometries(): Geometry[];
  39665. /**
  39666. * Gets the first added mesh found of a given ID
  39667. * @param id defines the id to search for
  39668. * @return the mesh found or null if not found at all
  39669. */
  39670. getMeshByID(id: string): Nullable<AbstractMesh>;
  39671. /**
  39672. * Gets a list of meshes using their id
  39673. * @param id defines the id to search for
  39674. * @returns a list of meshes
  39675. */
  39676. getMeshesByID(id: string): Array<AbstractMesh>;
  39677. /**
  39678. * Gets the first added transform node found of a given ID
  39679. * @param id defines the id to search for
  39680. * @return the found transform node or null if not found at all.
  39681. */
  39682. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39683. /**
  39684. * Gets a transform node with its auto-generated unique id
  39685. * @param uniqueId efines the unique id to search for
  39686. * @return the found transform node or null if not found at all.
  39687. */
  39688. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39689. /**
  39690. * Gets a list of transform nodes using their id
  39691. * @param id defines the id to search for
  39692. * @returns a list of transform nodes
  39693. */
  39694. getTransformNodesByID(id: string): Array<TransformNode>;
  39695. /**
  39696. * Gets a mesh with its auto-generated unique id
  39697. * @param uniqueId defines the unique id to search for
  39698. * @return the found mesh or null if not found at all.
  39699. */
  39700. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39701. /**
  39702. * Gets a the last added mesh using a given id
  39703. * @param id defines the id to search for
  39704. * @return the found mesh or null if not found at all.
  39705. */
  39706. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39707. /**
  39708. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39709. * @param id defines the id to search for
  39710. * @return the found node or null if not found at all
  39711. */
  39712. getLastEntryByID(id: string): Nullable<Node>;
  39713. /**
  39714. * Gets a node (Mesh, Camera, Light) using a given id
  39715. * @param id defines the id to search for
  39716. * @return the found node or null if not found at all
  39717. */
  39718. getNodeByID(id: string): Nullable<Node>;
  39719. /**
  39720. * Gets a node (Mesh, Camera, Light) using a given name
  39721. * @param name defines the name to search for
  39722. * @return the found node or null if not found at all.
  39723. */
  39724. getNodeByName(name: string): Nullable<Node>;
  39725. /**
  39726. * Gets a mesh using a given name
  39727. * @param name defines the name to search for
  39728. * @return the found mesh or null if not found at all.
  39729. */
  39730. getMeshByName(name: string): Nullable<AbstractMesh>;
  39731. /**
  39732. * Gets a transform node using a given name
  39733. * @param name defines the name to search for
  39734. * @return the found transform node or null if not found at all.
  39735. */
  39736. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39737. /**
  39738. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39739. * @param id defines the id to search for
  39740. * @return the found skeleton or null if not found at all.
  39741. */
  39742. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39743. /**
  39744. * Gets a skeleton using a given auto generated unique id
  39745. * @param uniqueId defines the unique id to search for
  39746. * @return the found skeleton or null if not found at all.
  39747. */
  39748. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39749. /**
  39750. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39751. * @param id defines the id to search for
  39752. * @return the found skeleton or null if not found at all.
  39753. */
  39754. getSkeletonById(id: string): Nullable<Skeleton>;
  39755. /**
  39756. * Gets a skeleton using a given name
  39757. * @param name defines the name to search for
  39758. * @return the found skeleton or null if not found at all.
  39759. */
  39760. getSkeletonByName(name: string): Nullable<Skeleton>;
  39761. /**
  39762. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39763. * @param id defines the id to search for
  39764. * @return the found morph target manager or null if not found at all.
  39765. */
  39766. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39767. /**
  39768. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39769. * @param id defines the id to search for
  39770. * @return the found morph target or null if not found at all.
  39771. */
  39772. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39773. /**
  39774. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39775. * @param name defines the name to search for
  39776. * @return the found morph target or null if not found at all.
  39777. */
  39778. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39779. /**
  39780. * Gets a boolean indicating if the given mesh is active
  39781. * @param mesh defines the mesh to look for
  39782. * @returns true if the mesh is in the active list
  39783. */
  39784. isActiveMesh(mesh: AbstractMesh): boolean;
  39785. /**
  39786. * Return a unique id as a string which can serve as an identifier for the scene
  39787. */
  39788. get uid(): string;
  39789. /**
  39790. * Add an externaly attached data from its key.
  39791. * This method call will fail and return false, if such key already exists.
  39792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39793. * @param key the unique key that identifies the data
  39794. * @param data the data object to associate to the key for this Engine instance
  39795. * @return true if no such key were already present and the data was added successfully, false otherwise
  39796. */
  39797. addExternalData<T>(key: string, data: T): boolean;
  39798. /**
  39799. * Get an externaly attached data from its key
  39800. * @param key the unique key that identifies the data
  39801. * @return the associated data, if present (can be null), or undefined if not present
  39802. */
  39803. getExternalData<T>(key: string): Nullable<T>;
  39804. /**
  39805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39806. * @param key the unique key that identifies the data
  39807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39808. * @return the associated data, can be null if the factory returned null.
  39809. */
  39810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39811. /**
  39812. * Remove an externaly attached data from the Engine instance
  39813. * @param key the unique key that identifies the data
  39814. * @return true if the data was successfully removed, false if it doesn't exist
  39815. */
  39816. removeExternalData(key: string): boolean;
  39817. private _evaluateSubMesh;
  39818. /**
  39819. * Clear the processed materials smart array preventing retention point in material dispose.
  39820. */
  39821. freeProcessedMaterials(): void;
  39822. private _preventFreeActiveMeshesAndRenderingGroups;
  39823. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39824. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39825. * when disposing several meshes in a row or a hierarchy of meshes.
  39826. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39827. */
  39828. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39829. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39830. /**
  39831. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39832. */
  39833. freeActiveMeshes(): void;
  39834. /**
  39835. * Clear the info related to rendering groups preventing retention points during dispose.
  39836. */
  39837. freeRenderingGroups(): void;
  39838. /** @hidden */
  39839. _isInIntermediateRendering(): boolean;
  39840. /**
  39841. * Lambda returning the list of potentially active meshes.
  39842. */
  39843. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39844. /**
  39845. * Lambda returning the list of potentially active sub meshes.
  39846. */
  39847. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39848. /**
  39849. * Lambda returning the list of potentially intersecting sub meshes.
  39850. */
  39851. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39852. /**
  39853. * Lambda returning the list of potentially colliding sub meshes.
  39854. */
  39855. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39856. private _activeMeshesFrozen;
  39857. private _skipEvaluateActiveMeshesCompletely;
  39858. /**
  39859. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39860. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39861. * @returns the current scene
  39862. */
  39863. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39864. /**
  39865. * Use this function to restart evaluating active meshes on every frame
  39866. * @returns the current scene
  39867. */
  39868. unfreezeActiveMeshes(): Scene;
  39869. private _evaluateActiveMeshes;
  39870. private _activeMesh;
  39871. /**
  39872. * Update the transform matrix to update from the current active camera
  39873. * @param force defines a boolean used to force the update even if cache is up to date
  39874. */
  39875. updateTransformMatrix(force?: boolean): void;
  39876. private _bindFrameBuffer;
  39877. /** @hidden */
  39878. _allowPostProcessClearColor: boolean;
  39879. /** @hidden */
  39880. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39881. private _processSubCameras;
  39882. private _checkIntersections;
  39883. /** @hidden */
  39884. _advancePhysicsEngineStep(step: number): void;
  39885. /**
  39886. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39887. */
  39888. getDeterministicFrameTime: () => number;
  39889. /** @hidden */
  39890. _animate(): void;
  39891. /** Execute all animations (for a frame) */
  39892. animate(): void;
  39893. /**
  39894. * Render the scene
  39895. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39896. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39897. */
  39898. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39899. /**
  39900. * Freeze all materials
  39901. * A frozen material will not be updatable but should be faster to render
  39902. */
  39903. freezeMaterials(): void;
  39904. /**
  39905. * Unfreeze all materials
  39906. * A frozen material will not be updatable but should be faster to render
  39907. */
  39908. unfreezeMaterials(): void;
  39909. /**
  39910. * Releases all held ressources
  39911. */
  39912. dispose(): void;
  39913. /**
  39914. * Gets if the scene is already disposed
  39915. */
  39916. get isDisposed(): boolean;
  39917. /**
  39918. * Call this function to reduce memory footprint of the scene.
  39919. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39920. */
  39921. clearCachedVertexData(): void;
  39922. /**
  39923. * This function will remove the local cached buffer data from texture.
  39924. * It will save memory but will prevent the texture from being rebuilt
  39925. */
  39926. cleanCachedTextureBuffer(): void;
  39927. /**
  39928. * Get the world extend vectors with an optional filter
  39929. *
  39930. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39931. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39932. */
  39933. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39934. min: Vector3;
  39935. max: Vector3;
  39936. };
  39937. /**
  39938. * Creates a ray that can be used to pick in the scene
  39939. * @param x defines the x coordinate of the origin (on-screen)
  39940. * @param y defines the y coordinate of the origin (on-screen)
  39941. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39942. * @param camera defines the camera to use for the picking
  39943. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39944. * @returns a Ray
  39945. */
  39946. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39947. /**
  39948. * Creates a ray that can be used to pick in the scene
  39949. * @param x defines the x coordinate of the origin (on-screen)
  39950. * @param y defines the y coordinate of the origin (on-screen)
  39951. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39952. * @param result defines the ray where to store the picking ray
  39953. * @param camera defines the camera to use for the picking
  39954. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39955. * @returns the current scene
  39956. */
  39957. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39958. /**
  39959. * Creates a ray that can be used to pick in the scene
  39960. * @param x defines the x coordinate of the origin (on-screen)
  39961. * @param y defines the y coordinate of the origin (on-screen)
  39962. * @param camera defines the camera to use for the picking
  39963. * @returns a Ray
  39964. */
  39965. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39966. /**
  39967. * Creates a ray that can be used to pick in the scene
  39968. * @param x defines the x coordinate of the origin (on-screen)
  39969. * @param y defines the y coordinate of the origin (on-screen)
  39970. * @param result defines the ray where to store the picking ray
  39971. * @param camera defines the camera to use for the picking
  39972. * @returns the current scene
  39973. */
  39974. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39975. /** Launch a ray to try to pick a mesh in the scene
  39976. * @param x position on screen
  39977. * @param y position on screen
  39978. * @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
  39979. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39980. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39982. * @returns a PickingInfo
  39983. */
  39984. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39985. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39986. * @param x position on screen
  39987. * @param y position on screen
  39988. * @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
  39989. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39990. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39991. * @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)
  39992. */
  39993. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39994. /** Use the given ray to pick a mesh in the scene
  39995. * @param ray The ray to use to pick meshes
  39996. * @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
  39997. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39999. * @returns a PickingInfo
  40000. */
  40001. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40002. /**
  40003. * Launch a ray to try to pick a mesh in the scene
  40004. * @param x X position on screen
  40005. * @param y Y position on screen
  40006. * @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
  40007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40009. * @returns an array of PickingInfo
  40010. */
  40011. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40012. /**
  40013. * Launch a ray to try to pick a mesh in the scene
  40014. * @param ray Ray to use
  40015. * @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
  40016. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40017. * @returns an array of PickingInfo
  40018. */
  40019. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40020. /**
  40021. * Force the value of meshUnderPointer
  40022. * @param mesh defines the mesh to use
  40023. */
  40024. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40025. /**
  40026. * Gets the mesh under the pointer
  40027. * @returns a Mesh or null if no mesh is under the pointer
  40028. */
  40029. getPointerOverMesh(): Nullable<AbstractMesh>;
  40030. /** @hidden */
  40031. _rebuildGeometries(): void;
  40032. /** @hidden */
  40033. _rebuildTextures(): void;
  40034. private _getByTags;
  40035. /**
  40036. * Get a list of meshes by tags
  40037. * @param tagsQuery defines the tags query to use
  40038. * @param forEach defines a predicate used to filter results
  40039. * @returns an array of Mesh
  40040. */
  40041. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40042. /**
  40043. * Get a list of cameras by tags
  40044. * @param tagsQuery defines the tags query to use
  40045. * @param forEach defines a predicate used to filter results
  40046. * @returns an array of Camera
  40047. */
  40048. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40049. /**
  40050. * Get a list of lights by tags
  40051. * @param tagsQuery defines the tags query to use
  40052. * @param forEach defines a predicate used to filter results
  40053. * @returns an array of Light
  40054. */
  40055. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40056. /**
  40057. * Get a list of materials by tags
  40058. * @param tagsQuery defines the tags query to use
  40059. * @param forEach defines a predicate used to filter results
  40060. * @returns an array of Material
  40061. */
  40062. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40063. /**
  40064. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40065. * This allowed control for front to back rendering or reversly depending of the special needs.
  40066. *
  40067. * @param renderingGroupId The rendering group id corresponding to its index
  40068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40071. */
  40072. 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;
  40073. /**
  40074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40075. *
  40076. * @param renderingGroupId The rendering group id corresponding to its index
  40077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40078. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40079. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40080. */
  40081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40082. /**
  40083. * Gets the current auto clear configuration for one rendering group of the rendering
  40084. * manager.
  40085. * @param index the rendering group index to get the information for
  40086. * @returns The auto clear setup for the requested rendering group
  40087. */
  40088. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40089. private _blockMaterialDirtyMechanism;
  40090. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40091. get blockMaterialDirtyMechanism(): boolean;
  40092. set blockMaterialDirtyMechanism(value: boolean);
  40093. /**
  40094. * Will flag all materials as dirty to trigger new shader compilation
  40095. * @param flag defines the flag used to specify which material part must be marked as dirty
  40096. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40097. */
  40098. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40099. /** @hidden */
  40100. _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;
  40101. /** @hidden */
  40102. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40103. /** @hidden */
  40104. _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;
  40105. /** @hidden */
  40106. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40107. /** @hidden */
  40108. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40109. /** @hidden */
  40110. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * Set of assets to keep when moving a scene into an asset container.
  40116. */
  40117. export class KeepAssets extends AbstractScene {
  40118. }
  40119. /**
  40120. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40121. */
  40122. export class InstantiatedEntries {
  40123. /**
  40124. * List of new root nodes (eg. nodes with no parent)
  40125. */
  40126. rootNodes: TransformNode[];
  40127. /**
  40128. * List of new skeletons
  40129. */
  40130. skeletons: Skeleton[];
  40131. /**
  40132. * List of new animation groups
  40133. */
  40134. animationGroups: AnimationGroup[];
  40135. }
  40136. /**
  40137. * Container with a set of assets that can be added or removed from a scene.
  40138. */
  40139. export class AssetContainer extends AbstractScene {
  40140. private _wasAddedToScene;
  40141. /**
  40142. * The scene the AssetContainer belongs to.
  40143. */
  40144. scene: Scene;
  40145. /**
  40146. * Instantiates an AssetContainer.
  40147. * @param scene The scene the AssetContainer belongs to.
  40148. */
  40149. constructor(scene: Scene);
  40150. /**
  40151. * Instantiate or clone all meshes and add the new ones to the scene.
  40152. * Skeletons and animation groups will all be cloned
  40153. * @param nameFunction defines an optional function used to get new names for clones
  40154. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40155. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40156. */
  40157. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40158. /**
  40159. * Adds all the assets from the container to the scene.
  40160. */
  40161. addAllToScene(): void;
  40162. /**
  40163. * Removes all the assets in the container from the scene
  40164. */
  40165. removeAllFromScene(): void;
  40166. /**
  40167. * Disposes all the assets in the container
  40168. */
  40169. dispose(): void;
  40170. private _moveAssets;
  40171. /**
  40172. * Removes all the assets contained in the scene and adds them to the container.
  40173. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40174. */
  40175. moveAllFromScene(keepAssets?: KeepAssets): void;
  40176. /**
  40177. * 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.
  40178. * @returns the root mesh
  40179. */
  40180. createRootMesh(): Mesh;
  40181. /**
  40182. * Merge animations (direct and animation groups) from this asset container into a scene
  40183. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40184. * @param animatables set of animatables to retarget to a node from the scene
  40185. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40186. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40187. */
  40188. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40189. }
  40190. }
  40191. declare module BABYLON {
  40192. /**
  40193. * Defines how the parser contract is defined.
  40194. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40195. */
  40196. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40197. /**
  40198. * Defines how the individual parser contract is defined.
  40199. * These parser can parse an individual asset
  40200. */
  40201. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40202. /**
  40203. * Base class of the scene acting as a container for the different elements composing a scene.
  40204. * This class is dynamically extended by the different components of the scene increasing
  40205. * flexibility and reducing coupling
  40206. */
  40207. export abstract class AbstractScene {
  40208. /**
  40209. * Stores the list of available parsers in the application.
  40210. */
  40211. private static _BabylonFileParsers;
  40212. /**
  40213. * Stores the list of available individual parsers in the application.
  40214. */
  40215. private static _IndividualBabylonFileParsers;
  40216. /**
  40217. * Adds a parser in the list of available ones
  40218. * @param name Defines the name of the parser
  40219. * @param parser Defines the parser to add
  40220. */
  40221. static AddParser(name: string, parser: BabylonFileParser): void;
  40222. /**
  40223. * Gets a general parser from the list of avaialble ones
  40224. * @param name Defines the name of the parser
  40225. * @returns the requested parser or null
  40226. */
  40227. static GetParser(name: string): Nullable<BabylonFileParser>;
  40228. /**
  40229. * Adds n individual parser in the list of available ones
  40230. * @param name Defines the name of the parser
  40231. * @param parser Defines the parser to add
  40232. */
  40233. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40234. /**
  40235. * Gets an individual parser from the list of avaialble ones
  40236. * @param name Defines the name of the parser
  40237. * @returns the requested parser or null
  40238. */
  40239. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40240. /**
  40241. * Parser json data and populate both a scene and its associated container object
  40242. * @param jsonData Defines the data to parse
  40243. * @param scene Defines the scene to parse the data for
  40244. * @param container Defines the container attached to the parsing sequence
  40245. * @param rootUrl Defines the root url of the data
  40246. */
  40247. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40248. /**
  40249. * Gets the list of root nodes (ie. nodes with no parent)
  40250. */
  40251. rootNodes: Node[];
  40252. /** All of the cameras added to this scene
  40253. * @see http://doc.babylonjs.com/babylon101/cameras
  40254. */
  40255. cameras: Camera[];
  40256. /**
  40257. * All of the lights added to this scene
  40258. * @see http://doc.babylonjs.com/babylon101/lights
  40259. */
  40260. lights: Light[];
  40261. /**
  40262. * All of the (abstract) meshes added to this scene
  40263. */
  40264. meshes: AbstractMesh[];
  40265. /**
  40266. * The list of skeletons added to the scene
  40267. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40268. */
  40269. skeletons: Skeleton[];
  40270. /**
  40271. * All of the particle systems added to this scene
  40272. * @see http://doc.babylonjs.com/babylon101/particles
  40273. */
  40274. particleSystems: IParticleSystem[];
  40275. /**
  40276. * Gets a list of Animations associated with the scene
  40277. */
  40278. animations: Animation[];
  40279. /**
  40280. * All of the animation groups added to this scene
  40281. * @see http://doc.babylonjs.com/how_to/group
  40282. */
  40283. animationGroups: AnimationGroup[];
  40284. /**
  40285. * All of the multi-materials added to this scene
  40286. * @see http://doc.babylonjs.com/how_to/multi_materials
  40287. */
  40288. multiMaterials: MultiMaterial[];
  40289. /**
  40290. * All of the materials added to this scene
  40291. * In the context of a Scene, it is not supposed to be modified manually.
  40292. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40293. * Note also that the order of the Material within the array is not significant and might change.
  40294. * @see http://doc.babylonjs.com/babylon101/materials
  40295. */
  40296. materials: Material[];
  40297. /**
  40298. * The list of morph target managers added to the scene
  40299. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40300. */
  40301. morphTargetManagers: MorphTargetManager[];
  40302. /**
  40303. * The list of geometries used in the scene.
  40304. */
  40305. geometries: Geometry[];
  40306. /**
  40307. * All of the tranform nodes added to this scene
  40308. * In the context of a Scene, it is not supposed to be modified manually.
  40309. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40310. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40311. * @see http://doc.babylonjs.com/how_to/transformnode
  40312. */
  40313. transformNodes: TransformNode[];
  40314. /**
  40315. * ActionManagers available on the scene.
  40316. */
  40317. actionManagers: AbstractActionManager[];
  40318. /**
  40319. * Textures to keep.
  40320. */
  40321. textures: BaseTexture[];
  40322. /**
  40323. * Environment texture for the scene
  40324. */
  40325. environmentTexture: Nullable<BaseTexture>;
  40326. /**
  40327. * @returns all meshes, lights, cameras, transformNodes and bones
  40328. */
  40329. getNodes(): Array<Node>;
  40330. }
  40331. }
  40332. declare module BABYLON {
  40333. /**
  40334. * Interface used to define options for Sound class
  40335. */
  40336. export interface ISoundOptions {
  40337. /**
  40338. * Does the sound autoplay once loaded.
  40339. */
  40340. autoplay?: boolean;
  40341. /**
  40342. * Does the sound loop after it finishes playing once.
  40343. */
  40344. loop?: boolean;
  40345. /**
  40346. * Sound's volume
  40347. */
  40348. volume?: number;
  40349. /**
  40350. * Is it a spatial sound?
  40351. */
  40352. spatialSound?: boolean;
  40353. /**
  40354. * Maximum distance to hear that sound
  40355. */
  40356. maxDistance?: number;
  40357. /**
  40358. * Uses user defined attenuation function
  40359. */
  40360. useCustomAttenuation?: boolean;
  40361. /**
  40362. * Define the roll off factor of spatial sounds.
  40363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40364. */
  40365. rolloffFactor?: number;
  40366. /**
  40367. * Define the reference distance the sound should be heard perfectly.
  40368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40369. */
  40370. refDistance?: number;
  40371. /**
  40372. * Define the distance attenuation model the sound will follow.
  40373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40374. */
  40375. distanceModel?: string;
  40376. /**
  40377. * Defines the playback speed (1 by default)
  40378. */
  40379. playbackRate?: number;
  40380. /**
  40381. * Defines if the sound is from a streaming source
  40382. */
  40383. streaming?: boolean;
  40384. /**
  40385. * Defines an optional length (in seconds) inside the sound file
  40386. */
  40387. length?: number;
  40388. /**
  40389. * Defines an optional offset (in seconds) inside the sound file
  40390. */
  40391. offset?: number;
  40392. /**
  40393. * If true, URLs will not be required to state the audio file codec to use.
  40394. */
  40395. skipCodecCheck?: boolean;
  40396. }
  40397. /**
  40398. * Defines a sound that can be played in the application.
  40399. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40401. */
  40402. export class Sound {
  40403. /**
  40404. * The name of the sound in the scene.
  40405. */
  40406. name: string;
  40407. /**
  40408. * Does the sound autoplay once loaded.
  40409. */
  40410. autoplay: boolean;
  40411. /**
  40412. * Does the sound loop after it finishes playing once.
  40413. */
  40414. loop: boolean;
  40415. /**
  40416. * Does the sound use a custom attenuation curve to simulate the falloff
  40417. * happening when the source gets further away from the camera.
  40418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40419. */
  40420. useCustomAttenuation: boolean;
  40421. /**
  40422. * The sound track id this sound belongs to.
  40423. */
  40424. soundTrackId: number;
  40425. /**
  40426. * Is this sound currently played.
  40427. */
  40428. isPlaying: boolean;
  40429. /**
  40430. * Is this sound currently paused.
  40431. */
  40432. isPaused: boolean;
  40433. /**
  40434. * Does this sound enables spatial sound.
  40435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40436. */
  40437. spatialSound: boolean;
  40438. /**
  40439. * Define the reference distance the sound should be heard perfectly.
  40440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40441. */
  40442. refDistance: number;
  40443. /**
  40444. * Define the roll off factor of spatial sounds.
  40445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40446. */
  40447. rolloffFactor: number;
  40448. /**
  40449. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40451. */
  40452. maxDistance: number;
  40453. /**
  40454. * Define the distance attenuation model the sound will follow.
  40455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40456. */
  40457. distanceModel: string;
  40458. /**
  40459. * @hidden
  40460. * Back Compat
  40461. **/
  40462. onended: () => any;
  40463. /**
  40464. * Gets or sets an object used to store user defined information for the sound.
  40465. */
  40466. metadata: any;
  40467. /**
  40468. * Observable event when the current playing sound finishes.
  40469. */
  40470. onEndedObservable: Observable<Sound>;
  40471. private _panningModel;
  40472. private _playbackRate;
  40473. private _streaming;
  40474. private _startTime;
  40475. private _startOffset;
  40476. private _position;
  40477. /** @hidden */
  40478. _positionInEmitterSpace: boolean;
  40479. private _localDirection;
  40480. private _volume;
  40481. private _isReadyToPlay;
  40482. private _isDirectional;
  40483. private _readyToPlayCallback;
  40484. private _audioBuffer;
  40485. private _soundSource;
  40486. private _streamingSource;
  40487. private _soundPanner;
  40488. private _soundGain;
  40489. private _inputAudioNode;
  40490. private _outputAudioNode;
  40491. private _coneInnerAngle;
  40492. private _coneOuterAngle;
  40493. private _coneOuterGain;
  40494. private _scene;
  40495. private _connectedTransformNode;
  40496. private _customAttenuationFunction;
  40497. private _registerFunc;
  40498. private _isOutputConnected;
  40499. private _htmlAudioElement;
  40500. private _urlType;
  40501. private _length?;
  40502. private _offset?;
  40503. /** @hidden */
  40504. static _SceneComponentInitialization: (scene: Scene) => void;
  40505. /**
  40506. * Create a sound and attach it to a scene
  40507. * @param name Name of your sound
  40508. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40509. * @param scene defines the scene the sound belongs to
  40510. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40511. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40512. */
  40513. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40514. /**
  40515. * Release the sound and its associated resources
  40516. */
  40517. dispose(): void;
  40518. /**
  40519. * Gets if the sounds is ready to be played or not.
  40520. * @returns true if ready, otherwise false
  40521. */
  40522. isReady(): boolean;
  40523. private _soundLoaded;
  40524. /**
  40525. * Sets the data of the sound from an audiobuffer
  40526. * @param audioBuffer The audioBuffer containing the data
  40527. */
  40528. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40529. /**
  40530. * Updates the current sounds options such as maxdistance, loop...
  40531. * @param options A JSON object containing values named as the object properties
  40532. */
  40533. updateOptions(options: ISoundOptions): void;
  40534. private _createSpatialParameters;
  40535. private _updateSpatialParameters;
  40536. /**
  40537. * Switch the panning model to HRTF:
  40538. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40540. */
  40541. switchPanningModelToHRTF(): void;
  40542. /**
  40543. * Switch the panning model to Equal Power:
  40544. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40546. */
  40547. switchPanningModelToEqualPower(): void;
  40548. private _switchPanningModel;
  40549. /**
  40550. * Connect this sound to a sound track audio node like gain...
  40551. * @param soundTrackAudioNode the sound track audio node to connect to
  40552. */
  40553. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40554. /**
  40555. * Transform this sound into a directional source
  40556. * @param coneInnerAngle Size of the inner cone in degree
  40557. * @param coneOuterAngle Size of the outer cone in degree
  40558. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40559. */
  40560. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40561. /**
  40562. * Gets or sets the inner angle for the directional cone.
  40563. */
  40564. get directionalConeInnerAngle(): number;
  40565. /**
  40566. * Gets or sets the inner angle for the directional cone.
  40567. */
  40568. set directionalConeInnerAngle(value: number);
  40569. /**
  40570. * Gets or sets the outer angle for the directional cone.
  40571. */
  40572. get directionalConeOuterAngle(): number;
  40573. /**
  40574. * Gets or sets the outer angle for the directional cone.
  40575. */
  40576. set directionalConeOuterAngle(value: number);
  40577. /**
  40578. * Sets the position of the emitter if spatial sound is enabled
  40579. * @param newPosition Defines the new posisiton
  40580. */
  40581. setPosition(newPosition: Vector3): void;
  40582. /**
  40583. * Sets the local direction of the emitter if spatial sound is enabled
  40584. * @param newLocalDirection Defines the new local direction
  40585. */
  40586. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40587. private _updateDirection;
  40588. /** @hidden */
  40589. updateDistanceFromListener(): void;
  40590. /**
  40591. * Sets a new custom attenuation function for the sound.
  40592. * @param callback Defines the function used for the attenuation
  40593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40594. */
  40595. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40596. /**
  40597. * Play the sound
  40598. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40599. * @param offset (optional) Start the sound at a specific time in seconds
  40600. * @param length (optional) Sound duration (in seconds)
  40601. */
  40602. play(time?: number, offset?: number, length?: number): void;
  40603. private _onended;
  40604. /**
  40605. * Stop the sound
  40606. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40607. */
  40608. stop(time?: number): void;
  40609. /**
  40610. * Put the sound in pause
  40611. */
  40612. pause(): void;
  40613. /**
  40614. * Sets a dedicated volume for this sounds
  40615. * @param newVolume Define the new volume of the sound
  40616. * @param time Define time for gradual change to new volume
  40617. */
  40618. setVolume(newVolume: number, time?: number): void;
  40619. /**
  40620. * Set the sound play back rate
  40621. * @param newPlaybackRate Define the playback rate the sound should be played at
  40622. */
  40623. setPlaybackRate(newPlaybackRate: number): void;
  40624. /**
  40625. * Gets the volume of the sound.
  40626. * @returns the volume of the sound
  40627. */
  40628. getVolume(): number;
  40629. /**
  40630. * Attach the sound to a dedicated mesh
  40631. * @param transformNode The transform node to connect the sound with
  40632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40633. */
  40634. attachToMesh(transformNode: TransformNode): void;
  40635. /**
  40636. * Detach the sound from the previously attached mesh
  40637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40638. */
  40639. detachFromMesh(): void;
  40640. private _onRegisterAfterWorldMatrixUpdate;
  40641. /**
  40642. * Clone the current sound in the scene.
  40643. * @returns the new sound clone
  40644. */
  40645. clone(): Nullable<Sound>;
  40646. /**
  40647. * Gets the current underlying audio buffer containing the data
  40648. * @returns the audio buffer
  40649. */
  40650. getAudioBuffer(): Nullable<AudioBuffer>;
  40651. /**
  40652. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40653. * @returns the source node
  40654. */
  40655. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40656. /**
  40657. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40658. * @returns the gain node
  40659. */
  40660. getSoundGain(): Nullable<GainNode>;
  40661. /**
  40662. * Serializes the Sound in a JSON representation
  40663. * @returns the JSON representation of the sound
  40664. */
  40665. serialize(): any;
  40666. /**
  40667. * Parse a JSON representation of a sound to innstantiate in a given scene
  40668. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40669. * @param scene Define the scene the new parsed sound should be created in
  40670. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40671. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40672. * @returns the newly parsed sound
  40673. */
  40674. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40675. }
  40676. }
  40677. declare module BABYLON {
  40678. /**
  40679. * This defines an action helpful to play a defined sound on a triggered action.
  40680. */
  40681. export class PlaySoundAction extends Action {
  40682. private _sound;
  40683. /**
  40684. * Instantiate the action
  40685. * @param triggerOptions defines the trigger options
  40686. * @param sound defines the sound to play
  40687. * @param condition defines the trigger related conditions
  40688. */
  40689. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40690. /** @hidden */
  40691. _prepare(): void;
  40692. /**
  40693. * Execute the action and play the sound.
  40694. */
  40695. execute(): void;
  40696. /**
  40697. * Serializes the actions and its related information.
  40698. * @param parent defines the object to serialize in
  40699. * @returns the serialized object
  40700. */
  40701. serialize(parent: any): any;
  40702. }
  40703. /**
  40704. * This defines an action helpful to stop a defined sound on a triggered action.
  40705. */
  40706. export class StopSoundAction extends Action {
  40707. private _sound;
  40708. /**
  40709. * Instantiate the action
  40710. * @param triggerOptions defines the trigger options
  40711. * @param sound defines the sound to stop
  40712. * @param condition defines the trigger related conditions
  40713. */
  40714. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40715. /** @hidden */
  40716. _prepare(): void;
  40717. /**
  40718. * Execute the action and stop the sound.
  40719. */
  40720. execute(): void;
  40721. /**
  40722. * Serializes the actions and its related information.
  40723. * @param parent defines the object to serialize in
  40724. * @returns the serialized object
  40725. */
  40726. serialize(parent: any): any;
  40727. }
  40728. }
  40729. declare module BABYLON {
  40730. /**
  40731. * This defines an action responsible to change the value of a property
  40732. * by interpolating between its current value and the newly set one once triggered.
  40733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40734. */
  40735. export class InterpolateValueAction extends Action {
  40736. /**
  40737. * Defines the path of the property where the value should be interpolated
  40738. */
  40739. propertyPath: string;
  40740. /**
  40741. * Defines the target value at the end of the interpolation.
  40742. */
  40743. value: any;
  40744. /**
  40745. * Defines the time it will take for the property to interpolate to the value.
  40746. */
  40747. duration: number;
  40748. /**
  40749. * Defines if the other scene animations should be stopped when the action has been triggered
  40750. */
  40751. stopOtherAnimations?: boolean;
  40752. /**
  40753. * Defines a callback raised once the interpolation animation has been done.
  40754. */
  40755. onInterpolationDone?: () => void;
  40756. /**
  40757. * Observable triggered once the interpolation animation has been done.
  40758. */
  40759. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40760. private _target;
  40761. private _effectiveTarget;
  40762. private _property;
  40763. /**
  40764. * Instantiate the action
  40765. * @param triggerOptions defines the trigger options
  40766. * @param target defines the object containing the value to interpolate
  40767. * @param propertyPath defines the path to the property in the target object
  40768. * @param value defines the target value at the end of the interpolation
  40769. * @param duration deines the time it will take for the property to interpolate to the value.
  40770. * @param condition defines the trigger related conditions
  40771. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40772. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40773. */
  40774. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40775. /** @hidden */
  40776. _prepare(): void;
  40777. /**
  40778. * Execute the action starts the value interpolation.
  40779. */
  40780. execute(): void;
  40781. /**
  40782. * Serializes the actions and its related information.
  40783. * @param parent defines the object to serialize in
  40784. * @returns the serialized object
  40785. */
  40786. serialize(parent: any): any;
  40787. }
  40788. }
  40789. declare module BABYLON {
  40790. /**
  40791. * Options allowed during the creation of a sound track.
  40792. */
  40793. export interface ISoundTrackOptions {
  40794. /**
  40795. * The volume the sound track should take during creation
  40796. */
  40797. volume?: number;
  40798. /**
  40799. * Define if the sound track is the main sound track of the scene
  40800. */
  40801. mainTrack?: boolean;
  40802. }
  40803. /**
  40804. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40805. * It will be also used in a future release to apply effects on a specific track.
  40806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40807. */
  40808. export class SoundTrack {
  40809. /**
  40810. * The unique identifier of the sound track in the scene.
  40811. */
  40812. id: number;
  40813. /**
  40814. * The list of sounds included in the sound track.
  40815. */
  40816. soundCollection: Array<Sound>;
  40817. private _outputAudioNode;
  40818. private _scene;
  40819. private _connectedAnalyser;
  40820. private _options;
  40821. private _isInitialized;
  40822. /**
  40823. * Creates a new sound track.
  40824. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40825. * @param scene Define the scene the sound track belongs to
  40826. * @param options
  40827. */
  40828. constructor(scene: Scene, options?: ISoundTrackOptions);
  40829. private _initializeSoundTrackAudioGraph;
  40830. /**
  40831. * Release the sound track and its associated resources
  40832. */
  40833. dispose(): void;
  40834. /**
  40835. * Adds a sound to this sound track
  40836. * @param sound define the cound to add
  40837. * @ignoreNaming
  40838. */
  40839. AddSound(sound: Sound): void;
  40840. /**
  40841. * Removes a sound to this sound track
  40842. * @param sound define the cound to remove
  40843. * @ignoreNaming
  40844. */
  40845. RemoveSound(sound: Sound): void;
  40846. /**
  40847. * Set a global volume for the full sound track.
  40848. * @param newVolume Define the new volume of the sound track
  40849. */
  40850. setVolume(newVolume: number): void;
  40851. /**
  40852. * Switch the panning model to HRTF:
  40853. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40855. */
  40856. switchPanningModelToHRTF(): void;
  40857. /**
  40858. * Switch the panning model to Equal Power:
  40859. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40861. */
  40862. switchPanningModelToEqualPower(): void;
  40863. /**
  40864. * Connect the sound track to an audio analyser allowing some amazing
  40865. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40867. * @param analyser The analyser to connect to the engine
  40868. */
  40869. connectToAnalyser(analyser: Analyser): void;
  40870. }
  40871. }
  40872. declare module BABYLON {
  40873. interface AbstractScene {
  40874. /**
  40875. * The list of sounds used in the scene.
  40876. */
  40877. sounds: Nullable<Array<Sound>>;
  40878. }
  40879. interface Scene {
  40880. /**
  40881. * @hidden
  40882. * Backing field
  40883. */
  40884. _mainSoundTrack: SoundTrack;
  40885. /**
  40886. * The main sound track played by the scene.
  40887. * It cotains your primary collection of sounds.
  40888. */
  40889. mainSoundTrack: SoundTrack;
  40890. /**
  40891. * The list of sound tracks added to the scene
  40892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40893. */
  40894. soundTracks: Nullable<Array<SoundTrack>>;
  40895. /**
  40896. * Gets a sound using a given name
  40897. * @param name defines the name to search for
  40898. * @return the found sound or null if not found at all.
  40899. */
  40900. getSoundByName(name: string): Nullable<Sound>;
  40901. /**
  40902. * Gets or sets if audio support is enabled
  40903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40904. */
  40905. audioEnabled: boolean;
  40906. /**
  40907. * Gets or sets if audio will be output to headphones
  40908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40909. */
  40910. headphone: boolean;
  40911. /**
  40912. * Gets or sets custom audio listener position provider
  40913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40914. */
  40915. audioListenerPositionProvider: Nullable<() => Vector3>;
  40916. /**
  40917. * Gets or sets a refresh rate when using 3D audio positioning
  40918. */
  40919. audioPositioningRefreshRate: number;
  40920. }
  40921. /**
  40922. * Defines the sound scene component responsible to manage any sounds
  40923. * in a given scene.
  40924. */
  40925. export class AudioSceneComponent implements ISceneSerializableComponent {
  40926. /**
  40927. * The component name helpfull to identify the component in the list of scene components.
  40928. */
  40929. readonly name: string;
  40930. /**
  40931. * The scene the component belongs to.
  40932. */
  40933. scene: Scene;
  40934. private _audioEnabled;
  40935. /**
  40936. * Gets whether audio is enabled or not.
  40937. * Please use related enable/disable method to switch state.
  40938. */
  40939. get audioEnabled(): boolean;
  40940. private _headphone;
  40941. /**
  40942. * Gets whether audio is outputing to headphone or not.
  40943. * Please use the according Switch methods to change output.
  40944. */
  40945. get headphone(): boolean;
  40946. /**
  40947. * Gets or sets a refresh rate when using 3D audio positioning
  40948. */
  40949. audioPositioningRefreshRate: number;
  40950. private _audioListenerPositionProvider;
  40951. /**
  40952. * Gets the current audio listener position provider
  40953. */
  40954. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40955. /**
  40956. * Sets a custom listener position for all sounds in the scene
  40957. * By default, this is the position of the first active camera
  40958. */
  40959. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40960. /**
  40961. * Creates a new instance of the component for the given scene
  40962. * @param scene Defines the scene to register the component in
  40963. */
  40964. constructor(scene: Scene);
  40965. /**
  40966. * Registers the component in a given scene
  40967. */
  40968. register(): void;
  40969. /**
  40970. * Rebuilds the elements related to this component in case of
  40971. * context lost for instance.
  40972. */
  40973. rebuild(): void;
  40974. /**
  40975. * Serializes the component data to the specified json object
  40976. * @param serializationObject The object to serialize to
  40977. */
  40978. serialize(serializationObject: any): void;
  40979. /**
  40980. * Adds all the elements from the container to the scene
  40981. * @param container the container holding the elements
  40982. */
  40983. addFromContainer(container: AbstractScene): void;
  40984. /**
  40985. * Removes all the elements in the container from the scene
  40986. * @param container contains the elements to remove
  40987. * @param dispose if the removed element should be disposed (default: false)
  40988. */
  40989. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40990. /**
  40991. * Disposes the component and the associated ressources.
  40992. */
  40993. dispose(): void;
  40994. /**
  40995. * Disables audio in the associated scene.
  40996. */
  40997. disableAudio(): void;
  40998. /**
  40999. * Enables audio in the associated scene.
  41000. */
  41001. enableAudio(): void;
  41002. /**
  41003. * Switch audio to headphone output.
  41004. */
  41005. switchAudioModeForHeadphones(): void;
  41006. /**
  41007. * Switch audio to normal speakers.
  41008. */
  41009. switchAudioModeForNormalSpeakers(): void;
  41010. private _cachedCameraDirection;
  41011. private _cachedCameraPosition;
  41012. private _lastCheck;
  41013. private _afterRender;
  41014. }
  41015. }
  41016. declare module BABYLON {
  41017. /**
  41018. * Wraps one or more Sound objects and selects one with random weight for playback.
  41019. */
  41020. export class WeightedSound {
  41021. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41022. loop: boolean;
  41023. private _coneInnerAngle;
  41024. private _coneOuterAngle;
  41025. private _volume;
  41026. /** A Sound is currently playing. */
  41027. isPlaying: boolean;
  41028. /** A Sound is currently paused. */
  41029. isPaused: boolean;
  41030. private _sounds;
  41031. private _weights;
  41032. private _currentIndex?;
  41033. /**
  41034. * Creates a new WeightedSound from the list of sounds given.
  41035. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41036. * @param sounds Array of Sounds that will be selected from.
  41037. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41038. */
  41039. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41040. /**
  41041. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41042. */
  41043. get directionalConeInnerAngle(): number;
  41044. /**
  41045. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41046. */
  41047. set directionalConeInnerAngle(value: number);
  41048. /**
  41049. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41050. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41051. */
  41052. get directionalConeOuterAngle(): number;
  41053. /**
  41054. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41055. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41056. */
  41057. set directionalConeOuterAngle(value: number);
  41058. /**
  41059. * Playback volume.
  41060. */
  41061. get volume(): number;
  41062. /**
  41063. * Playback volume.
  41064. */
  41065. set volume(value: number);
  41066. private _onended;
  41067. /**
  41068. * Suspend playback
  41069. */
  41070. pause(): void;
  41071. /**
  41072. * Stop playback
  41073. */
  41074. stop(): void;
  41075. /**
  41076. * Start playback.
  41077. * @param startOffset Position the clip head at a specific time in seconds.
  41078. */
  41079. play(startOffset?: number): void;
  41080. }
  41081. }
  41082. declare module BABYLON {
  41083. /**
  41084. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41086. */
  41087. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41088. /**
  41089. * Gets the name of the behavior.
  41090. */
  41091. get name(): string;
  41092. /**
  41093. * The easing function used by animations
  41094. */
  41095. static EasingFunction: BackEase;
  41096. /**
  41097. * The easing mode used by animations
  41098. */
  41099. static EasingMode: number;
  41100. /**
  41101. * The duration of the animation, in milliseconds
  41102. */
  41103. transitionDuration: number;
  41104. /**
  41105. * Length of the distance animated by the transition when lower radius is reached
  41106. */
  41107. lowerRadiusTransitionRange: number;
  41108. /**
  41109. * Length of the distance animated by the transition when upper radius is reached
  41110. */
  41111. upperRadiusTransitionRange: number;
  41112. private _autoTransitionRange;
  41113. /**
  41114. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41115. */
  41116. get autoTransitionRange(): boolean;
  41117. /**
  41118. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41119. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41120. */
  41121. set autoTransitionRange(value: boolean);
  41122. private _attachedCamera;
  41123. private _onAfterCheckInputsObserver;
  41124. private _onMeshTargetChangedObserver;
  41125. /**
  41126. * Initializes the behavior.
  41127. */
  41128. init(): void;
  41129. /**
  41130. * Attaches the behavior to its arc rotate camera.
  41131. * @param camera Defines the camera to attach the behavior to
  41132. */
  41133. attach(camera: ArcRotateCamera): void;
  41134. /**
  41135. * Detaches the behavior from its current arc rotate camera.
  41136. */
  41137. detach(): void;
  41138. private _radiusIsAnimating;
  41139. private _radiusBounceTransition;
  41140. private _animatables;
  41141. private _cachedWheelPrecision;
  41142. /**
  41143. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41144. * @param radiusLimit The limit to check against.
  41145. * @return Bool to indicate if at limit.
  41146. */
  41147. private _isRadiusAtLimit;
  41148. /**
  41149. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41150. * @param radiusDelta The delta by which to animate to. Can be negative.
  41151. */
  41152. private _applyBoundRadiusAnimation;
  41153. /**
  41154. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41155. */
  41156. protected _clearAnimationLocks(): void;
  41157. /**
  41158. * Stops and removes all animations that have been applied to the camera
  41159. */
  41160. stopAllAnimations(): void;
  41161. }
  41162. }
  41163. declare module BABYLON {
  41164. /**
  41165. * 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.
  41166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41167. */
  41168. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41169. /**
  41170. * Gets the name of the behavior.
  41171. */
  41172. get name(): string;
  41173. private _mode;
  41174. private _radiusScale;
  41175. private _positionScale;
  41176. private _defaultElevation;
  41177. private _elevationReturnTime;
  41178. private _elevationReturnWaitTime;
  41179. private _zoomStopsAnimation;
  41180. private _framingTime;
  41181. /**
  41182. * The easing function used by animations
  41183. */
  41184. static EasingFunction: ExponentialEase;
  41185. /**
  41186. * The easing mode used by animations
  41187. */
  41188. static EasingMode: number;
  41189. /**
  41190. * Sets the current mode used by the behavior
  41191. */
  41192. set mode(mode: number);
  41193. /**
  41194. * Gets current mode used by the behavior.
  41195. */
  41196. get mode(): number;
  41197. /**
  41198. * Sets the scale applied to the radius (1 by default)
  41199. */
  41200. set radiusScale(radius: number);
  41201. /**
  41202. * Gets the scale applied to the radius
  41203. */
  41204. get radiusScale(): number;
  41205. /**
  41206. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41207. */
  41208. set positionScale(scale: number);
  41209. /**
  41210. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41211. */
  41212. get positionScale(): number;
  41213. /**
  41214. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41215. * behaviour is triggered, in radians.
  41216. */
  41217. set defaultElevation(elevation: number);
  41218. /**
  41219. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41220. * behaviour is triggered, in radians.
  41221. */
  41222. get defaultElevation(): number;
  41223. /**
  41224. * Sets the time (in milliseconds) taken to return to the default beta position.
  41225. * Negative value indicates camera should not return to default.
  41226. */
  41227. set elevationReturnTime(speed: number);
  41228. /**
  41229. * Gets the time (in milliseconds) taken to return to the default beta position.
  41230. * Negative value indicates camera should not return to default.
  41231. */
  41232. get elevationReturnTime(): number;
  41233. /**
  41234. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41235. */
  41236. set elevationReturnWaitTime(time: number);
  41237. /**
  41238. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41239. */
  41240. get elevationReturnWaitTime(): number;
  41241. /**
  41242. * Sets the flag that indicates if user zooming should stop animation.
  41243. */
  41244. set zoomStopsAnimation(flag: boolean);
  41245. /**
  41246. * Gets the flag that indicates if user zooming should stop animation.
  41247. */
  41248. get zoomStopsAnimation(): boolean;
  41249. /**
  41250. * Sets the transition time when framing the mesh, in milliseconds
  41251. */
  41252. set framingTime(time: number);
  41253. /**
  41254. * Gets the transition time when framing the mesh, in milliseconds
  41255. */
  41256. get framingTime(): number;
  41257. /**
  41258. * Define if the behavior should automatically change the configured
  41259. * camera limits and sensibilities.
  41260. */
  41261. autoCorrectCameraLimitsAndSensibility: boolean;
  41262. private _onPrePointerObservableObserver;
  41263. private _onAfterCheckInputsObserver;
  41264. private _onMeshTargetChangedObserver;
  41265. private _attachedCamera;
  41266. private _isPointerDown;
  41267. private _lastInteractionTime;
  41268. /**
  41269. * Initializes the behavior.
  41270. */
  41271. init(): void;
  41272. /**
  41273. * Attaches the behavior to its arc rotate camera.
  41274. * @param camera Defines the camera to attach the behavior to
  41275. */
  41276. attach(camera: ArcRotateCamera): void;
  41277. /**
  41278. * Detaches the behavior from its current arc rotate camera.
  41279. */
  41280. detach(): void;
  41281. private _animatables;
  41282. private _betaIsAnimating;
  41283. private _betaTransition;
  41284. private _radiusTransition;
  41285. private _vectorTransition;
  41286. /**
  41287. * Targets the given mesh and updates zoom level accordingly.
  41288. * @param mesh The mesh to target.
  41289. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41290. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41291. */
  41292. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41293. /**
  41294. * Targets the given mesh with its children and updates zoom level accordingly.
  41295. * @param mesh The mesh to target.
  41296. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41297. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41298. */
  41299. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41300. /**
  41301. * Targets the given meshes with their children and updates zoom level accordingly.
  41302. * @param meshes The mesh to target.
  41303. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41304. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41305. */
  41306. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41307. /**
  41308. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41309. * @param minimumWorld Determines the smaller position of the bounding box extend
  41310. * @param maximumWorld Determines the bigger position of the bounding box extend
  41311. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41312. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41313. */
  41314. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41315. /**
  41316. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41317. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41318. * frustum width.
  41319. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41320. * to fully enclose the mesh in the viewing frustum.
  41321. */
  41322. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41323. /**
  41324. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41325. * is automatically returned to its default position (expected to be above ground plane).
  41326. */
  41327. private _maintainCameraAboveGround;
  41328. /**
  41329. * Returns the frustum slope based on the canvas ratio and camera FOV
  41330. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41331. */
  41332. private _getFrustumSlope;
  41333. /**
  41334. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41335. */
  41336. private _clearAnimationLocks;
  41337. /**
  41338. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41339. */
  41340. private _applyUserInteraction;
  41341. /**
  41342. * Stops and removes all animations that have been applied to the camera
  41343. */
  41344. stopAllAnimations(): void;
  41345. /**
  41346. * Gets a value indicating if the user is moving the camera
  41347. */
  41348. get isUserIsMoving(): boolean;
  41349. /**
  41350. * The camera can move all the way towards the mesh.
  41351. */
  41352. static IgnoreBoundsSizeMode: number;
  41353. /**
  41354. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41355. */
  41356. static FitFrustumSidesMode: number;
  41357. }
  41358. }
  41359. declare module BABYLON {
  41360. /**
  41361. * Base class for Camera Pointer Inputs.
  41362. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41363. * for example usage.
  41364. */
  41365. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41366. /**
  41367. * Defines the camera the input is attached to.
  41368. */
  41369. abstract camera: Camera;
  41370. /**
  41371. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41372. */
  41373. protected _altKey: boolean;
  41374. protected _ctrlKey: boolean;
  41375. protected _metaKey: boolean;
  41376. protected _shiftKey: boolean;
  41377. /**
  41378. * Which mouse buttons were pressed at time of last mouse event.
  41379. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41380. */
  41381. protected _buttonsPressed: number;
  41382. /**
  41383. * Defines the buttons associated with the input to handle camera move.
  41384. */
  41385. buttons: number[];
  41386. /**
  41387. * Attach the input controls to a specific dom element to get the input from.
  41388. * @param element Defines the element the controls should be listened from
  41389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41390. */
  41391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41392. /**
  41393. * Detach the current controls from the specified dom element.
  41394. * @param element Defines the element to stop listening the inputs from
  41395. */
  41396. detachControl(element: Nullable<HTMLElement>): void;
  41397. /**
  41398. * Gets the class name of the current input.
  41399. * @returns the class name
  41400. */
  41401. getClassName(): string;
  41402. /**
  41403. * Get the friendly name associated with the input class.
  41404. * @returns the input friendly name
  41405. */
  41406. getSimpleName(): string;
  41407. /**
  41408. * Called on pointer POINTERDOUBLETAP event.
  41409. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41410. */
  41411. protected onDoubleTap(type: string): void;
  41412. /**
  41413. * Called on pointer POINTERMOVE event if only a single touch is active.
  41414. * Override this method to provide functionality.
  41415. */
  41416. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41417. /**
  41418. * Called on pointer POINTERMOVE event if multiple touches are active.
  41419. * Override this method to provide functionality.
  41420. */
  41421. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41422. /**
  41423. * Called on JS contextmenu event.
  41424. * Override this method to provide functionality.
  41425. */
  41426. protected onContextMenu(evt: PointerEvent): void;
  41427. /**
  41428. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41429. * press.
  41430. * Override this method to provide functionality.
  41431. */
  41432. protected onButtonDown(evt: PointerEvent): void;
  41433. /**
  41434. * Called each time a new POINTERUP event occurs. Ie, for each button
  41435. * release.
  41436. * Override this method to provide functionality.
  41437. */
  41438. protected onButtonUp(evt: PointerEvent): void;
  41439. /**
  41440. * Called when window becomes inactive.
  41441. * Override this method to provide functionality.
  41442. */
  41443. protected onLostFocus(): void;
  41444. private _pointerInput;
  41445. private _observer;
  41446. private _onLostFocus;
  41447. private pointA;
  41448. private pointB;
  41449. }
  41450. }
  41451. declare module BABYLON {
  41452. /**
  41453. * Manage the pointers inputs to control an arc rotate camera.
  41454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41455. */
  41456. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41457. /**
  41458. * Defines the camera the input is attached to.
  41459. */
  41460. camera: ArcRotateCamera;
  41461. /**
  41462. * Gets the class name of the current input.
  41463. * @returns the class name
  41464. */
  41465. getClassName(): string;
  41466. /**
  41467. * Defines the buttons associated with the input to handle camera move.
  41468. */
  41469. buttons: number[];
  41470. /**
  41471. * Defines the pointer angular sensibility along the X axis or how fast is
  41472. * the camera rotating.
  41473. */
  41474. angularSensibilityX: number;
  41475. /**
  41476. * Defines the pointer angular sensibility along the Y axis or how fast is
  41477. * the camera rotating.
  41478. */
  41479. angularSensibilityY: number;
  41480. /**
  41481. * Defines the pointer pinch precision or how fast is the camera zooming.
  41482. */
  41483. pinchPrecision: number;
  41484. /**
  41485. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41486. * from 0.
  41487. * It defines the percentage of current camera.radius to use as delta when
  41488. * pinch zoom is used.
  41489. */
  41490. pinchDeltaPercentage: number;
  41491. /**
  41492. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41493. * that any object in the plane at the camera's target point will scale
  41494. * perfectly with finger motion.
  41495. * Overrides pinchDeltaPercentage and pinchPrecision.
  41496. */
  41497. useNaturalPinchZoom: boolean;
  41498. /**
  41499. * Defines the pointer panning sensibility or how fast is the camera moving.
  41500. */
  41501. panningSensibility: number;
  41502. /**
  41503. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41504. */
  41505. multiTouchPanning: boolean;
  41506. /**
  41507. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41508. * zoom (pinch) through multitouch.
  41509. */
  41510. multiTouchPanAndZoom: boolean;
  41511. /**
  41512. * Revers pinch action direction.
  41513. */
  41514. pinchInwards: boolean;
  41515. private _isPanClick;
  41516. private _twoFingerActivityCount;
  41517. private _isPinching;
  41518. /**
  41519. * Called on pointer POINTERMOVE event if only a single touch is active.
  41520. */
  41521. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41522. /**
  41523. * Called on pointer POINTERDOUBLETAP event.
  41524. */
  41525. protected onDoubleTap(type: string): void;
  41526. /**
  41527. * Called on pointer POINTERMOVE event if multiple touches are active.
  41528. */
  41529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41530. /**
  41531. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41532. * press.
  41533. */
  41534. protected onButtonDown(evt: PointerEvent): void;
  41535. /**
  41536. * Called each time a new POINTERUP event occurs. Ie, for each button
  41537. * release.
  41538. */
  41539. protected onButtonUp(evt: PointerEvent): void;
  41540. /**
  41541. * Called when window becomes inactive.
  41542. */
  41543. protected onLostFocus(): void;
  41544. }
  41545. }
  41546. declare module BABYLON {
  41547. /**
  41548. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41550. */
  41551. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41552. /**
  41553. * Defines the camera the input is attached to.
  41554. */
  41555. camera: ArcRotateCamera;
  41556. /**
  41557. * Defines the list of key codes associated with the up action (increase alpha)
  41558. */
  41559. keysUp: number[];
  41560. /**
  41561. * Defines the list of key codes associated with the down action (decrease alpha)
  41562. */
  41563. keysDown: number[];
  41564. /**
  41565. * Defines the list of key codes associated with the left action (increase beta)
  41566. */
  41567. keysLeft: number[];
  41568. /**
  41569. * Defines the list of key codes associated with the right action (decrease beta)
  41570. */
  41571. keysRight: number[];
  41572. /**
  41573. * Defines the list of key codes associated with the reset action.
  41574. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41575. */
  41576. keysReset: number[];
  41577. /**
  41578. * Defines the panning sensibility of the inputs.
  41579. * (How fast is the camera panning)
  41580. */
  41581. panningSensibility: number;
  41582. /**
  41583. * Defines the zooming sensibility of the inputs.
  41584. * (How fast is the camera zooming)
  41585. */
  41586. zoomingSensibility: number;
  41587. /**
  41588. * Defines whether maintaining the alt key down switch the movement mode from
  41589. * orientation to zoom.
  41590. */
  41591. useAltToZoom: boolean;
  41592. /**
  41593. * Rotation speed of the camera
  41594. */
  41595. angularSpeed: number;
  41596. private _keys;
  41597. private _ctrlPressed;
  41598. private _altPressed;
  41599. private _onCanvasBlurObserver;
  41600. private _onKeyboardObserver;
  41601. private _engine;
  41602. private _scene;
  41603. /**
  41604. * Attach the input controls to a specific dom element to get the input from.
  41605. * @param element Defines the element the controls should be listened from
  41606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41607. */
  41608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41609. /**
  41610. * Detach the current controls from the specified dom element.
  41611. * @param element Defines the element to stop listening the inputs from
  41612. */
  41613. detachControl(element: Nullable<HTMLElement>): void;
  41614. /**
  41615. * Update the current camera state depending on the inputs that have been used this frame.
  41616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41617. */
  41618. checkInputs(): void;
  41619. /**
  41620. * Gets the class name of the current intput.
  41621. * @returns the class name
  41622. */
  41623. getClassName(): string;
  41624. /**
  41625. * Get the friendly name associated with the input class.
  41626. * @returns the input friendly name
  41627. */
  41628. getSimpleName(): string;
  41629. }
  41630. }
  41631. declare module BABYLON {
  41632. /**
  41633. * Manage the mouse wheel inputs to control an arc rotate camera.
  41634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41635. */
  41636. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41637. /**
  41638. * Defines the camera the input is attached to.
  41639. */
  41640. camera: ArcRotateCamera;
  41641. /**
  41642. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41643. */
  41644. wheelPrecision: number;
  41645. /**
  41646. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41647. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41648. */
  41649. wheelDeltaPercentage: number;
  41650. private _wheel;
  41651. private _observer;
  41652. private computeDeltaFromMouseWheelLegacyEvent;
  41653. /**
  41654. * Attach the input controls to a specific dom element to get the input from.
  41655. * @param element Defines the element the controls should be listened from
  41656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41657. */
  41658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41659. /**
  41660. * Detach the current controls from the specified dom element.
  41661. * @param element Defines the element to stop listening the inputs from
  41662. */
  41663. detachControl(element: Nullable<HTMLElement>): void;
  41664. /**
  41665. * Gets the class name of the current intput.
  41666. * @returns the class name
  41667. */
  41668. getClassName(): string;
  41669. /**
  41670. * Get the friendly name associated with the input class.
  41671. * @returns the input friendly name
  41672. */
  41673. getSimpleName(): string;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Default Inputs manager for the ArcRotateCamera.
  41679. * It groups all the default supported inputs for ease of use.
  41680. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41681. */
  41682. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41683. /**
  41684. * Instantiates a new ArcRotateCameraInputsManager.
  41685. * @param camera Defines the camera the inputs belong to
  41686. */
  41687. constructor(camera: ArcRotateCamera);
  41688. /**
  41689. * Add mouse wheel input support to the input manager.
  41690. * @returns the current input manager
  41691. */
  41692. addMouseWheel(): ArcRotateCameraInputsManager;
  41693. /**
  41694. * Add pointers input support to the input manager.
  41695. * @returns the current input manager
  41696. */
  41697. addPointers(): ArcRotateCameraInputsManager;
  41698. /**
  41699. * Add keyboard input support to the input manager.
  41700. * @returns the current input manager
  41701. */
  41702. addKeyboard(): ArcRotateCameraInputsManager;
  41703. }
  41704. }
  41705. declare module BABYLON {
  41706. /**
  41707. * This represents an orbital type of camera.
  41708. *
  41709. * 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.
  41710. * 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.
  41711. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41712. */
  41713. export class ArcRotateCamera extends TargetCamera {
  41714. /**
  41715. * Defines the rotation angle of the camera along the longitudinal axis.
  41716. */
  41717. alpha: number;
  41718. /**
  41719. * Defines the rotation angle of the camera along the latitudinal axis.
  41720. */
  41721. beta: number;
  41722. /**
  41723. * Defines the radius of the camera from it s target point.
  41724. */
  41725. radius: number;
  41726. protected _target: Vector3;
  41727. protected _targetHost: Nullable<AbstractMesh>;
  41728. /**
  41729. * Defines the target point of the camera.
  41730. * The camera looks towards it form the radius distance.
  41731. */
  41732. get target(): Vector3;
  41733. set target(value: Vector3);
  41734. /**
  41735. * Define the current local position of the camera in the scene
  41736. */
  41737. get position(): Vector3;
  41738. set position(newPosition: Vector3);
  41739. protected _upVector: Vector3;
  41740. protected _upToYMatrix: Matrix;
  41741. protected _YToUpMatrix: Matrix;
  41742. /**
  41743. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41744. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41745. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41746. */
  41747. set upVector(vec: Vector3);
  41748. get upVector(): Vector3;
  41749. /**
  41750. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41751. */
  41752. setMatUp(): void;
  41753. /**
  41754. * Current inertia value on the longitudinal axis.
  41755. * The bigger this number the longer it will take for the camera to stop.
  41756. */
  41757. inertialAlphaOffset: number;
  41758. /**
  41759. * Current inertia value on the latitudinal axis.
  41760. * The bigger this number the longer it will take for the camera to stop.
  41761. */
  41762. inertialBetaOffset: number;
  41763. /**
  41764. * Current inertia value on the radius axis.
  41765. * The bigger this number the longer it will take for the camera to stop.
  41766. */
  41767. inertialRadiusOffset: number;
  41768. /**
  41769. * Minimum allowed angle on the longitudinal axis.
  41770. * This can help limiting how the Camera is able to move in the scene.
  41771. */
  41772. lowerAlphaLimit: Nullable<number>;
  41773. /**
  41774. * Maximum allowed angle on the longitudinal axis.
  41775. * This can help limiting how the Camera is able to move in the scene.
  41776. */
  41777. upperAlphaLimit: Nullable<number>;
  41778. /**
  41779. * Minimum allowed angle on the latitudinal axis.
  41780. * This can help limiting how the Camera is able to move in the scene.
  41781. */
  41782. lowerBetaLimit: number;
  41783. /**
  41784. * Maximum allowed angle on the latitudinal axis.
  41785. * This can help limiting how the Camera is able to move in the scene.
  41786. */
  41787. upperBetaLimit: number;
  41788. /**
  41789. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41790. * This can help limiting how the Camera is able to move in the scene.
  41791. */
  41792. lowerRadiusLimit: Nullable<number>;
  41793. /**
  41794. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41795. * This can help limiting how the Camera is able to move in the scene.
  41796. */
  41797. upperRadiusLimit: Nullable<number>;
  41798. /**
  41799. * Defines the current inertia value used during panning of the camera along the X axis.
  41800. */
  41801. inertialPanningX: number;
  41802. /**
  41803. * Defines the current inertia value used during panning of the camera along the Y axis.
  41804. */
  41805. inertialPanningY: number;
  41806. /**
  41807. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41808. * Basically if your fingers moves away from more than this distance you will be considered
  41809. * in pinch mode.
  41810. */
  41811. pinchToPanMaxDistance: number;
  41812. /**
  41813. * Defines the maximum distance the camera can pan.
  41814. * This could help keeping the cammera always in your scene.
  41815. */
  41816. panningDistanceLimit: Nullable<number>;
  41817. /**
  41818. * Defines the target of the camera before paning.
  41819. */
  41820. panningOriginTarget: Vector3;
  41821. /**
  41822. * Defines the value of the inertia used during panning.
  41823. * 0 would mean stop inertia and one would mean no decelleration at all.
  41824. */
  41825. panningInertia: number;
  41826. /**
  41827. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41828. */
  41829. get angularSensibilityX(): number;
  41830. set angularSensibilityX(value: number);
  41831. /**
  41832. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41833. */
  41834. get angularSensibilityY(): number;
  41835. set angularSensibilityY(value: number);
  41836. /**
  41837. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41838. */
  41839. get pinchPrecision(): number;
  41840. set pinchPrecision(value: number);
  41841. /**
  41842. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41843. * It will be used instead of pinchDeltaPrecision if different from 0.
  41844. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41845. */
  41846. get pinchDeltaPercentage(): number;
  41847. set pinchDeltaPercentage(value: number);
  41848. /**
  41849. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41850. * and pinch delta percentage.
  41851. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41852. * that any object in the plane at the camera's target point will scale
  41853. * perfectly with finger motion.
  41854. */
  41855. get useNaturalPinchZoom(): boolean;
  41856. set useNaturalPinchZoom(value: boolean);
  41857. /**
  41858. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41859. */
  41860. get panningSensibility(): number;
  41861. set panningSensibility(value: number);
  41862. /**
  41863. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41864. */
  41865. get keysUp(): number[];
  41866. set keysUp(value: number[]);
  41867. /**
  41868. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41869. */
  41870. get keysDown(): number[];
  41871. set keysDown(value: number[]);
  41872. /**
  41873. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41874. */
  41875. get keysLeft(): number[];
  41876. set keysLeft(value: number[]);
  41877. /**
  41878. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41879. */
  41880. get keysRight(): number[];
  41881. set keysRight(value: number[]);
  41882. /**
  41883. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41884. */
  41885. get wheelPrecision(): number;
  41886. set wheelPrecision(value: number);
  41887. /**
  41888. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41889. * It will be used instead of pinchDeltaPrecision if different from 0.
  41890. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41891. */
  41892. get wheelDeltaPercentage(): number;
  41893. set wheelDeltaPercentage(value: number);
  41894. /**
  41895. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41896. */
  41897. zoomOnFactor: number;
  41898. /**
  41899. * Defines a screen offset for the camera position.
  41900. */
  41901. targetScreenOffset: Vector2;
  41902. /**
  41903. * Allows the camera to be completely reversed.
  41904. * If false the camera can not arrive upside down.
  41905. */
  41906. allowUpsideDown: boolean;
  41907. /**
  41908. * Define if double tap/click is used to restore the previously saved state of the camera.
  41909. */
  41910. useInputToRestoreState: boolean;
  41911. /** @hidden */
  41912. _viewMatrix: Matrix;
  41913. /** @hidden */
  41914. _useCtrlForPanning: boolean;
  41915. /** @hidden */
  41916. _panningMouseButton: number;
  41917. /**
  41918. * Defines the input associated to the camera.
  41919. */
  41920. inputs: ArcRotateCameraInputsManager;
  41921. /** @hidden */
  41922. _reset: () => void;
  41923. /**
  41924. * Defines the allowed panning axis.
  41925. */
  41926. panningAxis: Vector3;
  41927. protected _localDirection: Vector3;
  41928. protected _transformedDirection: Vector3;
  41929. private _bouncingBehavior;
  41930. /**
  41931. * Gets the bouncing behavior of the camera if it has been enabled.
  41932. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41933. */
  41934. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41935. /**
  41936. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41937. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41938. */
  41939. get useBouncingBehavior(): boolean;
  41940. set useBouncingBehavior(value: boolean);
  41941. private _framingBehavior;
  41942. /**
  41943. * Gets the framing behavior of the camera if it has been enabled.
  41944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41945. */
  41946. get framingBehavior(): Nullable<FramingBehavior>;
  41947. /**
  41948. * Defines if the framing behavior of the camera is enabled on the camera.
  41949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41950. */
  41951. get useFramingBehavior(): boolean;
  41952. set useFramingBehavior(value: boolean);
  41953. private _autoRotationBehavior;
  41954. /**
  41955. * Gets the auto rotation behavior of the camera if it has been enabled.
  41956. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41957. */
  41958. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41959. /**
  41960. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41961. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41962. */
  41963. get useAutoRotationBehavior(): boolean;
  41964. set useAutoRotationBehavior(value: boolean);
  41965. /**
  41966. * Observable triggered when the mesh target has been changed on the camera.
  41967. */
  41968. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41969. /**
  41970. * Event raised when the camera is colliding with a mesh.
  41971. */
  41972. onCollide: (collidedMesh: AbstractMesh) => void;
  41973. /**
  41974. * Defines whether the camera should check collision with the objects oh the scene.
  41975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41976. */
  41977. checkCollisions: boolean;
  41978. /**
  41979. * Defines the collision radius of the camera.
  41980. * This simulates a sphere around the camera.
  41981. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41982. */
  41983. collisionRadius: Vector3;
  41984. protected _collider: Collider;
  41985. protected _previousPosition: Vector3;
  41986. protected _collisionVelocity: Vector3;
  41987. protected _newPosition: Vector3;
  41988. protected _previousAlpha: number;
  41989. protected _previousBeta: number;
  41990. protected _previousRadius: number;
  41991. protected _collisionTriggered: boolean;
  41992. protected _targetBoundingCenter: Nullable<Vector3>;
  41993. private _computationVector;
  41994. /**
  41995. * Instantiates a new ArcRotateCamera in a given scene
  41996. * @param name Defines the name of the camera
  41997. * @param alpha Defines the camera rotation along the logitudinal axis
  41998. * @param beta Defines the camera rotation along the latitudinal axis
  41999. * @param radius Defines the camera distance from its target
  42000. * @param target Defines the camera target
  42001. * @param scene Defines the scene the camera belongs to
  42002. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42003. */
  42004. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42005. /** @hidden */
  42006. _initCache(): void;
  42007. /** @hidden */
  42008. _updateCache(ignoreParentClass?: boolean): void;
  42009. protected _getTargetPosition(): Vector3;
  42010. private _storedAlpha;
  42011. private _storedBeta;
  42012. private _storedRadius;
  42013. private _storedTarget;
  42014. private _storedTargetScreenOffset;
  42015. /**
  42016. * Stores the current state of the camera (alpha, beta, radius and target)
  42017. * @returns the camera itself
  42018. */
  42019. storeState(): Camera;
  42020. /**
  42021. * @hidden
  42022. * Restored camera state. You must call storeState() first
  42023. */
  42024. _restoreStateValues(): boolean;
  42025. /** @hidden */
  42026. _isSynchronizedViewMatrix(): boolean;
  42027. /**
  42028. * Attached controls to the current camera.
  42029. * @param element Defines the element the controls should be listened from
  42030. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42031. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42032. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42033. */
  42034. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42035. /**
  42036. * Detach the current controls from the camera.
  42037. * The camera will stop reacting to inputs.
  42038. * @param element Defines the element to stop listening the inputs from
  42039. */
  42040. detachControl(element: HTMLElement): void;
  42041. /** @hidden */
  42042. _checkInputs(): void;
  42043. protected _checkLimits(): void;
  42044. /**
  42045. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42046. */
  42047. rebuildAnglesAndRadius(): void;
  42048. /**
  42049. * Use a position to define the current camera related information like alpha, beta and radius
  42050. * @param position Defines the position to set the camera at
  42051. */
  42052. setPosition(position: Vector3): void;
  42053. /**
  42054. * Defines the target the camera should look at.
  42055. * This will automatically adapt alpha beta and radius to fit within the new target.
  42056. * @param target Defines the new target as a Vector or a mesh
  42057. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42058. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42059. */
  42060. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42061. /** @hidden */
  42062. _getViewMatrix(): Matrix;
  42063. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42064. /**
  42065. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42066. * @param meshes Defines the mesh to zoom on
  42067. * @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)
  42068. */
  42069. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42070. /**
  42071. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42072. * The target will be changed but the radius
  42073. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42074. * @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)
  42075. */
  42076. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42077. min: Vector3;
  42078. max: Vector3;
  42079. distance: number;
  42080. }, doNotUpdateMaxZ?: boolean): void;
  42081. /**
  42082. * @override
  42083. * Override Camera.createRigCamera
  42084. */
  42085. createRigCamera(name: string, cameraIndex: number): Camera;
  42086. /**
  42087. * @hidden
  42088. * @override
  42089. * Override Camera._updateRigCameras
  42090. */
  42091. _updateRigCameras(): void;
  42092. /**
  42093. * Destroy the camera and release the current resources hold by it.
  42094. */
  42095. dispose(): void;
  42096. /**
  42097. * Gets the current object class name.
  42098. * @return the class name
  42099. */
  42100. getClassName(): string;
  42101. }
  42102. }
  42103. declare module BABYLON {
  42104. /**
  42105. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42107. */
  42108. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42109. /**
  42110. * Gets the name of the behavior.
  42111. */
  42112. get name(): string;
  42113. private _zoomStopsAnimation;
  42114. private _idleRotationSpeed;
  42115. private _idleRotationWaitTime;
  42116. private _idleRotationSpinupTime;
  42117. /**
  42118. * Sets the flag that indicates if user zooming should stop animation.
  42119. */
  42120. set zoomStopsAnimation(flag: boolean);
  42121. /**
  42122. * Gets the flag that indicates if user zooming should stop animation.
  42123. */
  42124. get zoomStopsAnimation(): boolean;
  42125. /**
  42126. * Sets the default speed at which the camera rotates around the model.
  42127. */
  42128. set idleRotationSpeed(speed: number);
  42129. /**
  42130. * Gets the default speed at which the camera rotates around the model.
  42131. */
  42132. get idleRotationSpeed(): number;
  42133. /**
  42134. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42135. */
  42136. set idleRotationWaitTime(time: number);
  42137. /**
  42138. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42139. */
  42140. get idleRotationWaitTime(): number;
  42141. /**
  42142. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42143. */
  42144. set idleRotationSpinupTime(time: number);
  42145. /**
  42146. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42147. */
  42148. get idleRotationSpinupTime(): number;
  42149. /**
  42150. * Gets a value indicating if the camera is currently rotating because of this behavior
  42151. */
  42152. get rotationInProgress(): boolean;
  42153. private _onPrePointerObservableObserver;
  42154. private _onAfterCheckInputsObserver;
  42155. private _attachedCamera;
  42156. private _isPointerDown;
  42157. private _lastFrameTime;
  42158. private _lastInteractionTime;
  42159. private _cameraRotationSpeed;
  42160. /**
  42161. * Initializes the behavior.
  42162. */
  42163. init(): void;
  42164. /**
  42165. * Attaches the behavior to its arc rotate camera.
  42166. * @param camera Defines the camera to attach the behavior to
  42167. */
  42168. attach(camera: ArcRotateCamera): void;
  42169. /**
  42170. * Detaches the behavior from its current arc rotate camera.
  42171. */
  42172. detach(): void;
  42173. /**
  42174. * Returns true if user is scrolling.
  42175. * @return true if user is scrolling.
  42176. */
  42177. private _userIsZooming;
  42178. private _lastFrameRadius;
  42179. private _shouldAnimationStopForInteraction;
  42180. /**
  42181. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42182. */
  42183. private _applyUserInteraction;
  42184. private _userIsMoving;
  42185. }
  42186. }
  42187. declare module BABYLON {
  42188. /**
  42189. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42190. */
  42191. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42192. private ui;
  42193. /**
  42194. * The name of the behavior
  42195. */
  42196. name: string;
  42197. /**
  42198. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42199. */
  42200. distanceAwayFromFace: number;
  42201. /**
  42202. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42203. */
  42204. distanceAwayFromBottomOfFace: number;
  42205. private _faceVectors;
  42206. private _target;
  42207. private _scene;
  42208. private _onRenderObserver;
  42209. private _tmpMatrix;
  42210. private _tmpVector;
  42211. /**
  42212. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42213. * @param ui The transform node that should be attched to the mesh
  42214. */
  42215. constructor(ui: TransformNode);
  42216. /**
  42217. * Initializes the behavior
  42218. */
  42219. init(): void;
  42220. private _closestFace;
  42221. private _zeroVector;
  42222. private _lookAtTmpMatrix;
  42223. private _lookAtToRef;
  42224. /**
  42225. * Attaches the AttachToBoxBehavior to the passed in mesh
  42226. * @param target The mesh that the specified node will be attached to
  42227. */
  42228. attach(target: Mesh): void;
  42229. /**
  42230. * Detaches the behavior from the mesh
  42231. */
  42232. detach(): void;
  42233. }
  42234. }
  42235. declare module BABYLON {
  42236. /**
  42237. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42238. */
  42239. export class FadeInOutBehavior implements Behavior<Mesh> {
  42240. /**
  42241. * Time in milliseconds to delay before fading in (Default: 0)
  42242. */
  42243. delay: number;
  42244. /**
  42245. * Time in milliseconds for the mesh to fade in (Default: 300)
  42246. */
  42247. fadeInTime: number;
  42248. private _millisecondsPerFrame;
  42249. private _hovered;
  42250. private _hoverValue;
  42251. private _ownerNode;
  42252. /**
  42253. * Instatiates the FadeInOutBehavior
  42254. */
  42255. constructor();
  42256. /**
  42257. * The name of the behavior
  42258. */
  42259. get name(): string;
  42260. /**
  42261. * Initializes the behavior
  42262. */
  42263. init(): void;
  42264. /**
  42265. * Attaches the fade behavior on the passed in mesh
  42266. * @param ownerNode The mesh that will be faded in/out once attached
  42267. */
  42268. attach(ownerNode: Mesh): void;
  42269. /**
  42270. * Detaches the behavior from the mesh
  42271. */
  42272. detach(): void;
  42273. /**
  42274. * Triggers the mesh to begin fading in or out
  42275. * @param value if the object should fade in or out (true to fade in)
  42276. */
  42277. fadeIn(value: boolean): void;
  42278. private _update;
  42279. private _setAllVisibility;
  42280. }
  42281. }
  42282. declare module BABYLON {
  42283. /**
  42284. * Class containing a set of static utilities functions for managing Pivots
  42285. * @hidden
  42286. */
  42287. export class PivotTools {
  42288. private static _PivotCached;
  42289. private static _OldPivotPoint;
  42290. private static _PivotTranslation;
  42291. private static _PivotTmpVector;
  42292. /** @hidden */
  42293. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42294. /** @hidden */
  42295. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42296. }
  42297. }
  42298. declare module BABYLON {
  42299. /**
  42300. * Class containing static functions to help procedurally build meshes
  42301. */
  42302. export class PlaneBuilder {
  42303. /**
  42304. * Creates a plane mesh
  42305. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42306. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42307. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42309. * * 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
  42310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42311. * @param name defines the name of the mesh
  42312. * @param options defines the options used to create the mesh
  42313. * @param scene defines the hosting scene
  42314. * @returns the plane mesh
  42315. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42316. */
  42317. static CreatePlane(name: string, options: {
  42318. size?: number;
  42319. width?: number;
  42320. height?: number;
  42321. sideOrientation?: number;
  42322. frontUVs?: Vector4;
  42323. backUVs?: Vector4;
  42324. updatable?: boolean;
  42325. sourcePlane?: Plane;
  42326. }, scene?: Nullable<Scene>): Mesh;
  42327. }
  42328. }
  42329. declare module BABYLON {
  42330. /**
  42331. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42332. */
  42333. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42334. private static _AnyMouseID;
  42335. /**
  42336. * Abstract mesh the behavior is set on
  42337. */
  42338. attachedNode: AbstractMesh;
  42339. private _dragPlane;
  42340. private _scene;
  42341. private _pointerObserver;
  42342. private _beforeRenderObserver;
  42343. private static _planeScene;
  42344. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42345. /**
  42346. * 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)
  42347. */
  42348. maxDragAngle: number;
  42349. /**
  42350. * @hidden
  42351. */
  42352. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42353. /**
  42354. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42355. */
  42356. currentDraggingPointerID: number;
  42357. /**
  42358. * The last position where the pointer hit the drag plane in world space
  42359. */
  42360. lastDragPosition: Vector3;
  42361. /**
  42362. * If the behavior is currently in a dragging state
  42363. */
  42364. dragging: boolean;
  42365. /**
  42366. * 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)
  42367. */
  42368. dragDeltaRatio: number;
  42369. /**
  42370. * If the drag plane orientation should be updated during the dragging (Default: true)
  42371. */
  42372. updateDragPlane: boolean;
  42373. private _debugMode;
  42374. private _moving;
  42375. /**
  42376. * Fires each time the attached mesh is dragged with the pointer
  42377. * * delta between last drag position and current drag position in world space
  42378. * * dragDistance along the drag axis
  42379. * * dragPlaneNormal normal of the current drag plane used during the drag
  42380. * * dragPlanePoint in world space where the drag intersects the drag plane
  42381. */
  42382. onDragObservable: Observable<{
  42383. delta: Vector3;
  42384. dragPlanePoint: Vector3;
  42385. dragPlaneNormal: Vector3;
  42386. dragDistance: number;
  42387. pointerId: number;
  42388. }>;
  42389. /**
  42390. * Fires each time a drag begins (eg. mouse down on mesh)
  42391. */
  42392. onDragStartObservable: Observable<{
  42393. dragPlanePoint: Vector3;
  42394. pointerId: number;
  42395. }>;
  42396. /**
  42397. * Fires each time a drag ends (eg. mouse release after drag)
  42398. */
  42399. onDragEndObservable: Observable<{
  42400. dragPlanePoint: Vector3;
  42401. pointerId: number;
  42402. }>;
  42403. /**
  42404. * If the attached mesh should be moved when dragged
  42405. */
  42406. moveAttached: boolean;
  42407. /**
  42408. * If the drag behavior will react to drag events (Default: true)
  42409. */
  42410. enabled: boolean;
  42411. /**
  42412. * If pointer events should start and release the drag (Default: true)
  42413. */
  42414. startAndReleaseDragOnPointerEvents: boolean;
  42415. /**
  42416. * If camera controls should be detached during the drag
  42417. */
  42418. detachCameraControls: boolean;
  42419. /**
  42420. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42421. */
  42422. useObjectOrientationForDragging: boolean;
  42423. private _options;
  42424. /**
  42425. * Gets the options used by the behavior
  42426. */
  42427. get options(): {
  42428. dragAxis?: Vector3;
  42429. dragPlaneNormal?: Vector3;
  42430. };
  42431. /**
  42432. * Sets the options used by the behavior
  42433. */
  42434. set options(options: {
  42435. dragAxis?: Vector3;
  42436. dragPlaneNormal?: Vector3;
  42437. });
  42438. /**
  42439. * Creates a pointer drag behavior that can be attached to a mesh
  42440. * @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)
  42441. */
  42442. constructor(options?: {
  42443. dragAxis?: Vector3;
  42444. dragPlaneNormal?: Vector3;
  42445. });
  42446. /**
  42447. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42448. */
  42449. validateDrag: (targetPosition: Vector3) => boolean;
  42450. /**
  42451. * The name of the behavior
  42452. */
  42453. get name(): string;
  42454. /**
  42455. * Initializes the behavior
  42456. */
  42457. init(): void;
  42458. private _tmpVector;
  42459. private _alternatePickedPoint;
  42460. private _worldDragAxis;
  42461. private _targetPosition;
  42462. private _attachedElement;
  42463. /**
  42464. * Attaches the drag behavior the passed in mesh
  42465. * @param ownerNode The mesh that will be dragged around once attached
  42466. * @param predicate Predicate to use for pick filtering
  42467. */
  42468. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42469. /**
  42470. * Force relase the drag action by code.
  42471. */
  42472. releaseDrag(): void;
  42473. private _startDragRay;
  42474. private _lastPointerRay;
  42475. /**
  42476. * Simulates the start of a pointer drag event on the behavior
  42477. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42478. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42479. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42480. */
  42481. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42482. private _startDrag;
  42483. private _dragDelta;
  42484. private _moveDrag;
  42485. private _pickWithRayOnDragPlane;
  42486. private _pointA;
  42487. private _pointB;
  42488. private _pointC;
  42489. private _lineA;
  42490. private _lineB;
  42491. private _localAxis;
  42492. private _lookAt;
  42493. private _updateDragPlanePosition;
  42494. /**
  42495. * Detaches the behavior from the mesh
  42496. */
  42497. detach(): void;
  42498. }
  42499. }
  42500. declare module BABYLON {
  42501. /**
  42502. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42503. */
  42504. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42505. private _dragBehaviorA;
  42506. private _dragBehaviorB;
  42507. private _startDistance;
  42508. private _initialScale;
  42509. private _targetScale;
  42510. private _ownerNode;
  42511. private _sceneRenderObserver;
  42512. /**
  42513. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42514. */
  42515. constructor();
  42516. /**
  42517. * The name of the behavior
  42518. */
  42519. get name(): string;
  42520. /**
  42521. * Initializes the behavior
  42522. */
  42523. init(): void;
  42524. private _getCurrentDistance;
  42525. /**
  42526. * Attaches the scale behavior the passed in mesh
  42527. * @param ownerNode The mesh that will be scaled around once attached
  42528. */
  42529. attach(ownerNode: Mesh): void;
  42530. /**
  42531. * Detaches the behavior from the mesh
  42532. */
  42533. detach(): void;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * 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
  42539. */
  42540. export class SixDofDragBehavior implements Behavior<Mesh> {
  42541. private static _virtualScene;
  42542. private _ownerNode;
  42543. private _sceneRenderObserver;
  42544. private _scene;
  42545. private _targetPosition;
  42546. private _virtualOriginMesh;
  42547. private _virtualDragMesh;
  42548. private _pointerObserver;
  42549. private _moving;
  42550. private _startingOrientation;
  42551. private _attachedElement;
  42552. /**
  42553. * 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)
  42554. */
  42555. private zDragFactor;
  42556. /**
  42557. * If the object should rotate to face the drag origin
  42558. */
  42559. rotateDraggedObject: boolean;
  42560. /**
  42561. * If the behavior is currently in a dragging state
  42562. */
  42563. dragging: boolean;
  42564. /**
  42565. * 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)
  42566. */
  42567. dragDeltaRatio: number;
  42568. /**
  42569. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42570. */
  42571. currentDraggingPointerID: number;
  42572. /**
  42573. * If camera controls should be detached during the drag
  42574. */
  42575. detachCameraControls: boolean;
  42576. /**
  42577. * Fires each time a drag starts
  42578. */
  42579. onDragStartObservable: Observable<{}>;
  42580. /**
  42581. * Fires each time a drag ends (eg. mouse release after drag)
  42582. */
  42583. onDragEndObservable: Observable<{}>;
  42584. /**
  42585. * 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
  42586. */
  42587. constructor();
  42588. /**
  42589. * The name of the behavior
  42590. */
  42591. get name(): string;
  42592. /**
  42593. * Initializes the behavior
  42594. */
  42595. init(): void;
  42596. /**
  42597. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42598. */
  42599. private get _pointerCamera();
  42600. /**
  42601. * Attaches the scale behavior the passed in mesh
  42602. * @param ownerNode The mesh that will be scaled around once attached
  42603. */
  42604. attach(ownerNode: Mesh): void;
  42605. /**
  42606. * Detaches the behavior from the mesh
  42607. */
  42608. detach(): void;
  42609. }
  42610. }
  42611. declare module BABYLON {
  42612. /**
  42613. * Class used to apply inverse kinematics to bones
  42614. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42615. */
  42616. export class BoneIKController {
  42617. private static _tmpVecs;
  42618. private static _tmpQuat;
  42619. private static _tmpMats;
  42620. /**
  42621. * Gets or sets the target mesh
  42622. */
  42623. targetMesh: AbstractMesh;
  42624. /** Gets or sets the mesh used as pole */
  42625. poleTargetMesh: AbstractMesh;
  42626. /**
  42627. * Gets or sets the bone used as pole
  42628. */
  42629. poleTargetBone: Nullable<Bone>;
  42630. /**
  42631. * Gets or sets the target position
  42632. */
  42633. targetPosition: Vector3;
  42634. /**
  42635. * Gets or sets the pole target position
  42636. */
  42637. poleTargetPosition: Vector3;
  42638. /**
  42639. * Gets or sets the pole target local offset
  42640. */
  42641. poleTargetLocalOffset: Vector3;
  42642. /**
  42643. * Gets or sets the pole angle
  42644. */
  42645. poleAngle: number;
  42646. /**
  42647. * Gets or sets the mesh associated with the controller
  42648. */
  42649. mesh: AbstractMesh;
  42650. /**
  42651. * 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)
  42652. */
  42653. slerpAmount: number;
  42654. private _bone1Quat;
  42655. private _bone1Mat;
  42656. private _bone2Ang;
  42657. private _bone1;
  42658. private _bone2;
  42659. private _bone1Length;
  42660. private _bone2Length;
  42661. private _maxAngle;
  42662. private _maxReach;
  42663. private _rightHandedSystem;
  42664. private _bendAxis;
  42665. private _slerping;
  42666. private _adjustRoll;
  42667. /**
  42668. * Gets or sets maximum allowed angle
  42669. */
  42670. get maxAngle(): number;
  42671. set maxAngle(value: number);
  42672. /**
  42673. * Creates a new BoneIKController
  42674. * @param mesh defines the mesh to control
  42675. * @param bone defines the bone to control
  42676. * @param options defines options to set up the controller
  42677. */
  42678. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42679. targetMesh?: AbstractMesh;
  42680. poleTargetMesh?: AbstractMesh;
  42681. poleTargetBone?: Bone;
  42682. poleTargetLocalOffset?: Vector3;
  42683. poleAngle?: number;
  42684. bendAxis?: Vector3;
  42685. maxAngle?: number;
  42686. slerpAmount?: number;
  42687. });
  42688. private _setMaxAngle;
  42689. /**
  42690. * Force the controller to update the bones
  42691. */
  42692. update(): void;
  42693. }
  42694. }
  42695. declare module BABYLON {
  42696. /**
  42697. * Class used to make a bone look toward a point in space
  42698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42699. */
  42700. export class BoneLookController {
  42701. private static _tmpVecs;
  42702. private static _tmpQuat;
  42703. private static _tmpMats;
  42704. /**
  42705. * The target Vector3 that the bone will look at
  42706. */
  42707. target: Vector3;
  42708. /**
  42709. * The mesh that the bone is attached to
  42710. */
  42711. mesh: AbstractMesh;
  42712. /**
  42713. * The bone that will be looking to the target
  42714. */
  42715. bone: Bone;
  42716. /**
  42717. * The up axis of the coordinate system that is used when the bone is rotated
  42718. */
  42719. upAxis: Vector3;
  42720. /**
  42721. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42722. */
  42723. upAxisSpace: Space;
  42724. /**
  42725. * Used to make an adjustment to the yaw of the bone
  42726. */
  42727. adjustYaw: number;
  42728. /**
  42729. * Used to make an adjustment to the pitch of the bone
  42730. */
  42731. adjustPitch: number;
  42732. /**
  42733. * Used to make an adjustment to the roll of the bone
  42734. */
  42735. adjustRoll: number;
  42736. /**
  42737. * 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)
  42738. */
  42739. slerpAmount: number;
  42740. private _minYaw;
  42741. private _maxYaw;
  42742. private _minPitch;
  42743. private _maxPitch;
  42744. private _minYawSin;
  42745. private _minYawCos;
  42746. private _maxYawSin;
  42747. private _maxYawCos;
  42748. private _midYawConstraint;
  42749. private _minPitchTan;
  42750. private _maxPitchTan;
  42751. private _boneQuat;
  42752. private _slerping;
  42753. private _transformYawPitch;
  42754. private _transformYawPitchInv;
  42755. private _firstFrameSkipped;
  42756. private _yawRange;
  42757. private _fowardAxis;
  42758. /**
  42759. * Gets or sets the minimum yaw angle that the bone can look to
  42760. */
  42761. get minYaw(): number;
  42762. set minYaw(value: number);
  42763. /**
  42764. * Gets or sets the maximum yaw angle that the bone can look to
  42765. */
  42766. get maxYaw(): number;
  42767. set maxYaw(value: number);
  42768. /**
  42769. * Gets or sets the minimum pitch angle that the bone can look to
  42770. */
  42771. get minPitch(): number;
  42772. set minPitch(value: number);
  42773. /**
  42774. * Gets or sets the maximum pitch angle that the bone can look to
  42775. */
  42776. get maxPitch(): number;
  42777. set maxPitch(value: number);
  42778. /**
  42779. * Create a BoneLookController
  42780. * @param mesh the mesh that the bone belongs to
  42781. * @param bone the bone that will be looking to the target
  42782. * @param target the target Vector3 to look at
  42783. * @param options optional settings:
  42784. * * maxYaw: the maximum angle the bone will yaw to
  42785. * * minYaw: the minimum angle the bone will yaw to
  42786. * * maxPitch: the maximum angle the bone will pitch to
  42787. * * minPitch: the minimum angle the bone will yaw to
  42788. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42789. * * upAxis: the up axis of the coordinate system
  42790. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42791. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42792. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42793. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42794. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42795. * * adjustRoll: used to make an adjustment to the roll of the bone
  42796. **/
  42797. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42798. maxYaw?: number;
  42799. minYaw?: number;
  42800. maxPitch?: number;
  42801. minPitch?: number;
  42802. slerpAmount?: number;
  42803. upAxis?: Vector3;
  42804. upAxisSpace?: Space;
  42805. yawAxis?: Vector3;
  42806. pitchAxis?: Vector3;
  42807. adjustYaw?: number;
  42808. adjustPitch?: number;
  42809. adjustRoll?: number;
  42810. });
  42811. /**
  42812. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42813. */
  42814. update(): void;
  42815. private _getAngleDiff;
  42816. private _getAngleBetween;
  42817. private _isAngleBetween;
  42818. }
  42819. }
  42820. declare module BABYLON {
  42821. /**
  42822. * Manage the gamepad inputs to control an arc rotate camera.
  42823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42824. */
  42825. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42826. /**
  42827. * Defines the camera the input is attached to.
  42828. */
  42829. camera: ArcRotateCamera;
  42830. /**
  42831. * Defines the gamepad the input is gathering event from.
  42832. */
  42833. gamepad: Nullable<Gamepad>;
  42834. /**
  42835. * Defines the gamepad rotation sensiblity.
  42836. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42837. */
  42838. gamepadRotationSensibility: number;
  42839. /**
  42840. * Defines the gamepad move sensiblity.
  42841. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42842. */
  42843. gamepadMoveSensibility: number;
  42844. private _yAxisScale;
  42845. /**
  42846. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42847. */
  42848. get invertYAxis(): boolean;
  42849. set invertYAxis(value: boolean);
  42850. private _onGamepadConnectedObserver;
  42851. private _onGamepadDisconnectedObserver;
  42852. /**
  42853. * Attach the input controls to a specific dom element to get the input from.
  42854. * @param element Defines the element the controls should be listened from
  42855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42856. */
  42857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42858. /**
  42859. * Detach the current controls from the specified dom element.
  42860. * @param element Defines the element to stop listening the inputs from
  42861. */
  42862. detachControl(element: Nullable<HTMLElement>): void;
  42863. /**
  42864. * Update the current camera state depending on the inputs that have been used this frame.
  42865. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42866. */
  42867. checkInputs(): void;
  42868. /**
  42869. * Gets the class name of the current intput.
  42870. * @returns the class name
  42871. */
  42872. getClassName(): string;
  42873. /**
  42874. * Get the friendly name associated with the input class.
  42875. * @returns the input friendly name
  42876. */
  42877. getSimpleName(): string;
  42878. }
  42879. }
  42880. declare module BABYLON {
  42881. interface ArcRotateCameraInputsManager {
  42882. /**
  42883. * Add orientation input support to the input manager.
  42884. * @returns the current input manager
  42885. */
  42886. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42887. }
  42888. /**
  42889. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42891. */
  42892. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42893. /**
  42894. * Defines the camera the input is attached to.
  42895. */
  42896. camera: ArcRotateCamera;
  42897. /**
  42898. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42899. */
  42900. alphaCorrection: number;
  42901. /**
  42902. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42903. */
  42904. gammaCorrection: number;
  42905. private _alpha;
  42906. private _gamma;
  42907. private _dirty;
  42908. private _deviceOrientationHandler;
  42909. /**
  42910. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42911. */
  42912. constructor();
  42913. /**
  42914. * Attach the input controls to a specific dom element to get the input from.
  42915. * @param element Defines the element the controls should be listened from
  42916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42917. */
  42918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42919. /** @hidden */
  42920. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42921. /**
  42922. * Update the current camera state depending on the inputs that have been used this frame.
  42923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42924. */
  42925. checkInputs(): void;
  42926. /**
  42927. * Detach the current controls from the specified dom element.
  42928. * @param element Defines the element to stop listening the inputs from
  42929. */
  42930. detachControl(element: Nullable<HTMLElement>): void;
  42931. /**
  42932. * Gets the class name of the current intput.
  42933. * @returns the class name
  42934. */
  42935. getClassName(): string;
  42936. /**
  42937. * Get the friendly name associated with the input class.
  42938. * @returns the input friendly name
  42939. */
  42940. getSimpleName(): string;
  42941. }
  42942. }
  42943. declare module BABYLON {
  42944. /**
  42945. * Listen to mouse events to control the camera.
  42946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42947. */
  42948. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42949. /**
  42950. * Defines the camera the input is attached to.
  42951. */
  42952. camera: FlyCamera;
  42953. /**
  42954. * Defines if touch is enabled. (Default is true.)
  42955. */
  42956. touchEnabled: boolean;
  42957. /**
  42958. * Defines the buttons associated with the input to handle camera rotation.
  42959. */
  42960. buttons: number[];
  42961. /**
  42962. * Assign buttons for Yaw control.
  42963. */
  42964. buttonsYaw: number[];
  42965. /**
  42966. * Assign buttons for Pitch control.
  42967. */
  42968. buttonsPitch: number[];
  42969. /**
  42970. * Assign buttons for Roll control.
  42971. */
  42972. buttonsRoll: number[];
  42973. /**
  42974. * Detect if any button is being pressed while mouse is moved.
  42975. * -1 = Mouse locked.
  42976. * 0 = Left button.
  42977. * 1 = Middle Button.
  42978. * 2 = Right Button.
  42979. */
  42980. activeButton: number;
  42981. /**
  42982. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42983. * Higher values reduce its sensitivity.
  42984. */
  42985. angularSensibility: number;
  42986. private _mousemoveCallback;
  42987. private _observer;
  42988. private _rollObserver;
  42989. private previousPosition;
  42990. private noPreventDefault;
  42991. private element;
  42992. /**
  42993. * Listen to mouse events to control the camera.
  42994. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42996. */
  42997. constructor(touchEnabled?: boolean);
  42998. /**
  42999. * Attach the mouse control to the HTML DOM element.
  43000. * @param element Defines the element that listens to the input events.
  43001. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43002. */
  43003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43004. /**
  43005. * Detach the current controls from the specified dom element.
  43006. * @param element Defines the element to stop listening the inputs from
  43007. */
  43008. detachControl(element: Nullable<HTMLElement>): void;
  43009. /**
  43010. * Gets the class name of the current input.
  43011. * @returns the class name.
  43012. */
  43013. getClassName(): string;
  43014. /**
  43015. * Get the friendly name associated with the input class.
  43016. * @returns the input's friendly name.
  43017. */
  43018. getSimpleName(): string;
  43019. private _pointerInput;
  43020. private _onMouseMove;
  43021. /**
  43022. * Rotate camera by mouse offset.
  43023. */
  43024. private rotateCamera;
  43025. }
  43026. }
  43027. declare module BABYLON {
  43028. /**
  43029. * Default Inputs manager for the FlyCamera.
  43030. * It groups all the default supported inputs for ease of use.
  43031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43032. */
  43033. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43034. /**
  43035. * Instantiates a new FlyCameraInputsManager.
  43036. * @param camera Defines the camera the inputs belong to.
  43037. */
  43038. constructor(camera: FlyCamera);
  43039. /**
  43040. * Add keyboard input support to the input manager.
  43041. * @returns the new FlyCameraKeyboardMoveInput().
  43042. */
  43043. addKeyboard(): FlyCameraInputsManager;
  43044. /**
  43045. * Add mouse input support to the input manager.
  43046. * @param touchEnabled Enable touch screen support.
  43047. * @returns the new FlyCameraMouseInput().
  43048. */
  43049. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43050. }
  43051. }
  43052. declare module BABYLON {
  43053. /**
  43054. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43055. * such as in a 3D Space Shooter or a Flight Simulator.
  43056. */
  43057. export class FlyCamera extends TargetCamera {
  43058. /**
  43059. * Define the collision ellipsoid of the camera.
  43060. * This is helpful for simulating a camera body, like a player's body.
  43061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43062. */
  43063. ellipsoid: Vector3;
  43064. /**
  43065. * Define an offset for the position of the ellipsoid around the camera.
  43066. * This can be helpful if the camera is attached away from the player's body center,
  43067. * such as at its head.
  43068. */
  43069. ellipsoidOffset: Vector3;
  43070. /**
  43071. * Enable or disable collisions of the camera with the rest of the scene objects.
  43072. */
  43073. checkCollisions: boolean;
  43074. /**
  43075. * Enable or disable gravity on the camera.
  43076. */
  43077. applyGravity: boolean;
  43078. /**
  43079. * Define the current direction the camera is moving to.
  43080. */
  43081. cameraDirection: Vector3;
  43082. /**
  43083. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43084. * This overrides and empties cameraRotation.
  43085. */
  43086. rotationQuaternion: Quaternion;
  43087. /**
  43088. * Track Roll to maintain the wanted Rolling when looking around.
  43089. */
  43090. _trackRoll: number;
  43091. /**
  43092. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43093. */
  43094. rollCorrect: number;
  43095. /**
  43096. * Mimic a banked turn, Rolling the camera when Yawing.
  43097. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43098. */
  43099. bankedTurn: boolean;
  43100. /**
  43101. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43102. */
  43103. bankedTurnLimit: number;
  43104. /**
  43105. * Value of 0 disables the banked Roll.
  43106. * Value of 1 is equal to the Yaw angle in radians.
  43107. */
  43108. bankedTurnMultiplier: number;
  43109. /**
  43110. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43111. */
  43112. inputs: FlyCameraInputsManager;
  43113. /**
  43114. * Gets the input sensibility for mouse input.
  43115. * Higher values reduce sensitivity.
  43116. */
  43117. get angularSensibility(): number;
  43118. /**
  43119. * Sets the input sensibility for a mouse input.
  43120. * Higher values reduce sensitivity.
  43121. */
  43122. set angularSensibility(value: number);
  43123. /**
  43124. * Get the keys for camera movement forward.
  43125. */
  43126. get keysForward(): number[];
  43127. /**
  43128. * Set the keys for camera movement forward.
  43129. */
  43130. set keysForward(value: number[]);
  43131. /**
  43132. * Get the keys for camera movement backward.
  43133. */
  43134. get keysBackward(): number[];
  43135. set keysBackward(value: number[]);
  43136. /**
  43137. * Get the keys for camera movement up.
  43138. */
  43139. get keysUp(): number[];
  43140. /**
  43141. * Set the keys for camera movement up.
  43142. */
  43143. set keysUp(value: number[]);
  43144. /**
  43145. * Get the keys for camera movement down.
  43146. */
  43147. get keysDown(): number[];
  43148. /**
  43149. * Set the keys for camera movement down.
  43150. */
  43151. set keysDown(value: number[]);
  43152. /**
  43153. * Get the keys for camera movement left.
  43154. */
  43155. get keysLeft(): number[];
  43156. /**
  43157. * Set the keys for camera movement left.
  43158. */
  43159. set keysLeft(value: number[]);
  43160. /**
  43161. * Set the keys for camera movement right.
  43162. */
  43163. get keysRight(): number[];
  43164. /**
  43165. * Set the keys for camera movement right.
  43166. */
  43167. set keysRight(value: number[]);
  43168. /**
  43169. * Event raised when the camera collides with a mesh in the scene.
  43170. */
  43171. onCollide: (collidedMesh: AbstractMesh) => void;
  43172. private _collider;
  43173. private _needMoveForGravity;
  43174. private _oldPosition;
  43175. private _diffPosition;
  43176. private _newPosition;
  43177. /** @hidden */
  43178. _localDirection: Vector3;
  43179. /** @hidden */
  43180. _transformedDirection: Vector3;
  43181. /**
  43182. * Instantiates a FlyCamera.
  43183. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43184. * such as in a 3D Space Shooter or a Flight Simulator.
  43185. * @param name Define the name of the camera in the scene.
  43186. * @param position Define the starting position of the camera in the scene.
  43187. * @param scene Define the scene the camera belongs to.
  43188. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43189. */
  43190. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43191. /**
  43192. * Attach a control to the HTML DOM element.
  43193. * @param element Defines the element that listens to the input events.
  43194. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43195. */
  43196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43197. /**
  43198. * Detach a control from the HTML DOM element.
  43199. * The camera will stop reacting to that input.
  43200. * @param element Defines the element that listens to the input events.
  43201. */
  43202. detachControl(element: HTMLElement): void;
  43203. private _collisionMask;
  43204. /**
  43205. * Get the mask that the camera ignores in collision events.
  43206. */
  43207. get collisionMask(): number;
  43208. /**
  43209. * Set the mask that the camera ignores in collision events.
  43210. */
  43211. set collisionMask(mask: number);
  43212. /** @hidden */
  43213. _collideWithWorld(displacement: Vector3): void;
  43214. /** @hidden */
  43215. private _onCollisionPositionChange;
  43216. /** @hidden */
  43217. _checkInputs(): void;
  43218. /** @hidden */
  43219. _decideIfNeedsToMove(): boolean;
  43220. /** @hidden */
  43221. _updatePosition(): void;
  43222. /**
  43223. * Restore the Roll to its target value at the rate specified.
  43224. * @param rate - Higher means slower restoring.
  43225. * @hidden
  43226. */
  43227. restoreRoll(rate: number): void;
  43228. /**
  43229. * Destroy the camera and release the current resources held by it.
  43230. */
  43231. dispose(): void;
  43232. /**
  43233. * Get the current object class name.
  43234. * @returns the class name.
  43235. */
  43236. getClassName(): string;
  43237. }
  43238. }
  43239. declare module BABYLON {
  43240. /**
  43241. * Listen to keyboard events to control the camera.
  43242. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43243. */
  43244. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43245. /**
  43246. * Defines the camera the input is attached to.
  43247. */
  43248. camera: FlyCamera;
  43249. /**
  43250. * The list of keyboard keys used to control the forward move of the camera.
  43251. */
  43252. keysForward: number[];
  43253. /**
  43254. * The list of keyboard keys used to control the backward move of the camera.
  43255. */
  43256. keysBackward: number[];
  43257. /**
  43258. * The list of keyboard keys used to control the forward move of the camera.
  43259. */
  43260. keysUp: number[];
  43261. /**
  43262. * The list of keyboard keys used to control the backward move of the camera.
  43263. */
  43264. keysDown: number[];
  43265. /**
  43266. * The list of keyboard keys used to control the right strafe move of the camera.
  43267. */
  43268. keysRight: number[];
  43269. /**
  43270. * The list of keyboard keys used to control the left strafe move of the camera.
  43271. */
  43272. keysLeft: number[];
  43273. private _keys;
  43274. private _onCanvasBlurObserver;
  43275. private _onKeyboardObserver;
  43276. private _engine;
  43277. private _scene;
  43278. /**
  43279. * Attach the input controls to a specific dom element to get the input from.
  43280. * @param element Defines the element the controls should be listened from
  43281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43282. */
  43283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43284. /**
  43285. * Detach the current controls from the specified dom element.
  43286. * @param element Defines the element to stop listening the inputs from
  43287. */
  43288. detachControl(element: Nullable<HTMLElement>): void;
  43289. /**
  43290. * Gets the class name of the current intput.
  43291. * @returns the class name
  43292. */
  43293. getClassName(): string;
  43294. /** @hidden */
  43295. _onLostFocus(e: FocusEvent): void;
  43296. /**
  43297. * Get the friendly name associated with the input class.
  43298. * @returns the input friendly name
  43299. */
  43300. getSimpleName(): string;
  43301. /**
  43302. * Update the current camera state depending on the inputs that have been used this frame.
  43303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43304. */
  43305. checkInputs(): void;
  43306. }
  43307. }
  43308. declare module BABYLON {
  43309. /**
  43310. * Manage the mouse wheel inputs to control a follow camera.
  43311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43312. */
  43313. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43314. /**
  43315. * Defines the camera the input is attached to.
  43316. */
  43317. camera: FollowCamera;
  43318. /**
  43319. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43320. */
  43321. axisControlRadius: boolean;
  43322. /**
  43323. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43324. */
  43325. axisControlHeight: boolean;
  43326. /**
  43327. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43328. */
  43329. axisControlRotation: boolean;
  43330. /**
  43331. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43332. * relation to mouseWheel events.
  43333. */
  43334. wheelPrecision: number;
  43335. /**
  43336. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43337. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43338. */
  43339. wheelDeltaPercentage: number;
  43340. private _wheel;
  43341. private _observer;
  43342. /**
  43343. * Attach the input controls to a specific dom element to get the input from.
  43344. * @param element Defines the element the controls should be listened from
  43345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43346. */
  43347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43348. /**
  43349. * Detach the current controls from the specified dom element.
  43350. * @param element Defines the element to stop listening the inputs from
  43351. */
  43352. detachControl(element: Nullable<HTMLElement>): void;
  43353. /**
  43354. * Gets the class name of the current intput.
  43355. * @returns the class name
  43356. */
  43357. getClassName(): string;
  43358. /**
  43359. * Get the friendly name associated with the input class.
  43360. * @returns the input friendly name
  43361. */
  43362. getSimpleName(): string;
  43363. }
  43364. }
  43365. declare module BABYLON {
  43366. /**
  43367. * Manage the pointers inputs to control an follow camera.
  43368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43369. */
  43370. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43371. /**
  43372. * Defines the camera the input is attached to.
  43373. */
  43374. camera: FollowCamera;
  43375. /**
  43376. * Gets the class name of the current input.
  43377. * @returns the class name
  43378. */
  43379. getClassName(): string;
  43380. /**
  43381. * Defines the pointer angular sensibility along the X axis or how fast is
  43382. * the camera rotating.
  43383. * A negative number will reverse the axis direction.
  43384. */
  43385. angularSensibilityX: number;
  43386. /**
  43387. * Defines the pointer angular sensibility along the Y axis or how fast is
  43388. * the camera rotating.
  43389. * A negative number will reverse the axis direction.
  43390. */
  43391. angularSensibilityY: number;
  43392. /**
  43393. * Defines the pointer pinch precision or how fast is the camera zooming.
  43394. * A negative number will reverse the axis direction.
  43395. */
  43396. pinchPrecision: number;
  43397. /**
  43398. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43399. * from 0.
  43400. * It defines the percentage of current camera.radius to use as delta when
  43401. * pinch zoom is used.
  43402. */
  43403. pinchDeltaPercentage: number;
  43404. /**
  43405. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43406. */
  43407. axisXControlRadius: boolean;
  43408. /**
  43409. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43410. */
  43411. axisXControlHeight: boolean;
  43412. /**
  43413. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43414. */
  43415. axisXControlRotation: boolean;
  43416. /**
  43417. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43418. */
  43419. axisYControlRadius: boolean;
  43420. /**
  43421. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43422. */
  43423. axisYControlHeight: boolean;
  43424. /**
  43425. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43426. */
  43427. axisYControlRotation: boolean;
  43428. /**
  43429. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43430. */
  43431. axisPinchControlRadius: boolean;
  43432. /**
  43433. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43434. */
  43435. axisPinchControlHeight: boolean;
  43436. /**
  43437. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43438. */
  43439. axisPinchControlRotation: boolean;
  43440. /**
  43441. * Log error messages if basic misconfiguration has occurred.
  43442. */
  43443. warningEnable: boolean;
  43444. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43445. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43446. private _warningCounter;
  43447. private _warning;
  43448. }
  43449. }
  43450. declare module BABYLON {
  43451. /**
  43452. * Default Inputs manager for the FollowCamera.
  43453. * It groups all the default supported inputs for ease of use.
  43454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43455. */
  43456. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43457. /**
  43458. * Instantiates a new FollowCameraInputsManager.
  43459. * @param camera Defines the camera the inputs belong to
  43460. */
  43461. constructor(camera: FollowCamera);
  43462. /**
  43463. * Add keyboard input support to the input manager.
  43464. * @returns the current input manager
  43465. */
  43466. addKeyboard(): FollowCameraInputsManager;
  43467. /**
  43468. * Add mouse wheel input support to the input manager.
  43469. * @returns the current input manager
  43470. */
  43471. addMouseWheel(): FollowCameraInputsManager;
  43472. /**
  43473. * Add pointers input support to the input manager.
  43474. * @returns the current input manager
  43475. */
  43476. addPointers(): FollowCameraInputsManager;
  43477. /**
  43478. * Add orientation input support to the input manager.
  43479. * @returns the current input manager
  43480. */
  43481. addVRDeviceOrientation(): FollowCameraInputsManager;
  43482. }
  43483. }
  43484. declare module BABYLON {
  43485. /**
  43486. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43487. * an arc rotate version arcFollowCamera are available.
  43488. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43489. */
  43490. export class FollowCamera extends TargetCamera {
  43491. /**
  43492. * Distance the follow camera should follow an object at
  43493. */
  43494. radius: number;
  43495. /**
  43496. * Minimum allowed distance of the camera to the axis of rotation
  43497. * (The camera can not get closer).
  43498. * This can help limiting how the Camera is able to move in the scene.
  43499. */
  43500. lowerRadiusLimit: Nullable<number>;
  43501. /**
  43502. * Maximum allowed distance of the camera to the axis of rotation
  43503. * (The camera can not get further).
  43504. * This can help limiting how the Camera is able to move in the scene.
  43505. */
  43506. upperRadiusLimit: Nullable<number>;
  43507. /**
  43508. * Define a rotation offset between the camera and the object it follows
  43509. */
  43510. rotationOffset: number;
  43511. /**
  43512. * Minimum allowed angle to camera position relative to target object.
  43513. * This can help limiting how the Camera is able to move in the scene.
  43514. */
  43515. lowerRotationOffsetLimit: Nullable<number>;
  43516. /**
  43517. * Maximum allowed angle to camera position relative to target object.
  43518. * This can help limiting how the Camera is able to move in the scene.
  43519. */
  43520. upperRotationOffsetLimit: Nullable<number>;
  43521. /**
  43522. * Define a height offset between the camera and the object it follows.
  43523. * It can help following an object from the top (like a car chaing a plane)
  43524. */
  43525. heightOffset: number;
  43526. /**
  43527. * Minimum allowed height of camera position relative to target object.
  43528. * This can help limiting how the Camera is able to move in the scene.
  43529. */
  43530. lowerHeightOffsetLimit: Nullable<number>;
  43531. /**
  43532. * Maximum allowed height of camera position relative to target object.
  43533. * This can help limiting how the Camera is able to move in the scene.
  43534. */
  43535. upperHeightOffsetLimit: Nullable<number>;
  43536. /**
  43537. * Define how fast the camera can accelerate to follow it s target.
  43538. */
  43539. cameraAcceleration: number;
  43540. /**
  43541. * Define the speed limit of the camera following an object.
  43542. */
  43543. maxCameraSpeed: number;
  43544. /**
  43545. * Define the target of the camera.
  43546. */
  43547. lockedTarget: Nullable<AbstractMesh>;
  43548. /**
  43549. * Defines the input associated with the camera.
  43550. */
  43551. inputs: FollowCameraInputsManager;
  43552. /**
  43553. * Instantiates the follow camera.
  43554. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43555. * @param name Define the name of the camera in the scene
  43556. * @param position Define the position of the camera
  43557. * @param scene Define the scene the camera belong to
  43558. * @param lockedTarget Define the target of the camera
  43559. */
  43560. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43561. private _follow;
  43562. /**
  43563. * Attached controls to the current camera.
  43564. * @param element Defines the element the controls should be listened from
  43565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43566. */
  43567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43568. /**
  43569. * Detach the current controls from the camera.
  43570. * The camera will stop reacting to inputs.
  43571. * @param element Defines the element to stop listening the inputs from
  43572. */
  43573. detachControl(element: HTMLElement): void;
  43574. /** @hidden */
  43575. _checkInputs(): void;
  43576. private _checkLimits;
  43577. /**
  43578. * Gets the camera class name.
  43579. * @returns the class name
  43580. */
  43581. getClassName(): string;
  43582. }
  43583. /**
  43584. * Arc Rotate version of the follow camera.
  43585. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43586. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43587. */
  43588. export class ArcFollowCamera extends TargetCamera {
  43589. /** The longitudinal angle of the camera */
  43590. alpha: number;
  43591. /** The latitudinal angle of the camera */
  43592. beta: number;
  43593. /** The radius of the camera from its target */
  43594. radius: number;
  43595. /** Define the camera target (the mesh it should follow) */
  43596. target: Nullable<AbstractMesh>;
  43597. private _cartesianCoordinates;
  43598. /**
  43599. * Instantiates a new ArcFollowCamera
  43600. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43601. * @param name Define the name of the camera
  43602. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43603. * @param beta Define the rotation angle of the camera around the elevation axis
  43604. * @param radius Define the radius of the camera from its target point
  43605. * @param target Define the target of the camera
  43606. * @param scene Define the scene the camera belongs to
  43607. */
  43608. constructor(name: string,
  43609. /** The longitudinal angle of the camera */
  43610. alpha: number,
  43611. /** The latitudinal angle of the camera */
  43612. beta: number,
  43613. /** The radius of the camera from its target */
  43614. radius: number,
  43615. /** Define the camera target (the mesh it should follow) */
  43616. target: Nullable<AbstractMesh>, scene: Scene);
  43617. private _follow;
  43618. /** @hidden */
  43619. _checkInputs(): void;
  43620. /**
  43621. * Returns the class name of the object.
  43622. * It is mostly used internally for serialization purposes.
  43623. */
  43624. getClassName(): string;
  43625. }
  43626. }
  43627. declare module BABYLON {
  43628. /**
  43629. * Manage the keyboard inputs to control the movement of a follow camera.
  43630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43631. */
  43632. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43633. /**
  43634. * Defines the camera the input is attached to.
  43635. */
  43636. camera: FollowCamera;
  43637. /**
  43638. * Defines the list of key codes associated with the up action (increase heightOffset)
  43639. */
  43640. keysHeightOffsetIncr: number[];
  43641. /**
  43642. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43643. */
  43644. keysHeightOffsetDecr: number[];
  43645. /**
  43646. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43647. */
  43648. keysHeightOffsetModifierAlt: boolean;
  43649. /**
  43650. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43651. */
  43652. keysHeightOffsetModifierCtrl: boolean;
  43653. /**
  43654. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43655. */
  43656. keysHeightOffsetModifierShift: boolean;
  43657. /**
  43658. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43659. */
  43660. keysRotationOffsetIncr: number[];
  43661. /**
  43662. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43663. */
  43664. keysRotationOffsetDecr: number[];
  43665. /**
  43666. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43667. */
  43668. keysRotationOffsetModifierAlt: boolean;
  43669. /**
  43670. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43671. */
  43672. keysRotationOffsetModifierCtrl: boolean;
  43673. /**
  43674. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43675. */
  43676. keysRotationOffsetModifierShift: boolean;
  43677. /**
  43678. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43679. */
  43680. keysRadiusIncr: number[];
  43681. /**
  43682. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43683. */
  43684. keysRadiusDecr: number[];
  43685. /**
  43686. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43687. */
  43688. keysRadiusModifierAlt: boolean;
  43689. /**
  43690. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43691. */
  43692. keysRadiusModifierCtrl: boolean;
  43693. /**
  43694. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43695. */
  43696. keysRadiusModifierShift: boolean;
  43697. /**
  43698. * Defines the rate of change of heightOffset.
  43699. */
  43700. heightSensibility: number;
  43701. /**
  43702. * Defines the rate of change of rotationOffset.
  43703. */
  43704. rotationSensibility: number;
  43705. /**
  43706. * Defines the rate of change of radius.
  43707. */
  43708. radiusSensibility: number;
  43709. private _keys;
  43710. private _ctrlPressed;
  43711. private _altPressed;
  43712. private _shiftPressed;
  43713. private _onCanvasBlurObserver;
  43714. private _onKeyboardObserver;
  43715. private _engine;
  43716. private _scene;
  43717. /**
  43718. * Attach the input controls to a specific dom element to get the input from.
  43719. * @param element Defines the element the controls should be listened from
  43720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43721. */
  43722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43723. /**
  43724. * Detach the current controls from the specified dom element.
  43725. * @param element Defines the element to stop listening the inputs from
  43726. */
  43727. detachControl(element: Nullable<HTMLElement>): void;
  43728. /**
  43729. * Update the current camera state depending on the inputs that have been used this frame.
  43730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43731. */
  43732. checkInputs(): void;
  43733. /**
  43734. * Gets the class name of the current input.
  43735. * @returns the class name
  43736. */
  43737. getClassName(): string;
  43738. /**
  43739. * Get the friendly name associated with the input class.
  43740. * @returns the input friendly name
  43741. */
  43742. getSimpleName(): string;
  43743. /**
  43744. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43745. * allow modification of the heightOffset value.
  43746. */
  43747. private _modifierHeightOffset;
  43748. /**
  43749. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43750. * allow modification of the rotationOffset value.
  43751. */
  43752. private _modifierRotationOffset;
  43753. /**
  43754. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43755. * allow modification of the radius value.
  43756. */
  43757. private _modifierRadius;
  43758. }
  43759. }
  43760. declare module BABYLON {
  43761. interface FreeCameraInputsManager {
  43762. /**
  43763. * @hidden
  43764. */
  43765. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43766. /**
  43767. * Add orientation input support to the input manager.
  43768. * @returns the current input manager
  43769. */
  43770. addDeviceOrientation(): FreeCameraInputsManager;
  43771. }
  43772. /**
  43773. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43774. * Screen rotation is taken into account.
  43775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43776. */
  43777. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43778. private _camera;
  43779. private _screenOrientationAngle;
  43780. private _constantTranform;
  43781. private _screenQuaternion;
  43782. private _alpha;
  43783. private _beta;
  43784. private _gamma;
  43785. /**
  43786. * Can be used to detect if a device orientation sensor is available on a device
  43787. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43788. * @returns a promise that will resolve on orientation change
  43789. */
  43790. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43791. /**
  43792. * @hidden
  43793. */
  43794. _onDeviceOrientationChangedObservable: Observable<void>;
  43795. /**
  43796. * Instantiates a new input
  43797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43798. */
  43799. constructor();
  43800. /**
  43801. * Define the camera controlled by the input.
  43802. */
  43803. get camera(): FreeCamera;
  43804. set camera(camera: FreeCamera);
  43805. /**
  43806. * Attach the input controls to a specific dom element to get the input from.
  43807. * @param element Defines the element the controls should be listened from
  43808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43809. */
  43810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43811. private _orientationChanged;
  43812. private _deviceOrientation;
  43813. /**
  43814. * Detach the current controls from the specified dom element.
  43815. * @param element Defines the element to stop listening the inputs from
  43816. */
  43817. detachControl(element: Nullable<HTMLElement>): void;
  43818. /**
  43819. * Update the current camera state depending on the inputs that have been used this frame.
  43820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43821. */
  43822. checkInputs(): void;
  43823. /**
  43824. * Gets the class name of the current intput.
  43825. * @returns the class name
  43826. */
  43827. getClassName(): string;
  43828. /**
  43829. * Get the friendly name associated with the input class.
  43830. * @returns the input friendly name
  43831. */
  43832. getSimpleName(): string;
  43833. }
  43834. }
  43835. declare module BABYLON {
  43836. /**
  43837. * Manage the gamepad inputs to control a free camera.
  43838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43839. */
  43840. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43841. /**
  43842. * Define the camera the input is attached to.
  43843. */
  43844. camera: FreeCamera;
  43845. /**
  43846. * Define the Gamepad controlling the input
  43847. */
  43848. gamepad: Nullable<Gamepad>;
  43849. /**
  43850. * Defines the gamepad rotation sensiblity.
  43851. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43852. */
  43853. gamepadAngularSensibility: number;
  43854. /**
  43855. * Defines the gamepad move sensiblity.
  43856. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43857. */
  43858. gamepadMoveSensibility: number;
  43859. private _yAxisScale;
  43860. /**
  43861. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43862. */
  43863. get invertYAxis(): boolean;
  43864. set invertYAxis(value: boolean);
  43865. private _onGamepadConnectedObserver;
  43866. private _onGamepadDisconnectedObserver;
  43867. private _cameraTransform;
  43868. private _deltaTransform;
  43869. private _vector3;
  43870. private _vector2;
  43871. /**
  43872. * Attach the input controls to a specific dom element to get the input from.
  43873. * @param element Defines the element the controls should be listened from
  43874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43875. */
  43876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43877. /**
  43878. * Detach the current controls from the specified dom element.
  43879. * @param element Defines the element to stop listening the inputs from
  43880. */
  43881. detachControl(element: Nullable<HTMLElement>): void;
  43882. /**
  43883. * Update the current camera state depending on the inputs that have been used this frame.
  43884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43885. */
  43886. checkInputs(): void;
  43887. /**
  43888. * Gets the class name of the current intput.
  43889. * @returns the class name
  43890. */
  43891. getClassName(): string;
  43892. /**
  43893. * Get the friendly name associated with the input class.
  43894. * @returns the input friendly name
  43895. */
  43896. getSimpleName(): string;
  43897. }
  43898. }
  43899. declare module BABYLON {
  43900. /**
  43901. * Defines the potential axis of a Joystick
  43902. */
  43903. export enum JoystickAxis {
  43904. /** X axis */
  43905. X = 0,
  43906. /** Y axis */
  43907. Y = 1,
  43908. /** Z axis */
  43909. Z = 2
  43910. }
  43911. /**
  43912. * Class used to define virtual joystick (used in touch mode)
  43913. */
  43914. export class VirtualJoystick {
  43915. /**
  43916. * Gets or sets a boolean indicating that left and right values must be inverted
  43917. */
  43918. reverseLeftRight: boolean;
  43919. /**
  43920. * Gets or sets a boolean indicating that up and down values must be inverted
  43921. */
  43922. reverseUpDown: boolean;
  43923. /**
  43924. * Gets the offset value for the position (ie. the change of the position value)
  43925. */
  43926. deltaPosition: Vector3;
  43927. /**
  43928. * Gets a boolean indicating if the virtual joystick was pressed
  43929. */
  43930. pressed: boolean;
  43931. /**
  43932. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43933. */
  43934. static Canvas: Nullable<HTMLCanvasElement>;
  43935. private static _globalJoystickIndex;
  43936. private static vjCanvasContext;
  43937. private static vjCanvasWidth;
  43938. private static vjCanvasHeight;
  43939. private static halfWidth;
  43940. private _action;
  43941. private _axisTargetedByLeftAndRight;
  43942. private _axisTargetedByUpAndDown;
  43943. private _joystickSensibility;
  43944. private _inversedSensibility;
  43945. private _joystickPointerID;
  43946. private _joystickColor;
  43947. private _joystickPointerPos;
  43948. private _joystickPreviousPointerPos;
  43949. private _joystickPointerStartPos;
  43950. private _deltaJoystickVector;
  43951. private _leftJoystick;
  43952. private _touches;
  43953. private _onPointerDownHandlerRef;
  43954. private _onPointerMoveHandlerRef;
  43955. private _onPointerUpHandlerRef;
  43956. private _onResize;
  43957. /**
  43958. * Creates a new virtual joystick
  43959. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43960. */
  43961. constructor(leftJoystick?: boolean);
  43962. /**
  43963. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43964. * @param newJoystickSensibility defines the new sensibility
  43965. */
  43966. setJoystickSensibility(newJoystickSensibility: number): void;
  43967. private _onPointerDown;
  43968. private _onPointerMove;
  43969. private _onPointerUp;
  43970. /**
  43971. * Change the color of the virtual joystick
  43972. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43973. */
  43974. setJoystickColor(newColor: string): void;
  43975. /**
  43976. * Defines a callback to call when the joystick is touched
  43977. * @param action defines the callback
  43978. */
  43979. setActionOnTouch(action: () => any): void;
  43980. /**
  43981. * Defines which axis you'd like to control for left & right
  43982. * @param axis defines the axis to use
  43983. */
  43984. setAxisForLeftRight(axis: JoystickAxis): void;
  43985. /**
  43986. * Defines which axis you'd like to control for up & down
  43987. * @param axis defines the axis to use
  43988. */
  43989. setAxisForUpDown(axis: JoystickAxis): void;
  43990. private _drawVirtualJoystick;
  43991. /**
  43992. * Release internal HTML canvas
  43993. */
  43994. releaseCanvas(): void;
  43995. }
  43996. }
  43997. declare module BABYLON {
  43998. interface FreeCameraInputsManager {
  43999. /**
  44000. * Add virtual joystick input support to the input manager.
  44001. * @returns the current input manager
  44002. */
  44003. addVirtualJoystick(): FreeCameraInputsManager;
  44004. }
  44005. /**
  44006. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44007. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44008. */
  44009. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44010. /**
  44011. * Defines the camera the input is attached to.
  44012. */
  44013. camera: FreeCamera;
  44014. private _leftjoystick;
  44015. private _rightjoystick;
  44016. /**
  44017. * Gets the left stick of the virtual joystick.
  44018. * @returns The virtual Joystick
  44019. */
  44020. getLeftJoystick(): VirtualJoystick;
  44021. /**
  44022. * Gets the right stick of the virtual joystick.
  44023. * @returns The virtual Joystick
  44024. */
  44025. getRightJoystick(): VirtualJoystick;
  44026. /**
  44027. * Update the current camera state depending on the inputs that have been used this frame.
  44028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44029. */
  44030. checkInputs(): void;
  44031. /**
  44032. * Attach the input controls to a specific dom element to get the input from.
  44033. * @param element Defines the element the controls should be listened from
  44034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44035. */
  44036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44037. /**
  44038. * Detach the current controls from the specified dom element.
  44039. * @param element Defines the element to stop listening the inputs from
  44040. */
  44041. detachControl(element: Nullable<HTMLElement>): void;
  44042. /**
  44043. * Gets the class name of the current intput.
  44044. * @returns the class name
  44045. */
  44046. getClassName(): string;
  44047. /**
  44048. * Get the friendly name associated with the input class.
  44049. * @returns the input friendly name
  44050. */
  44051. getSimpleName(): string;
  44052. }
  44053. }
  44054. declare module BABYLON {
  44055. /**
  44056. * This represents a FPS type of camera controlled by touch.
  44057. * This is like a universal camera minus the Gamepad controls.
  44058. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44059. */
  44060. export class TouchCamera extends FreeCamera {
  44061. /**
  44062. * Defines the touch sensibility for rotation.
  44063. * The higher the faster.
  44064. */
  44065. get touchAngularSensibility(): number;
  44066. set touchAngularSensibility(value: number);
  44067. /**
  44068. * Defines the touch sensibility for move.
  44069. * The higher the faster.
  44070. */
  44071. get touchMoveSensibility(): number;
  44072. set touchMoveSensibility(value: number);
  44073. /**
  44074. * Instantiates a new touch camera.
  44075. * This represents a FPS type of camera controlled by touch.
  44076. * This is like a universal camera minus the Gamepad controls.
  44077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44078. * @param name Define the name of the camera in the scene
  44079. * @param position Define the start position of the camera in the scene
  44080. * @param scene Define the scene the camera belongs to
  44081. */
  44082. constructor(name: string, position: Vector3, scene: Scene);
  44083. /**
  44084. * Gets the current object class name.
  44085. * @return the class name
  44086. */
  44087. getClassName(): string;
  44088. /** @hidden */
  44089. _setupInputs(): void;
  44090. }
  44091. }
  44092. declare module BABYLON {
  44093. /**
  44094. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44095. * being tilted forward or back and left or right.
  44096. */
  44097. export class DeviceOrientationCamera extends FreeCamera {
  44098. private _initialQuaternion;
  44099. private _quaternionCache;
  44100. private _tmpDragQuaternion;
  44101. private _disablePointerInputWhenUsingDeviceOrientation;
  44102. /**
  44103. * Creates a new device orientation camera
  44104. * @param name The name of the camera
  44105. * @param position The start position camera
  44106. * @param scene The scene the camera belongs to
  44107. */
  44108. constructor(name: string, position: Vector3, scene: Scene);
  44109. /**
  44110. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44111. */
  44112. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44113. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44114. private _dragFactor;
  44115. /**
  44116. * Enabled turning on the y axis when the orientation sensor is active
  44117. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44118. */
  44119. enableHorizontalDragging(dragFactor?: number): void;
  44120. /**
  44121. * Gets the current instance class name ("DeviceOrientationCamera").
  44122. * This helps avoiding instanceof at run time.
  44123. * @returns the class name
  44124. */
  44125. getClassName(): string;
  44126. /**
  44127. * @hidden
  44128. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44129. */
  44130. _checkInputs(): void;
  44131. /**
  44132. * Reset the camera to its default orientation on the specified axis only.
  44133. * @param axis The axis to reset
  44134. */
  44135. resetToCurrentRotation(axis?: Axis): void;
  44136. }
  44137. }
  44138. declare module BABYLON {
  44139. /**
  44140. * Defines supported buttons for XBox360 compatible gamepads
  44141. */
  44142. export enum Xbox360Button {
  44143. /** A */
  44144. A = 0,
  44145. /** B */
  44146. B = 1,
  44147. /** X */
  44148. X = 2,
  44149. /** Y */
  44150. Y = 3,
  44151. /** Left button */
  44152. LB = 4,
  44153. /** Right button */
  44154. RB = 5,
  44155. /** Back */
  44156. Back = 8,
  44157. /** Start */
  44158. Start = 9,
  44159. /** Left stick */
  44160. LeftStick = 10,
  44161. /** Right stick */
  44162. RightStick = 11
  44163. }
  44164. /** Defines values for XBox360 DPad */
  44165. export enum Xbox360Dpad {
  44166. /** Up */
  44167. Up = 12,
  44168. /** Down */
  44169. Down = 13,
  44170. /** Left */
  44171. Left = 14,
  44172. /** Right */
  44173. Right = 15
  44174. }
  44175. /**
  44176. * Defines a XBox360 gamepad
  44177. */
  44178. export class Xbox360Pad extends Gamepad {
  44179. private _leftTrigger;
  44180. private _rightTrigger;
  44181. private _onlefttriggerchanged;
  44182. private _onrighttriggerchanged;
  44183. private _onbuttondown;
  44184. private _onbuttonup;
  44185. private _ondpaddown;
  44186. private _ondpadup;
  44187. /** Observable raised when a button is pressed */
  44188. onButtonDownObservable: Observable<Xbox360Button>;
  44189. /** Observable raised when a button is released */
  44190. onButtonUpObservable: Observable<Xbox360Button>;
  44191. /** Observable raised when a pad is pressed */
  44192. onPadDownObservable: Observable<Xbox360Dpad>;
  44193. /** Observable raised when a pad is released */
  44194. onPadUpObservable: Observable<Xbox360Dpad>;
  44195. private _buttonA;
  44196. private _buttonB;
  44197. private _buttonX;
  44198. private _buttonY;
  44199. private _buttonBack;
  44200. private _buttonStart;
  44201. private _buttonLB;
  44202. private _buttonRB;
  44203. private _buttonLeftStick;
  44204. private _buttonRightStick;
  44205. private _dPadUp;
  44206. private _dPadDown;
  44207. private _dPadLeft;
  44208. private _dPadRight;
  44209. private _isXboxOnePad;
  44210. /**
  44211. * Creates a new XBox360 gamepad object
  44212. * @param id defines the id of this gamepad
  44213. * @param index defines its index
  44214. * @param gamepad defines the internal HTML gamepad object
  44215. * @param xboxOne defines if it is a XBox One gamepad
  44216. */
  44217. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44218. /**
  44219. * Defines the callback to call when left trigger is pressed
  44220. * @param callback defines the callback to use
  44221. */
  44222. onlefttriggerchanged(callback: (value: number) => void): void;
  44223. /**
  44224. * Defines the callback to call when right trigger is pressed
  44225. * @param callback defines the callback to use
  44226. */
  44227. onrighttriggerchanged(callback: (value: number) => void): void;
  44228. /**
  44229. * Gets the left trigger value
  44230. */
  44231. get leftTrigger(): number;
  44232. /**
  44233. * Sets the left trigger value
  44234. */
  44235. set leftTrigger(newValue: number);
  44236. /**
  44237. * Gets the right trigger value
  44238. */
  44239. get rightTrigger(): number;
  44240. /**
  44241. * Sets the right trigger value
  44242. */
  44243. set rightTrigger(newValue: number);
  44244. /**
  44245. * Defines the callback to call when a button is pressed
  44246. * @param callback defines the callback to use
  44247. */
  44248. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44249. /**
  44250. * Defines the callback to call when a button is released
  44251. * @param callback defines the callback to use
  44252. */
  44253. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44254. /**
  44255. * Defines the callback to call when a pad is pressed
  44256. * @param callback defines the callback to use
  44257. */
  44258. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44259. /**
  44260. * Defines the callback to call when a pad is released
  44261. * @param callback defines the callback to use
  44262. */
  44263. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44264. private _setButtonValue;
  44265. private _setDPadValue;
  44266. /**
  44267. * Gets the value of the `A` button
  44268. */
  44269. get buttonA(): number;
  44270. /**
  44271. * Sets the value of the `A` button
  44272. */
  44273. set buttonA(value: number);
  44274. /**
  44275. * Gets the value of the `B` button
  44276. */
  44277. get buttonB(): number;
  44278. /**
  44279. * Sets the value of the `B` button
  44280. */
  44281. set buttonB(value: number);
  44282. /**
  44283. * Gets the value of the `X` button
  44284. */
  44285. get buttonX(): number;
  44286. /**
  44287. * Sets the value of the `X` button
  44288. */
  44289. set buttonX(value: number);
  44290. /**
  44291. * Gets the value of the `Y` button
  44292. */
  44293. get buttonY(): number;
  44294. /**
  44295. * Sets the value of the `Y` button
  44296. */
  44297. set buttonY(value: number);
  44298. /**
  44299. * Gets the value of the `Start` button
  44300. */
  44301. get buttonStart(): number;
  44302. /**
  44303. * Sets the value of the `Start` button
  44304. */
  44305. set buttonStart(value: number);
  44306. /**
  44307. * Gets the value of the `Back` button
  44308. */
  44309. get buttonBack(): number;
  44310. /**
  44311. * Sets the value of the `Back` button
  44312. */
  44313. set buttonBack(value: number);
  44314. /**
  44315. * Gets the value of the `Left` button
  44316. */
  44317. get buttonLB(): number;
  44318. /**
  44319. * Sets the value of the `Left` button
  44320. */
  44321. set buttonLB(value: number);
  44322. /**
  44323. * Gets the value of the `Right` button
  44324. */
  44325. get buttonRB(): number;
  44326. /**
  44327. * Sets the value of the `Right` button
  44328. */
  44329. set buttonRB(value: number);
  44330. /**
  44331. * Gets the value of the Left joystick
  44332. */
  44333. get buttonLeftStick(): number;
  44334. /**
  44335. * Sets the value of the Left joystick
  44336. */
  44337. set buttonLeftStick(value: number);
  44338. /**
  44339. * Gets the value of the Right joystick
  44340. */
  44341. get buttonRightStick(): number;
  44342. /**
  44343. * Sets the value of the Right joystick
  44344. */
  44345. set buttonRightStick(value: number);
  44346. /**
  44347. * Gets the value of D-pad up
  44348. */
  44349. get dPadUp(): number;
  44350. /**
  44351. * Sets the value of D-pad up
  44352. */
  44353. set dPadUp(value: number);
  44354. /**
  44355. * Gets the value of D-pad down
  44356. */
  44357. get dPadDown(): number;
  44358. /**
  44359. * Sets the value of D-pad down
  44360. */
  44361. set dPadDown(value: number);
  44362. /**
  44363. * Gets the value of D-pad left
  44364. */
  44365. get dPadLeft(): number;
  44366. /**
  44367. * Sets the value of D-pad left
  44368. */
  44369. set dPadLeft(value: number);
  44370. /**
  44371. * Gets the value of D-pad right
  44372. */
  44373. get dPadRight(): number;
  44374. /**
  44375. * Sets the value of D-pad right
  44376. */
  44377. set dPadRight(value: number);
  44378. /**
  44379. * Force the gamepad to synchronize with device values
  44380. */
  44381. update(): void;
  44382. /**
  44383. * Disposes the gamepad
  44384. */
  44385. dispose(): void;
  44386. }
  44387. }
  44388. declare module BABYLON {
  44389. /**
  44390. * Defines supported buttons for DualShock compatible gamepads
  44391. */
  44392. export enum DualShockButton {
  44393. /** Cross */
  44394. Cross = 0,
  44395. /** Circle */
  44396. Circle = 1,
  44397. /** Square */
  44398. Square = 2,
  44399. /** Triangle */
  44400. Triangle = 3,
  44401. /** L1 */
  44402. L1 = 4,
  44403. /** R1 */
  44404. R1 = 5,
  44405. /** Share */
  44406. Share = 8,
  44407. /** Options */
  44408. Options = 9,
  44409. /** Left stick */
  44410. LeftStick = 10,
  44411. /** Right stick */
  44412. RightStick = 11
  44413. }
  44414. /** Defines values for DualShock DPad */
  44415. export enum DualShockDpad {
  44416. /** Up */
  44417. Up = 12,
  44418. /** Down */
  44419. Down = 13,
  44420. /** Left */
  44421. Left = 14,
  44422. /** Right */
  44423. Right = 15
  44424. }
  44425. /**
  44426. * Defines a DualShock gamepad
  44427. */
  44428. export class DualShockPad extends Gamepad {
  44429. private _leftTrigger;
  44430. private _rightTrigger;
  44431. private _onlefttriggerchanged;
  44432. private _onrighttriggerchanged;
  44433. private _onbuttondown;
  44434. private _onbuttonup;
  44435. private _ondpaddown;
  44436. private _ondpadup;
  44437. /** Observable raised when a button is pressed */
  44438. onButtonDownObservable: Observable<DualShockButton>;
  44439. /** Observable raised when a button is released */
  44440. onButtonUpObservable: Observable<DualShockButton>;
  44441. /** Observable raised when a pad is pressed */
  44442. onPadDownObservable: Observable<DualShockDpad>;
  44443. /** Observable raised when a pad is released */
  44444. onPadUpObservable: Observable<DualShockDpad>;
  44445. private _buttonCross;
  44446. private _buttonCircle;
  44447. private _buttonSquare;
  44448. private _buttonTriangle;
  44449. private _buttonShare;
  44450. private _buttonOptions;
  44451. private _buttonL1;
  44452. private _buttonR1;
  44453. private _buttonLeftStick;
  44454. private _buttonRightStick;
  44455. private _dPadUp;
  44456. private _dPadDown;
  44457. private _dPadLeft;
  44458. private _dPadRight;
  44459. /**
  44460. * Creates a new DualShock gamepad object
  44461. * @param id defines the id of this gamepad
  44462. * @param index defines its index
  44463. * @param gamepad defines the internal HTML gamepad object
  44464. */
  44465. constructor(id: string, index: number, gamepad: any);
  44466. /**
  44467. * Defines the callback to call when left trigger is pressed
  44468. * @param callback defines the callback to use
  44469. */
  44470. onlefttriggerchanged(callback: (value: number) => void): void;
  44471. /**
  44472. * Defines the callback to call when right trigger is pressed
  44473. * @param callback defines the callback to use
  44474. */
  44475. onrighttriggerchanged(callback: (value: number) => void): void;
  44476. /**
  44477. * Gets the left trigger value
  44478. */
  44479. get leftTrigger(): number;
  44480. /**
  44481. * Sets the left trigger value
  44482. */
  44483. set leftTrigger(newValue: number);
  44484. /**
  44485. * Gets the right trigger value
  44486. */
  44487. get rightTrigger(): number;
  44488. /**
  44489. * Sets the right trigger value
  44490. */
  44491. set rightTrigger(newValue: number);
  44492. /**
  44493. * Defines the callback to call when a button is pressed
  44494. * @param callback defines the callback to use
  44495. */
  44496. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44497. /**
  44498. * Defines the callback to call when a button is released
  44499. * @param callback defines the callback to use
  44500. */
  44501. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44502. /**
  44503. * Defines the callback to call when a pad is pressed
  44504. * @param callback defines the callback to use
  44505. */
  44506. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44507. /**
  44508. * Defines the callback to call when a pad is released
  44509. * @param callback defines the callback to use
  44510. */
  44511. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44512. private _setButtonValue;
  44513. private _setDPadValue;
  44514. /**
  44515. * Gets the value of the `Cross` button
  44516. */
  44517. get buttonCross(): number;
  44518. /**
  44519. * Sets the value of the `Cross` button
  44520. */
  44521. set buttonCross(value: number);
  44522. /**
  44523. * Gets the value of the `Circle` button
  44524. */
  44525. get buttonCircle(): number;
  44526. /**
  44527. * Sets the value of the `Circle` button
  44528. */
  44529. set buttonCircle(value: number);
  44530. /**
  44531. * Gets the value of the `Square` button
  44532. */
  44533. get buttonSquare(): number;
  44534. /**
  44535. * Sets the value of the `Square` button
  44536. */
  44537. set buttonSquare(value: number);
  44538. /**
  44539. * Gets the value of the `Triangle` button
  44540. */
  44541. get buttonTriangle(): number;
  44542. /**
  44543. * Sets the value of the `Triangle` button
  44544. */
  44545. set buttonTriangle(value: number);
  44546. /**
  44547. * Gets the value of the `Options` button
  44548. */
  44549. get buttonOptions(): number;
  44550. /**
  44551. * Sets the value of the `Options` button
  44552. */
  44553. set buttonOptions(value: number);
  44554. /**
  44555. * Gets the value of the `Share` button
  44556. */
  44557. get buttonShare(): number;
  44558. /**
  44559. * Sets the value of the `Share` button
  44560. */
  44561. set buttonShare(value: number);
  44562. /**
  44563. * Gets the value of the `L1` button
  44564. */
  44565. get buttonL1(): number;
  44566. /**
  44567. * Sets the value of the `L1` button
  44568. */
  44569. set buttonL1(value: number);
  44570. /**
  44571. * Gets the value of the `R1` button
  44572. */
  44573. get buttonR1(): number;
  44574. /**
  44575. * Sets the value of the `R1` button
  44576. */
  44577. set buttonR1(value: number);
  44578. /**
  44579. * Gets the value of the Left joystick
  44580. */
  44581. get buttonLeftStick(): number;
  44582. /**
  44583. * Sets the value of the Left joystick
  44584. */
  44585. set buttonLeftStick(value: number);
  44586. /**
  44587. * Gets the value of the Right joystick
  44588. */
  44589. get buttonRightStick(): number;
  44590. /**
  44591. * Sets the value of the Right joystick
  44592. */
  44593. set buttonRightStick(value: number);
  44594. /**
  44595. * Gets the value of D-pad up
  44596. */
  44597. get dPadUp(): number;
  44598. /**
  44599. * Sets the value of D-pad up
  44600. */
  44601. set dPadUp(value: number);
  44602. /**
  44603. * Gets the value of D-pad down
  44604. */
  44605. get dPadDown(): number;
  44606. /**
  44607. * Sets the value of D-pad down
  44608. */
  44609. set dPadDown(value: number);
  44610. /**
  44611. * Gets the value of D-pad left
  44612. */
  44613. get dPadLeft(): number;
  44614. /**
  44615. * Sets the value of D-pad left
  44616. */
  44617. set dPadLeft(value: number);
  44618. /**
  44619. * Gets the value of D-pad right
  44620. */
  44621. get dPadRight(): number;
  44622. /**
  44623. * Sets the value of D-pad right
  44624. */
  44625. set dPadRight(value: number);
  44626. /**
  44627. * Force the gamepad to synchronize with device values
  44628. */
  44629. update(): void;
  44630. /**
  44631. * Disposes the gamepad
  44632. */
  44633. dispose(): void;
  44634. }
  44635. }
  44636. declare module BABYLON {
  44637. /**
  44638. * Manager for handling gamepads
  44639. */
  44640. export class GamepadManager {
  44641. private _scene?;
  44642. private _babylonGamepads;
  44643. private _oneGamepadConnected;
  44644. /** @hidden */
  44645. _isMonitoring: boolean;
  44646. private _gamepadEventSupported;
  44647. private _gamepadSupport?;
  44648. /**
  44649. * observable to be triggered when the gamepad controller has been connected
  44650. */
  44651. onGamepadConnectedObservable: Observable<Gamepad>;
  44652. /**
  44653. * observable to be triggered when the gamepad controller has been disconnected
  44654. */
  44655. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44656. private _onGamepadConnectedEvent;
  44657. private _onGamepadDisconnectedEvent;
  44658. /**
  44659. * Initializes the gamepad manager
  44660. * @param _scene BabylonJS scene
  44661. */
  44662. constructor(_scene?: Scene | undefined);
  44663. /**
  44664. * The gamepads in the game pad manager
  44665. */
  44666. get gamepads(): Gamepad[];
  44667. /**
  44668. * Get the gamepad controllers based on type
  44669. * @param type The type of gamepad controller
  44670. * @returns Nullable gamepad
  44671. */
  44672. getGamepadByType(type?: number): Nullable<Gamepad>;
  44673. /**
  44674. * Disposes the gamepad manager
  44675. */
  44676. dispose(): void;
  44677. private _addNewGamepad;
  44678. private _startMonitoringGamepads;
  44679. private _stopMonitoringGamepads;
  44680. /** @hidden */
  44681. _checkGamepadsStatus(): void;
  44682. private _updateGamepadObjects;
  44683. }
  44684. }
  44685. declare module BABYLON {
  44686. interface Scene {
  44687. /** @hidden */
  44688. _gamepadManager: Nullable<GamepadManager>;
  44689. /**
  44690. * Gets the gamepad manager associated with the scene
  44691. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44692. */
  44693. gamepadManager: GamepadManager;
  44694. }
  44695. /**
  44696. * Interface representing a free camera inputs manager
  44697. */
  44698. interface FreeCameraInputsManager {
  44699. /**
  44700. * Adds gamepad input support to the FreeCameraInputsManager.
  44701. * @returns the FreeCameraInputsManager
  44702. */
  44703. addGamepad(): FreeCameraInputsManager;
  44704. }
  44705. /**
  44706. * Interface representing an arc rotate camera inputs manager
  44707. */
  44708. interface ArcRotateCameraInputsManager {
  44709. /**
  44710. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44711. * @returns the camera inputs manager
  44712. */
  44713. addGamepad(): ArcRotateCameraInputsManager;
  44714. }
  44715. /**
  44716. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44717. */
  44718. export class GamepadSystemSceneComponent implements ISceneComponent {
  44719. /**
  44720. * The component name helpfull to identify the component in the list of scene components.
  44721. */
  44722. readonly name: string;
  44723. /**
  44724. * The scene the component belongs to.
  44725. */
  44726. scene: Scene;
  44727. /**
  44728. * Creates a new instance of the component for the given scene
  44729. * @param scene Defines the scene to register the component in
  44730. */
  44731. constructor(scene: Scene);
  44732. /**
  44733. * Registers the component in a given scene
  44734. */
  44735. register(): void;
  44736. /**
  44737. * Rebuilds the elements related to this component in case of
  44738. * context lost for instance.
  44739. */
  44740. rebuild(): void;
  44741. /**
  44742. * Disposes the component and the associated ressources
  44743. */
  44744. dispose(): void;
  44745. private _beforeCameraUpdate;
  44746. }
  44747. }
  44748. declare module BABYLON {
  44749. /**
  44750. * 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,
  44751. * which still works and will still be found in many Playgrounds.
  44752. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44753. */
  44754. export class UniversalCamera extends TouchCamera {
  44755. /**
  44756. * Defines the gamepad rotation sensiblity.
  44757. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44758. */
  44759. get gamepadAngularSensibility(): number;
  44760. set gamepadAngularSensibility(value: number);
  44761. /**
  44762. * Defines the gamepad move sensiblity.
  44763. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44764. */
  44765. get gamepadMoveSensibility(): number;
  44766. set gamepadMoveSensibility(value: number);
  44767. /**
  44768. * 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,
  44769. * which still works and will still be found in many Playgrounds.
  44770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44771. * @param name Define the name of the camera in the scene
  44772. * @param position Define the start position of the camera in the scene
  44773. * @param scene Define the scene the camera belongs to
  44774. */
  44775. constructor(name: string, position: Vector3, scene: Scene);
  44776. /**
  44777. * Gets the current object class name.
  44778. * @return the class name
  44779. */
  44780. getClassName(): string;
  44781. }
  44782. }
  44783. declare module BABYLON {
  44784. /**
  44785. * This represents a FPS type of camera. This is only here for back compat purpose.
  44786. * Please use the UniversalCamera instead as both are identical.
  44787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44788. */
  44789. export class GamepadCamera extends UniversalCamera {
  44790. /**
  44791. * Instantiates a new Gamepad Camera
  44792. * This represents a FPS type of camera. This is only here for back compat purpose.
  44793. * Please use the UniversalCamera instead as both are identical.
  44794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44795. * @param name Define the name of the camera in the scene
  44796. * @param position Define the start position of the camera in the scene
  44797. * @param scene Define the scene the camera belongs to
  44798. */
  44799. constructor(name: string, position: Vector3, scene: Scene);
  44800. /**
  44801. * Gets the current object class name.
  44802. * @return the class name
  44803. */
  44804. getClassName(): string;
  44805. }
  44806. }
  44807. declare module BABYLON {
  44808. /** @hidden */
  44809. export var passPixelShader: {
  44810. name: string;
  44811. shader: string;
  44812. };
  44813. }
  44814. declare module BABYLON {
  44815. /** @hidden */
  44816. export var passCubePixelShader: {
  44817. name: string;
  44818. shader: string;
  44819. };
  44820. }
  44821. declare module BABYLON {
  44822. /**
  44823. * PassPostProcess which produces an output the same as it's input
  44824. */
  44825. export class PassPostProcess extends PostProcess {
  44826. /**
  44827. * Creates the PassPostProcess
  44828. * @param name The name of the effect.
  44829. * @param options The required width/height ratio to downsize to before computing the render pass.
  44830. * @param camera The camera to apply the render pass to.
  44831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44832. * @param engine The engine which the post process will be applied. (default: current engine)
  44833. * @param reusable If the post process can be reused on the same frame. (default: false)
  44834. * @param textureType The type of texture to be used when performing the post processing.
  44835. * @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)
  44836. */
  44837. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44838. }
  44839. /**
  44840. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44841. */
  44842. export class PassCubePostProcess extends PostProcess {
  44843. private _face;
  44844. /**
  44845. * Gets or sets the cube face to display.
  44846. * * 0 is +X
  44847. * * 1 is -X
  44848. * * 2 is +Y
  44849. * * 3 is -Y
  44850. * * 4 is +Z
  44851. * * 5 is -Z
  44852. */
  44853. get face(): number;
  44854. set face(value: number);
  44855. /**
  44856. * Creates the PassCubePostProcess
  44857. * @param name The name of the effect.
  44858. * @param options The required width/height ratio to downsize to before computing the render pass.
  44859. * @param camera The camera to apply the render pass to.
  44860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44861. * @param engine The engine which the post process will be applied. (default: current engine)
  44862. * @param reusable If the post process can be reused on the same frame. (default: false)
  44863. * @param textureType The type of texture to be used when performing the post processing.
  44864. * @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)
  44865. */
  44866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44867. }
  44868. }
  44869. declare module BABYLON {
  44870. /** @hidden */
  44871. export var anaglyphPixelShader: {
  44872. name: string;
  44873. shader: string;
  44874. };
  44875. }
  44876. declare module BABYLON {
  44877. /**
  44878. * Postprocess used to generate anaglyphic rendering
  44879. */
  44880. export class AnaglyphPostProcess extends PostProcess {
  44881. private _passedProcess;
  44882. /**
  44883. * Creates a new AnaglyphPostProcess
  44884. * @param name defines postprocess name
  44885. * @param options defines creation options or target ratio scale
  44886. * @param rigCameras defines cameras using this postprocess
  44887. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44888. * @param engine defines hosting engine
  44889. * @param reusable defines if the postprocess will be reused multiple times per frame
  44890. */
  44891. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44892. }
  44893. }
  44894. declare module BABYLON {
  44895. /**
  44896. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44897. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44898. */
  44899. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44900. /**
  44901. * Creates a new AnaglyphArcRotateCamera
  44902. * @param name defines camera name
  44903. * @param alpha defines alpha angle (in radians)
  44904. * @param beta defines beta angle (in radians)
  44905. * @param radius defines radius
  44906. * @param target defines camera target
  44907. * @param interaxialDistance defines distance between each color axis
  44908. * @param scene defines the hosting scene
  44909. */
  44910. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44911. /**
  44912. * Gets camera class name
  44913. * @returns AnaglyphArcRotateCamera
  44914. */
  44915. getClassName(): string;
  44916. }
  44917. }
  44918. declare module BABYLON {
  44919. /**
  44920. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44921. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44922. */
  44923. export class AnaglyphFreeCamera extends FreeCamera {
  44924. /**
  44925. * Creates a new AnaglyphFreeCamera
  44926. * @param name defines camera name
  44927. * @param position defines initial position
  44928. * @param interaxialDistance defines distance between each color axis
  44929. * @param scene defines the hosting scene
  44930. */
  44931. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44932. /**
  44933. * Gets camera class name
  44934. * @returns AnaglyphFreeCamera
  44935. */
  44936. getClassName(): string;
  44937. }
  44938. }
  44939. declare module BABYLON {
  44940. /**
  44941. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44942. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44943. */
  44944. export class AnaglyphGamepadCamera extends GamepadCamera {
  44945. /**
  44946. * Creates a new AnaglyphGamepadCamera
  44947. * @param name defines camera name
  44948. * @param position defines initial position
  44949. * @param interaxialDistance defines distance between each color axis
  44950. * @param scene defines the hosting scene
  44951. */
  44952. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44953. /**
  44954. * Gets camera class name
  44955. * @returns AnaglyphGamepadCamera
  44956. */
  44957. getClassName(): string;
  44958. }
  44959. }
  44960. declare module BABYLON {
  44961. /**
  44962. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44963. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44964. */
  44965. export class AnaglyphUniversalCamera extends UniversalCamera {
  44966. /**
  44967. * Creates a new AnaglyphUniversalCamera
  44968. * @param name defines camera name
  44969. * @param position defines initial position
  44970. * @param interaxialDistance defines distance between each color axis
  44971. * @param scene defines the hosting scene
  44972. */
  44973. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44974. /**
  44975. * Gets camera class name
  44976. * @returns AnaglyphUniversalCamera
  44977. */
  44978. getClassName(): string;
  44979. }
  44980. }
  44981. declare module BABYLON {
  44982. /**
  44983. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44984. * @see http://doc.babylonjs.com/features/cameras
  44985. */
  44986. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44987. /**
  44988. * Creates a new StereoscopicArcRotateCamera
  44989. * @param name defines camera name
  44990. * @param alpha defines alpha angle (in radians)
  44991. * @param beta defines beta angle (in radians)
  44992. * @param radius defines radius
  44993. * @param target defines camera target
  44994. * @param interaxialDistance defines distance between each color axis
  44995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44996. * @param scene defines the hosting scene
  44997. */
  44998. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44999. /**
  45000. * Gets camera class name
  45001. * @returns StereoscopicArcRotateCamera
  45002. */
  45003. getClassName(): string;
  45004. }
  45005. }
  45006. declare module BABYLON {
  45007. /**
  45008. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45009. * @see http://doc.babylonjs.com/features/cameras
  45010. */
  45011. export class StereoscopicFreeCamera extends FreeCamera {
  45012. /**
  45013. * Creates a new StereoscopicFreeCamera
  45014. * @param name defines camera name
  45015. * @param position defines initial position
  45016. * @param interaxialDistance defines distance between each color axis
  45017. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45018. * @param scene defines the hosting scene
  45019. */
  45020. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45021. /**
  45022. * Gets camera class name
  45023. * @returns StereoscopicFreeCamera
  45024. */
  45025. getClassName(): string;
  45026. }
  45027. }
  45028. declare module BABYLON {
  45029. /**
  45030. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45031. * @see http://doc.babylonjs.com/features/cameras
  45032. */
  45033. export class StereoscopicGamepadCamera extends GamepadCamera {
  45034. /**
  45035. * Creates a new StereoscopicGamepadCamera
  45036. * @param name defines camera name
  45037. * @param position defines initial position
  45038. * @param interaxialDistance defines distance between each color axis
  45039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45040. * @param scene defines the hosting scene
  45041. */
  45042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45043. /**
  45044. * Gets camera class name
  45045. * @returns StereoscopicGamepadCamera
  45046. */
  45047. getClassName(): string;
  45048. }
  45049. }
  45050. declare module BABYLON {
  45051. /**
  45052. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45053. * @see http://doc.babylonjs.com/features/cameras
  45054. */
  45055. export class StereoscopicUniversalCamera extends UniversalCamera {
  45056. /**
  45057. * Creates a new StereoscopicUniversalCamera
  45058. * @param name defines camera name
  45059. * @param position defines initial position
  45060. * @param interaxialDistance defines distance between each color axis
  45061. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45062. * @param scene defines the hosting scene
  45063. */
  45064. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45065. /**
  45066. * Gets camera class name
  45067. * @returns StereoscopicUniversalCamera
  45068. */
  45069. getClassName(): string;
  45070. }
  45071. }
  45072. declare module BABYLON {
  45073. /**
  45074. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45075. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45076. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45077. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45078. */
  45079. export class VirtualJoysticksCamera extends FreeCamera {
  45080. /**
  45081. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45082. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45083. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45084. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45085. * @param name Define the name of the camera in the scene
  45086. * @param position Define the start position of the camera in the scene
  45087. * @param scene Define the scene the camera belongs to
  45088. */
  45089. constructor(name: string, position: Vector3, scene: Scene);
  45090. /**
  45091. * Gets the current object class name.
  45092. * @return the class name
  45093. */
  45094. getClassName(): string;
  45095. }
  45096. }
  45097. declare module BABYLON {
  45098. /**
  45099. * This represents all the required metrics to create a VR camera.
  45100. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45101. */
  45102. export class VRCameraMetrics {
  45103. /**
  45104. * Define the horizontal resolution off the screen.
  45105. */
  45106. hResolution: number;
  45107. /**
  45108. * Define the vertical resolution off the screen.
  45109. */
  45110. vResolution: number;
  45111. /**
  45112. * Define the horizontal screen size.
  45113. */
  45114. hScreenSize: number;
  45115. /**
  45116. * Define the vertical screen size.
  45117. */
  45118. vScreenSize: number;
  45119. /**
  45120. * Define the vertical screen center position.
  45121. */
  45122. vScreenCenter: number;
  45123. /**
  45124. * Define the distance of the eyes to the screen.
  45125. */
  45126. eyeToScreenDistance: number;
  45127. /**
  45128. * Define the distance between both lenses
  45129. */
  45130. lensSeparationDistance: number;
  45131. /**
  45132. * Define the distance between both viewer's eyes.
  45133. */
  45134. interpupillaryDistance: number;
  45135. /**
  45136. * Define the distortion factor of the VR postprocess.
  45137. * Please, touch with care.
  45138. */
  45139. distortionK: number[];
  45140. /**
  45141. * Define the chromatic aberration correction factors for the VR post process.
  45142. */
  45143. chromaAbCorrection: number[];
  45144. /**
  45145. * Define the scale factor of the post process.
  45146. * The smaller the better but the slower.
  45147. */
  45148. postProcessScaleFactor: number;
  45149. /**
  45150. * Define an offset for the lens center.
  45151. */
  45152. lensCenterOffset: number;
  45153. /**
  45154. * Define if the current vr camera should compensate the distortion of the lense or not.
  45155. */
  45156. compensateDistortion: boolean;
  45157. /**
  45158. * Defines if multiview should be enabled when rendering (Default: false)
  45159. */
  45160. multiviewEnabled: boolean;
  45161. /**
  45162. * Gets the rendering aspect ratio based on the provided resolutions.
  45163. */
  45164. get aspectRatio(): number;
  45165. /**
  45166. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45167. */
  45168. get aspectRatioFov(): number;
  45169. /**
  45170. * @hidden
  45171. */
  45172. get leftHMatrix(): Matrix;
  45173. /**
  45174. * @hidden
  45175. */
  45176. get rightHMatrix(): Matrix;
  45177. /**
  45178. * @hidden
  45179. */
  45180. get leftPreViewMatrix(): Matrix;
  45181. /**
  45182. * @hidden
  45183. */
  45184. get rightPreViewMatrix(): Matrix;
  45185. /**
  45186. * Get the default VRMetrics based on the most generic setup.
  45187. * @returns the default vr metrics
  45188. */
  45189. static GetDefault(): VRCameraMetrics;
  45190. }
  45191. }
  45192. declare module BABYLON {
  45193. /** @hidden */
  45194. export var vrDistortionCorrectionPixelShader: {
  45195. name: string;
  45196. shader: string;
  45197. };
  45198. }
  45199. declare module BABYLON {
  45200. /**
  45201. * VRDistortionCorrectionPostProcess used for mobile VR
  45202. */
  45203. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45204. private _isRightEye;
  45205. private _distortionFactors;
  45206. private _postProcessScaleFactor;
  45207. private _lensCenterOffset;
  45208. private _scaleIn;
  45209. private _scaleFactor;
  45210. private _lensCenter;
  45211. /**
  45212. * Initializes the VRDistortionCorrectionPostProcess
  45213. * @param name The name of the effect.
  45214. * @param camera The camera to apply the render pass to.
  45215. * @param isRightEye If this is for the right eye distortion
  45216. * @param vrMetrics All the required metrics for the VR camera
  45217. */
  45218. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45219. }
  45220. }
  45221. declare module BABYLON {
  45222. /**
  45223. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45224. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45225. */
  45226. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45227. /**
  45228. * Creates a new VRDeviceOrientationArcRotateCamera
  45229. * @param name defines camera name
  45230. * @param alpha defines the camera rotation along the logitudinal axis
  45231. * @param beta defines the camera rotation along the latitudinal axis
  45232. * @param radius defines the camera distance from its target
  45233. * @param target defines the camera target
  45234. * @param scene defines the scene the camera belongs to
  45235. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45236. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45237. */
  45238. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45239. /**
  45240. * Gets camera class name
  45241. * @returns VRDeviceOrientationArcRotateCamera
  45242. */
  45243. getClassName(): string;
  45244. }
  45245. }
  45246. declare module BABYLON {
  45247. /**
  45248. * Camera used to simulate VR rendering (based on FreeCamera)
  45249. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45250. */
  45251. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45252. /**
  45253. * Creates a new VRDeviceOrientationFreeCamera
  45254. * @param name defines camera name
  45255. * @param position defines the start position of the camera
  45256. * @param scene defines the scene the camera belongs to
  45257. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45258. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45259. */
  45260. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45261. /**
  45262. * Gets camera class name
  45263. * @returns VRDeviceOrientationFreeCamera
  45264. */
  45265. getClassName(): string;
  45266. }
  45267. }
  45268. declare module BABYLON {
  45269. /**
  45270. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45271. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45272. */
  45273. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45274. /**
  45275. * Creates a new VRDeviceOrientationGamepadCamera
  45276. * @param name defines camera name
  45277. * @param position defines the start position of the camera
  45278. * @param scene defines the scene the camera belongs to
  45279. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45280. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45281. */
  45282. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45283. /**
  45284. * Gets camera class name
  45285. * @returns VRDeviceOrientationGamepadCamera
  45286. */
  45287. getClassName(): string;
  45288. }
  45289. }
  45290. declare module BABYLON {
  45291. /** @hidden */
  45292. export var imageProcessingPixelShader: {
  45293. name: string;
  45294. shader: string;
  45295. };
  45296. }
  45297. declare module BABYLON {
  45298. /**
  45299. * ImageProcessingPostProcess
  45300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45301. */
  45302. export class ImageProcessingPostProcess extends PostProcess {
  45303. /**
  45304. * Default configuration related to image processing available in the PBR Material.
  45305. */
  45306. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45307. /**
  45308. * Gets the image processing configuration used either in this material.
  45309. */
  45310. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45311. /**
  45312. * Sets the Default image processing configuration used either in the this material.
  45313. *
  45314. * If sets to null, the scene one is in use.
  45315. */
  45316. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45317. /**
  45318. * Keep track of the image processing observer to allow dispose and replace.
  45319. */
  45320. private _imageProcessingObserver;
  45321. /**
  45322. * Attaches a new image processing configuration to the PBR Material.
  45323. * @param configuration
  45324. */
  45325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45326. /**
  45327. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45328. */
  45329. get colorCurves(): Nullable<ColorCurves>;
  45330. /**
  45331. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45332. */
  45333. set colorCurves(value: Nullable<ColorCurves>);
  45334. /**
  45335. * Gets wether the color curves effect is enabled.
  45336. */
  45337. get colorCurvesEnabled(): boolean;
  45338. /**
  45339. * Sets wether the color curves effect is enabled.
  45340. */
  45341. set colorCurvesEnabled(value: boolean);
  45342. /**
  45343. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45344. */
  45345. get colorGradingTexture(): Nullable<BaseTexture>;
  45346. /**
  45347. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45348. */
  45349. set colorGradingTexture(value: Nullable<BaseTexture>);
  45350. /**
  45351. * Gets wether the color grading effect is enabled.
  45352. */
  45353. get colorGradingEnabled(): boolean;
  45354. /**
  45355. * Gets wether the color grading effect is enabled.
  45356. */
  45357. set colorGradingEnabled(value: boolean);
  45358. /**
  45359. * Gets exposure used in the effect.
  45360. */
  45361. get exposure(): number;
  45362. /**
  45363. * Sets exposure used in the effect.
  45364. */
  45365. set exposure(value: number);
  45366. /**
  45367. * Gets wether tonemapping is enabled or not.
  45368. */
  45369. get toneMappingEnabled(): boolean;
  45370. /**
  45371. * Sets wether tonemapping is enabled or not
  45372. */
  45373. set toneMappingEnabled(value: boolean);
  45374. /**
  45375. * Gets the type of tone mapping effect.
  45376. */
  45377. get toneMappingType(): number;
  45378. /**
  45379. * Sets the type of tone mapping effect.
  45380. */
  45381. set toneMappingType(value: number);
  45382. /**
  45383. * Gets contrast used in the effect.
  45384. */
  45385. get contrast(): number;
  45386. /**
  45387. * Sets contrast used in the effect.
  45388. */
  45389. set contrast(value: number);
  45390. /**
  45391. * Gets Vignette stretch size.
  45392. */
  45393. get vignetteStretch(): number;
  45394. /**
  45395. * Sets Vignette stretch size.
  45396. */
  45397. set vignetteStretch(value: number);
  45398. /**
  45399. * Gets Vignette centre X Offset.
  45400. */
  45401. get vignetteCentreX(): number;
  45402. /**
  45403. * Sets Vignette centre X Offset.
  45404. */
  45405. set vignetteCentreX(value: number);
  45406. /**
  45407. * Gets Vignette centre Y Offset.
  45408. */
  45409. get vignetteCentreY(): number;
  45410. /**
  45411. * Sets Vignette centre Y Offset.
  45412. */
  45413. set vignetteCentreY(value: number);
  45414. /**
  45415. * Gets Vignette weight or intensity of the vignette effect.
  45416. */
  45417. get vignetteWeight(): number;
  45418. /**
  45419. * Sets Vignette weight or intensity of the vignette effect.
  45420. */
  45421. set vignetteWeight(value: number);
  45422. /**
  45423. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45424. * if vignetteEnabled is set to true.
  45425. */
  45426. get vignetteColor(): Color4;
  45427. /**
  45428. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45429. * if vignetteEnabled is set to true.
  45430. */
  45431. set vignetteColor(value: Color4);
  45432. /**
  45433. * Gets Camera field of view used by the Vignette effect.
  45434. */
  45435. get vignetteCameraFov(): number;
  45436. /**
  45437. * Sets Camera field of view used by the Vignette effect.
  45438. */
  45439. set vignetteCameraFov(value: number);
  45440. /**
  45441. * Gets the vignette blend mode allowing different kind of effect.
  45442. */
  45443. get vignetteBlendMode(): number;
  45444. /**
  45445. * Sets the vignette blend mode allowing different kind of effect.
  45446. */
  45447. set vignetteBlendMode(value: number);
  45448. /**
  45449. * Gets wether the vignette effect is enabled.
  45450. */
  45451. get vignetteEnabled(): boolean;
  45452. /**
  45453. * Sets wether the vignette effect is enabled.
  45454. */
  45455. set vignetteEnabled(value: boolean);
  45456. private _fromLinearSpace;
  45457. /**
  45458. * Gets wether the input of the processing is in Gamma or Linear Space.
  45459. */
  45460. get fromLinearSpace(): boolean;
  45461. /**
  45462. * Sets wether the input of the processing is in Gamma or Linear Space.
  45463. */
  45464. set fromLinearSpace(value: boolean);
  45465. /**
  45466. * Defines cache preventing GC.
  45467. */
  45468. private _defines;
  45469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45470. /**
  45471. * "ImageProcessingPostProcess"
  45472. * @returns "ImageProcessingPostProcess"
  45473. */
  45474. getClassName(): string;
  45475. protected _updateParameters(): void;
  45476. dispose(camera?: Camera): void;
  45477. }
  45478. }
  45479. declare module BABYLON {
  45480. /**
  45481. * Class containing static functions to help procedurally build meshes
  45482. */
  45483. export class GroundBuilder {
  45484. /**
  45485. * Creates a ground mesh
  45486. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45487. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45489. * @param name defines the name of the mesh
  45490. * @param options defines the options used to create the mesh
  45491. * @param scene defines the hosting scene
  45492. * @returns the ground mesh
  45493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45494. */
  45495. static CreateGround(name: string, options: {
  45496. width?: number;
  45497. height?: number;
  45498. subdivisions?: number;
  45499. subdivisionsX?: number;
  45500. subdivisionsY?: number;
  45501. updatable?: boolean;
  45502. }, scene: any): Mesh;
  45503. /**
  45504. * Creates a tiled ground mesh
  45505. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45506. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45507. * * 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
  45508. * * 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
  45509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45510. * @param name defines the name of the mesh
  45511. * @param options defines the options used to create the mesh
  45512. * @param scene defines the hosting scene
  45513. * @returns the tiled ground mesh
  45514. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45515. */
  45516. static CreateTiledGround(name: string, options: {
  45517. xmin: number;
  45518. zmin: number;
  45519. xmax: number;
  45520. zmax: number;
  45521. subdivisions?: {
  45522. w: number;
  45523. h: number;
  45524. };
  45525. precision?: {
  45526. w: number;
  45527. h: number;
  45528. };
  45529. updatable?: boolean;
  45530. }, scene?: Nullable<Scene>): Mesh;
  45531. /**
  45532. * Creates a ground mesh from a height map
  45533. * * The parameter `url` sets the URL of the height map image resource.
  45534. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45535. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45536. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45537. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45538. * * 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.
  45539. * * 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).
  45540. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45542. * @param name defines the name of the mesh
  45543. * @param url defines the url to the height map
  45544. * @param options defines the options used to create the mesh
  45545. * @param scene defines the hosting scene
  45546. * @returns the ground mesh
  45547. * @see https://doc.babylonjs.com/babylon101/height_map
  45548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45549. */
  45550. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45551. width?: number;
  45552. height?: number;
  45553. subdivisions?: number;
  45554. minHeight?: number;
  45555. maxHeight?: number;
  45556. colorFilter?: Color3;
  45557. alphaFilter?: number;
  45558. updatable?: boolean;
  45559. onReady?: (mesh: GroundMesh) => void;
  45560. }, scene?: Nullable<Scene>): GroundMesh;
  45561. }
  45562. }
  45563. declare module BABYLON {
  45564. /**
  45565. * Class containing static functions to help procedurally build meshes
  45566. */
  45567. export class TorusBuilder {
  45568. /**
  45569. * Creates a torus mesh
  45570. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45571. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45572. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45574. * * 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
  45575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45576. * @param name defines the name of the mesh
  45577. * @param options defines the options used to create the mesh
  45578. * @param scene defines the hosting scene
  45579. * @returns the torus mesh
  45580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45581. */
  45582. static CreateTorus(name: string, options: {
  45583. diameter?: number;
  45584. thickness?: number;
  45585. tessellation?: number;
  45586. updatable?: boolean;
  45587. sideOrientation?: number;
  45588. frontUVs?: Vector4;
  45589. backUVs?: Vector4;
  45590. }, scene: any): Mesh;
  45591. }
  45592. }
  45593. declare module BABYLON {
  45594. /**
  45595. * Class containing static functions to help procedurally build meshes
  45596. */
  45597. export class CylinderBuilder {
  45598. /**
  45599. * Creates a cylinder or a cone mesh
  45600. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45601. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45602. * * 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.
  45603. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45604. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45605. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45606. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45607. * * 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).
  45608. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45609. * * 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).
  45610. * * 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
  45611. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45612. * * 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
  45613. * * 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.
  45614. * * If `enclose` is false, a ring surface is one element.
  45615. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45616. * * 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
  45617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45618. * * 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
  45619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45620. * @param name defines the name of the mesh
  45621. * @param options defines the options used to create the mesh
  45622. * @param scene defines the hosting scene
  45623. * @returns the cylinder mesh
  45624. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45625. */
  45626. static CreateCylinder(name: string, options: {
  45627. height?: number;
  45628. diameterTop?: number;
  45629. diameterBottom?: number;
  45630. diameter?: number;
  45631. tessellation?: number;
  45632. subdivisions?: number;
  45633. arc?: number;
  45634. faceColors?: Color4[];
  45635. faceUV?: Vector4[];
  45636. updatable?: boolean;
  45637. hasRings?: boolean;
  45638. enclose?: boolean;
  45639. cap?: number;
  45640. sideOrientation?: number;
  45641. frontUVs?: Vector4;
  45642. backUVs?: Vector4;
  45643. }, scene: any): Mesh;
  45644. }
  45645. }
  45646. declare module BABYLON {
  45647. /**
  45648. * States of the webXR experience
  45649. */
  45650. export enum WebXRState {
  45651. /**
  45652. * Transitioning to being in XR mode
  45653. */
  45654. ENTERING_XR = 0,
  45655. /**
  45656. * Transitioning to non XR mode
  45657. */
  45658. EXITING_XR = 1,
  45659. /**
  45660. * In XR mode and presenting
  45661. */
  45662. IN_XR = 2,
  45663. /**
  45664. * Not entered XR mode
  45665. */
  45666. NOT_IN_XR = 3
  45667. }
  45668. /**
  45669. * Abstraction of the XR render target
  45670. */
  45671. export interface WebXRRenderTarget extends IDisposable {
  45672. /**
  45673. * xrpresent context of the canvas which can be used to display/mirror xr content
  45674. */
  45675. canvasContext: WebGLRenderingContext;
  45676. /**
  45677. * xr layer for the canvas
  45678. */
  45679. xrLayer: Nullable<XRWebGLLayer>;
  45680. /**
  45681. * Initializes the xr layer for the session
  45682. * @param xrSession xr session
  45683. * @returns a promise that will resolve once the XR Layer has been created
  45684. */
  45685. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45686. }
  45687. }
  45688. declare module BABYLON {
  45689. /**
  45690. * COnfiguration object for WebXR output canvas
  45691. */
  45692. export class WebXRManagedOutputCanvasOptions {
  45693. /**
  45694. * An optional canvas in case you wish to create it yourself and provide it here.
  45695. * If not provided, a new canvas will be created
  45696. */
  45697. canvasElement?: HTMLCanvasElement;
  45698. /**
  45699. * Options for this XR Layer output
  45700. */
  45701. canvasOptions?: XRWebGLLayerOptions;
  45702. /**
  45703. * CSS styling for a newly created canvas (if not provided)
  45704. */
  45705. newCanvasCssStyle?: string;
  45706. /**
  45707. * Get the default values of the configuration object
  45708. * @returns default values of this configuration object
  45709. */
  45710. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45711. }
  45712. /**
  45713. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45714. */
  45715. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45716. private _options;
  45717. private _canvas;
  45718. private _engine;
  45719. /**
  45720. * Rendering context of the canvas which can be used to display/mirror xr content
  45721. */
  45722. canvasContext: WebGLRenderingContext;
  45723. /**
  45724. * xr layer for the canvas
  45725. */
  45726. xrLayer: Nullable<XRWebGLLayer>;
  45727. /**
  45728. * Initializes the canvas to be added/removed upon entering/exiting xr
  45729. * @param _xrSessionManager The XR Session manager
  45730. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45731. */
  45732. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45733. /**
  45734. * Disposes of the object
  45735. */
  45736. dispose(): void;
  45737. /**
  45738. * Initializes the xr layer for the session
  45739. * @param xrSession xr session
  45740. * @returns a promise that will resolve once the XR Layer has been created
  45741. */
  45742. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45743. private _addCanvas;
  45744. private _removeCanvas;
  45745. private _setManagedOutputCanvas;
  45746. }
  45747. }
  45748. declare module BABYLON {
  45749. /**
  45750. * Manages an XRSession to work with Babylon's engine
  45751. * @see https://doc.babylonjs.com/how_to/webxr
  45752. */
  45753. export class WebXRSessionManager implements IDisposable {
  45754. /** The scene which the session should be created for */
  45755. scene: Scene;
  45756. private _referenceSpace;
  45757. private _rttProvider;
  45758. private _sessionEnded;
  45759. private _xrNavigator;
  45760. private baseLayer;
  45761. /**
  45762. * The base reference space from which the session started. good if you want to reset your
  45763. * reference space
  45764. */
  45765. baseReferenceSpace: XRReferenceSpace;
  45766. /**
  45767. * Current XR frame
  45768. */
  45769. currentFrame: Nullable<XRFrame>;
  45770. /** WebXR timestamp updated every frame */
  45771. currentTimestamp: number;
  45772. /**
  45773. * Used just in case of a failure to initialize an immersive session.
  45774. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45775. */
  45776. defaultHeightCompensation: number;
  45777. /**
  45778. * Fires every time a new xrFrame arrives which can be used to update the camera
  45779. */
  45780. onXRFrameObservable: Observable<XRFrame>;
  45781. /**
  45782. * Fires when the reference space changed
  45783. */
  45784. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45785. /**
  45786. * Fires when the xr session is ended either by the device or manually done
  45787. */
  45788. onXRSessionEnded: Observable<any>;
  45789. /**
  45790. * Fires when the xr session is ended either by the device or manually done
  45791. */
  45792. onXRSessionInit: Observable<XRSession>;
  45793. /**
  45794. * Underlying xr session
  45795. */
  45796. session: XRSession;
  45797. /**
  45798. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45799. * or get the offset the player is currently at.
  45800. */
  45801. viewerReferenceSpace: XRReferenceSpace;
  45802. /**
  45803. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45804. * @param scene The scene which the session should be created for
  45805. */
  45806. constructor(
  45807. /** The scene which the session should be created for */
  45808. scene: Scene);
  45809. /**
  45810. * The current reference space used in this session. This reference space can constantly change!
  45811. * It is mainly used to offset the camera's position.
  45812. */
  45813. get referenceSpace(): XRReferenceSpace;
  45814. /**
  45815. * Set a new reference space and triggers the observable
  45816. */
  45817. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45818. /**
  45819. * Disposes of the session manager
  45820. */
  45821. dispose(): void;
  45822. /**
  45823. * Stops the xrSession and restores the render loop
  45824. * @returns Promise which resolves after it exits XR
  45825. */
  45826. exitXRAsync(): Promise<void>;
  45827. /**
  45828. * Gets the correct render target texture to be rendered this frame for this eye
  45829. * @param eye the eye for which to get the render target
  45830. * @returns the render target for the specified eye
  45831. */
  45832. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45833. /**
  45834. * Creates a WebXRRenderTarget object for the XR session
  45835. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45836. * @param options optional options to provide when creating a new render target
  45837. * @returns a WebXR render target to which the session can render
  45838. */
  45839. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45840. /**
  45841. * Initializes the manager
  45842. * After initialization enterXR can be called to start an XR session
  45843. * @returns Promise which resolves after it is initialized
  45844. */
  45845. initializeAsync(): Promise<void>;
  45846. /**
  45847. * Initializes an xr session
  45848. * @param xrSessionMode mode to initialize
  45849. * @param xrSessionInit defines optional and required values to pass to the session builder
  45850. * @returns a promise which will resolve once the session has been initialized
  45851. */
  45852. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45853. /**
  45854. * Checks if a session would be supported for the creation options specified
  45855. * @param sessionMode session mode to check if supported eg. immersive-vr
  45856. * @returns A Promise that resolves to true if supported and false if not
  45857. */
  45858. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45859. /**
  45860. * Resets the reference space to the one started the session
  45861. */
  45862. resetReferenceSpace(): void;
  45863. /**
  45864. * Starts rendering to the xr layer
  45865. */
  45866. runXRRenderLoop(): void;
  45867. /**
  45868. * Sets the reference space on the xr session
  45869. * @param referenceSpaceType space to set
  45870. * @returns a promise that will resolve once the reference space has been set
  45871. */
  45872. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45873. /**
  45874. * Updates the render state of the session
  45875. * @param state state to set
  45876. * @returns a promise that resolves once the render state has been updated
  45877. */
  45878. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45879. /**
  45880. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45881. * @param sessionMode defines the session to test
  45882. * @returns a promise with boolean as final value
  45883. */
  45884. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45885. private _createRenderTargetTexture;
  45886. }
  45887. }
  45888. declare module BABYLON {
  45889. /**
  45890. * WebXR Camera which holds the views for the xrSession
  45891. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45892. */
  45893. export class WebXRCamera extends FreeCamera {
  45894. private _xrSessionManager;
  45895. private _firstFrame;
  45896. private _referenceQuaternion;
  45897. private _referencedPosition;
  45898. private _xrInvPositionCache;
  45899. private _xrInvQuaternionCache;
  45900. /**
  45901. * Should position compensation execute on first frame.
  45902. * This is used when copying the position from a native (non XR) camera
  45903. */
  45904. compensateOnFirstFrame: boolean;
  45905. /**
  45906. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45907. * @param name the name of the camera
  45908. * @param scene the scene to add the camera to
  45909. * @param _xrSessionManager a constructed xr session manager
  45910. */
  45911. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45912. /**
  45913. * Return the user's height, unrelated to the current ground.
  45914. * This will be the y position of this camera, when ground level is 0.
  45915. */
  45916. get realWorldHeight(): number;
  45917. /** @hidden */
  45918. _updateForDualEyeDebugging(): void;
  45919. /**
  45920. * Sets this camera's transformation based on a non-vr camera
  45921. * @param otherCamera the non-vr camera to copy the transformation from
  45922. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45923. */
  45924. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45925. /**
  45926. * Gets the current instance class name ("WebXRCamera").
  45927. * @returns the class name
  45928. */
  45929. getClassName(): string;
  45930. /**
  45931. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45932. */
  45933. _getViewMatrix(): Matrix;
  45934. private _updateFromXRSession;
  45935. private _updateNumberOfRigCameras;
  45936. private _updateReferenceSpace;
  45937. private _updateReferenceSpaceOffset;
  45938. }
  45939. }
  45940. declare module BABYLON {
  45941. /**
  45942. * Defining the interface required for a (webxr) feature
  45943. */
  45944. export interface IWebXRFeature extends IDisposable {
  45945. /**
  45946. * Is this feature attached
  45947. */
  45948. attached: boolean;
  45949. /**
  45950. * Should auto-attach be disabled?
  45951. */
  45952. disableAutoAttach: boolean;
  45953. /**
  45954. * Attach the feature to the session
  45955. * Will usually be called by the features manager
  45956. *
  45957. * @param force should attachment be forced (even when already attached)
  45958. * @returns true if successful.
  45959. */
  45960. attach(force?: boolean): boolean;
  45961. /**
  45962. * Detach the feature from the session
  45963. * Will usually be called by the features manager
  45964. *
  45965. * @returns true if successful.
  45966. */
  45967. detach(): boolean;
  45968. }
  45969. /**
  45970. * A list of the currently available features without referencing them
  45971. */
  45972. export class WebXRFeatureName {
  45973. /**
  45974. * The name of the anchor system feature
  45975. */
  45976. static ANCHOR_SYSTEM: string;
  45977. /**
  45978. * The name of the background remover feature
  45979. */
  45980. static BACKGROUND_REMOVER: string;
  45981. /**
  45982. * The name of the hit test feature
  45983. */
  45984. static HIT_TEST: string;
  45985. /**
  45986. * physics impostors for xr controllers feature
  45987. */
  45988. static PHYSICS_CONTROLLERS: string;
  45989. /**
  45990. * The name of the plane detection feature
  45991. */
  45992. static PLANE_DETECTION: string;
  45993. /**
  45994. * The name of the pointer selection feature
  45995. */
  45996. static POINTER_SELECTION: string;
  45997. /**
  45998. * The name of the teleportation feature
  45999. */
  46000. static TELEPORTATION: string;
  46001. }
  46002. /**
  46003. * Defining the constructor of a feature. Used to register the modules.
  46004. */
  46005. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46006. /**
  46007. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46008. * It is mainly used in AR sessions.
  46009. *
  46010. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46011. */
  46012. export class WebXRFeaturesManager implements IDisposable {
  46013. private _xrSessionManager;
  46014. private static readonly _AvailableFeatures;
  46015. private _features;
  46016. /**
  46017. * constructs a new features manages.
  46018. *
  46019. * @param _xrSessionManager an instance of WebXRSessionManager
  46020. */
  46021. constructor(_xrSessionManager: WebXRSessionManager);
  46022. /**
  46023. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46024. * Mainly used internally.
  46025. *
  46026. * @param featureName the name of the feature to register
  46027. * @param constructorFunction the function used to construct the module
  46028. * @param version the (babylon) version of the module
  46029. * @param stable is that a stable version of this module
  46030. */
  46031. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46032. /**
  46033. * Returns a constructor of a specific feature.
  46034. *
  46035. * @param featureName the name of the feature to construct
  46036. * @param version the version of the feature to load
  46037. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46038. * @param options optional options provided to the module.
  46039. * @returns a function that, when called, will return a new instance of this feature
  46040. */
  46041. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46042. /**
  46043. * Can be used to return the list of features currently registered
  46044. *
  46045. * @returns an Array of available features
  46046. */
  46047. static GetAvailableFeatures(): string[];
  46048. /**
  46049. * Gets the versions available for a specific feature
  46050. * @param featureName the name of the feature
  46051. * @returns an array with the available versions
  46052. */
  46053. static GetAvailableVersions(featureName: string): string[];
  46054. /**
  46055. * Return the latest unstable version of this feature
  46056. * @param featureName the name of the feature to search
  46057. * @returns the version number. if not found will return -1
  46058. */
  46059. static GetLatestVersionOfFeature(featureName: string): number;
  46060. /**
  46061. * Return the latest stable version of this feature
  46062. * @param featureName the name of the feature to search
  46063. * @returns the version number. if not found will return -1
  46064. */
  46065. static GetStableVersionOfFeature(featureName: string): number;
  46066. /**
  46067. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46068. * Can be used during a session to start a feature
  46069. * @param featureName the name of feature to attach
  46070. */
  46071. attachFeature(featureName: string): void;
  46072. /**
  46073. * Can be used inside a session or when the session ends to detach a specific feature
  46074. * @param featureName the name of the feature to detach
  46075. */
  46076. detachFeature(featureName: string): void;
  46077. /**
  46078. * Used to disable an already-enabled feature
  46079. * The feature will be disposed and will be recreated once enabled.
  46080. * @param featureName the feature to disable
  46081. * @returns true if disable was successful
  46082. */
  46083. disableFeature(featureName: string | {
  46084. Name: string;
  46085. }): boolean;
  46086. /**
  46087. * dispose this features manager
  46088. */
  46089. dispose(): void;
  46090. /**
  46091. * 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.
  46092. * 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.
  46093. *
  46094. * @param featureName the name of the feature to load or the class of the feature
  46095. * @param version optional version to load. if not provided the latest version will be enabled
  46096. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46097. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46098. * @returns a new constructed feature or throws an error if feature not found.
  46099. */
  46100. enableFeature(featureName: string | {
  46101. Name: string;
  46102. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46103. /**
  46104. * get the implementation of an enabled feature.
  46105. * @param featureName the name of the feature to load
  46106. * @returns the feature class, if found
  46107. */
  46108. getEnabledFeature(featureName: string): IWebXRFeature;
  46109. /**
  46110. * Get the list of enabled features
  46111. * @returns an array of enabled features
  46112. */
  46113. getEnabledFeatures(): string[];
  46114. }
  46115. }
  46116. declare module BABYLON {
  46117. /**
  46118. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46119. * @see https://doc.babylonjs.com/how_to/webxr
  46120. */
  46121. export class WebXRExperienceHelper implements IDisposable {
  46122. private scene;
  46123. private _nonVRCamera;
  46124. private _originalSceneAutoClear;
  46125. private _supported;
  46126. /**
  46127. * Camera used to render xr content
  46128. */
  46129. camera: WebXRCamera;
  46130. /** A features manager for this xr session */
  46131. featuresManager: WebXRFeaturesManager;
  46132. /**
  46133. * Observers registered here will be triggered after the camera's initial transformation is set
  46134. * This can be used to set a different ground level or an extra rotation.
  46135. *
  46136. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46137. * to the position set after this observable is done executing.
  46138. */
  46139. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46140. /**
  46141. * Fires when the state of the experience helper has changed
  46142. */
  46143. onStateChangedObservable: Observable<WebXRState>;
  46144. /** Session manager used to keep track of xr session */
  46145. sessionManager: WebXRSessionManager;
  46146. /**
  46147. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46148. */
  46149. state: WebXRState;
  46150. /**
  46151. * Creates a WebXRExperienceHelper
  46152. * @param scene The scene the helper should be created in
  46153. */
  46154. private constructor();
  46155. /**
  46156. * Creates the experience helper
  46157. * @param scene the scene to attach the experience helper to
  46158. * @returns a promise for the experience helper
  46159. */
  46160. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46161. /**
  46162. * Disposes of the experience helper
  46163. */
  46164. dispose(): void;
  46165. /**
  46166. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46167. * @param sessionMode options for the XR session
  46168. * @param referenceSpaceType frame of reference of the XR session
  46169. * @param renderTarget the output canvas that will be used to enter XR mode
  46170. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46171. * @returns promise that resolves after xr mode has entered
  46172. */
  46173. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46174. /**
  46175. * Exits XR mode and returns the scene to its original state
  46176. * @returns promise that resolves after xr mode has exited
  46177. */
  46178. exitXRAsync(): Promise<void>;
  46179. private _nonXRToXRCamera;
  46180. private _setState;
  46181. }
  46182. }
  46183. declare module BABYLON {
  46184. /**
  46185. * X-Y values for axes in WebXR
  46186. */
  46187. export interface IWebXRMotionControllerAxesValue {
  46188. /**
  46189. * The value of the x axis
  46190. */
  46191. x: number;
  46192. /**
  46193. * The value of the y-axis
  46194. */
  46195. y: number;
  46196. }
  46197. /**
  46198. * changed / previous values for the values of this component
  46199. */
  46200. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46201. /**
  46202. * current (this frame) value
  46203. */
  46204. current: T;
  46205. /**
  46206. * previous (last change) value
  46207. */
  46208. previous: T;
  46209. }
  46210. /**
  46211. * Represents changes in the component between current frame and last values recorded
  46212. */
  46213. export interface IWebXRMotionControllerComponentChanges {
  46214. /**
  46215. * will be populated with previous and current values if axes changed
  46216. */
  46217. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46218. /**
  46219. * will be populated with previous and current values if pressed changed
  46220. */
  46221. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46222. /**
  46223. * will be populated with previous and current values if touched changed
  46224. */
  46225. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46226. /**
  46227. * will be populated with previous and current values if value changed
  46228. */
  46229. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46230. }
  46231. /**
  46232. * This class represents a single component (for example button or thumbstick) of a motion controller
  46233. */
  46234. export class WebXRControllerComponent implements IDisposable {
  46235. /**
  46236. * the id of this component
  46237. */
  46238. id: string;
  46239. /**
  46240. * the type of the component
  46241. */
  46242. type: MotionControllerComponentType;
  46243. private _buttonIndex;
  46244. private _axesIndices;
  46245. private _axes;
  46246. private _changes;
  46247. private _currentValue;
  46248. private _hasChanges;
  46249. private _pressed;
  46250. private _touched;
  46251. /**
  46252. * button component type
  46253. */
  46254. static BUTTON_TYPE: MotionControllerComponentType;
  46255. /**
  46256. * squeeze component type
  46257. */
  46258. static SQUEEZE_TYPE: MotionControllerComponentType;
  46259. /**
  46260. * Thumbstick component type
  46261. */
  46262. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46263. /**
  46264. * Touchpad component type
  46265. */
  46266. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46267. /**
  46268. * trigger component type
  46269. */
  46270. static TRIGGER_TYPE: MotionControllerComponentType;
  46271. /**
  46272. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46273. * the axes data changes
  46274. */
  46275. onAxisValueChangedObservable: Observable<{
  46276. x: number;
  46277. y: number;
  46278. }>;
  46279. /**
  46280. * Observers registered here will be triggered when the state of a button changes
  46281. * State change is either pressed / touched / value
  46282. */
  46283. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46284. /**
  46285. * Creates a new component for a motion controller.
  46286. * It is created by the motion controller itself
  46287. *
  46288. * @param id the id of this component
  46289. * @param type the type of the component
  46290. * @param _buttonIndex index in the buttons array of the gamepad
  46291. * @param _axesIndices indices of the values in the axes array of the gamepad
  46292. */
  46293. constructor(
  46294. /**
  46295. * the id of this component
  46296. */
  46297. id: string,
  46298. /**
  46299. * the type of the component
  46300. */
  46301. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46302. /**
  46303. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46304. */
  46305. get axes(): IWebXRMotionControllerAxesValue;
  46306. /**
  46307. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46308. */
  46309. get changes(): IWebXRMotionControllerComponentChanges;
  46310. /**
  46311. * Return whether or not the component changed the last frame
  46312. */
  46313. get hasChanges(): boolean;
  46314. /**
  46315. * is the button currently pressed
  46316. */
  46317. get pressed(): boolean;
  46318. /**
  46319. * is the button currently touched
  46320. */
  46321. get touched(): boolean;
  46322. /**
  46323. * Get the current value of this component
  46324. */
  46325. get value(): number;
  46326. /**
  46327. * Dispose this component
  46328. */
  46329. dispose(): void;
  46330. /**
  46331. * Are there axes correlating to this component
  46332. * @return true is axes data is available
  46333. */
  46334. isAxes(): boolean;
  46335. /**
  46336. * Is this component a button (hence - pressable)
  46337. * @returns true if can be pressed
  46338. */
  46339. isButton(): boolean;
  46340. /**
  46341. * update this component using the gamepad object it is in. Called on every frame
  46342. * @param nativeController the native gamepad controller object
  46343. */
  46344. update(nativeController: IMinimalMotionControllerObject): void;
  46345. }
  46346. }
  46347. declare module BABYLON {
  46348. /**
  46349. * Class used to represent data loading progression
  46350. */
  46351. export class SceneLoaderProgressEvent {
  46352. /** defines if data length to load can be evaluated */
  46353. readonly lengthComputable: boolean;
  46354. /** defines the loaded data length */
  46355. readonly loaded: number;
  46356. /** defines the data length to load */
  46357. readonly total: number;
  46358. /**
  46359. * Create a new progress event
  46360. * @param lengthComputable defines if data length to load can be evaluated
  46361. * @param loaded defines the loaded data length
  46362. * @param total defines the data length to load
  46363. */
  46364. constructor(
  46365. /** defines if data length to load can be evaluated */
  46366. lengthComputable: boolean,
  46367. /** defines the loaded data length */
  46368. loaded: number,
  46369. /** defines the data length to load */
  46370. total: number);
  46371. /**
  46372. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46373. * @param event defines the source event
  46374. * @returns a new SceneLoaderProgressEvent
  46375. */
  46376. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46377. }
  46378. /**
  46379. * Interface used by SceneLoader plugins to define supported file extensions
  46380. */
  46381. export interface ISceneLoaderPluginExtensions {
  46382. /**
  46383. * Defines the list of supported extensions
  46384. */
  46385. [extension: string]: {
  46386. isBinary: boolean;
  46387. };
  46388. }
  46389. /**
  46390. * Interface used by SceneLoader plugin factory
  46391. */
  46392. export interface ISceneLoaderPluginFactory {
  46393. /**
  46394. * Defines the name of the factory
  46395. */
  46396. name: string;
  46397. /**
  46398. * Function called to create a new plugin
  46399. * @return the new plugin
  46400. */
  46401. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46402. /**
  46403. * The callback that returns true if the data can be directly loaded.
  46404. * @param data string containing the file data
  46405. * @returns if the data can be loaded directly
  46406. */
  46407. canDirectLoad?(data: string): boolean;
  46408. }
  46409. /**
  46410. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46411. */
  46412. export interface ISceneLoaderPluginBase {
  46413. /**
  46414. * The friendly name of this plugin.
  46415. */
  46416. name: string;
  46417. /**
  46418. * The file extensions supported by this plugin.
  46419. */
  46420. extensions: string | ISceneLoaderPluginExtensions;
  46421. /**
  46422. * The callback called when loading from a url.
  46423. * @param scene scene loading this url
  46424. * @param url url to load
  46425. * @param onSuccess callback called when the file successfully loads
  46426. * @param onProgress callback called while file is loading (if the server supports this mode)
  46427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46428. * @param onError callback called when the file fails to load
  46429. * @returns a file request object
  46430. */
  46431. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46432. /**
  46433. * The callback called when loading from a file object.
  46434. * @param scene scene loading this file
  46435. * @param file defines the file to load
  46436. * @param onSuccess defines the callback to call when data is loaded
  46437. * @param onProgress defines the callback to call during loading process
  46438. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46439. * @param onError defines the callback to call when an error occurs
  46440. * @returns a file request object
  46441. */
  46442. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46443. /**
  46444. * The callback that returns true if the data can be directly loaded.
  46445. * @param data string containing the file data
  46446. * @returns if the data can be loaded directly
  46447. */
  46448. canDirectLoad?(data: string): boolean;
  46449. /**
  46450. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46451. * @param scene scene loading this data
  46452. * @param data string containing the data
  46453. * @returns data to pass to the plugin
  46454. */
  46455. directLoad?(scene: Scene, data: string): any;
  46456. /**
  46457. * The callback that allows custom handling of the root url based on the response url.
  46458. * @param rootUrl the original root url
  46459. * @param responseURL the response url if available
  46460. * @returns the new root url
  46461. */
  46462. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46463. }
  46464. /**
  46465. * Interface used to define a SceneLoader plugin
  46466. */
  46467. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46468. /**
  46469. * Import meshes into a scene.
  46470. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46471. * @param scene The scene to import into
  46472. * @param data The data to import
  46473. * @param rootUrl The root url for scene and resources
  46474. * @param meshes The meshes array to import into
  46475. * @param particleSystems The particle systems array to import into
  46476. * @param skeletons The skeletons array to import into
  46477. * @param onError The callback when import fails
  46478. * @returns True if successful or false otherwise
  46479. */
  46480. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46481. /**
  46482. * Load into a scene.
  46483. * @param scene The scene to load into
  46484. * @param data The data to import
  46485. * @param rootUrl The root url for scene and resources
  46486. * @param onError The callback when import fails
  46487. * @returns True if successful or false otherwise
  46488. */
  46489. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46490. /**
  46491. * Load into an asset container.
  46492. * @param scene The scene to load into
  46493. * @param data The data to import
  46494. * @param rootUrl The root url for scene and resources
  46495. * @param onError The callback when import fails
  46496. * @returns The loaded asset container
  46497. */
  46498. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46499. }
  46500. /**
  46501. * Interface used to define an async SceneLoader plugin
  46502. */
  46503. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46504. /**
  46505. * Import meshes into a scene.
  46506. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46507. * @param scene The scene to import into
  46508. * @param data The data to import
  46509. * @param rootUrl The root url for scene and resources
  46510. * @param onProgress The callback when the load progresses
  46511. * @param fileName Defines the name of the file to load
  46512. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46513. */
  46514. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46515. meshes: AbstractMesh[];
  46516. particleSystems: IParticleSystem[];
  46517. skeletons: Skeleton[];
  46518. animationGroups: AnimationGroup[];
  46519. }>;
  46520. /**
  46521. * Load into a scene.
  46522. * @param scene The scene to load into
  46523. * @param data The data to import
  46524. * @param rootUrl The root url for scene and resources
  46525. * @param onProgress The callback when the load progresses
  46526. * @param fileName Defines the name of the file to load
  46527. * @returns Nothing
  46528. */
  46529. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46530. /**
  46531. * Load into an asset container.
  46532. * @param scene The scene to load into
  46533. * @param data The data to import
  46534. * @param rootUrl The root url for scene and resources
  46535. * @param onProgress The callback when the load progresses
  46536. * @param fileName Defines the name of the file to load
  46537. * @returns The loaded asset container
  46538. */
  46539. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46540. }
  46541. /**
  46542. * Mode that determines how to handle old animation groups before loading new ones.
  46543. */
  46544. export enum SceneLoaderAnimationGroupLoadingMode {
  46545. /**
  46546. * Reset all old animations to initial state then dispose them.
  46547. */
  46548. Clean = 0,
  46549. /**
  46550. * Stop all old animations.
  46551. */
  46552. Stop = 1,
  46553. /**
  46554. * Restart old animations from first frame.
  46555. */
  46556. Sync = 2,
  46557. /**
  46558. * Old animations remains untouched.
  46559. */
  46560. NoSync = 3
  46561. }
  46562. /**
  46563. * Class used to load scene from various file formats using registered plugins
  46564. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46565. */
  46566. export class SceneLoader {
  46567. /**
  46568. * No logging while loading
  46569. */
  46570. static readonly NO_LOGGING: number;
  46571. /**
  46572. * Minimal logging while loading
  46573. */
  46574. static readonly MINIMAL_LOGGING: number;
  46575. /**
  46576. * Summary logging while loading
  46577. */
  46578. static readonly SUMMARY_LOGGING: number;
  46579. /**
  46580. * Detailled logging while loading
  46581. */
  46582. static readonly DETAILED_LOGGING: number;
  46583. /**
  46584. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46585. */
  46586. static get ForceFullSceneLoadingForIncremental(): boolean;
  46587. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46588. /**
  46589. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46590. */
  46591. static get ShowLoadingScreen(): boolean;
  46592. static set ShowLoadingScreen(value: boolean);
  46593. /**
  46594. * Defines the current logging level (while loading the scene)
  46595. * @ignorenaming
  46596. */
  46597. static get loggingLevel(): number;
  46598. static set loggingLevel(value: number);
  46599. /**
  46600. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46601. */
  46602. static get CleanBoneMatrixWeights(): boolean;
  46603. static set CleanBoneMatrixWeights(value: boolean);
  46604. /**
  46605. * Event raised when a plugin is used to load a scene
  46606. */
  46607. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46608. private static _registeredPlugins;
  46609. private static _getDefaultPlugin;
  46610. private static _getPluginForExtension;
  46611. private static _getPluginForDirectLoad;
  46612. private static _getPluginForFilename;
  46613. private static _getDirectLoad;
  46614. private static _loadData;
  46615. private static _getFileInfo;
  46616. /**
  46617. * Gets a plugin that can load the given extension
  46618. * @param extension defines the extension to load
  46619. * @returns a plugin or null if none works
  46620. */
  46621. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46622. /**
  46623. * Gets a boolean indicating that the given extension can be loaded
  46624. * @param extension defines the extension to load
  46625. * @returns true if the extension is supported
  46626. */
  46627. static IsPluginForExtensionAvailable(extension: string): boolean;
  46628. /**
  46629. * Adds a new plugin to the list of registered plugins
  46630. * @param plugin defines the plugin to add
  46631. */
  46632. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46633. /**
  46634. * Import meshes into a scene
  46635. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46636. * @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)
  46637. * @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)
  46638. * @param scene the instance of BABYLON.Scene to append to
  46639. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46640. * @param onProgress a callback with a progress event for each file being loaded
  46641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46642. * @param pluginExtension the extension used to determine the plugin
  46643. * @returns The loaded plugin
  46644. */
  46645. 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>;
  46646. /**
  46647. * Import meshes into a scene
  46648. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46649. * @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)
  46650. * @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)
  46651. * @param scene the instance of BABYLON.Scene to append to
  46652. * @param onProgress a callback with a progress event for each file being loaded
  46653. * @param pluginExtension the extension used to determine the plugin
  46654. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46655. */
  46656. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46657. meshes: AbstractMesh[];
  46658. particleSystems: IParticleSystem[];
  46659. skeletons: Skeleton[];
  46660. animationGroups: AnimationGroup[];
  46661. }>;
  46662. /**
  46663. * Load a scene
  46664. * @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)
  46665. * @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)
  46666. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46667. * @param onSuccess a callback with the scene when import succeeds
  46668. * @param onProgress a callback with a progress event for each file being loaded
  46669. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46670. * @param pluginExtension the extension used to determine the plugin
  46671. * @returns The loaded plugin
  46672. */
  46673. 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>;
  46674. /**
  46675. * Load a scene
  46676. * @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)
  46677. * @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)
  46678. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46679. * @param onProgress a callback with a progress event for each file being loaded
  46680. * @param pluginExtension the extension used to determine the plugin
  46681. * @returns The loaded scene
  46682. */
  46683. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46684. /**
  46685. * Append a scene
  46686. * @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)
  46687. * @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)
  46688. * @param scene is the instance of BABYLON.Scene to append to
  46689. * @param onSuccess a callback with the scene when import succeeds
  46690. * @param onProgress a callback with a progress event for each file being loaded
  46691. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46692. * @param pluginExtension the extension used to determine the plugin
  46693. * @returns The loaded plugin
  46694. */
  46695. 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>;
  46696. /**
  46697. * Append a scene
  46698. * @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)
  46699. * @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)
  46700. * @param scene is the instance of BABYLON.Scene to append to
  46701. * @param onProgress a callback with a progress event for each file being loaded
  46702. * @param pluginExtension the extension used to determine the plugin
  46703. * @returns The given scene
  46704. */
  46705. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46706. /**
  46707. * Load a scene into an asset container
  46708. * @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)
  46709. * @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)
  46710. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46711. * @param onSuccess a callback with the scene when import succeeds
  46712. * @param onProgress a callback with a progress event for each file being loaded
  46713. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46714. * @param pluginExtension the extension used to determine the plugin
  46715. * @returns The loaded plugin
  46716. */
  46717. 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>;
  46718. /**
  46719. * Load a scene into an asset container
  46720. * @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)
  46721. * @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)
  46722. * @param scene is the instance of Scene to append to
  46723. * @param onProgress a callback with a progress event for each file being loaded
  46724. * @param pluginExtension the extension used to determine the plugin
  46725. * @returns The loaded asset container
  46726. */
  46727. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46728. /**
  46729. * Import animations from a file into a scene
  46730. * @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)
  46731. * @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)
  46732. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46733. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46734. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46735. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46736. * @param onSuccess a callback with the scene when import succeeds
  46737. * @param onProgress a callback with a progress event for each file being loaded
  46738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46739. */
  46740. 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;
  46741. /**
  46742. * Import animations from a file into a scene
  46743. * @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)
  46744. * @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)
  46745. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46746. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46747. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46748. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46749. * @param onSuccess a callback with the scene when import succeeds
  46750. * @param onProgress a callback with a progress event for each file being loaded
  46751. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46752. * @returns the updated scene with imported animations
  46753. */
  46754. 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>;
  46755. }
  46756. }
  46757. declare module BABYLON {
  46758. /**
  46759. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46760. */
  46761. export type MotionControllerHandedness = "none" | "left" | "right";
  46762. /**
  46763. * The type of components available in motion controllers.
  46764. * This is not the name of the component.
  46765. */
  46766. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46767. /**
  46768. * The state of a controller component
  46769. */
  46770. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46771. /**
  46772. * The schema of motion controller layout.
  46773. * No object will be initialized using this interface
  46774. * This is used just to define the profile.
  46775. */
  46776. export interface IMotionControllerLayout {
  46777. /**
  46778. * Path to load the assets. Usually relative to the base path
  46779. */
  46780. assetPath: string;
  46781. /**
  46782. * Available components (unsorted)
  46783. */
  46784. components: {
  46785. /**
  46786. * A map of component Ids
  46787. */
  46788. [componentId: string]: {
  46789. /**
  46790. * The type of input the component outputs
  46791. */
  46792. type: MotionControllerComponentType;
  46793. /**
  46794. * The indices of this component in the gamepad object
  46795. */
  46796. gamepadIndices: {
  46797. /**
  46798. * Index of button
  46799. */
  46800. button?: number;
  46801. /**
  46802. * If available, index of x-axis
  46803. */
  46804. xAxis?: number;
  46805. /**
  46806. * If available, index of y-axis
  46807. */
  46808. yAxis?: number;
  46809. };
  46810. /**
  46811. * The mesh's root node name
  46812. */
  46813. rootNodeName: string;
  46814. /**
  46815. * Animation definitions for this model
  46816. */
  46817. visualResponses: {
  46818. [stateKey: string]: {
  46819. /**
  46820. * What property will be animated
  46821. */
  46822. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46823. /**
  46824. * What states influence this visual response
  46825. */
  46826. states: MotionControllerComponentStateType[];
  46827. /**
  46828. * Type of animation - movement or visibility
  46829. */
  46830. valueNodeProperty: "transform" | "visibility";
  46831. /**
  46832. * Base node name to move. Its position will be calculated according to the min and max nodes
  46833. */
  46834. valueNodeName?: string;
  46835. /**
  46836. * Minimum movement node
  46837. */
  46838. minNodeName?: string;
  46839. /**
  46840. * Max movement node
  46841. */
  46842. maxNodeName?: string;
  46843. };
  46844. };
  46845. /**
  46846. * If touch enabled, what is the name of node to display user feedback
  46847. */
  46848. touchPointNodeName?: string;
  46849. };
  46850. };
  46851. /**
  46852. * Is it xr standard mapping or not
  46853. */
  46854. gamepadMapping: "" | "xr-standard";
  46855. /**
  46856. * Base root node of this entire model
  46857. */
  46858. rootNodeName: string;
  46859. /**
  46860. * Defines the main button component id
  46861. */
  46862. selectComponentId: string;
  46863. }
  46864. /**
  46865. * A definition for the layout map in the input profile
  46866. */
  46867. export interface IMotionControllerLayoutMap {
  46868. /**
  46869. * Layouts with handedness type as a key
  46870. */
  46871. [handedness: string]: IMotionControllerLayout;
  46872. }
  46873. /**
  46874. * The XR Input profile schema
  46875. * Profiles can be found here:
  46876. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46877. */
  46878. export interface IMotionControllerProfile {
  46879. /**
  46880. * fallback profiles for this profileId
  46881. */
  46882. fallbackProfileIds: string[];
  46883. /**
  46884. * The layout map, with handedness as key
  46885. */
  46886. layouts: IMotionControllerLayoutMap;
  46887. /**
  46888. * The id of this profile
  46889. * correlates to the profile(s) in the xrInput.profiles array
  46890. */
  46891. profileId: string;
  46892. }
  46893. /**
  46894. * A helper-interface for the 3 meshes needed for controller button animation
  46895. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46896. */
  46897. export interface IMotionControllerButtonMeshMap {
  46898. /**
  46899. * the mesh that defines the pressed value mesh position.
  46900. * This is used to find the max-position of this button
  46901. */
  46902. pressedMesh: AbstractMesh;
  46903. /**
  46904. * the mesh that defines the unpressed value mesh position.
  46905. * This is used to find the min (or initial) position of this button
  46906. */
  46907. unpressedMesh: AbstractMesh;
  46908. /**
  46909. * The mesh that will be changed when value changes
  46910. */
  46911. valueMesh: AbstractMesh;
  46912. }
  46913. /**
  46914. * A helper-interface for the 3 meshes needed for controller axis animation.
  46915. * This will be expanded when touchpad animations are fully supported
  46916. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46917. */
  46918. export interface IMotionControllerMeshMap {
  46919. /**
  46920. * the mesh that defines the maximum value mesh position.
  46921. */
  46922. maxMesh?: AbstractMesh;
  46923. /**
  46924. * the mesh that defines the minimum value mesh position.
  46925. */
  46926. minMesh?: AbstractMesh;
  46927. /**
  46928. * The mesh that will be changed when axis value changes
  46929. */
  46930. valueMesh: AbstractMesh;
  46931. }
  46932. /**
  46933. * The elements needed for change-detection of the gamepad objects in motion controllers
  46934. */
  46935. export interface IMinimalMotionControllerObject {
  46936. /**
  46937. * Available axes of this controller
  46938. */
  46939. axes: number[];
  46940. /**
  46941. * An array of available buttons
  46942. */
  46943. buttons: Array<{
  46944. /**
  46945. * Value of the button/trigger
  46946. */
  46947. value: number;
  46948. /**
  46949. * If the button/trigger is currently touched
  46950. */
  46951. touched: boolean;
  46952. /**
  46953. * If the button/trigger is currently pressed
  46954. */
  46955. pressed: boolean;
  46956. }>;
  46957. /**
  46958. * EXPERIMENTAL haptic support.
  46959. */
  46960. hapticActuators?: Array<{
  46961. pulse: (value: number, duration: number) => Promise<boolean>;
  46962. }>;
  46963. }
  46964. /**
  46965. * An Abstract Motion controller
  46966. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46967. * Each component has an observable to check for changes in value and state
  46968. */
  46969. export abstract class WebXRAbstractMotionController implements IDisposable {
  46970. protected scene: Scene;
  46971. protected layout: IMotionControllerLayout;
  46972. /**
  46973. * The gamepad object correlating to this controller
  46974. */
  46975. gamepadObject: IMinimalMotionControllerObject;
  46976. /**
  46977. * handedness (left/right/none) of this controller
  46978. */
  46979. handedness: MotionControllerHandedness;
  46980. private _initComponent;
  46981. private _modelReady;
  46982. /**
  46983. * A map of components (WebXRControllerComponent) in this motion controller
  46984. * Components have a ComponentType and can also have both button and axis definitions
  46985. */
  46986. readonly components: {
  46987. [id: string]: WebXRControllerComponent;
  46988. };
  46989. /**
  46990. * Disable the model's animation. Can be set at any time.
  46991. */
  46992. disableAnimation: boolean;
  46993. /**
  46994. * Observers registered here will be triggered when the model of this controller is done loading
  46995. */
  46996. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46997. /**
  46998. * The profile id of this motion controller
  46999. */
  47000. abstract profileId: string;
  47001. /**
  47002. * The root mesh of the model. It is null if the model was not yet initialized
  47003. */
  47004. rootMesh: Nullable<AbstractMesh>;
  47005. /**
  47006. * constructs a new abstract motion controller
  47007. * @param scene the scene to which the model of the controller will be added
  47008. * @param layout The profile layout to load
  47009. * @param gamepadObject The gamepad object correlating to this controller
  47010. * @param handedness handedness (left/right/none) of this controller
  47011. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47012. */
  47013. constructor(scene: Scene, layout: IMotionControllerLayout,
  47014. /**
  47015. * The gamepad object correlating to this controller
  47016. */
  47017. gamepadObject: IMinimalMotionControllerObject,
  47018. /**
  47019. * handedness (left/right/none) of this controller
  47020. */
  47021. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47022. /**
  47023. * Dispose this controller, the model mesh and all its components
  47024. */
  47025. dispose(): void;
  47026. /**
  47027. * Returns all components of specific type
  47028. * @param type the type to search for
  47029. * @return an array of components with this type
  47030. */
  47031. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47032. /**
  47033. * get a component based an its component id as defined in layout.components
  47034. * @param id the id of the component
  47035. * @returns the component correlates to the id or undefined if not found
  47036. */
  47037. getComponent(id: string): WebXRControllerComponent;
  47038. /**
  47039. * Get the list of components available in this motion controller
  47040. * @returns an array of strings correlating to available components
  47041. */
  47042. getComponentIds(): string[];
  47043. /**
  47044. * Get the first component of specific type
  47045. * @param type type of component to find
  47046. * @return a controller component or null if not found
  47047. */
  47048. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47049. /**
  47050. * Get the main (Select) component of this controller as defined in the layout
  47051. * @returns the main component of this controller
  47052. */
  47053. getMainComponent(): WebXRControllerComponent;
  47054. /**
  47055. * Loads the model correlating to this controller
  47056. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47057. * @returns A promise fulfilled with the result of the model loading
  47058. */
  47059. loadModel(): Promise<boolean>;
  47060. /**
  47061. * Update this model using the current XRFrame
  47062. * @param xrFrame the current xr frame to use and update the model
  47063. */
  47064. updateFromXRFrame(xrFrame: XRFrame): void;
  47065. /**
  47066. * Backwards compatibility due to a deeply-integrated typo
  47067. */
  47068. get handness(): XREye;
  47069. /**
  47070. * Pulse (vibrate) this controller
  47071. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47072. * Consecutive calls to this function will cancel the last pulse call
  47073. *
  47074. * @param value the strength of the pulse in 0.0...1.0 range
  47075. * @param duration Duration of the pulse in milliseconds
  47076. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47077. * @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
  47078. */
  47079. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47080. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47081. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47082. /**
  47083. * Moves the axis on the controller mesh based on its current state
  47084. * @param axis the index of the axis
  47085. * @param axisValue the value of the axis which determines the meshes new position
  47086. * @hidden
  47087. */
  47088. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47089. /**
  47090. * Update the model itself with the current frame data
  47091. * @param xrFrame the frame to use for updating the model mesh
  47092. */
  47093. protected updateModel(xrFrame: XRFrame): void;
  47094. /**
  47095. * Get the filename and path for this controller's model
  47096. * @returns a map of filename and path
  47097. */
  47098. protected abstract _getFilenameAndPath(): {
  47099. filename: string;
  47100. path: string;
  47101. };
  47102. /**
  47103. * This function is called before the mesh is loaded. It checks for loading constraints.
  47104. * For example, this function can check if the GLB loader is available
  47105. * If this function returns false, the generic controller will be loaded instead
  47106. * @returns Is the client ready to load the mesh
  47107. */
  47108. protected abstract _getModelLoadingConstraints(): boolean;
  47109. /**
  47110. * This function will be called after the model was successfully loaded and can be used
  47111. * for mesh transformations before it is available for the user
  47112. * @param meshes the loaded meshes
  47113. */
  47114. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47115. /**
  47116. * Set the root mesh for this controller. Important for the WebXR controller class
  47117. * @param meshes the loaded meshes
  47118. */
  47119. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47120. /**
  47121. * A function executed each frame that updates the mesh (if needed)
  47122. * @param xrFrame the current xrFrame
  47123. */
  47124. protected abstract _updateModel(xrFrame: XRFrame): void;
  47125. private _getGenericFilenameAndPath;
  47126. private _getGenericParentMesh;
  47127. }
  47128. }
  47129. declare module BABYLON {
  47130. /**
  47131. * A generic trigger-only motion controller for WebXR
  47132. */
  47133. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47134. /**
  47135. * Static version of the profile id of this controller
  47136. */
  47137. static ProfileId: string;
  47138. profileId: string;
  47139. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47140. protected _getFilenameAndPath(): {
  47141. filename: string;
  47142. path: string;
  47143. };
  47144. protected _getModelLoadingConstraints(): boolean;
  47145. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47146. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47147. protected _updateModel(): void;
  47148. }
  47149. }
  47150. declare module BABYLON {
  47151. /**
  47152. * Class containing static functions to help procedurally build meshes
  47153. */
  47154. export class SphereBuilder {
  47155. /**
  47156. * Creates a sphere mesh
  47157. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47158. * * 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`)
  47159. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47160. * * 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
  47161. * * 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)
  47162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47163. * * 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
  47164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47165. * @param name defines the name of the mesh
  47166. * @param options defines the options used to create the mesh
  47167. * @param scene defines the hosting scene
  47168. * @returns the sphere mesh
  47169. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47170. */
  47171. static CreateSphere(name: string, options: {
  47172. segments?: number;
  47173. diameter?: number;
  47174. diameterX?: number;
  47175. diameterY?: number;
  47176. diameterZ?: number;
  47177. arc?: number;
  47178. slice?: number;
  47179. sideOrientation?: number;
  47180. frontUVs?: Vector4;
  47181. backUVs?: Vector4;
  47182. updatable?: boolean;
  47183. }, scene?: Nullable<Scene>): Mesh;
  47184. }
  47185. }
  47186. declare module BABYLON {
  47187. /**
  47188. * A profiled motion controller has its profile loaded from an online repository.
  47189. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47190. */
  47191. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47192. private _repositoryUrl;
  47193. private _buttonMeshMapping;
  47194. private _touchDots;
  47195. /**
  47196. * The profile ID of this controller. Will be populated when the controller initializes.
  47197. */
  47198. profileId: string;
  47199. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47200. dispose(): void;
  47201. protected _getFilenameAndPath(): {
  47202. filename: string;
  47203. path: string;
  47204. };
  47205. protected _getModelLoadingConstraints(): boolean;
  47206. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47207. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47208. protected _updateModel(_xrFrame: XRFrame): void;
  47209. }
  47210. }
  47211. declare module BABYLON {
  47212. /**
  47213. * A construction function type to create a new controller based on an xrInput object
  47214. */
  47215. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47216. /**
  47217. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47218. *
  47219. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47220. * it should be replaced with auto-loaded controllers.
  47221. *
  47222. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47223. */
  47224. export class WebXRMotionControllerManager {
  47225. private static _AvailableControllers;
  47226. private static _Fallbacks;
  47227. private static _ProfileLoadingPromises;
  47228. private static _ProfilesList;
  47229. /**
  47230. * The base URL of the online controller repository. Can be changed at any time.
  47231. */
  47232. static BaseRepositoryUrl: string;
  47233. /**
  47234. * Which repository gets priority - local or online
  47235. */
  47236. static PrioritizeOnlineRepository: boolean;
  47237. /**
  47238. * Use the online repository, or use only locally-defined controllers
  47239. */
  47240. static UseOnlineRepository: boolean;
  47241. /**
  47242. * Clear the cache used for profile loading and reload when requested again
  47243. */
  47244. static ClearProfilesCache(): void;
  47245. /**
  47246. * Register the default fallbacks.
  47247. * This function is called automatically when this file is imported.
  47248. */
  47249. static DefaultFallbacks(): void;
  47250. /**
  47251. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47252. * @param profileId the profile to which a fallback needs to be found
  47253. * @return an array with corresponding fallback profiles
  47254. */
  47255. static FindFallbackWithProfileId(profileId: string): string[];
  47256. /**
  47257. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47258. * The order of search:
  47259. *
  47260. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47261. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47262. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47263. * 4) return the generic trigger controller if none were found
  47264. *
  47265. * @param xrInput the xrInput to which a new controller is initialized
  47266. * @param scene the scene to which the model will be added
  47267. * @param forceProfile force a certain profile for this controller
  47268. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47269. */
  47270. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47271. /**
  47272. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47273. *
  47274. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47275. *
  47276. * @param type the profile type to register
  47277. * @param constructFunction the function to be called when loading this profile
  47278. */
  47279. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47280. /**
  47281. * Register a fallback to a specific profile.
  47282. * @param profileId the profileId that will receive the fallbacks
  47283. * @param fallbacks A list of fallback profiles
  47284. */
  47285. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47286. /**
  47287. * Will update the list of profiles available in the repository
  47288. * @return a promise that resolves to a map of profiles available online
  47289. */
  47290. static UpdateProfilesList(): Promise<{
  47291. [profile: string]: string;
  47292. }>;
  47293. private static _LoadProfileFromRepository;
  47294. private static _LoadProfilesFromAvailableControllers;
  47295. }
  47296. }
  47297. declare module BABYLON {
  47298. /**
  47299. * Configuration options for the WebXR controller creation
  47300. */
  47301. export interface IWebXRControllerOptions {
  47302. /**
  47303. * Should the controller mesh be animated when a user interacts with it
  47304. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47305. */
  47306. disableMotionControllerAnimation?: boolean;
  47307. /**
  47308. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47309. */
  47310. doNotLoadControllerMesh?: boolean;
  47311. /**
  47312. * Force a specific controller type for this controller.
  47313. * This can be used when creating your own profile or when testing different controllers
  47314. */
  47315. forceControllerProfile?: string;
  47316. /**
  47317. * Defines a rendering group ID for meshes that will be loaded.
  47318. * This is for the default controllers only.
  47319. */
  47320. renderingGroupId?: number;
  47321. }
  47322. /**
  47323. * Represents an XR controller
  47324. */
  47325. export class WebXRInputSource {
  47326. private _scene;
  47327. /** The underlying input source for the controller */
  47328. inputSource: XRInputSource;
  47329. private _options;
  47330. private _tmpVector;
  47331. private _uniqueId;
  47332. /**
  47333. * 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
  47334. */
  47335. grip?: AbstractMesh;
  47336. /**
  47337. * If available, this is the gamepad object related to this controller.
  47338. * Using this object it is possible to get click events and trackpad changes of the
  47339. * webxr controller that is currently being used.
  47340. */
  47341. motionController?: WebXRAbstractMotionController;
  47342. /**
  47343. * Event that fires when the controller is removed/disposed.
  47344. * The object provided as event data is this controller, after associated assets were disposed.
  47345. * uniqueId is still available.
  47346. */
  47347. onDisposeObservable: Observable<WebXRInputSource>;
  47348. /**
  47349. * Will be triggered when the mesh associated with the motion controller is done loading.
  47350. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47351. * A shortened version of controller -> motion controller -> on mesh loaded.
  47352. */
  47353. onMeshLoadedObservable: Observable<AbstractMesh>;
  47354. /**
  47355. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47356. */
  47357. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47358. /**
  47359. * Pointer which can be used to select objects or attach a visible laser to
  47360. */
  47361. pointer: AbstractMesh;
  47362. /**
  47363. * Creates the controller
  47364. * @see https://doc.babylonjs.com/how_to/webxr
  47365. * @param _scene the scene which the controller should be associated to
  47366. * @param inputSource the underlying input source for the controller
  47367. * @param _options options for this controller creation
  47368. */
  47369. constructor(_scene: Scene,
  47370. /** The underlying input source for the controller */
  47371. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47372. /**
  47373. * Get this controllers unique id
  47374. */
  47375. get uniqueId(): string;
  47376. /**
  47377. * Disposes of the object
  47378. */
  47379. dispose(): void;
  47380. /**
  47381. * Gets a world space ray coming from the pointer or grip
  47382. * @param result the resulting ray
  47383. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47384. */
  47385. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47386. /**
  47387. * Updates the controller pose based on the given XRFrame
  47388. * @param xrFrame xr frame to update the pose with
  47389. * @param referenceSpace reference space to use
  47390. */
  47391. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47392. }
  47393. }
  47394. declare module BABYLON {
  47395. /**
  47396. * The schema for initialization options of the XR Input class
  47397. */
  47398. export interface IWebXRInputOptions {
  47399. /**
  47400. * If set to true no model will be automatically loaded
  47401. */
  47402. doNotLoadControllerMeshes?: boolean;
  47403. /**
  47404. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47405. * If not found, the xr input profile data will be used.
  47406. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47407. */
  47408. forceInputProfile?: string;
  47409. /**
  47410. * Do not send a request to the controller repository to load the profile.
  47411. *
  47412. * Instead, use the controllers available in babylon itself.
  47413. */
  47414. disableOnlineControllerRepository?: boolean;
  47415. /**
  47416. * A custom URL for the controllers repository
  47417. */
  47418. customControllersRepositoryURL?: string;
  47419. /**
  47420. * Should the controller model's components not move according to the user input
  47421. */
  47422. disableControllerAnimation?: boolean;
  47423. /**
  47424. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47425. */
  47426. controllerOptions?: IWebXRControllerOptions;
  47427. }
  47428. /**
  47429. * XR input used to track XR inputs such as controllers/rays
  47430. */
  47431. export class WebXRInput implements IDisposable {
  47432. /**
  47433. * the xr session manager for this session
  47434. */
  47435. xrSessionManager: WebXRSessionManager;
  47436. /**
  47437. * the WebXR camera for this session. Mainly used for teleportation
  47438. */
  47439. xrCamera: WebXRCamera;
  47440. private readonly options;
  47441. /**
  47442. * XR controllers being tracked
  47443. */
  47444. controllers: Array<WebXRInputSource>;
  47445. private _frameObserver;
  47446. private _sessionEndedObserver;
  47447. private _sessionInitObserver;
  47448. /**
  47449. * Event when a controller has been connected/added
  47450. */
  47451. onControllerAddedObservable: Observable<WebXRInputSource>;
  47452. /**
  47453. * Event when a controller has been removed/disconnected
  47454. */
  47455. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47456. /**
  47457. * Initializes the WebXRInput
  47458. * @param xrSessionManager the xr session manager for this session
  47459. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47460. * @param options = initialization options for this xr input
  47461. */
  47462. constructor(
  47463. /**
  47464. * the xr session manager for this session
  47465. */
  47466. xrSessionManager: WebXRSessionManager,
  47467. /**
  47468. * the WebXR camera for this session. Mainly used for teleportation
  47469. */
  47470. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47471. private _onInputSourcesChange;
  47472. private _addAndRemoveControllers;
  47473. /**
  47474. * Disposes of the object
  47475. */
  47476. dispose(): void;
  47477. }
  47478. }
  47479. declare module BABYLON {
  47480. /**
  47481. * This is the base class for all WebXR features.
  47482. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47483. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47484. */
  47485. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47486. protected _xrSessionManager: WebXRSessionManager;
  47487. private _attached;
  47488. private _removeOnDetach;
  47489. /**
  47490. * Should auto-attach be disabled?
  47491. */
  47492. disableAutoAttach: boolean;
  47493. /**
  47494. * Construct a new (abstract) WebXR feature
  47495. * @param _xrSessionManager the xr session manager for this feature
  47496. */
  47497. constructor(_xrSessionManager: WebXRSessionManager);
  47498. /**
  47499. * Is this feature attached
  47500. */
  47501. get attached(): boolean;
  47502. /**
  47503. * attach this feature
  47504. *
  47505. * @param force should attachment be forced (even when already attached)
  47506. * @returns true if successful, false is failed or already attached
  47507. */
  47508. attach(force?: boolean): boolean;
  47509. /**
  47510. * detach this feature.
  47511. *
  47512. * @returns true if successful, false if failed or already detached
  47513. */
  47514. detach(): boolean;
  47515. /**
  47516. * Dispose this feature and all of the resources attached
  47517. */
  47518. dispose(): void;
  47519. /**
  47520. * This is used to register callbacks that will automatically be removed when detach is called.
  47521. * @param observable the observable to which the observer will be attached
  47522. * @param callback the callback to register
  47523. */
  47524. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47525. /**
  47526. * Code in this function will be executed on each xrFrame received from the browser.
  47527. * This function will not execute after the feature is detached.
  47528. * @param _xrFrame the current frame
  47529. */
  47530. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47531. }
  47532. }
  47533. declare module BABYLON {
  47534. /**
  47535. * Renders a layer on top of an existing scene
  47536. */
  47537. export class UtilityLayerRenderer implements IDisposable {
  47538. /** the original scene that will be rendered on top of */
  47539. originalScene: Scene;
  47540. private _pointerCaptures;
  47541. private _lastPointerEvents;
  47542. private static _DefaultUtilityLayer;
  47543. private static _DefaultKeepDepthUtilityLayer;
  47544. private _sharedGizmoLight;
  47545. private _renderCamera;
  47546. /**
  47547. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47548. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47549. * @returns the camera that is used when rendering the utility layer
  47550. */
  47551. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47552. /**
  47553. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47554. * @param cam the camera that should be used when rendering the utility layer
  47555. */
  47556. setRenderCamera(cam: Nullable<Camera>): void;
  47557. /**
  47558. * @hidden
  47559. * Light which used by gizmos to get light shading
  47560. */
  47561. _getSharedGizmoLight(): HemisphericLight;
  47562. /**
  47563. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47564. */
  47565. pickUtilitySceneFirst: boolean;
  47566. /**
  47567. * 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)
  47568. */
  47569. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47570. /**
  47571. * 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)
  47572. */
  47573. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47574. /**
  47575. * The scene that is rendered on top of the original scene
  47576. */
  47577. utilityLayerScene: Scene;
  47578. /**
  47579. * If the utility layer should automatically be rendered on top of existing scene
  47580. */
  47581. shouldRender: boolean;
  47582. /**
  47583. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47584. */
  47585. onlyCheckPointerDownEvents: boolean;
  47586. /**
  47587. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47588. */
  47589. processAllEvents: boolean;
  47590. /**
  47591. * Observable raised when the pointer move from the utility layer scene to the main scene
  47592. */
  47593. onPointerOutObservable: Observable<number>;
  47594. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47595. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47596. private _afterRenderObserver;
  47597. private _sceneDisposeObserver;
  47598. private _originalPointerObserver;
  47599. /**
  47600. * Instantiates a UtilityLayerRenderer
  47601. * @param originalScene the original scene that will be rendered on top of
  47602. * @param handleEvents boolean indicating if the utility layer should handle events
  47603. */
  47604. constructor(
  47605. /** the original scene that will be rendered on top of */
  47606. originalScene: Scene, handleEvents?: boolean);
  47607. private _notifyObservers;
  47608. /**
  47609. * Renders the utility layers scene on top of the original scene
  47610. */
  47611. render(): void;
  47612. /**
  47613. * Disposes of the renderer
  47614. */
  47615. dispose(): void;
  47616. private _updateCamera;
  47617. }
  47618. }
  47619. declare module BABYLON {
  47620. /**
  47621. * Options interface for the pointer selection module
  47622. */
  47623. export interface IWebXRControllerPointerSelectionOptions {
  47624. /**
  47625. * if provided, this scene will be used to render meshes.
  47626. */
  47627. customUtilityLayerScene?: Scene;
  47628. /**
  47629. * 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)
  47630. * If not disabled, the last picked point will be used to execute a pointer up event
  47631. * If disabled, pointer up event will be triggered right after the pointer down event.
  47632. * Used in screen and gaze target ray mode only
  47633. */
  47634. disablePointerUpOnTouchOut: boolean;
  47635. /**
  47636. * For gaze mode (time to select instead of press)
  47637. */
  47638. forceGazeMode: boolean;
  47639. /**
  47640. * 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
  47641. * to start a new countdown to the pointer down event.
  47642. * Defaults to 1.
  47643. */
  47644. gazeModePointerMovedFactor?: number;
  47645. /**
  47646. * Different button type to use instead of the main component
  47647. */
  47648. overrideButtonId?: string;
  47649. /**
  47650. * use this rendering group id for the meshes (optional)
  47651. */
  47652. renderingGroupId?: number;
  47653. /**
  47654. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47655. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47656. * 3000 means 3 seconds between pointing at something and selecting it
  47657. */
  47658. timeToSelect?: number;
  47659. /**
  47660. * Should meshes created here be added to a utility layer or the main scene
  47661. */
  47662. useUtilityLayer?: boolean;
  47663. /**
  47664. * the xr input to use with this pointer selection
  47665. */
  47666. xrInput: WebXRInput;
  47667. }
  47668. /**
  47669. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47670. */
  47671. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47672. private readonly _options;
  47673. private static _idCounter;
  47674. private _attachController;
  47675. private _controllers;
  47676. private _scene;
  47677. private _tmpVectorForPickCompare;
  47678. /**
  47679. * The module's name
  47680. */
  47681. static readonly Name: string;
  47682. /**
  47683. * The (Babylon) version of this module.
  47684. * This is an integer representing the implementation version.
  47685. * This number does not correspond to the WebXR specs version
  47686. */
  47687. static readonly Version: number;
  47688. /**
  47689. * Disable lighting on the laser pointer (so it will always be visible)
  47690. */
  47691. disablePointerLighting: boolean;
  47692. /**
  47693. * Disable lighting on the selection mesh (so it will always be visible)
  47694. */
  47695. disableSelectionMeshLighting: boolean;
  47696. /**
  47697. * Should the laser pointer be displayed
  47698. */
  47699. displayLaserPointer: boolean;
  47700. /**
  47701. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47702. */
  47703. displaySelectionMesh: boolean;
  47704. /**
  47705. * This color will be set to the laser pointer when selection is triggered
  47706. */
  47707. laserPointerPickedColor: Color3;
  47708. /**
  47709. * Default color of the laser pointer
  47710. */
  47711. laserPointerDefaultColor: Color3;
  47712. /**
  47713. * default color of the selection ring
  47714. */
  47715. selectionMeshDefaultColor: Color3;
  47716. /**
  47717. * This color will be applied to the selection ring when selection is triggered
  47718. */
  47719. selectionMeshPickedColor: Color3;
  47720. /**
  47721. * Optional filter to be used for ray selection. This predicate shares behavior with
  47722. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47723. */
  47724. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47725. /**
  47726. * constructs a new background remover module
  47727. * @param _xrSessionManager the session manager for this module
  47728. * @param _options read-only options to be used in this module
  47729. */
  47730. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47731. /**
  47732. * attach this feature
  47733. * Will usually be called by the features manager
  47734. *
  47735. * @returns true if successful.
  47736. */
  47737. attach(): boolean;
  47738. /**
  47739. * detach this feature.
  47740. * Will usually be called by the features manager
  47741. *
  47742. * @returns true if successful.
  47743. */
  47744. detach(): boolean;
  47745. /**
  47746. * Will get the mesh under a specific pointer.
  47747. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47748. * @param controllerId the controllerId to check
  47749. * @returns The mesh under pointer or null if no mesh is under the pointer
  47750. */
  47751. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47752. /**
  47753. * Get the xr controller that correlates to the pointer id in the pointer event
  47754. *
  47755. * @param id the pointer id to search for
  47756. * @returns the controller that correlates to this id or null if not found
  47757. */
  47758. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47759. protected _onXRFrame(_xrFrame: XRFrame): void;
  47760. private _attachGazeMode;
  47761. private _attachScreenRayMode;
  47762. private _attachTrackedPointerRayMode;
  47763. private _convertNormalToDirectionOfRay;
  47764. private _detachController;
  47765. private _generateNewMeshPair;
  47766. private _pickingMoved;
  47767. private _updatePointerDistance;
  47768. /** @hidden */
  47769. get lasterPointerDefaultColor(): Color3;
  47770. }
  47771. }
  47772. declare module BABYLON {
  47773. /**
  47774. * Button which can be used to enter a different mode of XR
  47775. */
  47776. export class WebXREnterExitUIButton {
  47777. /** button element */
  47778. element: HTMLElement;
  47779. /** XR initialization options for the button */
  47780. sessionMode: XRSessionMode;
  47781. /** Reference space type */
  47782. referenceSpaceType: XRReferenceSpaceType;
  47783. /**
  47784. * Creates a WebXREnterExitUIButton
  47785. * @param element button element
  47786. * @param sessionMode XR initialization session mode
  47787. * @param referenceSpaceType the type of reference space to be used
  47788. */
  47789. constructor(
  47790. /** button element */
  47791. element: HTMLElement,
  47792. /** XR initialization options for the button */
  47793. sessionMode: XRSessionMode,
  47794. /** Reference space type */
  47795. referenceSpaceType: XRReferenceSpaceType);
  47796. /**
  47797. * Extendable function which can be used to update the button's visuals when the state changes
  47798. * @param activeButton the current active button in the UI
  47799. */
  47800. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47801. }
  47802. /**
  47803. * Options to create the webXR UI
  47804. */
  47805. export class WebXREnterExitUIOptions {
  47806. /**
  47807. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47808. */
  47809. customButtons?: Array<WebXREnterExitUIButton>;
  47810. /**
  47811. * A reference space type to use when creating the default button.
  47812. * Default is local-floor
  47813. */
  47814. referenceSpaceType?: XRReferenceSpaceType;
  47815. /**
  47816. * Context to enter xr with
  47817. */
  47818. renderTarget?: Nullable<WebXRRenderTarget>;
  47819. /**
  47820. * A session mode to use when creating the default button.
  47821. * Default is immersive-vr
  47822. */
  47823. sessionMode?: XRSessionMode;
  47824. /**
  47825. * A list of optional features to init the session with
  47826. */
  47827. optionalFeatures?: string[];
  47828. }
  47829. /**
  47830. * UI to allow the user to enter/exit XR mode
  47831. */
  47832. export class WebXREnterExitUI implements IDisposable {
  47833. private scene;
  47834. /** version of the options passed to this UI */
  47835. options: WebXREnterExitUIOptions;
  47836. private _activeButton;
  47837. private _buttons;
  47838. private _overlay;
  47839. /**
  47840. * Fired every time the active button is changed.
  47841. *
  47842. * When xr is entered via a button that launches xr that button will be the callback parameter
  47843. *
  47844. * When exiting xr the callback parameter will be null)
  47845. */
  47846. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47847. /**
  47848. *
  47849. * @param scene babylon scene object to use
  47850. * @param options (read-only) version of the options passed to this UI
  47851. */
  47852. private constructor();
  47853. /**
  47854. * Creates UI to allow the user to enter/exit XR mode
  47855. * @param scene the scene to add the ui to
  47856. * @param helper the xr experience helper to enter/exit xr with
  47857. * @param options options to configure the UI
  47858. * @returns the created ui
  47859. */
  47860. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47861. /**
  47862. * Disposes of the XR UI component
  47863. */
  47864. dispose(): void;
  47865. private _updateButtons;
  47866. }
  47867. }
  47868. declare module BABYLON {
  47869. /**
  47870. * Class containing static functions to help procedurally build meshes
  47871. */
  47872. export class LinesBuilder {
  47873. /**
  47874. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47875. * * 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
  47876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47877. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47878. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47879. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47880. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47881. * * 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
  47882. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47885. * @param name defines the name of the new line system
  47886. * @param options defines the options used to create the line system
  47887. * @param scene defines the hosting scene
  47888. * @returns a new line system mesh
  47889. */
  47890. static CreateLineSystem(name: string, options: {
  47891. lines: Vector3[][];
  47892. updatable?: boolean;
  47893. instance?: Nullable<LinesMesh>;
  47894. colors?: Nullable<Color4[][]>;
  47895. useVertexAlpha?: boolean;
  47896. }, scene: Nullable<Scene>): LinesMesh;
  47897. /**
  47898. * Creates a line mesh
  47899. * 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
  47900. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47901. * * The parameter `points` is an array successive Vector3
  47902. * * 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
  47903. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47904. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47905. * * When updating an instance, remember that only point positions can change, not the number of points
  47906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47908. * @param name defines the name of the new line system
  47909. * @param options defines the options used to create the line system
  47910. * @param scene defines the hosting scene
  47911. * @returns a new line mesh
  47912. */
  47913. static CreateLines(name: string, options: {
  47914. points: Vector3[];
  47915. updatable?: boolean;
  47916. instance?: Nullable<LinesMesh>;
  47917. colors?: Color4[];
  47918. useVertexAlpha?: boolean;
  47919. }, scene?: Nullable<Scene>): LinesMesh;
  47920. /**
  47921. * Creates a dashed line mesh
  47922. * * 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
  47923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47924. * * The parameter `points` is an array successive Vector3
  47925. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47926. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47927. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47928. * * 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
  47929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47930. * * When updating an instance, remember that only point positions can change, not the number of points
  47931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47932. * @param name defines the name of the mesh
  47933. * @param options defines the options used to create the mesh
  47934. * @param scene defines the hosting scene
  47935. * @returns the dashed line mesh
  47936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47937. */
  47938. static CreateDashedLines(name: string, options: {
  47939. points: Vector3[];
  47940. dashSize?: number;
  47941. gapSize?: number;
  47942. dashNb?: number;
  47943. updatable?: boolean;
  47944. instance?: LinesMesh;
  47945. useVertexAlpha?: boolean;
  47946. }, scene?: Nullable<Scene>): LinesMesh;
  47947. }
  47948. }
  47949. declare module BABYLON {
  47950. /**
  47951. * Construction options for a timer
  47952. */
  47953. export interface ITimerOptions<T> {
  47954. /**
  47955. * Time-to-end
  47956. */
  47957. timeout: number;
  47958. /**
  47959. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  47960. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  47961. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  47962. */
  47963. contextObservable: Observable<T>;
  47964. /**
  47965. * Optional parameters when adding an observer to the observable
  47966. */
  47967. observableParameters?: {
  47968. mask?: number;
  47969. insertFirst?: boolean;
  47970. scope?: any;
  47971. };
  47972. /**
  47973. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  47974. */
  47975. breakCondition?: (data?: ITimerData<T>) => boolean;
  47976. /**
  47977. * Will be triggered when the time condition has met
  47978. */
  47979. onEnded?: (data: ITimerData<any>) => void;
  47980. /**
  47981. * Will be triggered when the break condition has met (prematurely ended)
  47982. */
  47983. onAborted?: (data: ITimerData<any>) => void;
  47984. /**
  47985. * Optional function to execute on each tick (or count)
  47986. */
  47987. onTick?: (data: ITimerData<any>) => void;
  47988. }
  47989. /**
  47990. * An interface defining the data sent by the timer
  47991. */
  47992. export interface ITimerData<T> {
  47993. /**
  47994. * When did it start
  47995. */
  47996. startTime: number;
  47997. /**
  47998. * Time now
  47999. */
  48000. currentTime: number;
  48001. /**
  48002. * Time passed since started
  48003. */
  48004. deltaTime: number;
  48005. /**
  48006. * How much is completed, in [0.0...1.0].
  48007. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48008. */
  48009. completeRate: number;
  48010. /**
  48011. * What the registered observable sent in the last count
  48012. */
  48013. payload: T;
  48014. }
  48015. /**
  48016. * The current state of the timer
  48017. */
  48018. export enum TimerState {
  48019. /**
  48020. * Timer initialized, not yet started
  48021. */
  48022. INIT = 0,
  48023. /**
  48024. * Timer started and counting
  48025. */
  48026. STARTED = 1,
  48027. /**
  48028. * Timer ended (whether aborted or time reached)
  48029. */
  48030. ENDED = 2
  48031. }
  48032. /**
  48033. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48034. *
  48035. * @param options options with which to initialize this timer
  48036. */
  48037. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48038. /**
  48039. * An advanced implementation of a timer class
  48040. */
  48041. export class AdvancedTimer<T = any> implements IDisposable {
  48042. /**
  48043. * Will notify each time the timer calculates the remaining time
  48044. */
  48045. onEachCountObservable: Observable<ITimerData<T>>;
  48046. /**
  48047. * Will trigger when the timer was aborted due to the break condition
  48048. */
  48049. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48050. /**
  48051. * Will trigger when the timer ended successfully
  48052. */
  48053. onTimerEndedObservable: Observable<ITimerData<T>>;
  48054. /**
  48055. * Will trigger when the timer state has changed
  48056. */
  48057. onStateChangedObservable: Observable<TimerState>;
  48058. private _observer;
  48059. private _contextObservable;
  48060. private _observableParameters;
  48061. private _startTime;
  48062. private _timer;
  48063. private _state;
  48064. private _breakCondition;
  48065. private _timeToEnd;
  48066. private _breakOnNextTick;
  48067. /**
  48068. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48069. * @param options construction options for this advanced timer
  48070. */
  48071. constructor(options: ITimerOptions<T>);
  48072. /**
  48073. * set a breaking condition for this timer. Default is to never break during count
  48074. * @param predicate the new break condition. Returns true to break, false otherwise
  48075. */
  48076. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48077. /**
  48078. * Reset ALL associated observables in this advanced timer
  48079. */
  48080. clearObservables(): void;
  48081. /**
  48082. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48083. *
  48084. * @param timeToEnd how much time to measure until timer ended
  48085. */
  48086. start(timeToEnd?: number): void;
  48087. /**
  48088. * Will force a stop on the next tick.
  48089. */
  48090. stop(): void;
  48091. /**
  48092. * Dispose this timer, clearing all resources
  48093. */
  48094. dispose(): void;
  48095. private _setState;
  48096. private _tick;
  48097. private _stop;
  48098. }
  48099. }
  48100. declare module BABYLON {
  48101. /**
  48102. * The options container for the teleportation module
  48103. */
  48104. export interface IWebXRTeleportationOptions {
  48105. /**
  48106. * if provided, this scene will be used to render meshes.
  48107. */
  48108. customUtilityLayerScene?: Scene;
  48109. /**
  48110. * Values to configure the default target mesh
  48111. */
  48112. defaultTargetMeshOptions?: {
  48113. /**
  48114. * Fill color of the teleportation area
  48115. */
  48116. teleportationFillColor?: string;
  48117. /**
  48118. * Border color for the teleportation area
  48119. */
  48120. teleportationBorderColor?: string;
  48121. /**
  48122. * Disable the mesh's animation sequence
  48123. */
  48124. disableAnimation?: boolean;
  48125. /**
  48126. * Disable lighting on the material or the ring and arrow
  48127. */
  48128. disableLighting?: boolean;
  48129. /**
  48130. * Override the default material of the torus and arrow
  48131. */
  48132. torusArrowMaterial?: Material;
  48133. };
  48134. /**
  48135. * A list of meshes to use as floor meshes.
  48136. * Meshes can be added and removed after initializing the feature using the
  48137. * addFloorMesh and removeFloorMesh functions
  48138. * If empty, rotation will still work
  48139. */
  48140. floorMeshes?: AbstractMesh[];
  48141. /**
  48142. * use this rendering group id for the meshes (optional)
  48143. */
  48144. renderingGroupId?: number;
  48145. /**
  48146. * Should teleportation move only to snap points
  48147. */
  48148. snapPointsOnly?: boolean;
  48149. /**
  48150. * An array of points to which the teleportation will snap to.
  48151. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48152. */
  48153. snapPositions?: Vector3[];
  48154. /**
  48155. * How close should the teleportation ray be in order to snap to position.
  48156. * Default to 0.8 units (meters)
  48157. */
  48158. snapToPositionRadius?: number;
  48159. /**
  48160. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48161. * If you want to support rotation, make sure your mesh has a direction indicator.
  48162. *
  48163. * When left untouched, the default mesh will be initialized.
  48164. */
  48165. teleportationTargetMesh?: AbstractMesh;
  48166. /**
  48167. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48168. */
  48169. timeToTeleport?: number;
  48170. /**
  48171. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48172. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48173. */
  48174. useMainComponentOnly?: boolean;
  48175. /**
  48176. * Should meshes created here be added to a utility layer or the main scene
  48177. */
  48178. useUtilityLayer?: boolean;
  48179. /**
  48180. * Babylon XR Input class for controller
  48181. */
  48182. xrInput: WebXRInput;
  48183. }
  48184. /**
  48185. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48186. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48187. * the input of the attached controllers.
  48188. */
  48189. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48190. private _options;
  48191. private _controllers;
  48192. private _currentTeleportationControllerId;
  48193. private _floorMeshes;
  48194. private _quadraticBezierCurve;
  48195. private _selectionFeature;
  48196. private _snapToPositions;
  48197. private _snappedToPoint;
  48198. private _teleportationRingMaterial?;
  48199. private _tmpRay;
  48200. private _tmpVector;
  48201. /**
  48202. * The module's name
  48203. */
  48204. static readonly Name: string;
  48205. /**
  48206. * The (Babylon) version of this module.
  48207. * This is an integer representing the implementation version.
  48208. * This number does not correspond to the webxr specs version
  48209. */
  48210. static readonly Version: number;
  48211. /**
  48212. * Is movement backwards enabled
  48213. */
  48214. backwardsMovementEnabled: boolean;
  48215. /**
  48216. * Distance to travel when moving backwards
  48217. */
  48218. backwardsTeleportationDistance: number;
  48219. /**
  48220. * The distance from the user to the inspection point in the direction of the controller
  48221. * A higher number will allow the user to move further
  48222. * defaults to 5 (meters, in xr units)
  48223. */
  48224. parabolicCheckRadius: number;
  48225. /**
  48226. * Should the module support parabolic ray on top of direct ray
  48227. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48228. * Very helpful when moving between floors / different heights
  48229. */
  48230. parabolicRayEnabled: boolean;
  48231. /**
  48232. * How much rotation should be applied when rotating right and left
  48233. */
  48234. rotationAngle: number;
  48235. /**
  48236. * Is rotation enabled when moving forward?
  48237. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48238. */
  48239. rotationEnabled: boolean;
  48240. /**
  48241. * constructs a new anchor system
  48242. * @param _xrSessionManager an instance of WebXRSessionManager
  48243. * @param _options configuration object for this feature
  48244. */
  48245. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48246. /**
  48247. * Get the snapPointsOnly flag
  48248. */
  48249. get snapPointsOnly(): boolean;
  48250. /**
  48251. * Sets the snapPointsOnly flag
  48252. * @param snapToPoints should teleportation be exclusively to snap points
  48253. */
  48254. set snapPointsOnly(snapToPoints: boolean);
  48255. /**
  48256. * Add a new mesh to the floor meshes array
  48257. * @param mesh the mesh to use as floor mesh
  48258. */
  48259. addFloorMesh(mesh: AbstractMesh): void;
  48260. /**
  48261. * Add a new snap-to point to fix teleportation to this position
  48262. * @param newSnapPoint The new Snap-To point
  48263. */
  48264. addSnapPoint(newSnapPoint: Vector3): void;
  48265. attach(): boolean;
  48266. detach(): boolean;
  48267. dispose(): void;
  48268. /**
  48269. * Remove a mesh from the floor meshes array
  48270. * @param mesh the mesh to remove
  48271. */
  48272. removeFloorMesh(mesh: AbstractMesh): void;
  48273. /**
  48274. * Remove a mesh from the floor meshes array using its name
  48275. * @param name the mesh name to remove
  48276. */
  48277. removeFloorMeshByName(name: string): void;
  48278. /**
  48279. * 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
  48280. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48281. * @returns was the point found and removed or not
  48282. */
  48283. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48284. /**
  48285. * This function sets a selection feature that will be disabled when
  48286. * the forward ray is shown and will be reattached when hidden.
  48287. * This is used to remove the selection rays when moving.
  48288. * @param selectionFeature the feature to disable when forward movement is enabled
  48289. */
  48290. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48291. protected _onXRFrame(_xrFrame: XRFrame): void;
  48292. private _attachController;
  48293. private _createDefaultTargetMesh;
  48294. private _detachController;
  48295. private _findClosestSnapPointWithRadius;
  48296. private _setTargetMeshPosition;
  48297. private _setTargetMeshVisibility;
  48298. private _showParabolicPath;
  48299. private _teleportForward;
  48300. }
  48301. }
  48302. declare module BABYLON {
  48303. /**
  48304. * Options for the default xr helper
  48305. */
  48306. export class WebXRDefaultExperienceOptions {
  48307. /**
  48308. * Enable or disable default UI to enter XR
  48309. */
  48310. disableDefaultUI?: boolean;
  48311. /**
  48312. * Should teleportation not initialize. defaults to false.
  48313. */
  48314. disableTeleportation?: boolean;
  48315. /**
  48316. * Floor meshes that will be used for teleport
  48317. */
  48318. floorMeshes?: Array<AbstractMesh>;
  48319. /**
  48320. * If set to true, the first frame will not be used to reset position
  48321. * The first frame is mainly used when copying transformation from the old camera
  48322. * Mainly used in AR
  48323. */
  48324. ignoreNativeCameraTransformation?: boolean;
  48325. /**
  48326. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48327. */
  48328. inputOptions?: IWebXRInputOptions;
  48329. /**
  48330. * optional configuration for the output canvas
  48331. */
  48332. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48333. /**
  48334. * optional UI options. This can be used among other to change session mode and reference space type
  48335. */
  48336. uiOptions?: WebXREnterExitUIOptions;
  48337. /**
  48338. * When loading teleportation and pointer select, use stable versions instead of latest.
  48339. */
  48340. useStablePlugins?: boolean;
  48341. /**
  48342. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48343. */
  48344. renderingGroupId?: number;
  48345. /**
  48346. * A list of optional features to init the session with
  48347. * If set to true, all features we support will be added
  48348. */
  48349. optionalFeatures?: boolean | string[];
  48350. }
  48351. /**
  48352. * Default experience which provides a similar setup to the previous webVRExperience
  48353. */
  48354. export class WebXRDefaultExperience {
  48355. /**
  48356. * Base experience
  48357. */
  48358. baseExperience: WebXRExperienceHelper;
  48359. /**
  48360. * Enables ui for entering/exiting xr
  48361. */
  48362. enterExitUI: WebXREnterExitUI;
  48363. /**
  48364. * Input experience extension
  48365. */
  48366. input: WebXRInput;
  48367. /**
  48368. * Enables laser pointer and selection
  48369. */
  48370. pointerSelection: WebXRControllerPointerSelection;
  48371. /**
  48372. * Default target xr should render to
  48373. */
  48374. renderTarget: WebXRRenderTarget;
  48375. /**
  48376. * Enables teleportation
  48377. */
  48378. teleportation: WebXRMotionControllerTeleportation;
  48379. private constructor();
  48380. /**
  48381. * Creates the default xr experience
  48382. * @param scene scene
  48383. * @param options options for basic configuration
  48384. * @returns resulting WebXRDefaultExperience
  48385. */
  48386. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48387. /**
  48388. * DIsposes of the experience helper
  48389. */
  48390. dispose(): void;
  48391. }
  48392. }
  48393. declare module BABYLON {
  48394. /**
  48395. * Options to modify the vr teleportation behavior.
  48396. */
  48397. export interface VRTeleportationOptions {
  48398. /**
  48399. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48400. */
  48401. floorMeshName?: string;
  48402. /**
  48403. * A list of meshes to be used as the teleportation floor. (default: empty)
  48404. */
  48405. floorMeshes?: Mesh[];
  48406. /**
  48407. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48408. */
  48409. teleportationMode?: number;
  48410. /**
  48411. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48412. */
  48413. teleportationTime?: number;
  48414. /**
  48415. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48416. */
  48417. teleportationSpeed?: number;
  48418. /**
  48419. * The easing function used in the animation or null for Linear. (default CircleEase)
  48420. */
  48421. easingFunction?: EasingFunction;
  48422. }
  48423. /**
  48424. * Options to modify the vr experience helper's behavior.
  48425. */
  48426. export interface VRExperienceHelperOptions extends WebVROptions {
  48427. /**
  48428. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48429. */
  48430. createDeviceOrientationCamera?: boolean;
  48431. /**
  48432. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48433. */
  48434. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48435. /**
  48436. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48437. */
  48438. laserToggle?: boolean;
  48439. /**
  48440. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48441. */
  48442. floorMeshes?: Mesh[];
  48443. /**
  48444. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48445. */
  48446. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48447. /**
  48448. * Defines if WebXR should be used instead of WebVR (if available)
  48449. */
  48450. useXR?: boolean;
  48451. }
  48452. /**
  48453. * Event containing information after VR has been entered
  48454. */
  48455. export class OnAfterEnteringVRObservableEvent {
  48456. /**
  48457. * If entering vr was successful
  48458. */
  48459. success: boolean;
  48460. }
  48461. /**
  48462. * Helps to quickly add VR support to an existing scene.
  48463. * See http://doc.babylonjs.com/how_to/webvr_helper
  48464. */
  48465. export class VRExperienceHelper {
  48466. /** Options to modify the vr experience helper's behavior. */
  48467. webVROptions: VRExperienceHelperOptions;
  48468. private _scene;
  48469. private _position;
  48470. private _btnVR;
  48471. private _btnVRDisplayed;
  48472. private _webVRsupported;
  48473. private _webVRready;
  48474. private _webVRrequesting;
  48475. private _webVRpresenting;
  48476. private _hasEnteredVR;
  48477. private _fullscreenVRpresenting;
  48478. private _inputElement;
  48479. private _webVRCamera;
  48480. private _vrDeviceOrientationCamera;
  48481. private _deviceOrientationCamera;
  48482. private _existingCamera;
  48483. private _onKeyDown;
  48484. private _onVrDisplayPresentChange;
  48485. private _onVRDisplayChanged;
  48486. private _onVRRequestPresentStart;
  48487. private _onVRRequestPresentComplete;
  48488. /**
  48489. * 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)
  48490. */
  48491. enableGazeEvenWhenNoPointerLock: boolean;
  48492. /**
  48493. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48494. */
  48495. exitVROnDoubleTap: boolean;
  48496. /**
  48497. * Observable raised right before entering VR.
  48498. */
  48499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48500. /**
  48501. * Observable raised when entering VR has completed.
  48502. */
  48503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48504. /**
  48505. * Observable raised when exiting VR.
  48506. */
  48507. onExitingVRObservable: Observable<VRExperienceHelper>;
  48508. /**
  48509. * Observable raised when controller mesh is loaded.
  48510. */
  48511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48512. /** Return this.onEnteringVRObservable
  48513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48514. */
  48515. get onEnteringVR(): Observable<VRExperienceHelper>;
  48516. /** Return this.onExitingVRObservable
  48517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48518. */
  48519. get onExitingVR(): Observable<VRExperienceHelper>;
  48520. /** Return this.onControllerMeshLoadedObservable
  48521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48522. */
  48523. get onControllerMeshLoaded(): Observable<WebVRController>;
  48524. private _rayLength;
  48525. private _useCustomVRButton;
  48526. private _teleportationRequested;
  48527. private _teleportActive;
  48528. private _floorMeshName;
  48529. private _floorMeshesCollection;
  48530. private _teleportationMode;
  48531. private _teleportationTime;
  48532. private _teleportationSpeed;
  48533. private _teleportationEasing;
  48534. private _rotationAllowed;
  48535. private _teleportBackwardsVector;
  48536. private _teleportationTarget;
  48537. private _isDefaultTeleportationTarget;
  48538. private _postProcessMove;
  48539. private _teleportationFillColor;
  48540. private _teleportationBorderColor;
  48541. private _rotationAngle;
  48542. private _haloCenter;
  48543. private _cameraGazer;
  48544. private _padSensibilityUp;
  48545. private _padSensibilityDown;
  48546. private _leftController;
  48547. private _rightController;
  48548. private _gazeColor;
  48549. private _laserColor;
  48550. private _pickedLaserColor;
  48551. private _pickedGazeColor;
  48552. /**
  48553. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48554. */
  48555. onNewMeshSelected: Observable<AbstractMesh>;
  48556. /**
  48557. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48558. * This observable will provide the mesh and the controller used to select the mesh
  48559. */
  48560. onMeshSelectedWithController: Observable<{
  48561. mesh: AbstractMesh;
  48562. controller: WebVRController;
  48563. }>;
  48564. /**
  48565. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48566. */
  48567. onNewMeshPicked: Observable<PickingInfo>;
  48568. private _circleEase;
  48569. /**
  48570. * Observable raised before camera teleportation
  48571. */
  48572. onBeforeCameraTeleport: Observable<Vector3>;
  48573. /**
  48574. * Observable raised after camera teleportation
  48575. */
  48576. onAfterCameraTeleport: Observable<Vector3>;
  48577. /**
  48578. * Observable raised when current selected mesh gets unselected
  48579. */
  48580. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48581. private _raySelectionPredicate;
  48582. /**
  48583. * To be optionaly changed by user to define custom ray selection
  48584. */
  48585. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48586. /**
  48587. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48588. */
  48589. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48590. /**
  48591. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48592. */
  48593. teleportationEnabled: boolean;
  48594. private _defaultHeight;
  48595. private _teleportationInitialized;
  48596. private _interactionsEnabled;
  48597. private _interactionsRequested;
  48598. private _displayGaze;
  48599. private _displayLaserPointer;
  48600. /**
  48601. * The mesh used to display where the user is going to teleport.
  48602. */
  48603. get teleportationTarget(): Mesh;
  48604. /**
  48605. * Sets the mesh to be used to display where the user is going to teleport.
  48606. */
  48607. set teleportationTarget(value: Mesh);
  48608. /**
  48609. * 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
  48610. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48611. * See http://doc.babylonjs.com/resources/baking_transformations
  48612. */
  48613. get gazeTrackerMesh(): Mesh;
  48614. set gazeTrackerMesh(value: Mesh);
  48615. /**
  48616. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48617. */
  48618. updateGazeTrackerScale: boolean;
  48619. /**
  48620. * If the gaze trackers color should be updated when selecting meshes
  48621. */
  48622. updateGazeTrackerColor: boolean;
  48623. /**
  48624. * If the controller laser color should be updated when selecting meshes
  48625. */
  48626. updateControllerLaserColor: boolean;
  48627. /**
  48628. * The gaze tracking mesh corresponding to the left controller
  48629. */
  48630. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48631. /**
  48632. * The gaze tracking mesh corresponding to the right controller
  48633. */
  48634. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48635. /**
  48636. * If the ray of the gaze should be displayed.
  48637. */
  48638. get displayGaze(): boolean;
  48639. /**
  48640. * Sets if the ray of the gaze should be displayed.
  48641. */
  48642. set displayGaze(value: boolean);
  48643. /**
  48644. * If the ray of the LaserPointer should be displayed.
  48645. */
  48646. get displayLaserPointer(): boolean;
  48647. /**
  48648. * Sets if the ray of the LaserPointer should be displayed.
  48649. */
  48650. set displayLaserPointer(value: boolean);
  48651. /**
  48652. * The deviceOrientationCamera used as the camera when not in VR.
  48653. */
  48654. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48655. /**
  48656. * Based on the current WebVR support, returns the current VR camera used.
  48657. */
  48658. get currentVRCamera(): Nullable<Camera>;
  48659. /**
  48660. * The webVRCamera which is used when in VR.
  48661. */
  48662. get webVRCamera(): WebVRFreeCamera;
  48663. /**
  48664. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48665. */
  48666. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48667. /**
  48668. * The html button that is used to trigger entering into VR.
  48669. */
  48670. get vrButton(): Nullable<HTMLButtonElement>;
  48671. private get _teleportationRequestInitiated();
  48672. /**
  48673. * Defines whether or not Pointer lock should be requested when switching to
  48674. * full screen.
  48675. */
  48676. requestPointerLockOnFullScreen: boolean;
  48677. /**
  48678. * If asking to force XR, this will be populated with the default xr experience
  48679. */
  48680. xr: WebXRDefaultExperience;
  48681. /**
  48682. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48683. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48684. */
  48685. xrTestDone: boolean;
  48686. /**
  48687. * Instantiates a VRExperienceHelper.
  48688. * Helps to quickly add VR support to an existing scene.
  48689. * @param scene The scene the VRExperienceHelper belongs to.
  48690. * @param webVROptions Options to modify the vr experience helper's behavior.
  48691. */
  48692. constructor(scene: Scene,
  48693. /** Options to modify the vr experience helper's behavior. */
  48694. webVROptions?: VRExperienceHelperOptions);
  48695. private completeVRInit;
  48696. private _onDefaultMeshLoaded;
  48697. private _onResize;
  48698. private _onFullscreenChange;
  48699. /**
  48700. * Gets a value indicating if we are currently in VR mode.
  48701. */
  48702. get isInVRMode(): boolean;
  48703. private onVrDisplayPresentChange;
  48704. private onVRDisplayChanged;
  48705. private moveButtonToBottomRight;
  48706. private displayVRButton;
  48707. private updateButtonVisibility;
  48708. private _cachedAngularSensibility;
  48709. /**
  48710. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48711. * Otherwise, will use the fullscreen API.
  48712. */
  48713. enterVR(): void;
  48714. /**
  48715. * Attempt to exit VR, or fullscreen.
  48716. */
  48717. exitVR(): void;
  48718. /**
  48719. * The position of the vr experience helper.
  48720. */
  48721. get position(): Vector3;
  48722. /**
  48723. * Sets the position of the vr experience helper.
  48724. */
  48725. set position(value: Vector3);
  48726. /**
  48727. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48728. */
  48729. enableInteractions(): void;
  48730. private get _noControllerIsActive();
  48731. private beforeRender;
  48732. private _isTeleportationFloor;
  48733. /**
  48734. * Adds a floor mesh to be used for teleportation.
  48735. * @param floorMesh the mesh to be used for teleportation.
  48736. */
  48737. addFloorMesh(floorMesh: Mesh): void;
  48738. /**
  48739. * Removes a floor mesh from being used for teleportation.
  48740. * @param floorMesh the mesh to be removed.
  48741. */
  48742. removeFloorMesh(floorMesh: Mesh): void;
  48743. /**
  48744. * Enables interactions and teleportation using the VR controllers and gaze.
  48745. * @param vrTeleportationOptions options to modify teleportation behavior.
  48746. */
  48747. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48748. private _onNewGamepadConnected;
  48749. private _tryEnableInteractionOnController;
  48750. private _onNewGamepadDisconnected;
  48751. private _enableInteractionOnController;
  48752. private _checkTeleportWithRay;
  48753. private _checkRotate;
  48754. private _checkTeleportBackwards;
  48755. private _enableTeleportationOnController;
  48756. private _createTeleportationCircles;
  48757. private _displayTeleportationTarget;
  48758. private _hideTeleportationTarget;
  48759. private _rotateCamera;
  48760. private _moveTeleportationSelectorTo;
  48761. private _workingVector;
  48762. private _workingQuaternion;
  48763. private _workingMatrix;
  48764. /**
  48765. * Time Constant Teleportation Mode
  48766. */
  48767. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48768. /**
  48769. * Speed Constant Teleportation Mode
  48770. */
  48771. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48772. /**
  48773. * Teleports the users feet to the desired location
  48774. * @param location The location where the user's feet should be placed
  48775. */
  48776. teleportCamera(location: Vector3): void;
  48777. private _convertNormalToDirectionOfRay;
  48778. private _castRayAndSelectObject;
  48779. private _notifySelectedMeshUnselected;
  48780. /**
  48781. * Permanently set new colors for the laser pointer
  48782. * @param color the new laser color
  48783. * @param pickedColor the new laser color when picked mesh detected
  48784. */
  48785. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48786. /**
  48787. * Set lighting enabled / disabled on the laser pointer of both controllers
  48788. * @param enabled should the lighting be enabled on the laser pointer
  48789. */
  48790. setLaserLightingState(enabled?: boolean): void;
  48791. /**
  48792. * Permanently set new colors for the gaze pointer
  48793. * @param color the new gaze color
  48794. * @param pickedColor the new gaze color when picked mesh detected
  48795. */
  48796. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48797. /**
  48798. * Sets the color of the laser ray from the vr controllers.
  48799. * @param color new color for the ray.
  48800. */
  48801. changeLaserColor(color: Color3): void;
  48802. /**
  48803. * Sets the color of the ray from the vr headsets gaze.
  48804. * @param color new color for the ray.
  48805. */
  48806. changeGazeColor(color: Color3): void;
  48807. /**
  48808. * Exits VR and disposes of the vr experience helper
  48809. */
  48810. dispose(): void;
  48811. /**
  48812. * Gets the name of the VRExperienceHelper class
  48813. * @returns "VRExperienceHelper"
  48814. */
  48815. getClassName(): string;
  48816. }
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * Contains an array of blocks representing the octree
  48821. */
  48822. export interface IOctreeContainer<T> {
  48823. /**
  48824. * Blocks within the octree
  48825. */
  48826. blocks: Array<OctreeBlock<T>>;
  48827. }
  48828. /**
  48829. * Class used to store a cell in an octree
  48830. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48831. */
  48832. export class OctreeBlock<T> {
  48833. /**
  48834. * Gets the content of the current block
  48835. */
  48836. entries: T[];
  48837. /**
  48838. * Gets the list of block children
  48839. */
  48840. blocks: Array<OctreeBlock<T>>;
  48841. private _depth;
  48842. private _maxDepth;
  48843. private _capacity;
  48844. private _minPoint;
  48845. private _maxPoint;
  48846. private _boundingVectors;
  48847. private _creationFunc;
  48848. /**
  48849. * Creates a new block
  48850. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48851. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48852. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48853. * @param depth defines the current depth of this block in the octree
  48854. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48855. * @param creationFunc defines a callback to call when an element is added to the block
  48856. */
  48857. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48858. /**
  48859. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48860. */
  48861. get capacity(): number;
  48862. /**
  48863. * Gets the minimum vector (in world space) of the block's bounding box
  48864. */
  48865. get minPoint(): Vector3;
  48866. /**
  48867. * Gets the maximum vector (in world space) of the block's bounding box
  48868. */
  48869. get maxPoint(): Vector3;
  48870. /**
  48871. * Add a new element to this block
  48872. * @param entry defines the element to add
  48873. */
  48874. addEntry(entry: T): void;
  48875. /**
  48876. * Remove an element from this block
  48877. * @param entry defines the element to remove
  48878. */
  48879. removeEntry(entry: T): void;
  48880. /**
  48881. * Add an array of elements to this block
  48882. * @param entries defines the array of elements to add
  48883. */
  48884. addEntries(entries: T[]): void;
  48885. /**
  48886. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48887. * @param frustumPlanes defines the frustum planes to test
  48888. * @param selection defines the array to store current content if selection is positive
  48889. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48890. */
  48891. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48892. /**
  48893. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48894. * @param sphereCenter defines the bounding sphere center
  48895. * @param sphereRadius defines the bounding sphere radius
  48896. * @param selection defines the array to store current content if selection is positive
  48897. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48898. */
  48899. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48900. /**
  48901. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48902. * @param ray defines the ray to test with
  48903. * @param selection defines the array to store current content if selection is positive
  48904. */
  48905. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48906. /**
  48907. * Subdivide the content into child blocks (this block will then be empty)
  48908. */
  48909. createInnerBlocks(): void;
  48910. /**
  48911. * @hidden
  48912. */
  48913. 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;
  48914. }
  48915. }
  48916. declare module BABYLON {
  48917. /**
  48918. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48919. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48920. */
  48921. export class Octree<T> {
  48922. /** 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.) */
  48923. maxDepth: number;
  48924. /**
  48925. * Blocks within the octree containing objects
  48926. */
  48927. blocks: Array<OctreeBlock<T>>;
  48928. /**
  48929. * Content stored in the octree
  48930. */
  48931. dynamicContent: T[];
  48932. private _maxBlockCapacity;
  48933. private _selectionContent;
  48934. private _creationFunc;
  48935. /**
  48936. * Creates a octree
  48937. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48938. * @param creationFunc function to be used to instatiate the octree
  48939. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48940. * @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.)
  48941. */
  48942. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48943. /** 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.) */
  48944. maxDepth?: number);
  48945. /**
  48946. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48947. * @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);
  48948. * @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);
  48949. * @param entries meshes to be added to the octree blocks
  48950. */
  48951. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48952. /**
  48953. * Adds a mesh to the octree
  48954. * @param entry Mesh to add to the octree
  48955. */
  48956. addMesh(entry: T): void;
  48957. /**
  48958. * Remove an element from the octree
  48959. * @param entry defines the element to remove
  48960. */
  48961. removeMesh(entry: T): void;
  48962. /**
  48963. * Selects an array of meshes within the frustum
  48964. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48965. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48966. * @returns array of meshes within the frustum
  48967. */
  48968. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48969. /**
  48970. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48971. * @param sphereCenter defines the bounding sphere center
  48972. * @param sphereRadius defines the bounding sphere radius
  48973. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48974. * @returns an array of objects that intersect the sphere
  48975. */
  48976. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48977. /**
  48978. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48979. * @param ray defines the ray to test with
  48980. * @returns array of intersected objects
  48981. */
  48982. intersectsRay(ray: Ray): SmartArray<T>;
  48983. /**
  48984. * Adds a mesh into the octree block if it intersects the block
  48985. */
  48986. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48987. /**
  48988. * Adds a submesh into the octree block if it intersects the block
  48989. */
  48990. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48991. }
  48992. }
  48993. declare module BABYLON {
  48994. interface Scene {
  48995. /**
  48996. * @hidden
  48997. * Backing Filed
  48998. */
  48999. _selectionOctree: Octree<AbstractMesh>;
  49000. /**
  49001. * Gets the octree used to boost mesh selection (picking)
  49002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49003. */
  49004. selectionOctree: Octree<AbstractMesh>;
  49005. /**
  49006. * Creates or updates the octree used to boost selection (picking)
  49007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49008. * @param maxCapacity defines the maximum capacity per leaf
  49009. * @param maxDepth defines the maximum depth of the octree
  49010. * @returns an octree of AbstractMesh
  49011. */
  49012. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49013. }
  49014. interface AbstractMesh {
  49015. /**
  49016. * @hidden
  49017. * Backing Field
  49018. */
  49019. _submeshesOctree: Octree<SubMesh>;
  49020. /**
  49021. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49022. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49023. * @param maxCapacity defines the maximum size of each block (64 by default)
  49024. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49025. * @returns the new octree
  49026. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49028. */
  49029. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49030. }
  49031. /**
  49032. * Defines the octree scene component responsible to manage any octrees
  49033. * in a given scene.
  49034. */
  49035. export class OctreeSceneComponent {
  49036. /**
  49037. * The component name help to identify the component in the list of scene components.
  49038. */
  49039. readonly name: string;
  49040. /**
  49041. * The scene the component belongs to.
  49042. */
  49043. scene: Scene;
  49044. /**
  49045. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49046. */
  49047. readonly checksIsEnabled: boolean;
  49048. /**
  49049. * Creates a new instance of the component for the given scene
  49050. * @param scene Defines the scene to register the component in
  49051. */
  49052. constructor(scene: Scene);
  49053. /**
  49054. * Registers the component in a given scene
  49055. */
  49056. register(): void;
  49057. /**
  49058. * Return the list of active meshes
  49059. * @returns the list of active meshes
  49060. */
  49061. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49062. /**
  49063. * Return the list of active sub meshes
  49064. * @param mesh The mesh to get the candidates sub meshes from
  49065. * @returns the list of active sub meshes
  49066. */
  49067. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49068. private _tempRay;
  49069. /**
  49070. * Return the list of sub meshes intersecting with a given local ray
  49071. * @param mesh defines the mesh to find the submesh for
  49072. * @param localRay defines the ray in local space
  49073. * @returns the list of intersecting sub meshes
  49074. */
  49075. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49076. /**
  49077. * Return the list of sub meshes colliding with a collider
  49078. * @param mesh defines the mesh to find the submesh for
  49079. * @param collider defines the collider to evaluate the collision against
  49080. * @returns the list of colliding sub meshes
  49081. */
  49082. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49083. /**
  49084. * Rebuilds the elements related to this component in case of
  49085. * context lost for instance.
  49086. */
  49087. rebuild(): void;
  49088. /**
  49089. * Disposes the component and the associated ressources.
  49090. */
  49091. dispose(): void;
  49092. }
  49093. }
  49094. declare module BABYLON {
  49095. /**
  49096. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49097. */
  49098. export class Gizmo implements IDisposable {
  49099. /** The utility layer the gizmo will be added to */
  49100. gizmoLayer: UtilityLayerRenderer;
  49101. /**
  49102. * The root mesh of the gizmo
  49103. */
  49104. _rootMesh: Mesh;
  49105. private _attachedMesh;
  49106. /**
  49107. * Ratio for the scale of the gizmo (Default: 1)
  49108. */
  49109. scaleRatio: number;
  49110. /**
  49111. * If a custom mesh has been set (Default: false)
  49112. */
  49113. protected _customMeshSet: boolean;
  49114. /**
  49115. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49116. * * When set, interactions will be enabled
  49117. */
  49118. get attachedMesh(): Nullable<AbstractMesh>;
  49119. set attachedMesh(value: Nullable<AbstractMesh>);
  49120. /**
  49121. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49122. * @param mesh The mesh to replace the default mesh of the gizmo
  49123. */
  49124. setCustomMesh(mesh: Mesh): void;
  49125. /**
  49126. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49127. */
  49128. updateGizmoRotationToMatchAttachedMesh: boolean;
  49129. /**
  49130. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49131. */
  49132. updateGizmoPositionToMatchAttachedMesh: boolean;
  49133. /**
  49134. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49135. */
  49136. updateScale: boolean;
  49137. protected _interactionsEnabled: boolean;
  49138. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49139. private _beforeRenderObserver;
  49140. private _tempVector;
  49141. /**
  49142. * Creates a gizmo
  49143. * @param gizmoLayer The utility layer the gizmo will be added to
  49144. */
  49145. constructor(
  49146. /** The utility layer the gizmo will be added to */
  49147. gizmoLayer?: UtilityLayerRenderer);
  49148. /**
  49149. * Updates the gizmo to match the attached mesh's position/rotation
  49150. */
  49151. protected _update(): void;
  49152. /**
  49153. * Disposes of the gizmo
  49154. */
  49155. dispose(): void;
  49156. }
  49157. }
  49158. declare module BABYLON {
  49159. /**
  49160. * Single plane drag gizmo
  49161. */
  49162. export class PlaneDragGizmo extends Gizmo {
  49163. /**
  49164. * Drag behavior responsible for the gizmos dragging interactions
  49165. */
  49166. dragBehavior: PointerDragBehavior;
  49167. private _pointerObserver;
  49168. /**
  49169. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49170. */
  49171. snapDistance: number;
  49172. /**
  49173. * Event that fires each time the gizmo snaps to a new location.
  49174. * * snapDistance is the the change in distance
  49175. */
  49176. onSnapObservable: Observable<{
  49177. snapDistance: number;
  49178. }>;
  49179. private _plane;
  49180. private _coloredMaterial;
  49181. private _hoverMaterial;
  49182. private _isEnabled;
  49183. private _parent;
  49184. /** @hidden */
  49185. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49186. /** @hidden */
  49187. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49188. /**
  49189. * Creates a PlaneDragGizmo
  49190. * @param gizmoLayer The utility layer the gizmo will be added to
  49191. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49192. * @param color The color of the gizmo
  49193. */
  49194. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49195. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49196. /**
  49197. * If the gizmo is enabled
  49198. */
  49199. set isEnabled(value: boolean);
  49200. get isEnabled(): boolean;
  49201. /**
  49202. * Disposes of the gizmo
  49203. */
  49204. dispose(): void;
  49205. }
  49206. }
  49207. declare module BABYLON {
  49208. /**
  49209. * Gizmo that enables dragging a mesh along 3 axis
  49210. */
  49211. export class PositionGizmo extends Gizmo {
  49212. /**
  49213. * Internal gizmo used for interactions on the x axis
  49214. */
  49215. xGizmo: AxisDragGizmo;
  49216. /**
  49217. * Internal gizmo used for interactions on the y axis
  49218. */
  49219. yGizmo: AxisDragGizmo;
  49220. /**
  49221. * Internal gizmo used for interactions on the z axis
  49222. */
  49223. zGizmo: AxisDragGizmo;
  49224. /**
  49225. * Internal gizmo used for interactions on the yz plane
  49226. */
  49227. xPlaneGizmo: PlaneDragGizmo;
  49228. /**
  49229. * Internal gizmo used for interactions on the xz plane
  49230. */
  49231. yPlaneGizmo: PlaneDragGizmo;
  49232. /**
  49233. * Internal gizmo used for interactions on the xy plane
  49234. */
  49235. zPlaneGizmo: PlaneDragGizmo;
  49236. /**
  49237. * private variables
  49238. */
  49239. private _meshAttached;
  49240. private _updateGizmoRotationToMatchAttachedMesh;
  49241. private _snapDistance;
  49242. private _scaleRatio;
  49243. /** Fires an event when any of it's sub gizmos are dragged */
  49244. onDragStartObservable: Observable<unknown>;
  49245. /** Fires an event when any of it's sub gizmos are released from dragging */
  49246. onDragEndObservable: Observable<unknown>;
  49247. /**
  49248. * If set to true, planar drag is enabled
  49249. */
  49250. private _planarGizmoEnabled;
  49251. get attachedMesh(): Nullable<AbstractMesh>;
  49252. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49253. /**
  49254. * Creates a PositionGizmo
  49255. * @param gizmoLayer The utility layer the gizmo will be added to
  49256. */
  49257. constructor(gizmoLayer?: UtilityLayerRenderer);
  49258. /**
  49259. * If the planar drag gizmo is enabled
  49260. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49261. */
  49262. set planarGizmoEnabled(value: boolean);
  49263. get planarGizmoEnabled(): boolean;
  49264. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49265. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49266. /**
  49267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49268. */
  49269. set snapDistance(value: number);
  49270. get snapDistance(): number;
  49271. /**
  49272. * Ratio for the scale of the gizmo (Default: 1)
  49273. */
  49274. set scaleRatio(value: number);
  49275. get scaleRatio(): number;
  49276. /**
  49277. * Disposes of the gizmo
  49278. */
  49279. dispose(): void;
  49280. /**
  49281. * CustomMeshes are not supported by this gizmo
  49282. * @param mesh The mesh to replace the default mesh of the gizmo
  49283. */
  49284. setCustomMesh(mesh: Mesh): void;
  49285. }
  49286. }
  49287. declare module BABYLON {
  49288. /**
  49289. * Single axis drag gizmo
  49290. */
  49291. export class AxisDragGizmo extends Gizmo {
  49292. /**
  49293. * Drag behavior responsible for the gizmos dragging interactions
  49294. */
  49295. dragBehavior: PointerDragBehavior;
  49296. private _pointerObserver;
  49297. /**
  49298. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49299. */
  49300. snapDistance: number;
  49301. /**
  49302. * Event that fires each time the gizmo snaps to a new location.
  49303. * * snapDistance is the the change in distance
  49304. */
  49305. onSnapObservable: Observable<{
  49306. snapDistance: number;
  49307. }>;
  49308. private _isEnabled;
  49309. private _parent;
  49310. private _arrow;
  49311. private _coloredMaterial;
  49312. private _hoverMaterial;
  49313. /** @hidden */
  49314. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49315. /** @hidden */
  49316. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49317. /**
  49318. * Creates an AxisDragGizmo
  49319. * @param gizmoLayer The utility layer the gizmo will be added to
  49320. * @param dragAxis The axis which the gizmo will be able to drag on
  49321. * @param color The color of the gizmo
  49322. */
  49323. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49324. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49325. /**
  49326. * If the gizmo is enabled
  49327. */
  49328. set isEnabled(value: boolean);
  49329. get isEnabled(): boolean;
  49330. /**
  49331. * Disposes of the gizmo
  49332. */
  49333. dispose(): void;
  49334. }
  49335. }
  49336. declare module BABYLON.Debug {
  49337. /**
  49338. * The Axes viewer will show 3 axes in a specific point in space
  49339. */
  49340. export class AxesViewer {
  49341. private _xAxis;
  49342. private _yAxis;
  49343. private _zAxis;
  49344. private _scaleLinesFactor;
  49345. private _instanced;
  49346. /**
  49347. * Gets the hosting scene
  49348. */
  49349. scene: Scene;
  49350. /**
  49351. * Gets or sets a number used to scale line length
  49352. */
  49353. scaleLines: number;
  49354. /** Gets the node hierarchy used to render x-axis */
  49355. get xAxis(): TransformNode;
  49356. /** Gets the node hierarchy used to render y-axis */
  49357. get yAxis(): TransformNode;
  49358. /** Gets the node hierarchy used to render z-axis */
  49359. get zAxis(): TransformNode;
  49360. /**
  49361. * Creates a new AxesViewer
  49362. * @param scene defines the hosting scene
  49363. * @param scaleLines defines a number used to scale line length (1 by default)
  49364. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49365. * @param xAxis defines the node hierarchy used to render the x-axis
  49366. * @param yAxis defines the node hierarchy used to render the y-axis
  49367. * @param zAxis defines the node hierarchy used to render the z-axis
  49368. */
  49369. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49370. /**
  49371. * Force the viewer to update
  49372. * @param position defines the position of the viewer
  49373. * @param xaxis defines the x axis of the viewer
  49374. * @param yaxis defines the y axis of the viewer
  49375. * @param zaxis defines the z axis of the viewer
  49376. */
  49377. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49378. /**
  49379. * Creates an instance of this axes viewer.
  49380. * @returns a new axes viewer with instanced meshes
  49381. */
  49382. createInstance(): AxesViewer;
  49383. /** Releases resources */
  49384. dispose(): void;
  49385. private static _SetRenderingGroupId;
  49386. }
  49387. }
  49388. declare module BABYLON.Debug {
  49389. /**
  49390. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49391. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49392. */
  49393. export class BoneAxesViewer extends AxesViewer {
  49394. /**
  49395. * Gets or sets the target mesh where to display the axes viewer
  49396. */
  49397. mesh: Nullable<Mesh>;
  49398. /**
  49399. * Gets or sets the target bone where to display the axes viewer
  49400. */
  49401. bone: Nullable<Bone>;
  49402. /** Gets current position */
  49403. pos: Vector3;
  49404. /** Gets direction of X axis */
  49405. xaxis: Vector3;
  49406. /** Gets direction of Y axis */
  49407. yaxis: Vector3;
  49408. /** Gets direction of Z axis */
  49409. zaxis: Vector3;
  49410. /**
  49411. * Creates a new BoneAxesViewer
  49412. * @param scene defines the hosting scene
  49413. * @param bone defines the target bone
  49414. * @param mesh defines the target mesh
  49415. * @param scaleLines defines a scaling factor for line length (1 by default)
  49416. */
  49417. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49418. /**
  49419. * Force the viewer to update
  49420. */
  49421. update(): void;
  49422. /** Releases resources */
  49423. dispose(): void;
  49424. }
  49425. }
  49426. declare module BABYLON {
  49427. /**
  49428. * Interface used to define scene explorer extensibility option
  49429. */
  49430. export interface IExplorerExtensibilityOption {
  49431. /**
  49432. * Define the option label
  49433. */
  49434. label: string;
  49435. /**
  49436. * Defines the action to execute on click
  49437. */
  49438. action: (entity: any) => void;
  49439. }
  49440. /**
  49441. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49442. */
  49443. export interface IExplorerExtensibilityGroup {
  49444. /**
  49445. * Defines a predicate to test if a given type mut be extended
  49446. */
  49447. predicate: (entity: any) => boolean;
  49448. /**
  49449. * Gets the list of options added to a type
  49450. */
  49451. entries: IExplorerExtensibilityOption[];
  49452. }
  49453. /**
  49454. * Interface used to define the options to use to create the Inspector
  49455. */
  49456. export interface IInspectorOptions {
  49457. /**
  49458. * Display in overlay mode (default: false)
  49459. */
  49460. overlay?: boolean;
  49461. /**
  49462. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49463. */
  49464. globalRoot?: HTMLElement;
  49465. /**
  49466. * Display the Scene explorer
  49467. */
  49468. showExplorer?: boolean;
  49469. /**
  49470. * Display the property inspector
  49471. */
  49472. showInspector?: boolean;
  49473. /**
  49474. * Display in embed mode (both panes on the right)
  49475. */
  49476. embedMode?: boolean;
  49477. /**
  49478. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49479. */
  49480. handleResize?: boolean;
  49481. /**
  49482. * Allow the panes to popup (default: true)
  49483. */
  49484. enablePopup?: boolean;
  49485. /**
  49486. * Allow the panes to be closed by users (default: true)
  49487. */
  49488. enableClose?: boolean;
  49489. /**
  49490. * Optional list of extensibility entries
  49491. */
  49492. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49493. /**
  49494. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49495. */
  49496. inspectorURL?: string;
  49497. /**
  49498. * Optional initial tab (default to DebugLayerTab.Properties)
  49499. */
  49500. initialTab?: DebugLayerTab;
  49501. }
  49502. interface Scene {
  49503. /**
  49504. * @hidden
  49505. * Backing field
  49506. */
  49507. _debugLayer: DebugLayer;
  49508. /**
  49509. * Gets the debug layer (aka Inspector) associated with the scene
  49510. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49511. */
  49512. debugLayer: DebugLayer;
  49513. }
  49514. /**
  49515. * Enum of inspector action tab
  49516. */
  49517. export enum DebugLayerTab {
  49518. /**
  49519. * Properties tag (default)
  49520. */
  49521. Properties = 0,
  49522. /**
  49523. * Debug tab
  49524. */
  49525. Debug = 1,
  49526. /**
  49527. * Statistics tab
  49528. */
  49529. Statistics = 2,
  49530. /**
  49531. * Tools tab
  49532. */
  49533. Tools = 3,
  49534. /**
  49535. * Settings tab
  49536. */
  49537. Settings = 4
  49538. }
  49539. /**
  49540. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49541. * what is happening in your scene
  49542. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49543. */
  49544. export class DebugLayer {
  49545. /**
  49546. * Define the url to get the inspector script from.
  49547. * By default it uses the babylonjs CDN.
  49548. * @ignoreNaming
  49549. */
  49550. static InspectorURL: string;
  49551. private _scene;
  49552. private BJSINSPECTOR;
  49553. private _onPropertyChangedObservable?;
  49554. /**
  49555. * Observable triggered when a property is changed through the inspector.
  49556. */
  49557. get onPropertyChangedObservable(): any;
  49558. /**
  49559. * Instantiates a new debug layer.
  49560. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49561. * what is happening in your scene
  49562. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49563. * @param scene Defines the scene to inspect
  49564. */
  49565. constructor(scene: Scene);
  49566. /** Creates the inspector window. */
  49567. private _createInspector;
  49568. /**
  49569. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49570. * @param entity defines the entity to select
  49571. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49572. */
  49573. select(entity: any, lineContainerTitles?: string | string[]): void;
  49574. /** Get the inspector from bundle or global */
  49575. private _getGlobalInspector;
  49576. /**
  49577. * Get if the inspector is visible or not.
  49578. * @returns true if visible otherwise, false
  49579. */
  49580. isVisible(): boolean;
  49581. /**
  49582. * Hide the inspector and close its window.
  49583. */
  49584. hide(): void;
  49585. /**
  49586. * Update the scene in the inspector
  49587. */
  49588. setAsActiveScene(): void;
  49589. /**
  49590. * Launch the debugLayer.
  49591. * @param config Define the configuration of the inspector
  49592. * @return a promise fulfilled when the debug layer is visible
  49593. */
  49594. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49595. }
  49596. }
  49597. declare module BABYLON {
  49598. /**
  49599. * Class containing static functions to help procedurally build meshes
  49600. */
  49601. export class BoxBuilder {
  49602. /**
  49603. * Creates a box mesh
  49604. * * The parameter `size` sets the size (float) of each box side (default 1)
  49605. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49606. * * 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)
  49607. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49609. * * 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
  49610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49611. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49612. * @param name defines the name of the mesh
  49613. * @param options defines the options used to create the mesh
  49614. * @param scene defines the hosting scene
  49615. * @returns the box mesh
  49616. */
  49617. static CreateBox(name: string, options: {
  49618. size?: number;
  49619. width?: number;
  49620. height?: number;
  49621. depth?: number;
  49622. faceUV?: Vector4[];
  49623. faceColors?: Color4[];
  49624. sideOrientation?: number;
  49625. frontUVs?: Vector4;
  49626. backUVs?: Vector4;
  49627. wrap?: boolean;
  49628. topBaseAt?: number;
  49629. bottomBaseAt?: number;
  49630. updatable?: boolean;
  49631. }, scene?: Nullable<Scene>): Mesh;
  49632. }
  49633. }
  49634. declare module BABYLON.Debug {
  49635. /**
  49636. * Used to show the physics impostor around the specific mesh
  49637. */
  49638. export class PhysicsViewer {
  49639. /** @hidden */
  49640. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49641. /** @hidden */
  49642. protected _meshes: Array<Nullable<AbstractMesh>>;
  49643. /** @hidden */
  49644. protected _scene: Nullable<Scene>;
  49645. /** @hidden */
  49646. protected _numMeshes: number;
  49647. /** @hidden */
  49648. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49649. private _renderFunction;
  49650. private _utilityLayer;
  49651. private _debugBoxMesh;
  49652. private _debugSphereMesh;
  49653. private _debugCylinderMesh;
  49654. private _debugMaterial;
  49655. private _debugMeshMeshes;
  49656. /**
  49657. * Creates a new PhysicsViewer
  49658. * @param scene defines the hosting scene
  49659. */
  49660. constructor(scene: Scene);
  49661. /** @hidden */
  49662. protected _updateDebugMeshes(): void;
  49663. /**
  49664. * Renders a specified physic impostor
  49665. * @param impostor defines the impostor to render
  49666. * @param targetMesh defines the mesh represented by the impostor
  49667. * @returns the new debug mesh used to render the impostor
  49668. */
  49669. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49670. /**
  49671. * Hides a specified physic impostor
  49672. * @param impostor defines the impostor to hide
  49673. */
  49674. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49675. private _getDebugMaterial;
  49676. private _getDebugBoxMesh;
  49677. private _getDebugSphereMesh;
  49678. private _getDebugCylinderMesh;
  49679. private _getDebugMeshMesh;
  49680. private _getDebugMesh;
  49681. /** Releases all resources */
  49682. dispose(): void;
  49683. }
  49684. }
  49685. declare module BABYLON {
  49686. /**
  49687. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49688. * in order to better appreciate the issue one might have.
  49689. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49690. */
  49691. export class RayHelper {
  49692. /**
  49693. * Defines the ray we are currently tryin to visualize.
  49694. */
  49695. ray: Nullable<Ray>;
  49696. private _renderPoints;
  49697. private _renderLine;
  49698. private _renderFunction;
  49699. private _scene;
  49700. private _updateToMeshFunction;
  49701. private _attachedToMesh;
  49702. private _meshSpaceDirection;
  49703. private _meshSpaceOrigin;
  49704. /**
  49705. * Helper function to create a colored helper in a scene in one line.
  49706. * @param ray Defines the ray we are currently tryin to visualize
  49707. * @param scene Defines the scene the ray is used in
  49708. * @param color Defines the color we want to see the ray in
  49709. * @returns The newly created ray helper.
  49710. */
  49711. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49712. /**
  49713. * Instantiate a new ray helper.
  49714. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49715. * in order to better appreciate the issue one might have.
  49716. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49717. * @param ray Defines the ray we are currently tryin to visualize
  49718. */
  49719. constructor(ray: Ray);
  49720. /**
  49721. * Shows the ray we are willing to debug.
  49722. * @param scene Defines the scene the ray needs to be rendered in
  49723. * @param color Defines the color the ray needs to be rendered in
  49724. */
  49725. show(scene: Scene, color?: Color3): void;
  49726. /**
  49727. * Hides the ray we are debugging.
  49728. */
  49729. hide(): void;
  49730. private _render;
  49731. /**
  49732. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49733. * @param mesh Defines the mesh we want the helper attached to
  49734. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49735. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49736. * @param length Defines the length of the ray
  49737. */
  49738. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49739. /**
  49740. * Detach the ray helper from the mesh it has previously been attached to.
  49741. */
  49742. detachFromMesh(): void;
  49743. private _updateToMesh;
  49744. /**
  49745. * Dispose the helper and release its associated resources.
  49746. */
  49747. dispose(): void;
  49748. }
  49749. }
  49750. declare module BABYLON.Debug {
  49751. /**
  49752. * Class used to render a debug view of a given skeleton
  49753. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49754. */
  49755. export class SkeletonViewer {
  49756. /** defines the skeleton to render */
  49757. skeleton: Skeleton;
  49758. /** defines the mesh attached to the skeleton */
  49759. mesh: AbstractMesh;
  49760. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49761. autoUpdateBonesMatrices: boolean;
  49762. /** defines the rendering group id to use with the viewer */
  49763. renderingGroupId: number;
  49764. /** Gets or sets the color used to render the skeleton */
  49765. color: Color3;
  49766. private _scene;
  49767. private _debugLines;
  49768. private _debugMesh;
  49769. private _isEnabled;
  49770. private _renderFunction;
  49771. private _utilityLayer;
  49772. /**
  49773. * Returns the mesh used to render the bones
  49774. */
  49775. get debugMesh(): Nullable<LinesMesh>;
  49776. /**
  49777. * Creates a new SkeletonViewer
  49778. * @param skeleton defines the skeleton to render
  49779. * @param mesh defines the mesh attached to the skeleton
  49780. * @param scene defines the hosting scene
  49781. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49782. * @param renderingGroupId defines the rendering group id to use with the viewer
  49783. */
  49784. constructor(
  49785. /** defines the skeleton to render */
  49786. skeleton: Skeleton,
  49787. /** defines the mesh attached to the skeleton */
  49788. mesh: AbstractMesh, scene: Scene,
  49789. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49790. autoUpdateBonesMatrices?: boolean,
  49791. /** defines the rendering group id to use with the viewer */
  49792. renderingGroupId?: number);
  49793. /** Gets or sets a boolean indicating if the viewer is enabled */
  49794. set isEnabled(value: boolean);
  49795. get isEnabled(): boolean;
  49796. private _getBonePosition;
  49797. private _getLinesForBonesWithLength;
  49798. private _getLinesForBonesNoLength;
  49799. /** Update the viewer to sync with current skeleton state */
  49800. update(): void;
  49801. /** Release associated resources */
  49802. dispose(): void;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * Enum for Device Types
  49808. */
  49809. export enum DeviceType {
  49810. /** Generic */
  49811. Generic = 0,
  49812. /** Keyboard */
  49813. Keyboard = 1,
  49814. /** Mouse */
  49815. Mouse = 2,
  49816. /** Touch Pointers */
  49817. Touch = 3,
  49818. /** PS4 Dual Shock */
  49819. DualShock = 4,
  49820. /** Xbox */
  49821. Xbox = 5,
  49822. /** Switch Controller */
  49823. Switch = 6
  49824. }
  49825. /**
  49826. * Enum for All Pointers (Touch/Mouse)
  49827. */
  49828. export enum PointerInput {
  49829. /** Horizontal Axis */
  49830. Horizontal = 0,
  49831. /** Vertical Axis */
  49832. Vertical = 1,
  49833. /** Left Click or Touch */
  49834. LeftClick = 2,
  49835. /** Middle Click */
  49836. MiddleClick = 3,
  49837. /** Right Click */
  49838. RightClick = 4,
  49839. /** Browser Back */
  49840. BrowserBack = 5,
  49841. /** Browser Forward */
  49842. BrowserForward = 6
  49843. }
  49844. /**
  49845. * Enum for Dual Shock Gamepad
  49846. */
  49847. export enum DualShockInput {
  49848. /** Cross */
  49849. Cross = 0,
  49850. /** Circle */
  49851. Circle = 1,
  49852. /** Square */
  49853. Square = 2,
  49854. /** Triangle */
  49855. Triangle = 3,
  49856. /** L1 */
  49857. L1 = 4,
  49858. /** R1 */
  49859. R1 = 5,
  49860. /** L2 */
  49861. L2 = 6,
  49862. /** R2 */
  49863. R2 = 7,
  49864. /** Share */
  49865. Share = 8,
  49866. /** Options */
  49867. Options = 9,
  49868. /** L3 */
  49869. L3 = 10,
  49870. /** R3 */
  49871. R3 = 11,
  49872. /** DPadUp */
  49873. DPadUp = 12,
  49874. /** DPadDown */
  49875. DPadDown = 13,
  49876. /** DPadLeft */
  49877. DPadLeft = 14,
  49878. /** DRight */
  49879. DPadRight = 15,
  49880. /** Home */
  49881. Home = 16,
  49882. /** TouchPad */
  49883. TouchPad = 17,
  49884. /** LStickXAxis */
  49885. LStickXAxis = 18,
  49886. /** LStickYAxis */
  49887. LStickYAxis = 19,
  49888. /** RStickXAxis */
  49889. RStickXAxis = 20,
  49890. /** RStickYAxis */
  49891. RStickYAxis = 21
  49892. }
  49893. /**
  49894. * Enum for Xbox Gamepad
  49895. */
  49896. export enum XboxInput {
  49897. /** A */
  49898. A = 0,
  49899. /** B */
  49900. B = 1,
  49901. /** X */
  49902. X = 2,
  49903. /** Y */
  49904. Y = 3,
  49905. /** LB */
  49906. LB = 4,
  49907. /** RB */
  49908. RB = 5,
  49909. /** LT */
  49910. LT = 6,
  49911. /** RT */
  49912. RT = 7,
  49913. /** Back */
  49914. Back = 8,
  49915. /** Start */
  49916. Start = 9,
  49917. /** LS */
  49918. LS = 10,
  49919. /** RS */
  49920. RS = 11,
  49921. /** DPadUp */
  49922. DPadUp = 12,
  49923. /** DPadDown */
  49924. DPadDown = 13,
  49925. /** DPadLeft */
  49926. DPadLeft = 14,
  49927. /** DRight */
  49928. DPadRight = 15,
  49929. /** Home */
  49930. Home = 16,
  49931. /** LStickXAxis */
  49932. LStickXAxis = 17,
  49933. /** LStickYAxis */
  49934. LStickYAxis = 18,
  49935. /** RStickXAxis */
  49936. RStickXAxis = 19,
  49937. /** RStickYAxis */
  49938. RStickYAxis = 20
  49939. }
  49940. /**
  49941. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49942. */
  49943. export enum SwitchInput {
  49944. /** B */
  49945. B = 0,
  49946. /** A */
  49947. A = 1,
  49948. /** Y */
  49949. Y = 2,
  49950. /** X */
  49951. X = 3,
  49952. /** L */
  49953. L = 4,
  49954. /** R */
  49955. R = 5,
  49956. /** ZL */
  49957. ZL = 6,
  49958. /** ZR */
  49959. ZR = 7,
  49960. /** Minus */
  49961. Minus = 8,
  49962. /** Plus */
  49963. Plus = 9,
  49964. /** LS */
  49965. LS = 10,
  49966. /** RS */
  49967. RS = 11,
  49968. /** DPadUp */
  49969. DPadUp = 12,
  49970. /** DPadDown */
  49971. DPadDown = 13,
  49972. /** DPadLeft */
  49973. DPadLeft = 14,
  49974. /** DRight */
  49975. DPadRight = 15,
  49976. /** Home */
  49977. Home = 16,
  49978. /** Capture */
  49979. Capture = 17,
  49980. /** LStickXAxis */
  49981. LStickXAxis = 18,
  49982. /** LStickYAxis */
  49983. LStickYAxis = 19,
  49984. /** RStickXAxis */
  49985. RStickXAxis = 20,
  49986. /** RStickYAxis */
  49987. RStickYAxis = 21
  49988. }
  49989. }
  49990. declare module BABYLON {
  49991. /**
  49992. * This class will take all inputs from Keyboard, Pointer, and
  49993. * any Gamepads and provide a polling system that all devices
  49994. * will use. This class assumes that there will only be one
  49995. * pointer device and one keyboard.
  49996. */
  49997. export class DeviceInputSystem implements IDisposable {
  49998. /**
  49999. * Callback to be triggered when a device is connected
  50000. */
  50001. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50002. /**
  50003. * Callback to be triggered when a device is disconnected
  50004. */
  50005. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50006. /**
  50007. * Callback to be triggered when event driven input is updated
  50008. */
  50009. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50010. private _inputs;
  50011. private _gamepads;
  50012. private _keyboardActive;
  50013. private _pointerActive;
  50014. private _elementToAttachTo;
  50015. private _keyboardDownEvent;
  50016. private _keyboardUpEvent;
  50017. private _pointerMoveEvent;
  50018. private _pointerDownEvent;
  50019. private _pointerUpEvent;
  50020. private _gamepadConnectedEvent;
  50021. private _gamepadDisconnectedEvent;
  50022. private static _MAX_KEYCODES;
  50023. private static _MAX_POINTER_INPUTS;
  50024. private constructor();
  50025. /**
  50026. * Creates a new DeviceInputSystem instance
  50027. * @param engine Engine to pull input element from
  50028. * @returns The new instance
  50029. */
  50030. static Create(engine: Engine): DeviceInputSystem;
  50031. /**
  50032. * Checks for current device input value, given an id and input index
  50033. * @param deviceName Id of connected device
  50034. * @param inputIndex Index of device input
  50035. * @returns Current value of input
  50036. */
  50037. /**
  50038. * Checks for current device input value, given an id and input index
  50039. * @param deviceType Enum specifiying device type
  50040. * @param deviceSlot "Slot" or index that device is referenced in
  50041. * @param inputIndex Id of input to be checked
  50042. * @returns Current value of input
  50043. */
  50044. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50045. /**
  50046. * Dispose of all the eventlisteners
  50047. */
  50048. dispose(): void;
  50049. /**
  50050. * Add device and inputs to device array
  50051. * @param deviceType Enum specifiying device type
  50052. * @param deviceSlot "Slot" or index that device is referenced in
  50053. * @param numberOfInputs Number of input entries to create for given device
  50054. */
  50055. private _registerDevice;
  50056. /**
  50057. * Given a specific device name, remove that device from the device map
  50058. * @param deviceType Enum specifiying device type
  50059. * @param deviceSlot "Slot" or index that device is referenced in
  50060. */
  50061. private _unregisterDevice;
  50062. /**
  50063. * Handle all actions that come from keyboard interaction
  50064. */
  50065. private _handleKeyActions;
  50066. /**
  50067. * Handle all actions that come from pointer interaction
  50068. */
  50069. private _handlePointerActions;
  50070. /**
  50071. * Handle all actions that come from gamepad interaction
  50072. */
  50073. private _handleGamepadActions;
  50074. /**
  50075. * Update all non-event based devices with each frame
  50076. * @param deviceType Enum specifiying device type
  50077. * @param deviceSlot "Slot" or index that device is referenced in
  50078. * @param inputIndex Id of input to be checked
  50079. */
  50080. private _updateDevice;
  50081. /**
  50082. * Gets DeviceType from the device name
  50083. * @param deviceName Name of Device from DeviceInputSystem
  50084. * @returns DeviceType enum value
  50085. */
  50086. private _getGamepadDeviceType;
  50087. }
  50088. }
  50089. declare module BABYLON {
  50090. /**
  50091. * Type to handle enforcement of inputs
  50092. */
  50093. 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;
  50094. }
  50095. declare module BABYLON {
  50096. /**
  50097. * Class that handles all input for a specific device
  50098. */
  50099. export class DeviceSource<T extends DeviceType> {
  50100. /** Type of device */
  50101. readonly deviceType: DeviceType;
  50102. /** "Slot" or index that device is referenced in */
  50103. readonly deviceSlot: number;
  50104. /**
  50105. * Observable to handle device input changes per device
  50106. */
  50107. readonly onInputChangedObservable: Observable<{
  50108. inputIndex: DeviceInput<T>;
  50109. previousState: Nullable<number>;
  50110. currentState: Nullable<number>;
  50111. }>;
  50112. private readonly _deviceInputSystem;
  50113. /**
  50114. * Default Constructor
  50115. * @param deviceInputSystem Reference to DeviceInputSystem
  50116. * @param deviceType Type of device
  50117. * @param deviceSlot "Slot" or index that device is referenced in
  50118. */
  50119. constructor(deviceInputSystem: DeviceInputSystem,
  50120. /** Type of device */
  50121. deviceType: DeviceType,
  50122. /** "Slot" or index that device is referenced in */
  50123. deviceSlot?: number);
  50124. /**
  50125. * Get input for specific input
  50126. * @param inputIndex index of specific input on device
  50127. * @returns Input value from DeviceInputSystem
  50128. */
  50129. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50130. }
  50131. /**
  50132. * Class to keep track of devices
  50133. */
  50134. export class DeviceSourceManager implements IDisposable {
  50135. /**
  50136. * Observable to be triggered when before a device is connected
  50137. */
  50138. readonly onBeforeDeviceConnectedObservable: Observable<{
  50139. deviceType: DeviceType;
  50140. deviceSlot: number;
  50141. }>;
  50142. /**
  50143. * Observable to be triggered when before a device is disconnected
  50144. */
  50145. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50146. deviceType: DeviceType;
  50147. deviceSlot: number;
  50148. }>;
  50149. /**
  50150. * Observable to be triggered when after a device is connected
  50151. */
  50152. readonly onAfterDeviceConnectedObservable: Observable<{
  50153. deviceType: DeviceType;
  50154. deviceSlot: number;
  50155. }>;
  50156. /**
  50157. * Observable to be triggered when after a device is disconnected
  50158. */
  50159. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50160. deviceType: DeviceType;
  50161. deviceSlot: number;
  50162. }>;
  50163. private readonly _devices;
  50164. private readonly _firstDevice;
  50165. private readonly _deviceInputSystem;
  50166. /**
  50167. * Default Constructor
  50168. * @param engine engine to pull input element from
  50169. */
  50170. constructor(engine: Engine);
  50171. /**
  50172. * Gets a DeviceSource, given a type and slot
  50173. * @param deviceType Enum specifying device type
  50174. * @param deviceSlot "Slot" or index that device is referenced in
  50175. * @returns DeviceSource object
  50176. */
  50177. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50178. /**
  50179. * Gets an array of DeviceSource objects for a given device type
  50180. * @param deviceType Enum specifying device type
  50181. * @returns Array of DeviceSource objects
  50182. */
  50183. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50184. /**
  50185. * Dispose of DeviceInputSystem and other parts
  50186. */
  50187. dispose(): void;
  50188. /**
  50189. * Function to add device name to device list
  50190. * @param deviceType Enum specifying device type
  50191. * @param deviceSlot "Slot" or index that device is referenced in
  50192. */
  50193. private _addDevice;
  50194. /**
  50195. * Function to remove device name to device list
  50196. * @param deviceType Enum specifying device type
  50197. * @param deviceSlot "Slot" or index that device is referenced in
  50198. */
  50199. private _removeDevice;
  50200. /**
  50201. * Updates array storing first connected device of each type
  50202. * @param type Type of Device
  50203. */
  50204. private _updateFirstDevices;
  50205. }
  50206. }
  50207. declare module BABYLON {
  50208. /**
  50209. * Options to create the null engine
  50210. */
  50211. export class NullEngineOptions {
  50212. /**
  50213. * Render width (Default: 512)
  50214. */
  50215. renderWidth: number;
  50216. /**
  50217. * Render height (Default: 256)
  50218. */
  50219. renderHeight: number;
  50220. /**
  50221. * Texture size (Default: 512)
  50222. */
  50223. textureSize: number;
  50224. /**
  50225. * If delta time between frames should be constant
  50226. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50227. */
  50228. deterministicLockstep: boolean;
  50229. /**
  50230. * Maximum about of steps between frames (Default: 4)
  50231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50232. */
  50233. lockstepMaxSteps: number;
  50234. }
  50235. /**
  50236. * The null engine class provides support for headless version of babylon.js.
  50237. * This can be used in server side scenario or for testing purposes
  50238. */
  50239. export class NullEngine extends Engine {
  50240. private _options;
  50241. /**
  50242. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50244. * @returns true if engine is in deterministic lock step mode
  50245. */
  50246. isDeterministicLockStep(): boolean;
  50247. /**
  50248. * Gets the max steps when engine is running in deterministic lock step
  50249. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50250. * @returns the max steps
  50251. */
  50252. getLockstepMaxSteps(): number;
  50253. /**
  50254. * Gets the current hardware scaling level.
  50255. * By default the hardware scaling level is computed from the window device ratio.
  50256. * 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.
  50257. * @returns a number indicating the current hardware scaling level
  50258. */
  50259. getHardwareScalingLevel(): number;
  50260. constructor(options?: NullEngineOptions);
  50261. /**
  50262. * Creates a vertex buffer
  50263. * @param vertices the data for the vertex buffer
  50264. * @returns the new WebGL static buffer
  50265. */
  50266. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50267. /**
  50268. * Creates a new index buffer
  50269. * @param indices defines the content of the index buffer
  50270. * @param updatable defines if the index buffer must be updatable
  50271. * @returns a new webGL buffer
  50272. */
  50273. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50274. /**
  50275. * Clear the current render buffer or the current render target (if any is set up)
  50276. * @param color defines the color to use
  50277. * @param backBuffer defines if the back buffer must be cleared
  50278. * @param depth defines if the depth buffer must be cleared
  50279. * @param stencil defines if the stencil buffer must be cleared
  50280. */
  50281. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50282. /**
  50283. * Gets the current render width
  50284. * @param useScreen defines if screen size must be used (or the current render target if any)
  50285. * @returns a number defining the current render width
  50286. */
  50287. getRenderWidth(useScreen?: boolean): number;
  50288. /**
  50289. * Gets the current render height
  50290. * @param useScreen defines if screen size must be used (or the current render target if any)
  50291. * @returns a number defining the current render height
  50292. */
  50293. getRenderHeight(useScreen?: boolean): number;
  50294. /**
  50295. * Set the WebGL's viewport
  50296. * @param viewport defines the viewport element to be used
  50297. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50298. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50299. */
  50300. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50301. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50302. /**
  50303. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50304. * @param pipelineContext defines the pipeline context to use
  50305. * @param uniformsNames defines the list of uniform names
  50306. * @returns an array of webGL uniform locations
  50307. */
  50308. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50309. /**
  50310. * Gets the lsit of active attributes for a given webGL program
  50311. * @param pipelineContext defines the pipeline context to use
  50312. * @param attributesNames defines the list of attribute names to get
  50313. * @returns an array of indices indicating the offset of each attribute
  50314. */
  50315. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50316. /**
  50317. * Binds an effect to the webGL context
  50318. * @param effect defines the effect to bind
  50319. */
  50320. bindSamplers(effect: Effect): void;
  50321. /**
  50322. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50323. * @param effect defines the effect to activate
  50324. */
  50325. enableEffect(effect: Effect): void;
  50326. /**
  50327. * Set various states to the webGL context
  50328. * @param culling defines backface culling state
  50329. * @param zOffset defines the value to apply to zOffset (0 by default)
  50330. * @param force defines if states must be applied even if cache is up to date
  50331. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50332. */
  50333. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50334. /**
  50335. * Set the value of an uniform to an array of int32
  50336. * @param uniform defines the webGL uniform location where to store the value
  50337. * @param array defines the array of int32 to store
  50338. */
  50339. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50340. /**
  50341. * Set the value of an uniform to an array of int32 (stored as vec2)
  50342. * @param uniform defines the webGL uniform location where to store the value
  50343. * @param array defines the array of int32 to store
  50344. */
  50345. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50346. /**
  50347. * Set the value of an uniform to an array of int32 (stored as vec3)
  50348. * @param uniform defines the webGL uniform location where to store the value
  50349. * @param array defines the array of int32 to store
  50350. */
  50351. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50352. /**
  50353. * Set the value of an uniform to an array of int32 (stored as vec4)
  50354. * @param uniform defines the webGL uniform location where to store the value
  50355. * @param array defines the array of int32 to store
  50356. */
  50357. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50358. /**
  50359. * Set the value of an uniform to an array of float32
  50360. * @param uniform defines the webGL uniform location where to store the value
  50361. * @param array defines the array of float32 to store
  50362. */
  50363. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50364. /**
  50365. * Set the value of an uniform to an array of float32 (stored as vec2)
  50366. * @param uniform defines the webGL uniform location where to store the value
  50367. * @param array defines the array of float32 to store
  50368. */
  50369. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50370. /**
  50371. * Set the value of an uniform to an array of float32 (stored as vec3)
  50372. * @param uniform defines the webGL uniform location where to store the value
  50373. * @param array defines the array of float32 to store
  50374. */
  50375. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50376. /**
  50377. * Set the value of an uniform to an array of float32 (stored as vec4)
  50378. * @param uniform defines the webGL uniform location where to store the value
  50379. * @param array defines the array of float32 to store
  50380. */
  50381. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50382. /**
  50383. * Set the value of an uniform to an array of number
  50384. * @param uniform defines the webGL uniform location where to store the value
  50385. * @param array defines the array of number to store
  50386. */
  50387. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50388. /**
  50389. * Set the value of an uniform to an array of number (stored as vec2)
  50390. * @param uniform defines the webGL uniform location where to store the value
  50391. * @param array defines the array of number to store
  50392. */
  50393. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50394. /**
  50395. * Set the value of an uniform to an array of number (stored as vec3)
  50396. * @param uniform defines the webGL uniform location where to store the value
  50397. * @param array defines the array of number to store
  50398. */
  50399. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50400. /**
  50401. * Set the value of an uniform to an array of number (stored as vec4)
  50402. * @param uniform defines the webGL uniform location where to store the value
  50403. * @param array defines the array of number to store
  50404. */
  50405. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50406. /**
  50407. * Set the value of an uniform to an array of float32 (stored as matrices)
  50408. * @param uniform defines the webGL uniform location where to store the value
  50409. * @param matrices defines the array of float32 to store
  50410. */
  50411. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50412. /**
  50413. * Set the value of an uniform to a matrix (3x3)
  50414. * @param uniform defines the webGL uniform location where to store the value
  50415. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50416. */
  50417. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50418. /**
  50419. * Set the value of an uniform to a matrix (2x2)
  50420. * @param uniform defines the webGL uniform location where to store the value
  50421. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50422. */
  50423. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50424. /**
  50425. * Set the value of an uniform to a number (float)
  50426. * @param uniform defines the webGL uniform location where to store the value
  50427. * @param value defines the float number to store
  50428. */
  50429. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50430. /**
  50431. * Set the value of an uniform to a vec2
  50432. * @param uniform defines the webGL uniform location where to store the value
  50433. * @param x defines the 1st component of the value
  50434. * @param y defines the 2nd component of the value
  50435. */
  50436. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50437. /**
  50438. * Set the value of an uniform to a vec3
  50439. * @param uniform defines the webGL uniform location where to store the value
  50440. * @param x defines the 1st component of the value
  50441. * @param y defines the 2nd component of the value
  50442. * @param z defines the 3rd component of the value
  50443. */
  50444. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50445. /**
  50446. * Set the value of an uniform to a boolean
  50447. * @param uniform defines the webGL uniform location where to store the value
  50448. * @param bool defines the boolean to store
  50449. */
  50450. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50451. /**
  50452. * Set the value of an uniform to a vec4
  50453. * @param uniform defines the webGL uniform location where to store the value
  50454. * @param x defines the 1st component of the value
  50455. * @param y defines the 2nd component of the value
  50456. * @param z defines the 3rd component of the value
  50457. * @param w defines the 4th component of the value
  50458. */
  50459. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50460. /**
  50461. * Sets the current alpha mode
  50462. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50463. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50464. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50465. */
  50466. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50467. /**
  50468. * Bind webGl buffers directly to the webGL context
  50469. * @param vertexBuffers defines the vertex buffer to bind
  50470. * @param indexBuffer defines the index buffer to bind
  50471. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50472. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50473. * @param effect defines the effect associated with the vertex buffer
  50474. */
  50475. bindBuffers(vertexBuffers: {
  50476. [key: string]: VertexBuffer;
  50477. }, indexBuffer: DataBuffer, effect: Effect): void;
  50478. /**
  50479. * Force the entire cache to be cleared
  50480. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50481. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50482. */
  50483. wipeCaches(bruteForce?: boolean): void;
  50484. /**
  50485. * Send a draw order
  50486. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50487. * @param indexStart defines the starting index
  50488. * @param indexCount defines the number of index to draw
  50489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50490. */
  50491. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50492. /**
  50493. * Draw a list of indexed primitives
  50494. * @param fillMode defines the primitive to use
  50495. * @param indexStart defines the starting index
  50496. * @param indexCount defines the number of index to draw
  50497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50498. */
  50499. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50500. /**
  50501. * Draw a list of unindexed primitives
  50502. * @param fillMode defines the primitive to use
  50503. * @param verticesStart defines the index of first vertex to draw
  50504. * @param verticesCount defines the count of vertices to draw
  50505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50506. */
  50507. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50508. /** @hidden */
  50509. _createTexture(): WebGLTexture;
  50510. /** @hidden */
  50511. _releaseTexture(texture: InternalTexture): void;
  50512. /**
  50513. * Usually called from Texture.ts.
  50514. * Passed information to create a WebGLTexture
  50515. * @param urlArg defines a value which contains one of the following:
  50516. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50517. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50518. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50519. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50520. * @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)
  50521. * @param scene needed for loading to the correct scene
  50522. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50523. * @param onLoad optional callback to be called upon successful completion
  50524. * @param onError optional callback to be called upon failure
  50525. * @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
  50526. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50527. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50528. * @param forcedExtension defines the extension to use to pick the right loader
  50529. * @param mimeType defines an optional mime type
  50530. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50531. */
  50532. 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;
  50533. /**
  50534. * Creates a new render target texture
  50535. * @param size defines the size of the texture
  50536. * @param options defines the options used to create the texture
  50537. * @returns a new render target texture stored in an InternalTexture
  50538. */
  50539. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50540. /**
  50541. * Update the sampling mode of a given texture
  50542. * @param samplingMode defines the required sampling mode
  50543. * @param texture defines the texture to update
  50544. */
  50545. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50546. /**
  50547. * Binds the frame buffer to the specified texture.
  50548. * @param texture The texture to render to or null for the default canvas
  50549. * @param faceIndex The face of the texture to render to in case of cube texture
  50550. * @param requiredWidth The width of the target to render to
  50551. * @param requiredHeight The height of the target to render to
  50552. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50553. * @param lodLevel defines le lod level to bind to the frame buffer
  50554. */
  50555. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50556. /**
  50557. * Unbind the current render target texture from the webGL context
  50558. * @param texture defines the render target texture to unbind
  50559. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50560. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50561. */
  50562. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50563. /**
  50564. * Creates a dynamic vertex buffer
  50565. * @param vertices the data for the dynamic vertex buffer
  50566. * @returns the new WebGL dynamic buffer
  50567. */
  50568. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50569. /**
  50570. * Update the content of a dynamic texture
  50571. * @param texture defines the texture to update
  50572. * @param canvas defines the canvas containing the source
  50573. * @param invertY defines if data must be stored with Y axis inverted
  50574. * @param premulAlpha defines if alpha is stored as premultiplied
  50575. * @param format defines the format of the data
  50576. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50577. */
  50578. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50579. /**
  50580. * Gets a boolean indicating if all created effects are ready
  50581. * @returns true if all effects are ready
  50582. */
  50583. areAllEffectsReady(): boolean;
  50584. /**
  50585. * @hidden
  50586. * Get the current error code of the webGL context
  50587. * @returns the error code
  50588. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50589. */
  50590. getError(): number;
  50591. /** @hidden */
  50592. _getUnpackAlignement(): number;
  50593. /** @hidden */
  50594. _unpackFlipY(value: boolean): void;
  50595. /**
  50596. * Update a dynamic index buffer
  50597. * @param indexBuffer defines the target index buffer
  50598. * @param indices defines the data to update
  50599. * @param offset defines the offset in the target index buffer where update should start
  50600. */
  50601. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50602. /**
  50603. * Updates a dynamic vertex buffer.
  50604. * @param vertexBuffer the vertex buffer to update
  50605. * @param vertices the data used to update the vertex buffer
  50606. * @param byteOffset the byte offset of the data (optional)
  50607. * @param byteLength the byte length of the data (optional)
  50608. */
  50609. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50610. /** @hidden */
  50611. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50612. /** @hidden */
  50613. _bindTexture(channel: number, texture: InternalTexture): void;
  50614. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50615. /**
  50616. * 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
  50617. */
  50618. releaseEffects(): void;
  50619. displayLoadingUI(): void;
  50620. hideLoadingUI(): void;
  50621. /** @hidden */
  50622. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50623. /** @hidden */
  50624. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50625. /** @hidden */
  50626. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50627. /** @hidden */
  50628. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50629. }
  50630. }
  50631. declare module BABYLON {
  50632. /**
  50633. * @hidden
  50634. **/
  50635. export class _TimeToken {
  50636. _startTimeQuery: Nullable<WebGLQuery>;
  50637. _endTimeQuery: Nullable<WebGLQuery>;
  50638. _timeElapsedQuery: Nullable<WebGLQuery>;
  50639. _timeElapsedQueryEnded: boolean;
  50640. }
  50641. }
  50642. declare module BABYLON {
  50643. /** @hidden */
  50644. export class _OcclusionDataStorage {
  50645. /** @hidden */
  50646. occlusionInternalRetryCounter: number;
  50647. /** @hidden */
  50648. isOcclusionQueryInProgress: boolean;
  50649. /** @hidden */
  50650. isOccluded: boolean;
  50651. /** @hidden */
  50652. occlusionRetryCount: number;
  50653. /** @hidden */
  50654. occlusionType: number;
  50655. /** @hidden */
  50656. occlusionQueryAlgorithmType: number;
  50657. }
  50658. interface Engine {
  50659. /**
  50660. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50661. * @return the new query
  50662. */
  50663. createQuery(): WebGLQuery;
  50664. /**
  50665. * Delete and release a webGL query
  50666. * @param query defines the query to delete
  50667. * @return the current engine
  50668. */
  50669. deleteQuery(query: WebGLQuery): Engine;
  50670. /**
  50671. * Check if a given query has resolved and got its value
  50672. * @param query defines the query to check
  50673. * @returns true if the query got its value
  50674. */
  50675. isQueryResultAvailable(query: WebGLQuery): boolean;
  50676. /**
  50677. * Gets the value of a given query
  50678. * @param query defines the query to check
  50679. * @returns the value of the query
  50680. */
  50681. getQueryResult(query: WebGLQuery): number;
  50682. /**
  50683. * Initiates an occlusion query
  50684. * @param algorithmType defines the algorithm to use
  50685. * @param query defines the query to use
  50686. * @returns the current engine
  50687. * @see http://doc.babylonjs.com/features/occlusionquery
  50688. */
  50689. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50690. /**
  50691. * Ends an occlusion query
  50692. * @see http://doc.babylonjs.com/features/occlusionquery
  50693. * @param algorithmType defines the algorithm to use
  50694. * @returns the current engine
  50695. */
  50696. endOcclusionQuery(algorithmType: number): Engine;
  50697. /**
  50698. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50699. * Please note that only one query can be issued at a time
  50700. * @returns a time token used to track the time span
  50701. */
  50702. startTimeQuery(): Nullable<_TimeToken>;
  50703. /**
  50704. * Ends a time query
  50705. * @param token defines the token used to measure the time span
  50706. * @returns the time spent (in ns)
  50707. */
  50708. endTimeQuery(token: _TimeToken): int;
  50709. /** @hidden */
  50710. _currentNonTimestampToken: Nullable<_TimeToken>;
  50711. /** @hidden */
  50712. _createTimeQuery(): WebGLQuery;
  50713. /** @hidden */
  50714. _deleteTimeQuery(query: WebGLQuery): void;
  50715. /** @hidden */
  50716. _getGlAlgorithmType(algorithmType: number): number;
  50717. /** @hidden */
  50718. _getTimeQueryResult(query: WebGLQuery): any;
  50719. /** @hidden */
  50720. _getTimeQueryAvailability(query: WebGLQuery): any;
  50721. }
  50722. interface AbstractMesh {
  50723. /**
  50724. * Backing filed
  50725. * @hidden
  50726. */
  50727. __occlusionDataStorage: _OcclusionDataStorage;
  50728. /**
  50729. * Access property
  50730. * @hidden
  50731. */
  50732. _occlusionDataStorage: _OcclusionDataStorage;
  50733. /**
  50734. * 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.
  50735. * The default value is -1 which means don't break the query and wait till the result
  50736. * @see http://doc.babylonjs.com/features/occlusionquery
  50737. */
  50738. occlusionRetryCount: number;
  50739. /**
  50740. * 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:
  50741. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50742. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50743. * * 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.
  50744. * @see http://doc.babylonjs.com/features/occlusionquery
  50745. */
  50746. occlusionType: number;
  50747. /**
  50748. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50749. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50750. * * 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.
  50751. * @see http://doc.babylonjs.com/features/occlusionquery
  50752. */
  50753. occlusionQueryAlgorithmType: number;
  50754. /**
  50755. * 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
  50756. * @see http://doc.babylonjs.com/features/occlusionquery
  50757. */
  50758. isOccluded: boolean;
  50759. /**
  50760. * Flag to check the progress status of the query
  50761. * @see http://doc.babylonjs.com/features/occlusionquery
  50762. */
  50763. isOcclusionQueryInProgress: boolean;
  50764. }
  50765. }
  50766. declare module BABYLON {
  50767. /** @hidden */
  50768. export var _forceTransformFeedbackToBundle: boolean;
  50769. interface Engine {
  50770. /**
  50771. * Creates a webGL transform feedback object
  50772. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50773. * @returns the webGL transform feedback object
  50774. */
  50775. createTransformFeedback(): WebGLTransformFeedback;
  50776. /**
  50777. * Delete a webGL transform feedback object
  50778. * @param value defines the webGL transform feedback object to delete
  50779. */
  50780. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50781. /**
  50782. * Bind a webGL transform feedback object to the webgl context
  50783. * @param value defines the webGL transform feedback object to bind
  50784. */
  50785. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50786. /**
  50787. * Begins a transform feedback operation
  50788. * @param usePoints defines if points or triangles must be used
  50789. */
  50790. beginTransformFeedback(usePoints: boolean): void;
  50791. /**
  50792. * Ends a transform feedback operation
  50793. */
  50794. endTransformFeedback(): void;
  50795. /**
  50796. * Specify the varyings to use with transform feedback
  50797. * @param program defines the associated webGL program
  50798. * @param value defines the list of strings representing the varying names
  50799. */
  50800. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50801. /**
  50802. * Bind a webGL buffer for a transform feedback operation
  50803. * @param value defines the webGL buffer to bind
  50804. */
  50805. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50806. }
  50807. }
  50808. declare module BABYLON {
  50809. /**
  50810. * Creation options of the multi render target texture.
  50811. */
  50812. export interface IMultiRenderTargetOptions {
  50813. /**
  50814. * Define if the texture needs to create mip maps after render.
  50815. */
  50816. generateMipMaps?: boolean;
  50817. /**
  50818. * Define the types of all the draw buffers we want to create
  50819. */
  50820. types?: number[];
  50821. /**
  50822. * Define the sampling modes of all the draw buffers we want to create
  50823. */
  50824. samplingModes?: number[];
  50825. /**
  50826. * Define if a depth buffer is required
  50827. */
  50828. generateDepthBuffer?: boolean;
  50829. /**
  50830. * Define if a stencil buffer is required
  50831. */
  50832. generateStencilBuffer?: boolean;
  50833. /**
  50834. * Define if a depth texture is required instead of a depth buffer
  50835. */
  50836. generateDepthTexture?: boolean;
  50837. /**
  50838. * Define the number of desired draw buffers
  50839. */
  50840. textureCount?: number;
  50841. /**
  50842. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50843. */
  50844. doNotChangeAspectRatio?: boolean;
  50845. /**
  50846. * Define the default type of the buffers we are creating
  50847. */
  50848. defaultType?: number;
  50849. }
  50850. /**
  50851. * A multi render target, like a render target provides the ability to render to a texture.
  50852. * Unlike the render target, it can render to several draw buffers in one draw.
  50853. * This is specially interesting in deferred rendering or for any effects requiring more than
  50854. * just one color from a single pass.
  50855. */
  50856. export class MultiRenderTarget extends RenderTargetTexture {
  50857. private _internalTextures;
  50858. private _textures;
  50859. private _multiRenderTargetOptions;
  50860. /**
  50861. * Get if draw buffers are currently supported by the used hardware and browser.
  50862. */
  50863. get isSupported(): boolean;
  50864. /**
  50865. * Get the list of textures generated by the multi render target.
  50866. */
  50867. get textures(): Texture[];
  50868. /**
  50869. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50870. */
  50871. get depthTexture(): Texture;
  50872. /**
  50873. * Set the wrapping mode on U of all the textures we are rendering to.
  50874. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50875. */
  50876. set wrapU(wrap: number);
  50877. /**
  50878. * Set the wrapping mode on V of all the textures we are rendering to.
  50879. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50880. */
  50881. set wrapV(wrap: number);
  50882. /**
  50883. * Instantiate a new multi render target texture.
  50884. * A multi render target, like a render target provides the ability to render to a texture.
  50885. * Unlike the render target, it can render to several draw buffers in one draw.
  50886. * This is specially interesting in deferred rendering or for any effects requiring more than
  50887. * just one color from a single pass.
  50888. * @param name Define the name of the texture
  50889. * @param size Define the size of the buffers to render to
  50890. * @param count Define the number of target we are rendering into
  50891. * @param scene Define the scene the texture belongs to
  50892. * @param options Define the options used to create the multi render target
  50893. */
  50894. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50895. /** @hidden */
  50896. _rebuild(): void;
  50897. private _createInternalTextures;
  50898. private _createTextures;
  50899. /**
  50900. * Define the number of samples used if MSAA is enabled.
  50901. */
  50902. get samples(): number;
  50903. set samples(value: number);
  50904. /**
  50905. * Resize all the textures in the multi render target.
  50906. * Be carrefull as it will recreate all the data in the new texture.
  50907. * @param size Define the new size
  50908. */
  50909. resize(size: any): void;
  50910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50911. /**
  50912. * Dispose the render targets and their associated resources
  50913. */
  50914. dispose(): void;
  50915. /**
  50916. * Release all the underlying texture used as draw buffers.
  50917. */
  50918. releaseInternalTextures(): void;
  50919. }
  50920. }
  50921. declare module BABYLON {
  50922. interface ThinEngine {
  50923. /**
  50924. * Unbind a list of render target textures from the webGL context
  50925. * This is used only when drawBuffer extension or webGL2 are active
  50926. * @param textures defines the render target textures to unbind
  50927. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50928. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50929. */
  50930. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50931. /**
  50932. * Create a multi render target texture
  50933. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50934. * @param size defines the size of the texture
  50935. * @param options defines the creation options
  50936. * @returns the cube texture as an InternalTexture
  50937. */
  50938. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50939. /**
  50940. * Update the sample count for a given multiple render target texture
  50941. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50942. * @param textures defines the textures to update
  50943. * @param samples defines the sample count to set
  50944. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50945. */
  50946. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50947. }
  50948. }
  50949. declare module BABYLON {
  50950. /**
  50951. * Class used to define an additional view for the engine
  50952. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50953. */
  50954. export class EngineView {
  50955. /** Defines the canvas where to render the view */
  50956. target: HTMLCanvasElement;
  50957. /** Defines an optional camera used to render the view (will use active camera else) */
  50958. camera?: Camera;
  50959. }
  50960. interface Engine {
  50961. /**
  50962. * Gets or sets the HTML element to use for attaching events
  50963. */
  50964. inputElement: Nullable<HTMLElement>;
  50965. /**
  50966. * Gets the current engine view
  50967. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50968. */
  50969. activeView: Nullable<EngineView>;
  50970. /** Gets or sets the list of views */
  50971. views: EngineView[];
  50972. /**
  50973. * Register a new child canvas
  50974. * @param canvas defines the canvas to register
  50975. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50976. * @returns the associated view
  50977. */
  50978. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50979. /**
  50980. * Remove a registered child canvas
  50981. * @param canvas defines the canvas to remove
  50982. * @returns the current engine
  50983. */
  50984. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50985. }
  50986. }
  50987. declare module BABYLON {
  50988. interface Engine {
  50989. /** @hidden */
  50990. _excludedCompressedTextures: string[];
  50991. /** @hidden */
  50992. _textureFormatInUse: string;
  50993. /**
  50994. * Gets the list of texture formats supported
  50995. */
  50996. readonly texturesSupported: Array<string>;
  50997. /**
  50998. * Gets the texture format in use
  50999. */
  51000. readonly textureFormatInUse: Nullable<string>;
  51001. /**
  51002. * Set the compressed texture extensions or file names to skip.
  51003. *
  51004. * @param skippedFiles defines the list of those texture files you want to skip
  51005. * Example: [".dds", ".env", "myfile.png"]
  51006. */
  51007. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51008. /**
  51009. * Set the compressed texture format to use, based on the formats you have, and the formats
  51010. * supported by the hardware / browser.
  51011. *
  51012. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51013. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51014. * to API arguments needed to compressed textures. This puts the burden on the container
  51015. * generator to house the arcane code for determining these for current & future formats.
  51016. *
  51017. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51018. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51019. *
  51020. * Note: The result of this call is not taken into account when a texture is base64.
  51021. *
  51022. * @param formatsAvailable defines the list of those format families you have created
  51023. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51024. *
  51025. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51026. * @returns The extension selected.
  51027. */
  51028. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51029. }
  51030. }
  51031. declare module BABYLON {
  51032. /**
  51033. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51034. */
  51035. export interface CubeMapInfo {
  51036. /**
  51037. * The pixel array for the front face.
  51038. * This is stored in format, left to right, up to down format.
  51039. */
  51040. front: Nullable<ArrayBufferView>;
  51041. /**
  51042. * The pixel array for the back face.
  51043. * This is stored in format, left to right, up to down format.
  51044. */
  51045. back: Nullable<ArrayBufferView>;
  51046. /**
  51047. * The pixel array for the left face.
  51048. * This is stored in format, left to right, up to down format.
  51049. */
  51050. left: Nullable<ArrayBufferView>;
  51051. /**
  51052. * The pixel array for the right face.
  51053. * This is stored in format, left to right, up to down format.
  51054. */
  51055. right: Nullable<ArrayBufferView>;
  51056. /**
  51057. * The pixel array for the up face.
  51058. * This is stored in format, left to right, up to down format.
  51059. */
  51060. up: Nullable<ArrayBufferView>;
  51061. /**
  51062. * The pixel array for the down face.
  51063. * This is stored in format, left to right, up to down format.
  51064. */
  51065. down: Nullable<ArrayBufferView>;
  51066. /**
  51067. * The size of the cubemap stored.
  51068. *
  51069. * Each faces will be size * size pixels.
  51070. */
  51071. size: number;
  51072. /**
  51073. * The format of the texture.
  51074. *
  51075. * RGBA, RGB.
  51076. */
  51077. format: number;
  51078. /**
  51079. * The type of the texture data.
  51080. *
  51081. * UNSIGNED_INT, FLOAT.
  51082. */
  51083. type: number;
  51084. /**
  51085. * Specifies whether the texture is in gamma space.
  51086. */
  51087. gammaSpace: boolean;
  51088. }
  51089. /**
  51090. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51091. */
  51092. export class PanoramaToCubeMapTools {
  51093. private static FACE_LEFT;
  51094. private static FACE_RIGHT;
  51095. private static FACE_FRONT;
  51096. private static FACE_BACK;
  51097. private static FACE_DOWN;
  51098. private static FACE_UP;
  51099. /**
  51100. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51101. *
  51102. * @param float32Array The source data.
  51103. * @param inputWidth The width of the input panorama.
  51104. * @param inputHeight The height of the input panorama.
  51105. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51106. * @return The cubemap data
  51107. */
  51108. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51109. private static CreateCubemapTexture;
  51110. private static CalcProjectionSpherical;
  51111. }
  51112. }
  51113. declare module BABYLON {
  51114. /**
  51115. * Helper class dealing with the extraction of spherical polynomial dataArray
  51116. * from a cube map.
  51117. */
  51118. export class CubeMapToSphericalPolynomialTools {
  51119. private static FileFaces;
  51120. /**
  51121. * Converts a texture to the according Spherical Polynomial data.
  51122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51123. *
  51124. * @param texture The texture to extract the information from.
  51125. * @return The Spherical Polynomial data.
  51126. */
  51127. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51128. /**
  51129. * Converts a cubemap to the according Spherical Polynomial data.
  51130. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51131. *
  51132. * @param cubeInfo The Cube map to extract the information from.
  51133. * @return The Spherical Polynomial data.
  51134. */
  51135. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51136. }
  51137. }
  51138. declare module BABYLON {
  51139. interface BaseTexture {
  51140. /**
  51141. * Get the polynomial representation of the texture data.
  51142. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51143. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51144. */
  51145. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51146. }
  51147. }
  51148. declare module BABYLON {
  51149. /** @hidden */
  51150. export var rgbdEncodePixelShader: {
  51151. name: string;
  51152. shader: string;
  51153. };
  51154. }
  51155. declare module BABYLON {
  51156. /** @hidden */
  51157. export var rgbdDecodePixelShader: {
  51158. name: string;
  51159. shader: string;
  51160. };
  51161. }
  51162. declare module BABYLON {
  51163. /**
  51164. * Raw texture data and descriptor sufficient for WebGL texture upload
  51165. */
  51166. export interface EnvironmentTextureInfo {
  51167. /**
  51168. * Version of the environment map
  51169. */
  51170. version: number;
  51171. /**
  51172. * Width of image
  51173. */
  51174. width: number;
  51175. /**
  51176. * Irradiance information stored in the file.
  51177. */
  51178. irradiance: any;
  51179. /**
  51180. * Specular information stored in the file.
  51181. */
  51182. specular: any;
  51183. }
  51184. /**
  51185. * Defines One Image in the file. It requires only the position in the file
  51186. * as well as the length.
  51187. */
  51188. interface BufferImageData {
  51189. /**
  51190. * Length of the image data.
  51191. */
  51192. length: number;
  51193. /**
  51194. * Position of the data from the null terminator delimiting the end of the JSON.
  51195. */
  51196. position: number;
  51197. }
  51198. /**
  51199. * Defines the specular data enclosed in the file.
  51200. * This corresponds to the version 1 of the data.
  51201. */
  51202. export interface EnvironmentTextureSpecularInfoV1 {
  51203. /**
  51204. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51205. */
  51206. specularDataPosition?: number;
  51207. /**
  51208. * This contains all the images data needed to reconstruct the cubemap.
  51209. */
  51210. mipmaps: Array<BufferImageData>;
  51211. /**
  51212. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51213. */
  51214. lodGenerationScale: number;
  51215. }
  51216. /**
  51217. * Sets of helpers addressing the serialization and deserialization of environment texture
  51218. * stored in a BabylonJS env file.
  51219. * Those files are usually stored as .env files.
  51220. */
  51221. export class EnvironmentTextureTools {
  51222. /**
  51223. * Magic number identifying the env file.
  51224. */
  51225. private static _MagicBytes;
  51226. /**
  51227. * Gets the environment info from an env file.
  51228. * @param data The array buffer containing the .env bytes.
  51229. * @returns the environment file info (the json header) if successfully parsed.
  51230. */
  51231. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51232. /**
  51233. * Creates an environment texture from a loaded cube texture.
  51234. * @param texture defines the cube texture to convert in env file
  51235. * @return a promise containing the environment data if succesfull.
  51236. */
  51237. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51238. /**
  51239. * Creates a JSON representation of the spherical data.
  51240. * @param texture defines the texture containing the polynomials
  51241. * @return the JSON representation of the spherical info
  51242. */
  51243. private static _CreateEnvTextureIrradiance;
  51244. /**
  51245. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51246. * @param data the image data
  51247. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51248. * @return the views described by info providing access to the underlying buffer
  51249. */
  51250. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51251. /**
  51252. * Uploads the texture info contained in the env file to the GPU.
  51253. * @param texture defines the internal texture to upload to
  51254. * @param data defines the data to load
  51255. * @param info defines the texture info retrieved through the GetEnvInfo method
  51256. * @returns a promise
  51257. */
  51258. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51259. private static _OnImageReadyAsync;
  51260. /**
  51261. * Uploads the levels of image data to the GPU.
  51262. * @param texture defines the internal texture to upload to
  51263. * @param imageData defines the array buffer views of image data [mipmap][face]
  51264. * @returns a promise
  51265. */
  51266. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51267. /**
  51268. * Uploads spherical polynomials information to the texture.
  51269. * @param texture defines the texture we are trying to upload the information to
  51270. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51271. */
  51272. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51273. /** @hidden */
  51274. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51275. }
  51276. }
  51277. declare module BABYLON {
  51278. /** @hidden */
  51279. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51280. private _genericAttributeLocation;
  51281. private _varyingLocationCount;
  51282. private _varyingLocationMap;
  51283. private _replacements;
  51284. private _textureCount;
  51285. private _uniforms;
  51286. lineProcessor(line: string): string;
  51287. attributeProcessor(attribute: string): string;
  51288. varyingProcessor(varying: string, isFragment: boolean): string;
  51289. uniformProcessor(uniform: string): string;
  51290. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51291. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51292. }
  51293. }
  51294. declare module BABYLON {
  51295. /**
  51296. * Class used to inline functions in shader code
  51297. */
  51298. export class ShaderCodeInliner {
  51299. private static readonly _RegexpFindFunctionNameAndType;
  51300. private _sourceCode;
  51301. private _functionDescr;
  51302. private _numMaxIterations;
  51303. /** Gets or sets the token used to mark the functions to inline */
  51304. inlineToken: string;
  51305. /** Gets or sets the debug mode */
  51306. debug: boolean;
  51307. /** Gets the code after the inlining process */
  51308. get code(): string;
  51309. /**
  51310. * Initializes the inliner
  51311. * @param sourceCode shader code source to inline
  51312. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51313. */
  51314. constructor(sourceCode: string, numMaxIterations?: number);
  51315. /**
  51316. * Start the processing of the shader code
  51317. */
  51318. processCode(): void;
  51319. private _collectFunctions;
  51320. private _processInlining;
  51321. private _extractBetweenMarkers;
  51322. private _skipWhitespaces;
  51323. private _removeComments;
  51324. private _replaceFunctionCallsByCode;
  51325. private _findBackward;
  51326. private _escapeRegExp;
  51327. private _replaceNames;
  51328. }
  51329. }
  51330. declare module BABYLON {
  51331. /**
  51332. * Container for accessors for natively-stored mesh data buffers.
  51333. */
  51334. class NativeDataBuffer extends DataBuffer {
  51335. /**
  51336. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51337. */
  51338. nativeIndexBuffer?: any;
  51339. /**
  51340. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51341. */
  51342. nativeVertexBuffer?: any;
  51343. }
  51344. /** @hidden */
  51345. class NativeTexture extends InternalTexture {
  51346. getInternalTexture(): InternalTexture;
  51347. getViewCount(): number;
  51348. }
  51349. /** @hidden */
  51350. export class NativeEngine extends Engine {
  51351. private readonly _native;
  51352. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51353. private readonly INVALID_HANDLE;
  51354. getHardwareScalingLevel(): number;
  51355. constructor();
  51356. dispose(): void;
  51357. /**
  51358. * Can be used to override the current requestAnimationFrame requester.
  51359. * @hidden
  51360. */
  51361. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51362. /**
  51363. * Override default engine behavior.
  51364. * @param color
  51365. * @param backBuffer
  51366. * @param depth
  51367. * @param stencil
  51368. */
  51369. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51370. /**
  51371. * Gets host document
  51372. * @returns the host document object
  51373. */
  51374. getHostDocument(): Nullable<Document>;
  51375. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51376. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51377. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51378. recordVertexArrayObject(vertexBuffers: {
  51379. [key: string]: VertexBuffer;
  51380. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51381. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51382. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51383. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51384. /**
  51385. * Draw a list of indexed primitives
  51386. * @param fillMode defines the primitive to use
  51387. * @param indexStart defines the starting index
  51388. * @param indexCount defines the number of index to draw
  51389. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51390. */
  51391. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51392. /**
  51393. * Draw a list of unindexed primitives
  51394. * @param fillMode defines the primitive to use
  51395. * @param verticesStart defines the index of first vertex to draw
  51396. * @param verticesCount defines the count of vertices to draw
  51397. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51398. */
  51399. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51400. createPipelineContext(): IPipelineContext;
  51401. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51402. /** @hidden */
  51403. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51404. /** @hidden */
  51405. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51406. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51407. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51408. protected _setProgram(program: WebGLProgram): void;
  51409. _releaseEffect(effect: Effect): void;
  51410. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51411. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51412. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51413. bindSamplers(effect: Effect): void;
  51414. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51415. getRenderWidth(useScreen?: boolean): number;
  51416. getRenderHeight(useScreen?: boolean): number;
  51417. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51418. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51419. /**
  51420. * Set the z offset to apply to current rendering
  51421. * @param value defines the offset to apply
  51422. */
  51423. setZOffset(value: number): void;
  51424. /**
  51425. * Gets the current value of the zOffset
  51426. * @returns the current zOffset state
  51427. */
  51428. getZOffset(): number;
  51429. /**
  51430. * Enable or disable depth buffering
  51431. * @param enable defines the state to set
  51432. */
  51433. setDepthBuffer(enable: boolean): void;
  51434. /**
  51435. * Gets a boolean indicating if depth writing is enabled
  51436. * @returns the current depth writing state
  51437. */
  51438. getDepthWrite(): boolean;
  51439. /**
  51440. * Enable or disable depth writing
  51441. * @param enable defines the state to set
  51442. */
  51443. setDepthWrite(enable: boolean): void;
  51444. /**
  51445. * Enable or disable color writing
  51446. * @param enable defines the state to set
  51447. */
  51448. setColorWrite(enable: boolean): void;
  51449. /**
  51450. * Gets a boolean indicating if color writing is enabled
  51451. * @returns the current color writing state
  51452. */
  51453. getColorWrite(): boolean;
  51454. /**
  51455. * Sets alpha constants used by some alpha blending modes
  51456. * @param r defines the red component
  51457. * @param g defines the green component
  51458. * @param b defines the blue component
  51459. * @param a defines the alpha component
  51460. */
  51461. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51462. /**
  51463. * Sets the current alpha mode
  51464. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51465. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51466. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51467. */
  51468. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51469. /**
  51470. * Gets the current alpha mode
  51471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51472. * @returns the current alpha mode
  51473. */
  51474. getAlphaMode(): number;
  51475. setInt(uniform: WebGLUniformLocation, int: number): void;
  51476. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51477. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51478. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51479. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51480. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51481. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51482. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51483. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51484. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51485. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51486. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51487. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51488. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51489. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51490. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51491. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51492. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51493. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51494. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51495. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51496. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51497. wipeCaches(bruteForce?: boolean): void;
  51498. _createTexture(): WebGLTexture;
  51499. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51500. /**
  51501. * Usually called from Texture.ts.
  51502. * Passed information to create a WebGLTexture
  51503. * @param url defines a value which contains one of the following:
  51504. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51505. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51506. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51507. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51508. * @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)
  51509. * @param scene needed for loading to the correct scene
  51510. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51511. * @param onLoad optional callback to be called upon successful completion
  51512. * @param onError optional callback to be called upon failure
  51513. * @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
  51514. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51515. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51516. * @param forcedExtension defines the extension to use to pick the right loader
  51517. * @param mimeType defines an optional mime type
  51518. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51519. */
  51520. 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;
  51521. /**
  51522. * Creates a cube texture
  51523. * @param rootUrl defines the url where the files to load is located
  51524. * @param scene defines the current scene
  51525. * @param files defines the list of files to load (1 per face)
  51526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51527. * @param onLoad defines an optional callback raised when the texture is loaded
  51528. * @param onError defines an optional callback raised if there is an issue to load the texture
  51529. * @param format defines the format of the data
  51530. * @param forcedExtension defines the extension to use to pick the right loader
  51531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51534. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51535. * @returns the cube texture as an InternalTexture
  51536. */
  51537. 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;
  51538. private _getSamplingFilter;
  51539. private static _GetNativeTextureFormat;
  51540. createRenderTargetTexture(size: number | {
  51541. width: number;
  51542. height: number;
  51543. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51544. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51545. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51546. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51547. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51548. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51549. /**
  51550. * Updates a dynamic vertex buffer.
  51551. * @param vertexBuffer the vertex buffer to update
  51552. * @param data the data used to update the vertex buffer
  51553. * @param byteOffset the byte offset of the data (optional)
  51554. * @param byteLength the byte length of the data (optional)
  51555. */
  51556. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51557. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51558. private _updateAnisotropicLevel;
  51559. private _getAddressMode;
  51560. /** @hidden */
  51561. _bindTexture(channel: number, texture: InternalTexture): void;
  51562. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51563. releaseEffects(): void;
  51564. /** @hidden */
  51565. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51566. /** @hidden */
  51567. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51568. /** @hidden */
  51569. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51570. /** @hidden */
  51571. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51572. }
  51573. }
  51574. declare module BABYLON {
  51575. /**
  51576. * Gather the list of clipboard event types as constants.
  51577. */
  51578. export class ClipboardEventTypes {
  51579. /**
  51580. * The clipboard event is fired when a copy command is active (pressed).
  51581. */
  51582. static readonly COPY: number;
  51583. /**
  51584. * The clipboard event is fired when a cut command is active (pressed).
  51585. */
  51586. static readonly CUT: number;
  51587. /**
  51588. * The clipboard event is fired when a paste command is active (pressed).
  51589. */
  51590. static readonly PASTE: number;
  51591. }
  51592. /**
  51593. * This class is used to store clipboard related info for the onClipboardObservable event.
  51594. */
  51595. export class ClipboardInfo {
  51596. /**
  51597. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51598. */
  51599. type: number;
  51600. /**
  51601. * Defines the related dom event
  51602. */
  51603. event: ClipboardEvent;
  51604. /**
  51605. *Creates an instance of ClipboardInfo.
  51606. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51607. * @param event Defines the related dom event
  51608. */
  51609. constructor(
  51610. /**
  51611. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51612. */
  51613. type: number,
  51614. /**
  51615. * Defines the related dom event
  51616. */
  51617. event: ClipboardEvent);
  51618. /**
  51619. * Get the clipboard event's type from the keycode.
  51620. * @param keyCode Defines the keyCode for the current keyboard event.
  51621. * @return {number}
  51622. */
  51623. static GetTypeFromCharacter(keyCode: number): number;
  51624. }
  51625. }
  51626. declare module BABYLON {
  51627. /**
  51628. * Google Daydream controller
  51629. */
  51630. export class DaydreamController extends WebVRController {
  51631. /**
  51632. * Base Url for the controller model.
  51633. */
  51634. static MODEL_BASE_URL: string;
  51635. /**
  51636. * File name for the controller model.
  51637. */
  51638. static MODEL_FILENAME: string;
  51639. /**
  51640. * Gamepad Id prefix used to identify Daydream Controller.
  51641. */
  51642. static readonly GAMEPAD_ID_PREFIX: string;
  51643. /**
  51644. * Creates a new DaydreamController from a gamepad
  51645. * @param vrGamepad the gamepad that the controller should be created from
  51646. */
  51647. constructor(vrGamepad: any);
  51648. /**
  51649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51650. * @param scene scene in which to add meshes
  51651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51652. */
  51653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51654. /**
  51655. * Called once for each button that changed state since the last frame
  51656. * @param buttonIdx Which button index changed
  51657. * @param state New state of the button
  51658. * @param changes Which properties on the state changed since last frame
  51659. */
  51660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51661. }
  51662. }
  51663. declare module BABYLON {
  51664. /**
  51665. * Gear VR Controller
  51666. */
  51667. export class GearVRController extends WebVRController {
  51668. /**
  51669. * Base Url for the controller model.
  51670. */
  51671. static MODEL_BASE_URL: string;
  51672. /**
  51673. * File name for the controller model.
  51674. */
  51675. static MODEL_FILENAME: string;
  51676. /**
  51677. * Gamepad Id prefix used to identify this controller.
  51678. */
  51679. static readonly GAMEPAD_ID_PREFIX: string;
  51680. private readonly _buttonIndexToObservableNameMap;
  51681. /**
  51682. * Creates a new GearVRController from a gamepad
  51683. * @param vrGamepad the gamepad that the controller should be created from
  51684. */
  51685. constructor(vrGamepad: any);
  51686. /**
  51687. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51688. * @param scene scene in which to add meshes
  51689. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51690. */
  51691. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51692. /**
  51693. * Called once for each button that changed state since the last frame
  51694. * @param buttonIdx Which button index changed
  51695. * @param state New state of the button
  51696. * @param changes Which properties on the state changed since last frame
  51697. */
  51698. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51699. }
  51700. }
  51701. declare module BABYLON {
  51702. /**
  51703. * Generic Controller
  51704. */
  51705. export class GenericController extends WebVRController {
  51706. /**
  51707. * Base Url for the controller model.
  51708. */
  51709. static readonly MODEL_BASE_URL: string;
  51710. /**
  51711. * File name for the controller model.
  51712. */
  51713. static readonly MODEL_FILENAME: string;
  51714. /**
  51715. * Creates a new GenericController from a gamepad
  51716. * @param vrGamepad the gamepad that the controller should be created from
  51717. */
  51718. constructor(vrGamepad: any);
  51719. /**
  51720. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51721. * @param scene scene in which to add meshes
  51722. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51723. */
  51724. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51725. /**
  51726. * Called once for each button that changed state since the last frame
  51727. * @param buttonIdx Which button index changed
  51728. * @param state New state of the button
  51729. * @param changes Which properties on the state changed since last frame
  51730. */
  51731. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51732. }
  51733. }
  51734. declare module BABYLON {
  51735. /**
  51736. * Oculus Touch Controller
  51737. */
  51738. export class OculusTouchController extends WebVRController {
  51739. /**
  51740. * Base Url for the controller model.
  51741. */
  51742. static MODEL_BASE_URL: string;
  51743. /**
  51744. * File name for the left controller model.
  51745. */
  51746. static MODEL_LEFT_FILENAME: string;
  51747. /**
  51748. * File name for the right controller model.
  51749. */
  51750. static MODEL_RIGHT_FILENAME: string;
  51751. /**
  51752. * Base Url for the Quest controller model.
  51753. */
  51754. static QUEST_MODEL_BASE_URL: string;
  51755. /**
  51756. * @hidden
  51757. * If the controllers are running on a device that needs the updated Quest controller models
  51758. */
  51759. static _IsQuest: boolean;
  51760. /**
  51761. * Fired when the secondary trigger on this controller is modified
  51762. */
  51763. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51764. /**
  51765. * Fired when the thumb rest on this controller is modified
  51766. */
  51767. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51768. /**
  51769. * Creates a new OculusTouchController from a gamepad
  51770. * @param vrGamepad the gamepad that the controller should be created from
  51771. */
  51772. constructor(vrGamepad: any);
  51773. /**
  51774. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51775. * @param scene scene in which to add meshes
  51776. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51777. */
  51778. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51779. /**
  51780. * Fired when the A button on this controller is modified
  51781. */
  51782. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51783. /**
  51784. * Fired when the B button on this controller is modified
  51785. */
  51786. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51787. /**
  51788. * Fired when the X button on this controller is modified
  51789. */
  51790. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51791. /**
  51792. * Fired when the Y button on this controller is modified
  51793. */
  51794. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51795. /**
  51796. * Called once for each button that changed state since the last frame
  51797. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51798. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51799. * 2) secondary trigger (same)
  51800. * 3) A (right) X (left), touch, pressed = value
  51801. * 4) B / Y
  51802. * 5) thumb rest
  51803. * @param buttonIdx Which button index changed
  51804. * @param state New state of the button
  51805. * @param changes Which properties on the state changed since last frame
  51806. */
  51807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51808. }
  51809. }
  51810. declare module BABYLON {
  51811. /**
  51812. * Vive Controller
  51813. */
  51814. export class ViveController extends WebVRController {
  51815. /**
  51816. * Base Url for the controller model.
  51817. */
  51818. static MODEL_BASE_URL: string;
  51819. /**
  51820. * File name for the controller model.
  51821. */
  51822. static MODEL_FILENAME: string;
  51823. /**
  51824. * Creates a new ViveController from a gamepad
  51825. * @param vrGamepad the gamepad that the controller should be created from
  51826. */
  51827. constructor(vrGamepad: any);
  51828. /**
  51829. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51830. * @param scene scene in which to add meshes
  51831. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51832. */
  51833. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51834. /**
  51835. * Fired when the left button on this controller is modified
  51836. */
  51837. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51838. /**
  51839. * Fired when the right button on this controller is modified
  51840. */
  51841. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51842. /**
  51843. * Fired when the menu button on this controller is modified
  51844. */
  51845. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51846. /**
  51847. * Called once for each button that changed state since the last frame
  51848. * Vive mapping:
  51849. * 0: touchpad
  51850. * 1: trigger
  51851. * 2: left AND right buttons
  51852. * 3: menu button
  51853. * @param buttonIdx Which button index changed
  51854. * @param state New state of the button
  51855. * @param changes Which properties on the state changed since last frame
  51856. */
  51857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51858. }
  51859. }
  51860. declare module BABYLON {
  51861. /**
  51862. * Defines the WindowsMotionController object that the state of the windows motion controller
  51863. */
  51864. export class WindowsMotionController extends WebVRController {
  51865. /**
  51866. * The base url used to load the left and right controller models
  51867. */
  51868. static MODEL_BASE_URL: string;
  51869. /**
  51870. * The name of the left controller model file
  51871. */
  51872. static MODEL_LEFT_FILENAME: string;
  51873. /**
  51874. * The name of the right controller model file
  51875. */
  51876. static MODEL_RIGHT_FILENAME: string;
  51877. /**
  51878. * The controller name prefix for this controller type
  51879. */
  51880. static readonly GAMEPAD_ID_PREFIX: string;
  51881. /**
  51882. * The controller id pattern for this controller type
  51883. */
  51884. private static readonly GAMEPAD_ID_PATTERN;
  51885. private _loadedMeshInfo;
  51886. protected readonly _mapping: {
  51887. buttons: string[];
  51888. buttonMeshNames: {
  51889. trigger: string;
  51890. menu: string;
  51891. grip: string;
  51892. thumbstick: string;
  51893. trackpad: string;
  51894. };
  51895. buttonObservableNames: {
  51896. trigger: string;
  51897. menu: string;
  51898. grip: string;
  51899. thumbstick: string;
  51900. trackpad: string;
  51901. };
  51902. axisMeshNames: string[];
  51903. pointingPoseMeshName: string;
  51904. };
  51905. /**
  51906. * Fired when the trackpad on this controller is clicked
  51907. */
  51908. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51909. /**
  51910. * Fired when the trackpad on this controller is modified
  51911. */
  51912. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51913. /**
  51914. * The current x and y values of this controller's trackpad
  51915. */
  51916. trackpad: StickValues;
  51917. /**
  51918. * Creates a new WindowsMotionController from a gamepad
  51919. * @param vrGamepad the gamepad that the controller should be created from
  51920. */
  51921. constructor(vrGamepad: any);
  51922. /**
  51923. * Fired when the trigger on this controller is modified
  51924. */
  51925. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51926. /**
  51927. * Fired when the menu button on this controller is modified
  51928. */
  51929. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51930. /**
  51931. * Fired when the grip button on this controller is modified
  51932. */
  51933. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51934. /**
  51935. * Fired when the thumbstick button on this controller is modified
  51936. */
  51937. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51938. /**
  51939. * Fired when the touchpad button on this controller is modified
  51940. */
  51941. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51942. /**
  51943. * Fired when the touchpad values on this controller are modified
  51944. */
  51945. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51946. protected _updateTrackpad(): void;
  51947. /**
  51948. * Called once per frame by the engine.
  51949. */
  51950. update(): void;
  51951. /**
  51952. * Called once for each button that changed state since the last frame
  51953. * @param buttonIdx Which button index changed
  51954. * @param state New state of the button
  51955. * @param changes Which properties on the state changed since last frame
  51956. */
  51957. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51958. /**
  51959. * Moves the buttons on the controller mesh based on their current state
  51960. * @param buttonName the name of the button to move
  51961. * @param buttonValue the value of the button which determines the buttons new position
  51962. */
  51963. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51964. /**
  51965. * Moves the axis on the controller mesh based on its current state
  51966. * @param axis the index of the axis
  51967. * @param axisValue the value of the axis which determines the meshes new position
  51968. * @hidden
  51969. */
  51970. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51971. /**
  51972. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51973. * @param scene scene in which to add meshes
  51974. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51975. */
  51976. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51977. /**
  51978. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51979. * can be transformed by button presses and axes values, based on this._mapping.
  51980. *
  51981. * @param scene scene in which the meshes exist
  51982. * @param meshes list of meshes that make up the controller model to process
  51983. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51984. */
  51985. private processModel;
  51986. private createMeshInfo;
  51987. /**
  51988. * Gets the ray of the controller in the direction the controller is pointing
  51989. * @param length the length the resulting ray should be
  51990. * @returns a ray in the direction the controller is pointing
  51991. */
  51992. getForwardRay(length?: number): Ray;
  51993. /**
  51994. * Disposes of the controller
  51995. */
  51996. dispose(): void;
  51997. }
  51998. /**
  51999. * This class represents a new windows motion controller in XR.
  52000. */
  52001. export class XRWindowsMotionController extends WindowsMotionController {
  52002. /**
  52003. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52004. */
  52005. protected readonly _mapping: {
  52006. buttons: string[];
  52007. buttonMeshNames: {
  52008. trigger: string;
  52009. menu: string;
  52010. grip: string;
  52011. thumbstick: string;
  52012. trackpad: string;
  52013. };
  52014. buttonObservableNames: {
  52015. trigger: string;
  52016. menu: string;
  52017. grip: string;
  52018. thumbstick: string;
  52019. trackpad: string;
  52020. };
  52021. axisMeshNames: string[];
  52022. pointingPoseMeshName: string;
  52023. };
  52024. /**
  52025. * Construct a new XR-Based windows motion controller
  52026. *
  52027. * @param gamepadInfo the gamepad object from the browser
  52028. */
  52029. constructor(gamepadInfo: any);
  52030. /**
  52031. * holds the thumbstick values (X,Y)
  52032. */
  52033. thumbstickValues: StickValues;
  52034. /**
  52035. * Fired when the thumbstick on this controller is clicked
  52036. */
  52037. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52038. /**
  52039. * Fired when the thumbstick on this controller is modified
  52040. */
  52041. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52042. /**
  52043. * Fired when the touchpad button on this controller is modified
  52044. */
  52045. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52046. /**
  52047. * Fired when the touchpad values on this controller are modified
  52048. */
  52049. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52050. /**
  52051. * Fired when the thumbstick button on this controller is modified
  52052. * here to prevent breaking changes
  52053. */
  52054. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52055. /**
  52056. * updating the thumbstick(!) and not the trackpad.
  52057. * This is named this way due to the difference between WebVR and XR and to avoid
  52058. * changing the parent class.
  52059. */
  52060. protected _updateTrackpad(): void;
  52061. /**
  52062. * Disposes the class with joy
  52063. */
  52064. dispose(): void;
  52065. }
  52066. }
  52067. declare module BABYLON {
  52068. /**
  52069. * Class containing static functions to help procedurally build meshes
  52070. */
  52071. export class PolyhedronBuilder {
  52072. /**
  52073. * Creates a polyhedron mesh
  52074. * * 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
  52075. * * The parameter `size` (positive float, default 1) sets the polygon size
  52076. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52077. * * 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`
  52078. * * 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
  52079. * * 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)`)
  52080. * * 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
  52081. * * 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
  52082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52083. * * 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
  52084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52085. * @param name defines the name of the mesh
  52086. * @param options defines the options used to create the mesh
  52087. * @param scene defines the hosting scene
  52088. * @returns the polyhedron mesh
  52089. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52090. */
  52091. static CreatePolyhedron(name: string, options: {
  52092. type?: number;
  52093. size?: number;
  52094. sizeX?: number;
  52095. sizeY?: number;
  52096. sizeZ?: number;
  52097. custom?: any;
  52098. faceUV?: Vector4[];
  52099. faceColors?: Color4[];
  52100. flat?: boolean;
  52101. updatable?: boolean;
  52102. sideOrientation?: number;
  52103. frontUVs?: Vector4;
  52104. backUVs?: Vector4;
  52105. }, scene?: Nullable<Scene>): Mesh;
  52106. }
  52107. }
  52108. declare module BABYLON {
  52109. /**
  52110. * Gizmo that enables scaling a mesh along 3 axis
  52111. */
  52112. export class ScaleGizmo extends Gizmo {
  52113. /**
  52114. * Internal gizmo used for interactions on the x axis
  52115. */
  52116. xGizmo: AxisScaleGizmo;
  52117. /**
  52118. * Internal gizmo used for interactions on the y axis
  52119. */
  52120. yGizmo: AxisScaleGizmo;
  52121. /**
  52122. * Internal gizmo used for interactions on the z axis
  52123. */
  52124. zGizmo: AxisScaleGizmo;
  52125. /**
  52126. * Internal gizmo used to scale all axis equally
  52127. */
  52128. uniformScaleGizmo: AxisScaleGizmo;
  52129. private _meshAttached;
  52130. private _updateGizmoRotationToMatchAttachedMesh;
  52131. private _snapDistance;
  52132. private _scaleRatio;
  52133. private _uniformScalingMesh;
  52134. private _octahedron;
  52135. private _sensitivity;
  52136. /** Fires an event when any of it's sub gizmos are dragged */
  52137. onDragStartObservable: Observable<unknown>;
  52138. /** Fires an event when any of it's sub gizmos are released from dragging */
  52139. onDragEndObservable: Observable<unknown>;
  52140. get attachedMesh(): Nullable<AbstractMesh>;
  52141. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52142. /**
  52143. * Creates a ScaleGizmo
  52144. * @param gizmoLayer The utility layer the gizmo will be added to
  52145. */
  52146. constructor(gizmoLayer?: UtilityLayerRenderer);
  52147. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52148. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52149. /**
  52150. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52151. */
  52152. set snapDistance(value: number);
  52153. get snapDistance(): number;
  52154. /**
  52155. * Ratio for the scale of the gizmo (Default: 1)
  52156. */
  52157. set scaleRatio(value: number);
  52158. get scaleRatio(): number;
  52159. /**
  52160. * Sensitivity factor for dragging (Default: 1)
  52161. */
  52162. set sensitivity(value: number);
  52163. get sensitivity(): number;
  52164. /**
  52165. * Disposes of the gizmo
  52166. */
  52167. dispose(): void;
  52168. }
  52169. }
  52170. declare module BABYLON {
  52171. /**
  52172. * Single axis scale gizmo
  52173. */
  52174. export class AxisScaleGizmo extends Gizmo {
  52175. /**
  52176. * Drag behavior responsible for the gizmos dragging interactions
  52177. */
  52178. dragBehavior: PointerDragBehavior;
  52179. private _pointerObserver;
  52180. /**
  52181. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52182. */
  52183. snapDistance: number;
  52184. /**
  52185. * Event that fires each time the gizmo snaps to a new location.
  52186. * * snapDistance is the the change in distance
  52187. */
  52188. onSnapObservable: Observable<{
  52189. snapDistance: number;
  52190. }>;
  52191. /**
  52192. * If the scaling operation should be done on all axis (default: false)
  52193. */
  52194. uniformScaling: boolean;
  52195. /**
  52196. * Custom sensitivity value for the drag strength
  52197. */
  52198. sensitivity: number;
  52199. private _isEnabled;
  52200. private _parent;
  52201. private _arrow;
  52202. private _coloredMaterial;
  52203. private _hoverMaterial;
  52204. /**
  52205. * Creates an AxisScaleGizmo
  52206. * @param gizmoLayer The utility layer the gizmo will be added to
  52207. * @param dragAxis The axis which the gizmo will be able to scale on
  52208. * @param color The color of the gizmo
  52209. */
  52210. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52211. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52212. /**
  52213. * If the gizmo is enabled
  52214. */
  52215. set isEnabled(value: boolean);
  52216. get isEnabled(): boolean;
  52217. /**
  52218. * Disposes of the gizmo
  52219. */
  52220. dispose(): void;
  52221. /**
  52222. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52223. * @param mesh The mesh to replace the default mesh of the gizmo
  52224. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52225. */
  52226. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52227. }
  52228. }
  52229. declare module BABYLON {
  52230. /**
  52231. * Bounding box gizmo
  52232. */
  52233. export class BoundingBoxGizmo extends Gizmo {
  52234. private _lineBoundingBox;
  52235. private _rotateSpheresParent;
  52236. private _scaleBoxesParent;
  52237. private _boundingDimensions;
  52238. private _renderObserver;
  52239. private _pointerObserver;
  52240. private _scaleDragSpeed;
  52241. private _tmpQuaternion;
  52242. private _tmpVector;
  52243. private _tmpRotationMatrix;
  52244. /**
  52245. * 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)
  52246. */
  52247. ignoreChildren: boolean;
  52248. /**
  52249. * 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)
  52250. */
  52251. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52252. /**
  52253. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52254. */
  52255. rotationSphereSize: number;
  52256. /**
  52257. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52258. */
  52259. scaleBoxSize: number;
  52260. /**
  52261. * 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)
  52262. */
  52263. fixedDragMeshScreenSize: boolean;
  52264. /**
  52265. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52266. */
  52267. fixedDragMeshScreenSizeDistanceFactor: number;
  52268. /**
  52269. * Fired when a rotation sphere or scale box is dragged
  52270. */
  52271. onDragStartObservable: Observable<{}>;
  52272. /**
  52273. * Fired when a scale box is dragged
  52274. */
  52275. onScaleBoxDragObservable: Observable<{}>;
  52276. /**
  52277. * Fired when a scale box drag is ended
  52278. */
  52279. onScaleBoxDragEndObservable: Observable<{}>;
  52280. /**
  52281. * Fired when a rotation sphere is dragged
  52282. */
  52283. onRotationSphereDragObservable: Observable<{}>;
  52284. /**
  52285. * Fired when a rotation sphere drag is ended
  52286. */
  52287. onRotationSphereDragEndObservable: Observable<{}>;
  52288. /**
  52289. * 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)
  52290. */
  52291. scalePivot: Nullable<Vector3>;
  52292. /**
  52293. * Mesh used as a pivot to rotate the attached mesh
  52294. */
  52295. private _anchorMesh;
  52296. private _existingMeshScale;
  52297. private _dragMesh;
  52298. private pointerDragBehavior;
  52299. private coloredMaterial;
  52300. private hoverColoredMaterial;
  52301. /**
  52302. * Sets the color of the bounding box gizmo
  52303. * @param color the color to set
  52304. */
  52305. setColor(color: Color3): void;
  52306. /**
  52307. * Creates an BoundingBoxGizmo
  52308. * @param gizmoLayer The utility layer the gizmo will be added to
  52309. * @param color The color of the gizmo
  52310. */
  52311. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52313. private _selectNode;
  52314. /**
  52315. * Updates the bounding box information for the Gizmo
  52316. */
  52317. updateBoundingBox(): void;
  52318. private _updateRotationSpheres;
  52319. private _updateScaleBoxes;
  52320. /**
  52321. * Enables rotation on the specified axis and disables rotation on the others
  52322. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52323. */
  52324. setEnabledRotationAxis(axis: string): void;
  52325. /**
  52326. * Enables/disables scaling
  52327. * @param enable if scaling should be enabled
  52328. * @param homogeneousScaling defines if scaling should only be homogeneous
  52329. */
  52330. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52331. private _updateDummy;
  52332. /**
  52333. * Enables a pointer drag behavior on the bounding box of the gizmo
  52334. */
  52335. enableDragBehavior(): void;
  52336. /**
  52337. * Disposes of the gizmo
  52338. */
  52339. dispose(): void;
  52340. /**
  52341. * 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)
  52342. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52343. * @returns the bounding box mesh with the passed in mesh as a child
  52344. */
  52345. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52346. /**
  52347. * CustomMeshes are not supported by this gizmo
  52348. * @param mesh The mesh to replace the default mesh of the gizmo
  52349. */
  52350. setCustomMesh(mesh: Mesh): void;
  52351. }
  52352. }
  52353. declare module BABYLON {
  52354. /**
  52355. * Single plane rotation gizmo
  52356. */
  52357. export class PlaneRotationGizmo extends Gizmo {
  52358. /**
  52359. * Drag behavior responsible for the gizmos dragging interactions
  52360. */
  52361. dragBehavior: PointerDragBehavior;
  52362. private _pointerObserver;
  52363. /**
  52364. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52365. */
  52366. snapDistance: number;
  52367. /**
  52368. * Event that fires each time the gizmo snaps to a new location.
  52369. * * snapDistance is the the change in distance
  52370. */
  52371. onSnapObservable: Observable<{
  52372. snapDistance: number;
  52373. }>;
  52374. private _isEnabled;
  52375. private _parent;
  52376. /**
  52377. * Creates a PlaneRotationGizmo
  52378. * @param gizmoLayer The utility layer the gizmo will be added to
  52379. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52380. * @param color The color of the gizmo
  52381. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52382. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52383. */
  52384. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52386. /**
  52387. * If the gizmo is enabled
  52388. */
  52389. set isEnabled(value: boolean);
  52390. get isEnabled(): boolean;
  52391. /**
  52392. * Disposes of the gizmo
  52393. */
  52394. dispose(): void;
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Gizmo that enables rotating a mesh along 3 axis
  52400. */
  52401. export class RotationGizmo extends Gizmo {
  52402. /**
  52403. * Internal gizmo used for interactions on the x axis
  52404. */
  52405. xGizmo: PlaneRotationGizmo;
  52406. /**
  52407. * Internal gizmo used for interactions on the y axis
  52408. */
  52409. yGizmo: PlaneRotationGizmo;
  52410. /**
  52411. * Internal gizmo used for interactions on the z axis
  52412. */
  52413. zGizmo: PlaneRotationGizmo;
  52414. /** Fires an event when any of it's sub gizmos are dragged */
  52415. onDragStartObservable: Observable<unknown>;
  52416. /** Fires an event when any of it's sub gizmos are released from dragging */
  52417. onDragEndObservable: Observable<unknown>;
  52418. private _meshAttached;
  52419. get attachedMesh(): Nullable<AbstractMesh>;
  52420. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52421. /**
  52422. * Creates a RotationGizmo
  52423. * @param gizmoLayer The utility layer the gizmo will be added to
  52424. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52425. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52426. */
  52427. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52428. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52429. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52430. /**
  52431. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52432. */
  52433. set snapDistance(value: number);
  52434. get snapDistance(): number;
  52435. /**
  52436. * Ratio for the scale of the gizmo (Default: 1)
  52437. */
  52438. set scaleRatio(value: number);
  52439. get scaleRatio(): number;
  52440. /**
  52441. * Disposes of the gizmo
  52442. */
  52443. dispose(): void;
  52444. /**
  52445. * CustomMeshes are not supported by this gizmo
  52446. * @param mesh The mesh to replace the default mesh of the gizmo
  52447. */
  52448. setCustomMesh(mesh: Mesh): void;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /**
  52453. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52454. */
  52455. export class GizmoManager implements IDisposable {
  52456. private scene;
  52457. /**
  52458. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52459. */
  52460. gizmos: {
  52461. positionGizmo: Nullable<PositionGizmo>;
  52462. rotationGizmo: Nullable<RotationGizmo>;
  52463. scaleGizmo: Nullable<ScaleGizmo>;
  52464. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52465. };
  52466. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52467. clearGizmoOnEmptyPointerEvent: boolean;
  52468. /** Fires an event when the manager is attached to a mesh */
  52469. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52470. private _gizmosEnabled;
  52471. private _pointerObserver;
  52472. private _attachedMesh;
  52473. private _boundingBoxColor;
  52474. private _defaultUtilityLayer;
  52475. private _defaultKeepDepthUtilityLayer;
  52476. /**
  52477. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52478. */
  52479. boundingBoxDragBehavior: SixDofDragBehavior;
  52480. /**
  52481. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52482. */
  52483. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52484. /**
  52485. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52486. */
  52487. usePointerToAttachGizmos: boolean;
  52488. /**
  52489. * Utility layer that the bounding box gizmo belongs to
  52490. */
  52491. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52492. /**
  52493. * Utility layer that all gizmos besides bounding box belong to
  52494. */
  52495. get utilityLayer(): UtilityLayerRenderer;
  52496. /**
  52497. * Instatiates a gizmo manager
  52498. * @param scene the scene to overlay the gizmos on top of
  52499. */
  52500. constructor(scene: Scene);
  52501. /**
  52502. * Attaches a set of gizmos to the specified mesh
  52503. * @param mesh The mesh the gizmo's should be attached to
  52504. */
  52505. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52506. /**
  52507. * If the position gizmo is enabled
  52508. */
  52509. set positionGizmoEnabled(value: boolean);
  52510. get positionGizmoEnabled(): boolean;
  52511. /**
  52512. * If the rotation gizmo is enabled
  52513. */
  52514. set rotationGizmoEnabled(value: boolean);
  52515. get rotationGizmoEnabled(): boolean;
  52516. /**
  52517. * If the scale gizmo is enabled
  52518. */
  52519. set scaleGizmoEnabled(value: boolean);
  52520. get scaleGizmoEnabled(): boolean;
  52521. /**
  52522. * If the boundingBox gizmo is enabled
  52523. */
  52524. set boundingBoxGizmoEnabled(value: boolean);
  52525. get boundingBoxGizmoEnabled(): boolean;
  52526. /**
  52527. * Disposes of the gizmo manager
  52528. */
  52529. dispose(): void;
  52530. }
  52531. }
  52532. declare module BABYLON {
  52533. /**
  52534. * A directional light is defined by a direction (what a surprise!).
  52535. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52536. * 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.
  52537. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52538. */
  52539. export class DirectionalLight extends ShadowLight {
  52540. private _shadowFrustumSize;
  52541. /**
  52542. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52543. */
  52544. get shadowFrustumSize(): number;
  52545. /**
  52546. * Specifies a fix frustum size for the shadow generation.
  52547. */
  52548. set shadowFrustumSize(value: number);
  52549. private _shadowOrthoScale;
  52550. /**
  52551. * Gets the shadow projection scale against the optimal computed one.
  52552. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52553. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52554. */
  52555. get shadowOrthoScale(): number;
  52556. /**
  52557. * Sets the shadow projection scale against the optimal computed one.
  52558. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52559. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52560. */
  52561. set shadowOrthoScale(value: number);
  52562. /**
  52563. * Automatically compute the projection matrix to best fit (including all the casters)
  52564. * on each frame.
  52565. */
  52566. autoUpdateExtends: boolean;
  52567. /**
  52568. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52569. * on each frame. autoUpdateExtends must be set to true for this to work
  52570. */
  52571. autoCalcShadowZBounds: boolean;
  52572. private _orthoLeft;
  52573. private _orthoRight;
  52574. private _orthoTop;
  52575. private _orthoBottom;
  52576. /**
  52577. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52578. * The directional light is emitted from everywhere in the given direction.
  52579. * It can cast shadows.
  52580. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52581. * @param name The friendly name of the light
  52582. * @param direction The direction of the light
  52583. * @param scene The scene the light belongs to
  52584. */
  52585. constructor(name: string, direction: Vector3, scene: Scene);
  52586. /**
  52587. * Returns the string "DirectionalLight".
  52588. * @return The class name
  52589. */
  52590. getClassName(): string;
  52591. /**
  52592. * Returns the integer 1.
  52593. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52594. */
  52595. getTypeID(): number;
  52596. /**
  52597. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52598. * Returns the DirectionalLight Shadow projection matrix.
  52599. */
  52600. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52601. /**
  52602. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52603. * Returns the DirectionalLight Shadow projection matrix.
  52604. */
  52605. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52606. /**
  52607. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52608. * Returns the DirectionalLight Shadow projection matrix.
  52609. */
  52610. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52611. protected _buildUniformLayout(): void;
  52612. /**
  52613. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52614. * @param effect The effect to update
  52615. * @param lightIndex The index of the light in the effect to update
  52616. * @returns The directional light
  52617. */
  52618. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52619. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52620. /**
  52621. * Gets the minZ used for shadow according to both the scene and the light.
  52622. *
  52623. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52624. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52625. * @param activeCamera The camera we are returning the min for
  52626. * @returns the depth min z
  52627. */
  52628. getDepthMinZ(activeCamera: Camera): number;
  52629. /**
  52630. * Gets the maxZ used for shadow according to both the scene and the light.
  52631. *
  52632. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52633. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52634. * @param activeCamera The camera we are returning the max for
  52635. * @returns the depth max z
  52636. */
  52637. getDepthMaxZ(activeCamera: Camera): number;
  52638. /**
  52639. * Prepares the list of defines specific to the light type.
  52640. * @param defines the list of defines
  52641. * @param lightIndex defines the index of the light for the effect
  52642. */
  52643. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52644. }
  52645. }
  52646. declare module BABYLON {
  52647. /**
  52648. * Class containing static functions to help procedurally build meshes
  52649. */
  52650. export class HemisphereBuilder {
  52651. /**
  52652. * Creates a hemisphere mesh
  52653. * @param name defines the name of the mesh
  52654. * @param options defines the options used to create the mesh
  52655. * @param scene defines the hosting scene
  52656. * @returns the hemisphere mesh
  52657. */
  52658. static CreateHemisphere(name: string, options: {
  52659. segments?: number;
  52660. diameter?: number;
  52661. sideOrientation?: number;
  52662. }, scene: any): Mesh;
  52663. }
  52664. }
  52665. declare module BABYLON {
  52666. /**
  52667. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52668. * These values define a cone of light starting from the position, emitting toward the direction.
  52669. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52670. * and the exponent defines the speed of the decay of the light with distance (reach).
  52671. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52672. */
  52673. export class SpotLight extends ShadowLight {
  52674. private _angle;
  52675. private _innerAngle;
  52676. private _cosHalfAngle;
  52677. private _lightAngleScale;
  52678. private _lightAngleOffset;
  52679. /**
  52680. * Gets the cone angle of the spot light in Radians.
  52681. */
  52682. get angle(): number;
  52683. /**
  52684. * Sets the cone angle of the spot light in Radians.
  52685. */
  52686. set angle(value: number);
  52687. /**
  52688. * Only used in gltf falloff mode, this defines the angle where
  52689. * the directional falloff will start before cutting at angle which could be seen
  52690. * as outer angle.
  52691. */
  52692. get innerAngle(): number;
  52693. /**
  52694. * Only used in gltf falloff mode, this defines the angle where
  52695. * the directional falloff will start before cutting at angle which could be seen
  52696. * as outer angle.
  52697. */
  52698. set innerAngle(value: number);
  52699. private _shadowAngleScale;
  52700. /**
  52701. * Allows scaling the angle of the light for shadow generation only.
  52702. */
  52703. get shadowAngleScale(): number;
  52704. /**
  52705. * Allows scaling the angle of the light for shadow generation only.
  52706. */
  52707. set shadowAngleScale(value: number);
  52708. /**
  52709. * The light decay speed with the distance from the emission spot.
  52710. */
  52711. exponent: number;
  52712. private _projectionTextureMatrix;
  52713. /**
  52714. * Allows reading the projecton texture
  52715. */
  52716. get projectionTextureMatrix(): Matrix;
  52717. protected _projectionTextureLightNear: number;
  52718. /**
  52719. * Gets the near clip of the Spotlight for texture projection.
  52720. */
  52721. get projectionTextureLightNear(): number;
  52722. /**
  52723. * Sets the near clip of the Spotlight for texture projection.
  52724. */
  52725. set projectionTextureLightNear(value: number);
  52726. protected _projectionTextureLightFar: number;
  52727. /**
  52728. * Gets the far clip of the Spotlight for texture projection.
  52729. */
  52730. get projectionTextureLightFar(): number;
  52731. /**
  52732. * Sets the far clip of the Spotlight for texture projection.
  52733. */
  52734. set projectionTextureLightFar(value: number);
  52735. protected _projectionTextureUpDirection: Vector3;
  52736. /**
  52737. * Gets the Up vector of the Spotlight for texture projection.
  52738. */
  52739. get projectionTextureUpDirection(): Vector3;
  52740. /**
  52741. * Sets the Up vector of the Spotlight for texture projection.
  52742. */
  52743. set projectionTextureUpDirection(value: Vector3);
  52744. private _projectionTexture;
  52745. /**
  52746. * Gets the projection texture of the light.
  52747. */
  52748. get projectionTexture(): Nullable<BaseTexture>;
  52749. /**
  52750. * Sets the projection texture of the light.
  52751. */
  52752. set projectionTexture(value: Nullable<BaseTexture>);
  52753. private _projectionTextureViewLightDirty;
  52754. private _projectionTextureProjectionLightDirty;
  52755. private _projectionTextureDirty;
  52756. private _projectionTextureViewTargetVector;
  52757. private _projectionTextureViewLightMatrix;
  52758. private _projectionTextureProjectionLightMatrix;
  52759. private _projectionTextureScalingMatrix;
  52760. /**
  52761. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52762. * It can cast shadows.
  52763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52764. * @param name The light friendly name
  52765. * @param position The position of the spot light in the scene
  52766. * @param direction The direction of the light in the scene
  52767. * @param angle The cone angle of the light in Radians
  52768. * @param exponent The light decay speed with the distance from the emission spot
  52769. * @param scene The scene the lights belongs to
  52770. */
  52771. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52772. /**
  52773. * Returns the string "SpotLight".
  52774. * @returns the class name
  52775. */
  52776. getClassName(): string;
  52777. /**
  52778. * Returns the integer 2.
  52779. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52780. */
  52781. getTypeID(): number;
  52782. /**
  52783. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52784. */
  52785. protected _setDirection(value: Vector3): void;
  52786. /**
  52787. * Overrides the position setter to recompute the projection texture view light Matrix.
  52788. */
  52789. protected _setPosition(value: Vector3): void;
  52790. /**
  52791. * 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.
  52792. * Returns the SpotLight.
  52793. */
  52794. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52795. protected _computeProjectionTextureViewLightMatrix(): void;
  52796. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52797. /**
  52798. * Main function for light texture projection matrix computing.
  52799. */
  52800. protected _computeProjectionTextureMatrix(): void;
  52801. protected _buildUniformLayout(): void;
  52802. private _computeAngleValues;
  52803. /**
  52804. * Sets the passed Effect "effect" with the Light textures.
  52805. * @param effect The effect to update
  52806. * @param lightIndex The index of the light in the effect to update
  52807. * @returns The light
  52808. */
  52809. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52810. /**
  52811. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52812. * @param effect The effect to update
  52813. * @param lightIndex The index of the light in the effect to update
  52814. * @returns The spot light
  52815. */
  52816. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52817. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52818. /**
  52819. * Disposes the light and the associated resources.
  52820. */
  52821. dispose(): void;
  52822. /**
  52823. * Prepares the list of defines specific to the light type.
  52824. * @param defines the list of defines
  52825. * @param lightIndex defines the index of the light for the effect
  52826. */
  52827. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52828. }
  52829. }
  52830. declare module BABYLON {
  52831. /**
  52832. * Gizmo that enables viewing a light
  52833. */
  52834. export class LightGizmo extends Gizmo {
  52835. private _lightMesh;
  52836. private _material;
  52837. private _cachedPosition;
  52838. private _cachedForward;
  52839. private _attachedMeshParent;
  52840. /**
  52841. * Creates a LightGizmo
  52842. * @param gizmoLayer The utility layer the gizmo will be added to
  52843. */
  52844. constructor(gizmoLayer?: UtilityLayerRenderer);
  52845. private _light;
  52846. /**
  52847. * The light that the gizmo is attached to
  52848. */
  52849. set light(light: Nullable<Light>);
  52850. get light(): Nullable<Light>;
  52851. /**
  52852. * Gets the material used to render the light gizmo
  52853. */
  52854. get material(): StandardMaterial;
  52855. /**
  52856. * @hidden
  52857. * Updates the gizmo to match the attached mesh's position/rotation
  52858. */
  52859. protected _update(): void;
  52860. private static _Scale;
  52861. /**
  52862. * Creates the lines for a light mesh
  52863. */
  52864. private static _CreateLightLines;
  52865. /**
  52866. * Disposes of the light gizmo
  52867. */
  52868. dispose(): void;
  52869. private static _CreateHemisphericLightMesh;
  52870. private static _CreatePointLightMesh;
  52871. private static _CreateSpotLightMesh;
  52872. private static _CreateDirectionalLightMesh;
  52873. }
  52874. }
  52875. declare module BABYLON {
  52876. /** @hidden */
  52877. export var backgroundFragmentDeclaration: {
  52878. name: string;
  52879. shader: string;
  52880. };
  52881. }
  52882. declare module BABYLON {
  52883. /** @hidden */
  52884. export var backgroundUboDeclaration: {
  52885. name: string;
  52886. shader: string;
  52887. };
  52888. }
  52889. declare module BABYLON {
  52890. /** @hidden */
  52891. export var backgroundPixelShader: {
  52892. name: string;
  52893. shader: string;
  52894. };
  52895. }
  52896. declare module BABYLON {
  52897. /** @hidden */
  52898. export var backgroundVertexDeclaration: {
  52899. name: string;
  52900. shader: string;
  52901. };
  52902. }
  52903. declare module BABYLON {
  52904. /** @hidden */
  52905. export var backgroundVertexShader: {
  52906. name: string;
  52907. shader: string;
  52908. };
  52909. }
  52910. declare module BABYLON {
  52911. /**
  52912. * Background material used to create an efficient environement around your scene.
  52913. */
  52914. export class BackgroundMaterial extends PushMaterial {
  52915. /**
  52916. * Standard reflectance value at parallel view angle.
  52917. */
  52918. static StandardReflectance0: number;
  52919. /**
  52920. * Standard reflectance value at grazing angle.
  52921. */
  52922. static StandardReflectance90: number;
  52923. protected _primaryColor: Color3;
  52924. /**
  52925. * Key light Color (multiply against the environement texture)
  52926. */
  52927. primaryColor: Color3;
  52928. protected __perceptualColor: Nullable<Color3>;
  52929. /**
  52930. * Experimental Internal Use Only.
  52931. *
  52932. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52933. * This acts as a helper to set the primary color to a more "human friendly" value.
  52934. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52935. * output color as close as possible from the chosen value.
  52936. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52937. * part of lighting setup.)
  52938. */
  52939. get _perceptualColor(): Nullable<Color3>;
  52940. set _perceptualColor(value: Nullable<Color3>);
  52941. protected _primaryColorShadowLevel: float;
  52942. /**
  52943. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52944. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52945. */
  52946. get primaryColorShadowLevel(): float;
  52947. set primaryColorShadowLevel(value: float);
  52948. protected _primaryColorHighlightLevel: float;
  52949. /**
  52950. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52951. * The primary color is used at the level chosen to define what the white area would look.
  52952. */
  52953. get primaryColorHighlightLevel(): float;
  52954. set primaryColorHighlightLevel(value: float);
  52955. protected _reflectionTexture: Nullable<BaseTexture>;
  52956. /**
  52957. * Reflection Texture used in the material.
  52958. * Should be author in a specific way for the best result (refer to the documentation).
  52959. */
  52960. reflectionTexture: Nullable<BaseTexture>;
  52961. protected _reflectionBlur: float;
  52962. /**
  52963. * Reflection Texture level of blur.
  52964. *
  52965. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52966. * texture twice.
  52967. */
  52968. reflectionBlur: float;
  52969. protected _diffuseTexture: Nullable<BaseTexture>;
  52970. /**
  52971. * Diffuse Texture used in the material.
  52972. * Should be author in a specific way for the best result (refer to the documentation).
  52973. */
  52974. diffuseTexture: Nullable<BaseTexture>;
  52975. protected _shadowLights: Nullable<IShadowLight[]>;
  52976. /**
  52977. * Specify the list of lights casting shadow on the material.
  52978. * All scene shadow lights will be included if null.
  52979. */
  52980. shadowLights: Nullable<IShadowLight[]>;
  52981. protected _shadowLevel: float;
  52982. /**
  52983. * Helps adjusting the shadow to a softer level if required.
  52984. * 0 means black shadows and 1 means no shadows.
  52985. */
  52986. shadowLevel: float;
  52987. protected _sceneCenter: Vector3;
  52988. /**
  52989. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52990. * It is usually zero but might be interesting to modify according to your setup.
  52991. */
  52992. sceneCenter: Vector3;
  52993. protected _opacityFresnel: boolean;
  52994. /**
  52995. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52996. * This helps ensuring a nice transition when the camera goes under the ground.
  52997. */
  52998. opacityFresnel: boolean;
  52999. protected _reflectionFresnel: boolean;
  53000. /**
  53001. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53002. * This helps adding a mirror texture on the ground.
  53003. */
  53004. reflectionFresnel: boolean;
  53005. protected _reflectionFalloffDistance: number;
  53006. /**
  53007. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53008. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53009. */
  53010. reflectionFalloffDistance: number;
  53011. protected _reflectionAmount: number;
  53012. /**
  53013. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53014. */
  53015. reflectionAmount: number;
  53016. protected _reflectionReflectance0: number;
  53017. /**
  53018. * This specifies the weight of the reflection at grazing angle.
  53019. */
  53020. reflectionReflectance0: number;
  53021. protected _reflectionReflectance90: number;
  53022. /**
  53023. * This specifies the weight of the reflection at a perpendicular point of view.
  53024. */
  53025. reflectionReflectance90: number;
  53026. /**
  53027. * Sets the reflection reflectance fresnel values according to the default standard
  53028. * empirically know to work well :-)
  53029. */
  53030. set reflectionStandardFresnelWeight(value: number);
  53031. protected _useRGBColor: boolean;
  53032. /**
  53033. * Helps to directly use the maps channels instead of their level.
  53034. */
  53035. useRGBColor: boolean;
  53036. protected _enableNoise: boolean;
  53037. /**
  53038. * This helps reducing the banding effect that could occur on the background.
  53039. */
  53040. enableNoise: boolean;
  53041. /**
  53042. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53043. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53044. * Recommended to be keep at 1.0 except for special cases.
  53045. */
  53046. get fovMultiplier(): number;
  53047. set fovMultiplier(value: number);
  53048. private _fovMultiplier;
  53049. /**
  53050. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53051. */
  53052. useEquirectangularFOV: boolean;
  53053. private _maxSimultaneousLights;
  53054. /**
  53055. * Number of Simultaneous lights allowed on the material.
  53056. */
  53057. maxSimultaneousLights: int;
  53058. /**
  53059. * Default configuration related to image processing available in the Background Material.
  53060. */
  53061. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53062. /**
  53063. * Keep track of the image processing observer to allow dispose and replace.
  53064. */
  53065. private _imageProcessingObserver;
  53066. /**
  53067. * Attaches a new image processing configuration to the PBR Material.
  53068. * @param configuration (if null the scene configuration will be use)
  53069. */
  53070. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53071. /**
  53072. * Gets the image processing configuration used either in this material.
  53073. */
  53074. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53075. /**
  53076. * Sets the Default image processing configuration used either in the this material.
  53077. *
  53078. * If sets to null, the scene one is in use.
  53079. */
  53080. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53081. /**
  53082. * Gets wether the color curves effect is enabled.
  53083. */
  53084. get cameraColorCurvesEnabled(): boolean;
  53085. /**
  53086. * Sets wether the color curves effect is enabled.
  53087. */
  53088. set cameraColorCurvesEnabled(value: boolean);
  53089. /**
  53090. * Gets wether the color grading effect is enabled.
  53091. */
  53092. get cameraColorGradingEnabled(): boolean;
  53093. /**
  53094. * Gets wether the color grading effect is enabled.
  53095. */
  53096. set cameraColorGradingEnabled(value: boolean);
  53097. /**
  53098. * Gets wether tonemapping is enabled or not.
  53099. */
  53100. get cameraToneMappingEnabled(): boolean;
  53101. /**
  53102. * Sets wether tonemapping is enabled or not
  53103. */
  53104. set cameraToneMappingEnabled(value: boolean);
  53105. /**
  53106. * The camera exposure used on this material.
  53107. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53108. * This corresponds to a photographic exposure.
  53109. */
  53110. get cameraExposure(): float;
  53111. /**
  53112. * The camera exposure used on this material.
  53113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53114. * This corresponds to a photographic exposure.
  53115. */
  53116. set cameraExposure(value: float);
  53117. /**
  53118. * Gets The camera contrast used on this material.
  53119. */
  53120. get cameraContrast(): float;
  53121. /**
  53122. * Sets The camera contrast used on this material.
  53123. */
  53124. set cameraContrast(value: float);
  53125. /**
  53126. * Gets the Color Grading 2D Lookup Texture.
  53127. */
  53128. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53129. /**
  53130. * Sets the Color Grading 2D Lookup Texture.
  53131. */
  53132. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53133. /**
  53134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53136. * 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;
  53137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53138. */
  53139. get cameraColorCurves(): Nullable<ColorCurves>;
  53140. /**
  53141. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53142. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53143. * 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;
  53144. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53145. */
  53146. set cameraColorCurves(value: Nullable<ColorCurves>);
  53147. /**
  53148. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53149. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53150. */
  53151. switchToBGR: boolean;
  53152. private _renderTargets;
  53153. private _reflectionControls;
  53154. private _white;
  53155. private _primaryShadowColor;
  53156. private _primaryHighlightColor;
  53157. /**
  53158. * Instantiates a Background Material in the given scene
  53159. * @param name The friendly name of the material
  53160. * @param scene The scene to add the material to
  53161. */
  53162. constructor(name: string, scene: Scene);
  53163. /**
  53164. * Gets a boolean indicating that current material needs to register RTT
  53165. */
  53166. get hasRenderTargetTextures(): boolean;
  53167. /**
  53168. * The entire material has been created in order to prevent overdraw.
  53169. * @returns false
  53170. */
  53171. needAlphaTesting(): boolean;
  53172. /**
  53173. * The entire material has been created in order to prevent overdraw.
  53174. * @returns true if blending is enable
  53175. */
  53176. needAlphaBlending(): boolean;
  53177. /**
  53178. * Checks wether the material is ready to be rendered for a given mesh.
  53179. * @param mesh The mesh to render
  53180. * @param subMesh The submesh to check against
  53181. * @param useInstances Specify wether or not the material is used with instances
  53182. * @returns true if all the dependencies are ready (Textures, Effects...)
  53183. */
  53184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53185. /**
  53186. * Compute the primary color according to the chosen perceptual color.
  53187. */
  53188. private _computePrimaryColorFromPerceptualColor;
  53189. /**
  53190. * Compute the highlights and shadow colors according to their chosen levels.
  53191. */
  53192. private _computePrimaryColors;
  53193. /**
  53194. * Build the uniform buffer used in the material.
  53195. */
  53196. buildUniformLayout(): void;
  53197. /**
  53198. * Unbind the material.
  53199. */
  53200. unbind(): void;
  53201. /**
  53202. * Bind only the world matrix to the material.
  53203. * @param world The world matrix to bind.
  53204. */
  53205. bindOnlyWorldMatrix(world: Matrix): void;
  53206. /**
  53207. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53208. * @param world The world matrix to bind.
  53209. * @param subMesh The submesh to bind for.
  53210. */
  53211. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53212. /**
  53213. * Checks to see if a texture is used in the material.
  53214. * @param texture - Base texture to use.
  53215. * @returns - Boolean specifying if a texture is used in the material.
  53216. */
  53217. hasTexture(texture: BaseTexture): boolean;
  53218. /**
  53219. * Dispose the material.
  53220. * @param forceDisposeEffect Force disposal of the associated effect.
  53221. * @param forceDisposeTextures Force disposal of the associated textures.
  53222. */
  53223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53224. /**
  53225. * Clones the material.
  53226. * @param name The cloned name.
  53227. * @returns The cloned material.
  53228. */
  53229. clone(name: string): BackgroundMaterial;
  53230. /**
  53231. * Serializes the current material to its JSON representation.
  53232. * @returns The JSON representation.
  53233. */
  53234. serialize(): any;
  53235. /**
  53236. * Gets the class name of the material
  53237. * @returns "BackgroundMaterial"
  53238. */
  53239. getClassName(): string;
  53240. /**
  53241. * Parse a JSON input to create back a background material.
  53242. * @param source The JSON data to parse
  53243. * @param scene The scene to create the parsed material in
  53244. * @param rootUrl The root url of the assets the material depends upon
  53245. * @returns the instantiated BackgroundMaterial.
  53246. */
  53247. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53248. }
  53249. }
  53250. declare module BABYLON {
  53251. /**
  53252. * Represents the different options available during the creation of
  53253. * a Environment helper.
  53254. *
  53255. * This can control the default ground, skybox and image processing setup of your scene.
  53256. */
  53257. export interface IEnvironmentHelperOptions {
  53258. /**
  53259. * Specifies whether or not to create a ground.
  53260. * True by default.
  53261. */
  53262. createGround: boolean;
  53263. /**
  53264. * Specifies the ground size.
  53265. * 15 by default.
  53266. */
  53267. groundSize: number;
  53268. /**
  53269. * The texture used on the ground for the main color.
  53270. * Comes from the BabylonJS CDN by default.
  53271. *
  53272. * Remarks: Can be either a texture or a url.
  53273. */
  53274. groundTexture: string | BaseTexture;
  53275. /**
  53276. * The color mixed in the ground texture by default.
  53277. * BabylonJS clearColor by default.
  53278. */
  53279. groundColor: Color3;
  53280. /**
  53281. * Specifies the ground opacity.
  53282. * 1 by default.
  53283. */
  53284. groundOpacity: number;
  53285. /**
  53286. * Enables the ground to receive shadows.
  53287. * True by default.
  53288. */
  53289. enableGroundShadow: boolean;
  53290. /**
  53291. * Helps preventing the shadow to be fully black on the ground.
  53292. * 0.5 by default.
  53293. */
  53294. groundShadowLevel: number;
  53295. /**
  53296. * Creates a mirror texture attach to the ground.
  53297. * false by default.
  53298. */
  53299. enableGroundMirror: boolean;
  53300. /**
  53301. * Specifies the ground mirror size ratio.
  53302. * 0.3 by default as the default kernel is 64.
  53303. */
  53304. groundMirrorSizeRatio: number;
  53305. /**
  53306. * Specifies the ground mirror blur kernel size.
  53307. * 64 by default.
  53308. */
  53309. groundMirrorBlurKernel: number;
  53310. /**
  53311. * Specifies the ground mirror visibility amount.
  53312. * 1 by default
  53313. */
  53314. groundMirrorAmount: number;
  53315. /**
  53316. * Specifies the ground mirror reflectance weight.
  53317. * This uses the standard weight of the background material to setup the fresnel effect
  53318. * of the mirror.
  53319. * 1 by default.
  53320. */
  53321. groundMirrorFresnelWeight: number;
  53322. /**
  53323. * Specifies the ground mirror Falloff distance.
  53324. * This can helps reducing the size of the reflection.
  53325. * 0 by Default.
  53326. */
  53327. groundMirrorFallOffDistance: number;
  53328. /**
  53329. * Specifies the ground mirror texture type.
  53330. * Unsigned Int by Default.
  53331. */
  53332. groundMirrorTextureType: number;
  53333. /**
  53334. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53335. * the shown objects.
  53336. */
  53337. groundYBias: number;
  53338. /**
  53339. * Specifies whether or not to create a skybox.
  53340. * True by default.
  53341. */
  53342. createSkybox: boolean;
  53343. /**
  53344. * Specifies the skybox size.
  53345. * 20 by default.
  53346. */
  53347. skyboxSize: number;
  53348. /**
  53349. * The texture used on the skybox for the main color.
  53350. * Comes from the BabylonJS CDN by default.
  53351. *
  53352. * Remarks: Can be either a texture or a url.
  53353. */
  53354. skyboxTexture: string | BaseTexture;
  53355. /**
  53356. * The color mixed in the skybox texture by default.
  53357. * BabylonJS clearColor by default.
  53358. */
  53359. skyboxColor: Color3;
  53360. /**
  53361. * The background rotation around the Y axis of the scene.
  53362. * This helps aligning the key lights of your scene with the background.
  53363. * 0 by default.
  53364. */
  53365. backgroundYRotation: number;
  53366. /**
  53367. * Compute automatically the size of the elements to best fit with the scene.
  53368. */
  53369. sizeAuto: boolean;
  53370. /**
  53371. * Default position of the rootMesh if autoSize is not true.
  53372. */
  53373. rootPosition: Vector3;
  53374. /**
  53375. * Sets up the image processing in the scene.
  53376. * true by default.
  53377. */
  53378. setupImageProcessing: boolean;
  53379. /**
  53380. * The texture used as your environment texture in the scene.
  53381. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53382. *
  53383. * Remarks: Can be either a texture or a url.
  53384. */
  53385. environmentTexture: string | BaseTexture;
  53386. /**
  53387. * The value of the exposure to apply to the scene.
  53388. * 0.6 by default if setupImageProcessing is true.
  53389. */
  53390. cameraExposure: number;
  53391. /**
  53392. * The value of the contrast to apply to the scene.
  53393. * 1.6 by default if setupImageProcessing is true.
  53394. */
  53395. cameraContrast: number;
  53396. /**
  53397. * Specifies whether or not tonemapping should be enabled in the scene.
  53398. * true by default if setupImageProcessing is true.
  53399. */
  53400. toneMappingEnabled: boolean;
  53401. }
  53402. /**
  53403. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53404. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53405. * It also helps with the default setup of your imageProcessing configuration.
  53406. */
  53407. export class EnvironmentHelper {
  53408. /**
  53409. * Default ground texture URL.
  53410. */
  53411. private static _groundTextureCDNUrl;
  53412. /**
  53413. * Default skybox texture URL.
  53414. */
  53415. private static _skyboxTextureCDNUrl;
  53416. /**
  53417. * Default environment texture URL.
  53418. */
  53419. private static _environmentTextureCDNUrl;
  53420. /**
  53421. * Creates the default options for the helper.
  53422. */
  53423. private static _getDefaultOptions;
  53424. private _rootMesh;
  53425. /**
  53426. * Gets the root mesh created by the helper.
  53427. */
  53428. get rootMesh(): Mesh;
  53429. private _skybox;
  53430. /**
  53431. * Gets the skybox created by the helper.
  53432. */
  53433. get skybox(): Nullable<Mesh>;
  53434. private _skyboxTexture;
  53435. /**
  53436. * Gets the skybox texture created by the helper.
  53437. */
  53438. get skyboxTexture(): Nullable<BaseTexture>;
  53439. private _skyboxMaterial;
  53440. /**
  53441. * Gets the skybox material created by the helper.
  53442. */
  53443. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53444. private _ground;
  53445. /**
  53446. * Gets the ground mesh created by the helper.
  53447. */
  53448. get ground(): Nullable<Mesh>;
  53449. private _groundTexture;
  53450. /**
  53451. * Gets the ground texture created by the helper.
  53452. */
  53453. get groundTexture(): Nullable<BaseTexture>;
  53454. private _groundMirror;
  53455. /**
  53456. * Gets the ground mirror created by the helper.
  53457. */
  53458. get groundMirror(): Nullable<MirrorTexture>;
  53459. /**
  53460. * Gets the ground mirror render list to helps pushing the meshes
  53461. * you wish in the ground reflection.
  53462. */
  53463. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53464. private _groundMaterial;
  53465. /**
  53466. * Gets the ground material created by the helper.
  53467. */
  53468. get groundMaterial(): Nullable<BackgroundMaterial>;
  53469. /**
  53470. * Stores the creation options.
  53471. */
  53472. private readonly _scene;
  53473. private _options;
  53474. /**
  53475. * This observable will be notified with any error during the creation of the environment,
  53476. * mainly texture creation errors.
  53477. */
  53478. onErrorObservable: Observable<{
  53479. message?: string;
  53480. exception?: any;
  53481. }>;
  53482. /**
  53483. * constructor
  53484. * @param options Defines the options we want to customize the helper
  53485. * @param scene The scene to add the material to
  53486. */
  53487. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53488. /**
  53489. * Updates the background according to the new options
  53490. * @param options
  53491. */
  53492. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53493. /**
  53494. * Sets the primary color of all the available elements.
  53495. * @param color the main color to affect to the ground and the background
  53496. */
  53497. setMainColor(color: Color3): void;
  53498. /**
  53499. * Setup the image processing according to the specified options.
  53500. */
  53501. private _setupImageProcessing;
  53502. /**
  53503. * Setup the environment texture according to the specified options.
  53504. */
  53505. private _setupEnvironmentTexture;
  53506. /**
  53507. * Setup the background according to the specified options.
  53508. */
  53509. private _setupBackground;
  53510. /**
  53511. * Get the scene sizes according to the setup.
  53512. */
  53513. private _getSceneSize;
  53514. /**
  53515. * Setup the ground according to the specified options.
  53516. */
  53517. private _setupGround;
  53518. /**
  53519. * Setup the ground material according to the specified options.
  53520. */
  53521. private _setupGroundMaterial;
  53522. /**
  53523. * Setup the ground diffuse texture according to the specified options.
  53524. */
  53525. private _setupGroundDiffuseTexture;
  53526. /**
  53527. * Setup the ground mirror texture according to the specified options.
  53528. */
  53529. private _setupGroundMirrorTexture;
  53530. /**
  53531. * Setup the ground to receive the mirror texture.
  53532. */
  53533. private _setupMirrorInGroundMaterial;
  53534. /**
  53535. * Setup the skybox according to the specified options.
  53536. */
  53537. private _setupSkybox;
  53538. /**
  53539. * Setup the skybox material according to the specified options.
  53540. */
  53541. private _setupSkyboxMaterial;
  53542. /**
  53543. * Setup the skybox reflection texture according to the specified options.
  53544. */
  53545. private _setupSkyboxReflectionTexture;
  53546. private _errorHandler;
  53547. /**
  53548. * Dispose all the elements created by the Helper.
  53549. */
  53550. dispose(): void;
  53551. }
  53552. }
  53553. declare module BABYLON {
  53554. /**
  53555. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53556. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53557. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53558. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53559. */
  53560. export class PhotoDome extends TransformNode {
  53561. /**
  53562. * Define the image as a Monoscopic panoramic 360 image.
  53563. */
  53564. static readonly MODE_MONOSCOPIC: number;
  53565. /**
  53566. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53567. */
  53568. static readonly MODE_TOPBOTTOM: number;
  53569. /**
  53570. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53571. */
  53572. static readonly MODE_SIDEBYSIDE: number;
  53573. private _useDirectMapping;
  53574. /**
  53575. * The texture being displayed on the sphere
  53576. */
  53577. protected _photoTexture: Texture;
  53578. /**
  53579. * Gets or sets the texture being displayed on the sphere
  53580. */
  53581. get photoTexture(): Texture;
  53582. set photoTexture(value: Texture);
  53583. /**
  53584. * Observable raised when an error occured while loading the 360 image
  53585. */
  53586. onLoadErrorObservable: Observable<string>;
  53587. /**
  53588. * The skybox material
  53589. */
  53590. protected _material: BackgroundMaterial;
  53591. /**
  53592. * The surface used for the skybox
  53593. */
  53594. protected _mesh: Mesh;
  53595. /**
  53596. * Gets the mesh used for the skybox.
  53597. */
  53598. get mesh(): Mesh;
  53599. /**
  53600. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53601. * Also see the options.resolution property.
  53602. */
  53603. get fovMultiplier(): number;
  53604. set fovMultiplier(value: number);
  53605. private _imageMode;
  53606. /**
  53607. * Gets or set the current video mode for the video. It can be:
  53608. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53609. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53610. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53611. */
  53612. get imageMode(): number;
  53613. set imageMode(value: number);
  53614. /**
  53615. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53616. * @param name Element's name, child elements will append suffixes for their own names.
  53617. * @param urlsOfPhoto defines the url of the photo to display
  53618. * @param options defines an object containing optional or exposed sub element properties
  53619. * @param onError defines a callback called when an error occured while loading the texture
  53620. */
  53621. constructor(name: string, urlOfPhoto: string, options: {
  53622. resolution?: number;
  53623. size?: number;
  53624. useDirectMapping?: boolean;
  53625. faceForward?: boolean;
  53626. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53627. private _onBeforeCameraRenderObserver;
  53628. private _changeImageMode;
  53629. /**
  53630. * Releases resources associated with this node.
  53631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53633. */
  53634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53635. }
  53636. }
  53637. declare module BABYLON {
  53638. /**
  53639. * Class used to host RGBD texture specific utilities
  53640. */
  53641. export class RGBDTextureTools {
  53642. /**
  53643. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53644. * @param texture the texture to expand.
  53645. */
  53646. static ExpandRGBDTexture(texture: Texture): void;
  53647. }
  53648. }
  53649. declare module BABYLON {
  53650. /**
  53651. * Class used to host texture specific utilities
  53652. */
  53653. export class BRDFTextureTools {
  53654. /**
  53655. * Prevents texture cache collision
  53656. */
  53657. private static _instanceNumber;
  53658. /**
  53659. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53660. * @param scene defines the hosting scene
  53661. * @returns the environment BRDF texture
  53662. */
  53663. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53664. private static _environmentBRDFBase64Texture;
  53665. }
  53666. }
  53667. declare module BABYLON {
  53668. /**
  53669. * @hidden
  53670. */
  53671. export interface IMaterialClearCoatDefines {
  53672. CLEARCOAT: boolean;
  53673. CLEARCOAT_DEFAULTIOR: boolean;
  53674. CLEARCOAT_TEXTURE: boolean;
  53675. CLEARCOAT_TEXTUREDIRECTUV: number;
  53676. CLEARCOAT_BUMP: boolean;
  53677. CLEARCOAT_BUMPDIRECTUV: number;
  53678. CLEARCOAT_TINT: boolean;
  53679. CLEARCOAT_TINT_TEXTURE: boolean;
  53680. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53681. /** @hidden */
  53682. _areTexturesDirty: boolean;
  53683. }
  53684. /**
  53685. * Define the code related to the clear coat parameters of the pbr material.
  53686. */
  53687. export class PBRClearCoatConfiguration {
  53688. /**
  53689. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53690. * The default fits with a polyurethane material.
  53691. */
  53692. private static readonly _DefaultIndexOfRefraction;
  53693. private _isEnabled;
  53694. /**
  53695. * Defines if the clear coat is enabled in the material.
  53696. */
  53697. isEnabled: boolean;
  53698. /**
  53699. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53700. */
  53701. intensity: number;
  53702. /**
  53703. * Defines the clear coat layer roughness.
  53704. */
  53705. roughness: number;
  53706. private _indexOfRefraction;
  53707. /**
  53708. * Defines the index of refraction of the clear coat.
  53709. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53710. * The default fits with a polyurethane material.
  53711. * Changing the default value is more performance intensive.
  53712. */
  53713. indexOfRefraction: number;
  53714. private _texture;
  53715. /**
  53716. * Stores the clear coat values in a texture.
  53717. */
  53718. texture: Nullable<BaseTexture>;
  53719. private _bumpTexture;
  53720. /**
  53721. * Define the clear coat specific bump texture.
  53722. */
  53723. bumpTexture: Nullable<BaseTexture>;
  53724. private _isTintEnabled;
  53725. /**
  53726. * Defines if the clear coat tint is enabled in the material.
  53727. */
  53728. isTintEnabled: boolean;
  53729. /**
  53730. * Defines the clear coat tint of the material.
  53731. * This is only use if tint is enabled
  53732. */
  53733. tintColor: Color3;
  53734. /**
  53735. * Defines the distance at which the tint color should be found in the
  53736. * clear coat media.
  53737. * This is only use if tint is enabled
  53738. */
  53739. tintColorAtDistance: number;
  53740. /**
  53741. * Defines the clear coat layer thickness.
  53742. * This is only use if tint is enabled
  53743. */
  53744. tintThickness: number;
  53745. private _tintTexture;
  53746. /**
  53747. * Stores the clear tint values in a texture.
  53748. * rgb is tint
  53749. * a is a thickness factor
  53750. */
  53751. tintTexture: Nullable<BaseTexture>;
  53752. /** @hidden */
  53753. private _internalMarkAllSubMeshesAsTexturesDirty;
  53754. /** @hidden */
  53755. _markAllSubMeshesAsTexturesDirty(): void;
  53756. /**
  53757. * Instantiate a new istance of clear coat configuration.
  53758. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53759. */
  53760. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53761. /**
  53762. * Gets wehter the submesh is ready to be used or not.
  53763. * @param defines the list of "defines" to update.
  53764. * @param scene defines the scene the material belongs to.
  53765. * @param engine defines the engine the material belongs to.
  53766. * @param disableBumpMap defines wether the material disables bump or not.
  53767. * @returns - boolean indicating that the submesh is ready or not.
  53768. */
  53769. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53770. /**
  53771. * Checks to see if a texture is used in the material.
  53772. * @param defines the list of "defines" to update.
  53773. * @param scene defines the scene to the material belongs to.
  53774. */
  53775. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53776. /**
  53777. * Binds the material data.
  53778. * @param uniformBuffer defines the Uniform buffer to fill in.
  53779. * @param scene defines the scene the material belongs to.
  53780. * @param engine defines the engine the material belongs to.
  53781. * @param disableBumpMap defines wether the material disables bump or not.
  53782. * @param isFrozen defines wether the material is frozen or not.
  53783. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53784. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53785. */
  53786. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53787. /**
  53788. * Checks to see if a texture is used in the material.
  53789. * @param texture - Base texture to use.
  53790. * @returns - Boolean specifying if a texture is used in the material.
  53791. */
  53792. hasTexture(texture: BaseTexture): boolean;
  53793. /**
  53794. * Returns an array of the actively used textures.
  53795. * @param activeTextures Array of BaseTextures
  53796. */
  53797. getActiveTextures(activeTextures: BaseTexture[]): void;
  53798. /**
  53799. * Returns the animatable textures.
  53800. * @param animatables Array of animatable textures.
  53801. */
  53802. getAnimatables(animatables: IAnimatable[]): void;
  53803. /**
  53804. * Disposes the resources of the material.
  53805. * @param forceDisposeTextures - Forces the disposal of all textures.
  53806. */
  53807. dispose(forceDisposeTextures?: boolean): void;
  53808. /**
  53809. * Get the current class name of the texture useful for serialization or dynamic coding.
  53810. * @returns "PBRClearCoatConfiguration"
  53811. */
  53812. getClassName(): string;
  53813. /**
  53814. * Add fallbacks to the effect fallbacks list.
  53815. * @param defines defines the Base texture to use.
  53816. * @param fallbacks defines the current fallback list.
  53817. * @param currentRank defines the current fallback rank.
  53818. * @returns the new fallback rank.
  53819. */
  53820. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53821. /**
  53822. * Add the required uniforms to the current list.
  53823. * @param uniforms defines the current uniform list.
  53824. */
  53825. static AddUniforms(uniforms: string[]): void;
  53826. /**
  53827. * Add the required samplers to the current list.
  53828. * @param samplers defines the current sampler list.
  53829. */
  53830. static AddSamplers(samplers: string[]): void;
  53831. /**
  53832. * Add the required uniforms to the current buffer.
  53833. * @param uniformBuffer defines the current uniform buffer.
  53834. */
  53835. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53836. /**
  53837. * Makes a duplicate of the current configuration into another one.
  53838. * @param clearCoatConfiguration define the config where to copy the info
  53839. */
  53840. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53841. /**
  53842. * Serializes this clear coat configuration.
  53843. * @returns - An object with the serialized config.
  53844. */
  53845. serialize(): any;
  53846. /**
  53847. * Parses a anisotropy Configuration from a serialized object.
  53848. * @param source - Serialized object.
  53849. * @param scene Defines the scene we are parsing for
  53850. * @param rootUrl Defines the rootUrl to load from
  53851. */
  53852. parse(source: any, scene: Scene, rootUrl: string): void;
  53853. }
  53854. }
  53855. declare module BABYLON {
  53856. /**
  53857. * @hidden
  53858. */
  53859. export interface IMaterialAnisotropicDefines {
  53860. ANISOTROPIC: boolean;
  53861. ANISOTROPIC_TEXTURE: boolean;
  53862. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53863. MAINUV1: boolean;
  53864. _areTexturesDirty: boolean;
  53865. _needUVs: boolean;
  53866. }
  53867. /**
  53868. * Define the code related to the anisotropic parameters of the pbr material.
  53869. */
  53870. export class PBRAnisotropicConfiguration {
  53871. private _isEnabled;
  53872. /**
  53873. * Defines if the anisotropy is enabled in the material.
  53874. */
  53875. isEnabled: boolean;
  53876. /**
  53877. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53878. */
  53879. intensity: number;
  53880. /**
  53881. * Defines if the effect is along the tangents, bitangents or in between.
  53882. * By default, the effect is "strectching" the highlights along the tangents.
  53883. */
  53884. direction: Vector2;
  53885. private _texture;
  53886. /**
  53887. * Stores the anisotropy values in a texture.
  53888. * rg is direction (like normal from -1 to 1)
  53889. * b is a intensity
  53890. */
  53891. texture: Nullable<BaseTexture>;
  53892. /** @hidden */
  53893. private _internalMarkAllSubMeshesAsTexturesDirty;
  53894. /** @hidden */
  53895. _markAllSubMeshesAsTexturesDirty(): void;
  53896. /**
  53897. * Instantiate a new istance of anisotropy configuration.
  53898. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53899. */
  53900. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53901. /**
  53902. * Specifies that the submesh is ready to be used.
  53903. * @param defines the list of "defines" to update.
  53904. * @param scene defines the scene the material belongs to.
  53905. * @returns - boolean indicating that the submesh is ready or not.
  53906. */
  53907. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53908. /**
  53909. * Checks to see if a texture is used in the material.
  53910. * @param defines the list of "defines" to update.
  53911. * @param mesh the mesh we are preparing the defines for.
  53912. * @param scene defines the scene the material belongs to.
  53913. */
  53914. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53915. /**
  53916. * Binds the material data.
  53917. * @param uniformBuffer defines the Uniform buffer to fill in.
  53918. * @param scene defines the scene the material belongs to.
  53919. * @param isFrozen defines wether the material is frozen or not.
  53920. */
  53921. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53922. /**
  53923. * Checks to see if a texture is used in the material.
  53924. * @param texture - Base texture to use.
  53925. * @returns - Boolean specifying if a texture is used in the material.
  53926. */
  53927. hasTexture(texture: BaseTexture): boolean;
  53928. /**
  53929. * Returns an array of the actively used textures.
  53930. * @param activeTextures Array of BaseTextures
  53931. */
  53932. getActiveTextures(activeTextures: BaseTexture[]): void;
  53933. /**
  53934. * Returns the animatable textures.
  53935. * @param animatables Array of animatable textures.
  53936. */
  53937. getAnimatables(animatables: IAnimatable[]): void;
  53938. /**
  53939. * Disposes the resources of the material.
  53940. * @param forceDisposeTextures - Forces the disposal of all textures.
  53941. */
  53942. dispose(forceDisposeTextures?: boolean): void;
  53943. /**
  53944. * Get the current class name of the texture useful for serialization or dynamic coding.
  53945. * @returns "PBRAnisotropicConfiguration"
  53946. */
  53947. getClassName(): string;
  53948. /**
  53949. * Add fallbacks to the effect fallbacks list.
  53950. * @param defines defines the Base texture to use.
  53951. * @param fallbacks defines the current fallback list.
  53952. * @param currentRank defines the current fallback rank.
  53953. * @returns the new fallback rank.
  53954. */
  53955. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53956. /**
  53957. * Add the required uniforms to the current list.
  53958. * @param uniforms defines the current uniform list.
  53959. */
  53960. static AddUniforms(uniforms: string[]): void;
  53961. /**
  53962. * Add the required uniforms to the current buffer.
  53963. * @param uniformBuffer defines the current uniform buffer.
  53964. */
  53965. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53966. /**
  53967. * Add the required samplers to the current list.
  53968. * @param samplers defines the current sampler list.
  53969. */
  53970. static AddSamplers(samplers: string[]): void;
  53971. /**
  53972. * Makes a duplicate of the current configuration into another one.
  53973. * @param anisotropicConfiguration define the config where to copy the info
  53974. */
  53975. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53976. /**
  53977. * Serializes this anisotropy configuration.
  53978. * @returns - An object with the serialized config.
  53979. */
  53980. serialize(): any;
  53981. /**
  53982. * Parses a anisotropy Configuration from a serialized object.
  53983. * @param source - Serialized object.
  53984. * @param scene Defines the scene we are parsing for
  53985. * @param rootUrl Defines the rootUrl to load from
  53986. */
  53987. parse(source: any, scene: Scene, rootUrl: string): void;
  53988. }
  53989. }
  53990. declare module BABYLON {
  53991. /**
  53992. * @hidden
  53993. */
  53994. export interface IMaterialBRDFDefines {
  53995. BRDF_V_HEIGHT_CORRELATED: boolean;
  53996. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53997. SPHERICAL_HARMONICS: boolean;
  53998. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53999. /** @hidden */
  54000. _areMiscDirty: boolean;
  54001. }
  54002. /**
  54003. * Define the code related to the BRDF parameters of the pbr material.
  54004. */
  54005. export class PBRBRDFConfiguration {
  54006. /**
  54007. * Default value used for the energy conservation.
  54008. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54009. */
  54010. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54011. /**
  54012. * Default value used for the Smith Visibility Height Correlated mode.
  54013. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54014. */
  54015. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54016. /**
  54017. * Default value used for the IBL diffuse part.
  54018. * This can help switching back to the polynomials mode globally which is a tiny bit
  54019. * less GPU intensive at the drawback of a lower quality.
  54020. */
  54021. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54022. /**
  54023. * Default value used for activating energy conservation for the specular workflow.
  54024. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54025. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54026. */
  54027. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54028. private _useEnergyConservation;
  54029. /**
  54030. * Defines if the material uses energy conservation.
  54031. */
  54032. useEnergyConservation: boolean;
  54033. private _useSmithVisibilityHeightCorrelated;
  54034. /**
  54035. * LEGACY Mode set to false
  54036. * Defines if the material uses height smith correlated visibility term.
  54037. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54038. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54039. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54040. * Not relying on height correlated will also disable energy conservation.
  54041. */
  54042. useSmithVisibilityHeightCorrelated: boolean;
  54043. private _useSphericalHarmonics;
  54044. /**
  54045. * LEGACY Mode set to false
  54046. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54047. * diffuse part of the IBL.
  54048. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54049. * to the ground truth.
  54050. */
  54051. useSphericalHarmonics: boolean;
  54052. private _useSpecularGlossinessInputEnergyConservation;
  54053. /**
  54054. * Defines if the material uses energy conservation, when the specular workflow is active.
  54055. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54056. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54057. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54058. */
  54059. useSpecularGlossinessInputEnergyConservation: boolean;
  54060. /** @hidden */
  54061. private _internalMarkAllSubMeshesAsMiscDirty;
  54062. /** @hidden */
  54063. _markAllSubMeshesAsMiscDirty(): void;
  54064. /**
  54065. * Instantiate a new istance of clear coat configuration.
  54066. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54067. */
  54068. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54069. /**
  54070. * Checks to see if a texture is used in the material.
  54071. * @param defines the list of "defines" to update.
  54072. */
  54073. prepareDefines(defines: IMaterialBRDFDefines): void;
  54074. /**
  54075. * Get the current class name of the texture useful for serialization or dynamic coding.
  54076. * @returns "PBRClearCoatConfiguration"
  54077. */
  54078. getClassName(): string;
  54079. /**
  54080. * Makes a duplicate of the current configuration into another one.
  54081. * @param brdfConfiguration define the config where to copy the info
  54082. */
  54083. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54084. /**
  54085. * Serializes this BRDF configuration.
  54086. * @returns - An object with the serialized config.
  54087. */
  54088. serialize(): any;
  54089. /**
  54090. * Parses a anisotropy Configuration from a serialized object.
  54091. * @param source - Serialized object.
  54092. * @param scene Defines the scene we are parsing for
  54093. * @param rootUrl Defines the rootUrl to load from
  54094. */
  54095. parse(source: any, scene: Scene, rootUrl: string): void;
  54096. }
  54097. }
  54098. declare module BABYLON {
  54099. /**
  54100. * @hidden
  54101. */
  54102. export interface IMaterialSheenDefines {
  54103. SHEEN: boolean;
  54104. SHEEN_TEXTURE: boolean;
  54105. SHEEN_TEXTUREDIRECTUV: number;
  54106. SHEEN_LINKWITHALBEDO: boolean;
  54107. SHEEN_ROUGHNESS: boolean;
  54108. SHEEN_ALBEDOSCALING: boolean;
  54109. /** @hidden */
  54110. _areTexturesDirty: boolean;
  54111. }
  54112. /**
  54113. * Define the code related to the Sheen parameters of the pbr material.
  54114. */
  54115. export class PBRSheenConfiguration {
  54116. private _isEnabled;
  54117. /**
  54118. * Defines if the material uses sheen.
  54119. */
  54120. isEnabled: boolean;
  54121. private _linkSheenWithAlbedo;
  54122. /**
  54123. * Defines if the sheen is linked to the sheen color.
  54124. */
  54125. linkSheenWithAlbedo: boolean;
  54126. /**
  54127. * Defines the sheen intensity.
  54128. */
  54129. intensity: number;
  54130. /**
  54131. * Defines the sheen color.
  54132. */
  54133. color: Color3;
  54134. private _texture;
  54135. /**
  54136. * Stores the sheen tint values in a texture.
  54137. * rgb is tint
  54138. * a is a intensity
  54139. */
  54140. texture: Nullable<BaseTexture>;
  54141. private _roughness;
  54142. /**
  54143. * Defines the sheen roughness.
  54144. * It is not taken into account if linkSheenWithAlbedo is true.
  54145. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54146. */
  54147. roughness: Nullable<number>;
  54148. private _albedoScaling;
  54149. /**
  54150. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54151. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54152. * making it easier to setup and tweak the effect
  54153. */
  54154. albedoScaling: boolean;
  54155. /** @hidden */
  54156. private _internalMarkAllSubMeshesAsTexturesDirty;
  54157. /** @hidden */
  54158. _markAllSubMeshesAsTexturesDirty(): void;
  54159. /**
  54160. * Instantiate a new istance of clear coat configuration.
  54161. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54162. */
  54163. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54164. /**
  54165. * Specifies that the submesh is ready to be used.
  54166. * @param defines the list of "defines" to update.
  54167. * @param scene defines the scene the material belongs to.
  54168. * @returns - boolean indicating that the submesh is ready or not.
  54169. */
  54170. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54171. /**
  54172. * Checks to see if a texture is used in the material.
  54173. * @param defines the list of "defines" to update.
  54174. * @param scene defines the scene the material belongs to.
  54175. */
  54176. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54177. /**
  54178. * Binds the material data.
  54179. * @param uniformBuffer defines the Uniform buffer to fill in.
  54180. * @param scene defines the scene the material belongs to.
  54181. * @param isFrozen defines wether the material is frozen or not.
  54182. */
  54183. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54184. /**
  54185. * Checks to see if a texture is used in the material.
  54186. * @param texture - Base texture to use.
  54187. * @returns - Boolean specifying if a texture is used in the material.
  54188. */
  54189. hasTexture(texture: BaseTexture): boolean;
  54190. /**
  54191. * Returns an array of the actively used textures.
  54192. * @param activeTextures Array of BaseTextures
  54193. */
  54194. getActiveTextures(activeTextures: BaseTexture[]): void;
  54195. /**
  54196. * Returns the animatable textures.
  54197. * @param animatables Array of animatable textures.
  54198. */
  54199. getAnimatables(animatables: IAnimatable[]): void;
  54200. /**
  54201. * Disposes the resources of the material.
  54202. * @param forceDisposeTextures - Forces the disposal of all textures.
  54203. */
  54204. dispose(forceDisposeTextures?: boolean): void;
  54205. /**
  54206. * Get the current class name of the texture useful for serialization or dynamic coding.
  54207. * @returns "PBRSheenConfiguration"
  54208. */
  54209. getClassName(): string;
  54210. /**
  54211. * Add fallbacks to the effect fallbacks list.
  54212. * @param defines defines the Base texture to use.
  54213. * @param fallbacks defines the current fallback list.
  54214. * @param currentRank defines the current fallback rank.
  54215. * @returns the new fallback rank.
  54216. */
  54217. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54218. /**
  54219. * Add the required uniforms to the current list.
  54220. * @param uniforms defines the current uniform list.
  54221. */
  54222. static AddUniforms(uniforms: string[]): void;
  54223. /**
  54224. * Add the required uniforms to the current buffer.
  54225. * @param uniformBuffer defines the current uniform buffer.
  54226. */
  54227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54228. /**
  54229. * Add the required samplers to the current list.
  54230. * @param samplers defines the current sampler list.
  54231. */
  54232. static AddSamplers(samplers: string[]): void;
  54233. /**
  54234. * Makes a duplicate of the current configuration into another one.
  54235. * @param sheenConfiguration define the config where to copy the info
  54236. */
  54237. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54238. /**
  54239. * Serializes this BRDF configuration.
  54240. * @returns - An object with the serialized config.
  54241. */
  54242. serialize(): any;
  54243. /**
  54244. * Parses a anisotropy Configuration from a serialized object.
  54245. * @param source - Serialized object.
  54246. * @param scene Defines the scene we are parsing for
  54247. * @param rootUrl Defines the rootUrl to load from
  54248. */
  54249. parse(source: any, scene: Scene, rootUrl: string): void;
  54250. }
  54251. }
  54252. declare module BABYLON {
  54253. /**
  54254. * @hidden
  54255. */
  54256. export interface IMaterialSubSurfaceDefines {
  54257. SUBSURFACE: boolean;
  54258. SS_REFRACTION: boolean;
  54259. SS_TRANSLUCENCY: boolean;
  54260. SS_SCATTERING: boolean;
  54261. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54262. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54263. SS_REFRACTIONMAP_3D: boolean;
  54264. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54265. SS_LODINREFRACTIONALPHA: boolean;
  54266. SS_GAMMAREFRACTION: boolean;
  54267. SS_RGBDREFRACTION: boolean;
  54268. SS_LINEARSPECULARREFRACTION: boolean;
  54269. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54270. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54271. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54272. /** @hidden */
  54273. _areTexturesDirty: boolean;
  54274. }
  54275. /**
  54276. * Define the code related to the sub surface parameters of the pbr material.
  54277. */
  54278. export class PBRSubSurfaceConfiguration {
  54279. private _isRefractionEnabled;
  54280. /**
  54281. * Defines if the refraction is enabled in the material.
  54282. */
  54283. isRefractionEnabled: boolean;
  54284. private _isTranslucencyEnabled;
  54285. /**
  54286. * Defines if the translucency is enabled in the material.
  54287. */
  54288. isTranslucencyEnabled: boolean;
  54289. private _isScatteringEnabled;
  54290. /**
  54291. * Defines the refraction intensity of the material.
  54292. * The refraction when enabled replaces the Diffuse part of the material.
  54293. * The intensity helps transitionning between diffuse and refraction.
  54294. */
  54295. refractionIntensity: number;
  54296. /**
  54297. * Defines the translucency intensity of the material.
  54298. * When translucency has been enabled, this defines how much of the "translucency"
  54299. * is addded to the diffuse part of the material.
  54300. */
  54301. translucencyIntensity: number;
  54302. /**
  54303. * Defines the scattering intensity of the material.
  54304. * When scattering has been enabled, this defines how much of the "scattered light"
  54305. * is addded to the diffuse part of the material.
  54306. */
  54307. scatteringIntensity: number;
  54308. /**
  54309. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54310. */
  54311. useAlbedoToTintRefraction: boolean;
  54312. private _thicknessTexture;
  54313. /**
  54314. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54315. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54316. * 0 would mean minimumThickness
  54317. * 1 would mean maximumThickness
  54318. * The other channels might be use as a mask to vary the different effects intensity.
  54319. */
  54320. thicknessTexture: Nullable<BaseTexture>;
  54321. private _refractionTexture;
  54322. /**
  54323. * Defines the texture to use for refraction.
  54324. */
  54325. refractionTexture: Nullable<BaseTexture>;
  54326. private _indexOfRefraction;
  54327. /**
  54328. * Index of refraction of the material base layer.
  54329. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54330. *
  54331. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54332. *
  54333. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54334. */
  54335. indexOfRefraction: number;
  54336. private _volumeIndexOfRefraction;
  54337. /**
  54338. * Index of refraction of the material's volume.
  54339. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54340. *
  54341. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54342. * the volume will use the same IOR as the surface.
  54343. */
  54344. get volumeIndexOfRefraction(): number;
  54345. set volumeIndexOfRefraction(value: number);
  54346. private _invertRefractionY;
  54347. /**
  54348. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54349. */
  54350. invertRefractionY: boolean;
  54351. private _linkRefractionWithTransparency;
  54352. /**
  54353. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54354. * Materials half opaque for instance using refraction could benefit from this control.
  54355. */
  54356. linkRefractionWithTransparency: boolean;
  54357. /**
  54358. * Defines the minimum thickness stored in the thickness map.
  54359. * If no thickness map is defined, this value will be used to simulate thickness.
  54360. */
  54361. minimumThickness: number;
  54362. /**
  54363. * Defines the maximum thickness stored in the thickness map.
  54364. */
  54365. maximumThickness: number;
  54366. /**
  54367. * Defines the volume tint of the material.
  54368. * This is used for both translucency and scattering.
  54369. */
  54370. tintColor: Color3;
  54371. /**
  54372. * Defines the distance at which the tint color should be found in the media.
  54373. * This is used for refraction only.
  54374. */
  54375. tintColorAtDistance: number;
  54376. /**
  54377. * Defines how far each channel transmit through the media.
  54378. * It is defined as a color to simplify it selection.
  54379. */
  54380. diffusionDistance: Color3;
  54381. private _useMaskFromThicknessTexture;
  54382. /**
  54383. * Stores the intensity of the different subsurface effects in the thickness texture.
  54384. * * the green channel is the translucency intensity.
  54385. * * the blue channel is the scattering intensity.
  54386. * * the alpha channel is the refraction intensity.
  54387. */
  54388. useMaskFromThicknessTexture: boolean;
  54389. /** @hidden */
  54390. private _internalMarkAllSubMeshesAsTexturesDirty;
  54391. /** @hidden */
  54392. _markAllSubMeshesAsTexturesDirty(): void;
  54393. /**
  54394. * Instantiate a new istance of sub surface configuration.
  54395. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54396. */
  54397. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54398. /**
  54399. * Gets wehter the submesh is ready to be used or not.
  54400. * @param defines the list of "defines" to update.
  54401. * @param scene defines the scene the material belongs to.
  54402. * @returns - boolean indicating that the submesh is ready or not.
  54403. */
  54404. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54405. /**
  54406. * Checks to see if a texture is used in the material.
  54407. * @param defines the list of "defines" to update.
  54408. * @param scene defines the scene to the material belongs to.
  54409. */
  54410. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54411. /**
  54412. * Binds the material data.
  54413. * @param uniformBuffer defines the Uniform buffer to fill in.
  54414. * @param scene defines the scene the material belongs to.
  54415. * @param engine defines the engine the material belongs to.
  54416. * @param isFrozen defines whether the material is frozen or not.
  54417. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54418. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54419. */
  54420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54421. /**
  54422. * Unbinds the material from the mesh.
  54423. * @param activeEffect defines the effect that should be unbound from.
  54424. * @returns true if unbound, otherwise false
  54425. */
  54426. unbind(activeEffect: Effect): boolean;
  54427. /**
  54428. * Returns the texture used for refraction or null if none is used.
  54429. * @param scene defines the scene the material belongs to.
  54430. * @returns - Refraction texture if present. If no refraction texture and refraction
  54431. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54432. */
  54433. private _getRefractionTexture;
  54434. /**
  54435. * Returns true if alpha blending should be disabled.
  54436. */
  54437. get disableAlphaBlending(): boolean;
  54438. /**
  54439. * Fills the list of render target textures.
  54440. * @param renderTargets the list of render targets to update
  54441. */
  54442. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54443. /**
  54444. * Checks to see if a texture is used in the material.
  54445. * @param texture - Base texture to use.
  54446. * @returns - Boolean specifying if a texture is used in the material.
  54447. */
  54448. hasTexture(texture: BaseTexture): boolean;
  54449. /**
  54450. * Gets a boolean indicating that current material needs to register RTT
  54451. * @returns true if this uses a render target otherwise false.
  54452. */
  54453. hasRenderTargetTextures(): boolean;
  54454. /**
  54455. * Returns an array of the actively used textures.
  54456. * @param activeTextures Array of BaseTextures
  54457. */
  54458. getActiveTextures(activeTextures: BaseTexture[]): void;
  54459. /**
  54460. * Returns the animatable textures.
  54461. * @param animatables Array of animatable textures.
  54462. */
  54463. getAnimatables(animatables: IAnimatable[]): void;
  54464. /**
  54465. * Disposes the resources of the material.
  54466. * @param forceDisposeTextures - Forces the disposal of all textures.
  54467. */
  54468. dispose(forceDisposeTextures?: boolean): void;
  54469. /**
  54470. * Get the current class name of the texture useful for serialization or dynamic coding.
  54471. * @returns "PBRSubSurfaceConfiguration"
  54472. */
  54473. getClassName(): string;
  54474. /**
  54475. * Add fallbacks to the effect fallbacks list.
  54476. * @param defines defines the Base texture to use.
  54477. * @param fallbacks defines the current fallback list.
  54478. * @param currentRank defines the current fallback rank.
  54479. * @returns the new fallback rank.
  54480. */
  54481. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54482. /**
  54483. * Add the required uniforms to the current list.
  54484. * @param uniforms defines the current uniform list.
  54485. */
  54486. static AddUniforms(uniforms: string[]): void;
  54487. /**
  54488. * Add the required samplers to the current list.
  54489. * @param samplers defines the current sampler list.
  54490. */
  54491. static AddSamplers(samplers: string[]): void;
  54492. /**
  54493. * Add the required uniforms to the current buffer.
  54494. * @param uniformBuffer defines the current uniform buffer.
  54495. */
  54496. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54497. /**
  54498. * Makes a duplicate of the current configuration into another one.
  54499. * @param configuration define the config where to copy the info
  54500. */
  54501. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54502. /**
  54503. * Serializes this Sub Surface configuration.
  54504. * @returns - An object with the serialized config.
  54505. */
  54506. serialize(): any;
  54507. /**
  54508. * Parses a anisotropy Configuration from a serialized object.
  54509. * @param source - Serialized object.
  54510. * @param scene Defines the scene we are parsing for
  54511. * @param rootUrl Defines the rootUrl to load from
  54512. */
  54513. parse(source: any, scene: Scene, rootUrl: string): void;
  54514. }
  54515. }
  54516. declare module BABYLON {
  54517. /** @hidden */
  54518. export var pbrFragmentDeclaration: {
  54519. name: string;
  54520. shader: string;
  54521. };
  54522. }
  54523. declare module BABYLON {
  54524. /** @hidden */
  54525. export var pbrUboDeclaration: {
  54526. name: string;
  54527. shader: string;
  54528. };
  54529. }
  54530. declare module BABYLON {
  54531. /** @hidden */
  54532. export var pbrFragmentExtraDeclaration: {
  54533. name: string;
  54534. shader: string;
  54535. };
  54536. }
  54537. declare module BABYLON {
  54538. /** @hidden */
  54539. export var pbrFragmentSamplersDeclaration: {
  54540. name: string;
  54541. shader: string;
  54542. };
  54543. }
  54544. declare module BABYLON {
  54545. /** @hidden */
  54546. export var importanceSampling: {
  54547. name: string;
  54548. shader: string;
  54549. };
  54550. }
  54551. declare module BABYLON {
  54552. /** @hidden */
  54553. export var pbrHelperFunctions: {
  54554. name: string;
  54555. shader: string;
  54556. };
  54557. }
  54558. declare module BABYLON {
  54559. /** @hidden */
  54560. export var harmonicsFunctions: {
  54561. name: string;
  54562. shader: string;
  54563. };
  54564. }
  54565. declare module BABYLON {
  54566. /** @hidden */
  54567. export var pbrDirectLightingSetupFunctions: {
  54568. name: string;
  54569. shader: string;
  54570. };
  54571. }
  54572. declare module BABYLON {
  54573. /** @hidden */
  54574. export var pbrDirectLightingFalloffFunctions: {
  54575. name: string;
  54576. shader: string;
  54577. };
  54578. }
  54579. declare module BABYLON {
  54580. /** @hidden */
  54581. export var pbrBRDFFunctions: {
  54582. name: string;
  54583. shader: string;
  54584. };
  54585. }
  54586. declare module BABYLON {
  54587. /** @hidden */
  54588. export var hdrFilteringFunctions: {
  54589. name: string;
  54590. shader: string;
  54591. };
  54592. }
  54593. declare module BABYLON {
  54594. /** @hidden */
  54595. export var pbrDirectLightingFunctions: {
  54596. name: string;
  54597. shader: string;
  54598. };
  54599. }
  54600. declare module BABYLON {
  54601. /** @hidden */
  54602. export var pbrIBLFunctions: {
  54603. name: string;
  54604. shader: string;
  54605. };
  54606. }
  54607. declare module BABYLON {
  54608. /** @hidden */
  54609. export var pbrBlockAlbedoOpacity: {
  54610. name: string;
  54611. shader: string;
  54612. };
  54613. }
  54614. declare module BABYLON {
  54615. /** @hidden */
  54616. export var pbrBlockReflectivity: {
  54617. name: string;
  54618. shader: string;
  54619. };
  54620. }
  54621. declare module BABYLON {
  54622. /** @hidden */
  54623. export var pbrBlockAmbientOcclusion: {
  54624. name: string;
  54625. shader: string;
  54626. };
  54627. }
  54628. declare module BABYLON {
  54629. /** @hidden */
  54630. export var pbrBlockAlphaFresnel: {
  54631. name: string;
  54632. shader: string;
  54633. };
  54634. }
  54635. declare module BABYLON {
  54636. /** @hidden */
  54637. export var pbrBlockAnisotropic: {
  54638. name: string;
  54639. shader: string;
  54640. };
  54641. }
  54642. declare module BABYLON {
  54643. /** @hidden */
  54644. export var pbrBlockReflection: {
  54645. name: string;
  54646. shader: string;
  54647. };
  54648. }
  54649. declare module BABYLON {
  54650. /** @hidden */
  54651. export var pbrBlockSheen: {
  54652. name: string;
  54653. shader: string;
  54654. };
  54655. }
  54656. declare module BABYLON {
  54657. /** @hidden */
  54658. export var pbrBlockClearcoat: {
  54659. name: string;
  54660. shader: string;
  54661. };
  54662. }
  54663. declare module BABYLON {
  54664. /** @hidden */
  54665. export var pbrBlockSubSurface: {
  54666. name: string;
  54667. shader: string;
  54668. };
  54669. }
  54670. declare module BABYLON {
  54671. /** @hidden */
  54672. export var pbrBlockNormalGeometric: {
  54673. name: string;
  54674. shader: string;
  54675. };
  54676. }
  54677. declare module BABYLON {
  54678. /** @hidden */
  54679. export var pbrBlockNormalFinal: {
  54680. name: string;
  54681. shader: string;
  54682. };
  54683. }
  54684. declare module BABYLON {
  54685. /** @hidden */
  54686. export var pbrBlockGeometryInfo: {
  54687. name: string;
  54688. shader: string;
  54689. };
  54690. }
  54691. declare module BABYLON {
  54692. /** @hidden */
  54693. export var pbrBlockReflectance0: {
  54694. name: string;
  54695. shader: string;
  54696. };
  54697. }
  54698. declare module BABYLON {
  54699. /** @hidden */
  54700. export var pbrBlockReflectance: {
  54701. name: string;
  54702. shader: string;
  54703. };
  54704. }
  54705. declare module BABYLON {
  54706. /** @hidden */
  54707. export var pbrBlockDirectLighting: {
  54708. name: string;
  54709. shader: string;
  54710. };
  54711. }
  54712. declare module BABYLON {
  54713. /** @hidden */
  54714. export var pbrBlockFinalLitComponents: {
  54715. name: string;
  54716. shader: string;
  54717. };
  54718. }
  54719. declare module BABYLON {
  54720. /** @hidden */
  54721. export var pbrBlockFinalUnlitComponents: {
  54722. name: string;
  54723. shader: string;
  54724. };
  54725. }
  54726. declare module BABYLON {
  54727. /** @hidden */
  54728. export var pbrBlockFinalColorComposition: {
  54729. name: string;
  54730. shader: string;
  54731. };
  54732. }
  54733. declare module BABYLON {
  54734. /** @hidden */
  54735. export var pbrBlockImageProcessing: {
  54736. name: string;
  54737. shader: string;
  54738. };
  54739. }
  54740. declare module BABYLON {
  54741. /** @hidden */
  54742. export var pbrDebug: {
  54743. name: string;
  54744. shader: string;
  54745. };
  54746. }
  54747. declare module BABYLON {
  54748. /** @hidden */
  54749. export var pbrPixelShader: {
  54750. name: string;
  54751. shader: string;
  54752. };
  54753. }
  54754. declare module BABYLON {
  54755. /** @hidden */
  54756. export var pbrVertexDeclaration: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module BABYLON {
  54762. /** @hidden */
  54763. export var pbrVertexShader: {
  54764. name: string;
  54765. shader: string;
  54766. };
  54767. }
  54768. declare module BABYLON {
  54769. /**
  54770. * Manages the defines for the PBR Material.
  54771. * @hidden
  54772. */
  54773. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54774. PBR: boolean;
  54775. NUM_SAMPLES: string;
  54776. REALTIME_FILTERING: boolean;
  54777. MAINUV1: boolean;
  54778. MAINUV2: boolean;
  54779. UV1: boolean;
  54780. UV2: boolean;
  54781. ALBEDO: boolean;
  54782. GAMMAALBEDO: boolean;
  54783. ALBEDODIRECTUV: number;
  54784. VERTEXCOLOR: boolean;
  54785. AMBIENT: boolean;
  54786. AMBIENTDIRECTUV: number;
  54787. AMBIENTINGRAYSCALE: boolean;
  54788. OPACITY: boolean;
  54789. VERTEXALPHA: boolean;
  54790. OPACITYDIRECTUV: number;
  54791. OPACITYRGB: boolean;
  54792. ALPHATEST: boolean;
  54793. DEPTHPREPASS: boolean;
  54794. ALPHABLEND: boolean;
  54795. ALPHAFROMALBEDO: boolean;
  54796. ALPHATESTVALUE: string;
  54797. SPECULAROVERALPHA: boolean;
  54798. RADIANCEOVERALPHA: boolean;
  54799. ALPHAFRESNEL: boolean;
  54800. LINEARALPHAFRESNEL: boolean;
  54801. PREMULTIPLYALPHA: boolean;
  54802. EMISSIVE: boolean;
  54803. EMISSIVEDIRECTUV: number;
  54804. REFLECTIVITY: boolean;
  54805. REFLECTIVITYDIRECTUV: number;
  54806. SPECULARTERM: boolean;
  54807. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54808. MICROSURFACEAUTOMATIC: boolean;
  54809. LODBASEDMICROSFURACE: boolean;
  54810. MICROSURFACEMAP: boolean;
  54811. MICROSURFACEMAPDIRECTUV: number;
  54812. METALLICWORKFLOW: boolean;
  54813. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54814. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54815. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54816. AOSTOREINMETALMAPRED: boolean;
  54817. METALLIC_REFLECTANCE: boolean;
  54818. METALLIC_REFLECTANCEDIRECTUV: number;
  54819. ENVIRONMENTBRDF: boolean;
  54820. ENVIRONMENTBRDF_RGBD: boolean;
  54821. NORMAL: boolean;
  54822. TANGENT: boolean;
  54823. BUMP: boolean;
  54824. BUMPDIRECTUV: number;
  54825. OBJECTSPACE_NORMALMAP: boolean;
  54826. PARALLAX: boolean;
  54827. PARALLAXOCCLUSION: boolean;
  54828. NORMALXYSCALE: boolean;
  54829. LIGHTMAP: boolean;
  54830. LIGHTMAPDIRECTUV: number;
  54831. USELIGHTMAPASSHADOWMAP: boolean;
  54832. GAMMALIGHTMAP: boolean;
  54833. RGBDLIGHTMAP: boolean;
  54834. REFLECTION: boolean;
  54835. REFLECTIONMAP_3D: boolean;
  54836. REFLECTIONMAP_SPHERICAL: boolean;
  54837. REFLECTIONMAP_PLANAR: boolean;
  54838. REFLECTIONMAP_CUBIC: boolean;
  54839. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54840. REFLECTIONMAP_PROJECTION: boolean;
  54841. REFLECTIONMAP_SKYBOX: boolean;
  54842. REFLECTIONMAP_EXPLICIT: boolean;
  54843. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54844. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54845. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54846. INVERTCUBICMAP: boolean;
  54847. USESPHERICALFROMREFLECTIONMAP: boolean;
  54848. USEIRRADIANCEMAP: boolean;
  54849. SPHERICAL_HARMONICS: boolean;
  54850. USESPHERICALINVERTEX: boolean;
  54851. REFLECTIONMAP_OPPOSITEZ: boolean;
  54852. LODINREFLECTIONALPHA: boolean;
  54853. GAMMAREFLECTION: boolean;
  54854. RGBDREFLECTION: boolean;
  54855. LINEARSPECULARREFLECTION: boolean;
  54856. RADIANCEOCCLUSION: boolean;
  54857. HORIZONOCCLUSION: boolean;
  54858. INSTANCES: boolean;
  54859. THIN_INSTANCES: boolean;
  54860. NUM_BONE_INFLUENCERS: number;
  54861. BonesPerMesh: number;
  54862. BONETEXTURE: boolean;
  54863. NONUNIFORMSCALING: boolean;
  54864. MORPHTARGETS: boolean;
  54865. MORPHTARGETS_NORMAL: boolean;
  54866. MORPHTARGETS_TANGENT: boolean;
  54867. MORPHTARGETS_UV: boolean;
  54868. NUM_MORPH_INFLUENCERS: number;
  54869. IMAGEPROCESSING: boolean;
  54870. VIGNETTE: boolean;
  54871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54872. VIGNETTEBLENDMODEOPAQUE: boolean;
  54873. TONEMAPPING: boolean;
  54874. TONEMAPPING_ACES: boolean;
  54875. CONTRAST: boolean;
  54876. COLORCURVES: boolean;
  54877. COLORGRADING: boolean;
  54878. COLORGRADING3D: boolean;
  54879. SAMPLER3DGREENDEPTH: boolean;
  54880. SAMPLER3DBGRMAP: boolean;
  54881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54882. EXPOSURE: boolean;
  54883. MULTIVIEW: boolean;
  54884. USEPHYSICALLIGHTFALLOFF: boolean;
  54885. USEGLTFLIGHTFALLOFF: boolean;
  54886. TWOSIDEDLIGHTING: boolean;
  54887. SHADOWFLOAT: boolean;
  54888. CLIPPLANE: boolean;
  54889. CLIPPLANE2: boolean;
  54890. CLIPPLANE3: boolean;
  54891. CLIPPLANE4: boolean;
  54892. CLIPPLANE5: boolean;
  54893. CLIPPLANE6: boolean;
  54894. POINTSIZE: boolean;
  54895. FOG: boolean;
  54896. LOGARITHMICDEPTH: boolean;
  54897. FORCENORMALFORWARD: boolean;
  54898. SPECULARAA: boolean;
  54899. CLEARCOAT: boolean;
  54900. CLEARCOAT_DEFAULTIOR: boolean;
  54901. CLEARCOAT_TEXTURE: boolean;
  54902. CLEARCOAT_TEXTUREDIRECTUV: number;
  54903. CLEARCOAT_BUMP: boolean;
  54904. CLEARCOAT_BUMPDIRECTUV: number;
  54905. CLEARCOAT_TINT: boolean;
  54906. CLEARCOAT_TINT_TEXTURE: boolean;
  54907. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54908. ANISOTROPIC: boolean;
  54909. ANISOTROPIC_TEXTURE: boolean;
  54910. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54911. BRDF_V_HEIGHT_CORRELATED: boolean;
  54912. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54913. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54914. SHEEN: boolean;
  54915. SHEEN_TEXTURE: boolean;
  54916. SHEEN_TEXTUREDIRECTUV: number;
  54917. SHEEN_LINKWITHALBEDO: boolean;
  54918. SHEEN_ROUGHNESS: boolean;
  54919. SHEEN_ALBEDOSCALING: boolean;
  54920. SUBSURFACE: boolean;
  54921. SS_REFRACTION: boolean;
  54922. SS_TRANSLUCENCY: boolean;
  54923. SS_SCATTERING: boolean;
  54924. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54925. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54926. SS_REFRACTIONMAP_3D: boolean;
  54927. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54928. SS_LODINREFRACTIONALPHA: boolean;
  54929. SS_GAMMAREFRACTION: boolean;
  54930. SS_RGBDREFRACTION: boolean;
  54931. SS_LINEARSPECULARREFRACTION: boolean;
  54932. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54933. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54934. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54935. UNLIT: boolean;
  54936. DEBUGMODE: number;
  54937. /**
  54938. * Initializes the PBR Material defines.
  54939. */
  54940. constructor();
  54941. /**
  54942. * Resets the PBR Material defines.
  54943. */
  54944. reset(): void;
  54945. }
  54946. /**
  54947. * The Physically based material base class of BJS.
  54948. *
  54949. * This offers the main features of a standard PBR material.
  54950. * For more information, please refer to the documentation :
  54951. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54952. */
  54953. export abstract class PBRBaseMaterial extends PushMaterial {
  54954. /**
  54955. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54956. */
  54957. static readonly PBRMATERIAL_OPAQUE: number;
  54958. /**
  54959. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54960. */
  54961. static readonly PBRMATERIAL_ALPHATEST: number;
  54962. /**
  54963. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54964. */
  54965. static readonly PBRMATERIAL_ALPHABLEND: number;
  54966. /**
  54967. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54968. * They are also discarded below the alpha cutoff threshold to improve performances.
  54969. */
  54970. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54971. /**
  54972. * Defines the default value of how much AO map is occluding the analytical lights
  54973. * (point spot...).
  54974. */
  54975. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54976. /**
  54977. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54978. */
  54979. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54980. /**
  54981. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54982. * to enhance interoperability with other engines.
  54983. */
  54984. static readonly LIGHTFALLOFF_GLTF: number;
  54985. /**
  54986. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54987. * to enhance interoperability with other materials.
  54988. */
  54989. static readonly LIGHTFALLOFF_STANDARD: number;
  54990. /**
  54991. * Intensity of the direct lights e.g. the four lights available in your scene.
  54992. * This impacts both the direct diffuse and specular highlights.
  54993. */
  54994. protected _directIntensity: number;
  54995. /**
  54996. * Intensity of the emissive part of the material.
  54997. * This helps controlling the emissive effect without modifying the emissive color.
  54998. */
  54999. protected _emissiveIntensity: number;
  55000. /**
  55001. * Intensity of the environment e.g. how much the environment will light the object
  55002. * either through harmonics for rough material or through the refelction for shiny ones.
  55003. */
  55004. protected _environmentIntensity: number;
  55005. /**
  55006. * This is a special control allowing the reduction of the specular highlights coming from the
  55007. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55008. */
  55009. protected _specularIntensity: number;
  55010. /**
  55011. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55012. */
  55013. private _lightingInfos;
  55014. /**
  55015. * Debug Control allowing disabling the bump map on this material.
  55016. */
  55017. protected _disableBumpMap: boolean;
  55018. /**
  55019. * AKA Diffuse Texture in standard nomenclature.
  55020. */
  55021. protected _albedoTexture: Nullable<BaseTexture>;
  55022. /**
  55023. * AKA Occlusion Texture in other nomenclature.
  55024. */
  55025. protected _ambientTexture: Nullable<BaseTexture>;
  55026. /**
  55027. * AKA Occlusion Texture Intensity in other nomenclature.
  55028. */
  55029. protected _ambientTextureStrength: number;
  55030. /**
  55031. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55032. * 1 means it completely occludes it
  55033. * 0 mean it has no impact
  55034. */
  55035. protected _ambientTextureImpactOnAnalyticalLights: number;
  55036. /**
  55037. * Stores the alpha values in a texture.
  55038. */
  55039. protected _opacityTexture: Nullable<BaseTexture>;
  55040. /**
  55041. * Stores the reflection values in a texture.
  55042. */
  55043. protected _reflectionTexture: Nullable<BaseTexture>;
  55044. /**
  55045. * Stores the emissive values in a texture.
  55046. */
  55047. protected _emissiveTexture: Nullable<BaseTexture>;
  55048. /**
  55049. * AKA Specular texture in other nomenclature.
  55050. */
  55051. protected _reflectivityTexture: Nullable<BaseTexture>;
  55052. /**
  55053. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55054. */
  55055. protected _metallicTexture: Nullable<BaseTexture>;
  55056. /**
  55057. * Specifies the metallic scalar of the metallic/roughness workflow.
  55058. * Can also be used to scale the metalness values of the metallic texture.
  55059. */
  55060. protected _metallic: Nullable<number>;
  55061. /**
  55062. * Specifies the roughness scalar of the metallic/roughness workflow.
  55063. * Can also be used to scale the roughness values of the metallic texture.
  55064. */
  55065. protected _roughness: Nullable<number>;
  55066. /**
  55067. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55068. * By default the indexOfrefraction is used to compute F0;
  55069. *
  55070. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55071. *
  55072. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55073. * F90 = metallicReflectanceColor;
  55074. */
  55075. protected _metallicF0Factor: number;
  55076. /**
  55077. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55078. * By default the F90 is always 1;
  55079. *
  55080. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55081. *
  55082. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55083. * F90 = metallicReflectanceColor;
  55084. */
  55085. protected _metallicReflectanceColor: Color3;
  55086. /**
  55087. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55088. * This is multiply against the scalar values defined in the material.
  55089. */
  55090. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55091. /**
  55092. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55093. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55094. */
  55095. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55096. /**
  55097. * Stores surface normal data used to displace a mesh in a texture.
  55098. */
  55099. protected _bumpTexture: Nullable<BaseTexture>;
  55100. /**
  55101. * Stores the pre-calculated light information of a mesh in a texture.
  55102. */
  55103. protected _lightmapTexture: Nullable<BaseTexture>;
  55104. /**
  55105. * The color of a material in ambient lighting.
  55106. */
  55107. protected _ambientColor: Color3;
  55108. /**
  55109. * AKA Diffuse Color in other nomenclature.
  55110. */
  55111. protected _albedoColor: Color3;
  55112. /**
  55113. * AKA Specular Color in other nomenclature.
  55114. */
  55115. protected _reflectivityColor: Color3;
  55116. /**
  55117. * The color applied when light is reflected from a material.
  55118. */
  55119. protected _reflectionColor: Color3;
  55120. /**
  55121. * The color applied when light is emitted from a material.
  55122. */
  55123. protected _emissiveColor: Color3;
  55124. /**
  55125. * AKA Glossiness in other nomenclature.
  55126. */
  55127. protected _microSurface: number;
  55128. /**
  55129. * Specifies that the material will use the light map as a show map.
  55130. */
  55131. protected _useLightmapAsShadowmap: boolean;
  55132. /**
  55133. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55134. * makes the reflect vector face the model (under horizon).
  55135. */
  55136. protected _useHorizonOcclusion: boolean;
  55137. /**
  55138. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55139. * too much the area relying on ambient texture to define their ambient occlusion.
  55140. */
  55141. protected _useRadianceOcclusion: boolean;
  55142. /**
  55143. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55144. */
  55145. protected _useAlphaFromAlbedoTexture: boolean;
  55146. /**
  55147. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55148. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55149. */
  55150. protected _useSpecularOverAlpha: boolean;
  55151. /**
  55152. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55153. */
  55154. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55155. /**
  55156. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55157. */
  55158. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55159. /**
  55160. * Specifies if the metallic texture contains the roughness information in its green channel.
  55161. */
  55162. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55163. /**
  55164. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55165. */
  55166. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55167. /**
  55168. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55169. */
  55170. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55171. /**
  55172. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55173. */
  55174. protected _useAmbientInGrayScale: boolean;
  55175. /**
  55176. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55177. * The material will try to infer what glossiness each pixel should be.
  55178. */
  55179. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55180. /**
  55181. * Defines the falloff type used in this material.
  55182. * It by default is Physical.
  55183. */
  55184. protected _lightFalloff: number;
  55185. /**
  55186. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55187. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55188. */
  55189. protected _useRadianceOverAlpha: boolean;
  55190. /**
  55191. * Allows using an object space normal map (instead of tangent space).
  55192. */
  55193. protected _useObjectSpaceNormalMap: boolean;
  55194. /**
  55195. * Allows using the bump map in parallax mode.
  55196. */
  55197. protected _useParallax: boolean;
  55198. /**
  55199. * Allows using the bump map in parallax occlusion mode.
  55200. */
  55201. protected _useParallaxOcclusion: boolean;
  55202. /**
  55203. * Controls the scale bias of the parallax mode.
  55204. */
  55205. protected _parallaxScaleBias: number;
  55206. /**
  55207. * If sets to true, disables all the lights affecting the material.
  55208. */
  55209. protected _disableLighting: boolean;
  55210. /**
  55211. * Number of Simultaneous lights allowed on the material.
  55212. */
  55213. protected _maxSimultaneousLights: number;
  55214. /**
  55215. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55216. */
  55217. protected _invertNormalMapX: boolean;
  55218. /**
  55219. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55220. */
  55221. protected _invertNormalMapY: boolean;
  55222. /**
  55223. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55224. */
  55225. protected _twoSidedLighting: boolean;
  55226. /**
  55227. * Defines the alpha limits in alpha test mode.
  55228. */
  55229. protected _alphaCutOff: number;
  55230. /**
  55231. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55232. */
  55233. protected _forceAlphaTest: boolean;
  55234. /**
  55235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55236. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55237. */
  55238. protected _useAlphaFresnel: boolean;
  55239. /**
  55240. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55241. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55242. */
  55243. protected _useLinearAlphaFresnel: boolean;
  55244. /**
  55245. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55246. * from cos thetav and roughness:
  55247. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55248. */
  55249. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55250. /**
  55251. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55252. */
  55253. protected _forceIrradianceInFragment: boolean;
  55254. private _realTimeFiltering;
  55255. /**
  55256. * Enables realtime filtering on the texture.
  55257. */
  55258. get realTimeFiltering(): boolean;
  55259. set realTimeFiltering(b: boolean);
  55260. private _realTimeFilteringQuality;
  55261. /**
  55262. * Quality switch for realtime filtering
  55263. */
  55264. get realTimeFilteringQuality(): number;
  55265. set realTimeFilteringQuality(n: number);
  55266. /**
  55267. * Force normal to face away from face.
  55268. */
  55269. protected _forceNormalForward: boolean;
  55270. /**
  55271. * Enables specular anti aliasing in the PBR shader.
  55272. * It will both interacts on the Geometry for analytical and IBL lighting.
  55273. * It also prefilter the roughness map based on the bump values.
  55274. */
  55275. protected _enableSpecularAntiAliasing: boolean;
  55276. /**
  55277. * Default configuration related to image processing available in the PBR Material.
  55278. */
  55279. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55280. /**
  55281. * Keep track of the image processing observer to allow dispose and replace.
  55282. */
  55283. private _imageProcessingObserver;
  55284. /**
  55285. * Attaches a new image processing configuration to the PBR Material.
  55286. * @param configuration
  55287. */
  55288. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55289. /**
  55290. * Stores the available render targets.
  55291. */
  55292. private _renderTargets;
  55293. /**
  55294. * Sets the global ambient color for the material used in lighting calculations.
  55295. */
  55296. private _globalAmbientColor;
  55297. /**
  55298. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55299. */
  55300. private _useLogarithmicDepth;
  55301. /**
  55302. * If set to true, no lighting calculations will be applied.
  55303. */
  55304. private _unlit;
  55305. private _debugMode;
  55306. /**
  55307. * @hidden
  55308. * This is reserved for the inspector.
  55309. * Defines the material debug mode.
  55310. * It helps seeing only some components of the material while troubleshooting.
  55311. */
  55312. debugMode: number;
  55313. /**
  55314. * @hidden
  55315. * This is reserved for the inspector.
  55316. * Specify from where on screen the debug mode should start.
  55317. * The value goes from -1 (full screen) to 1 (not visible)
  55318. * It helps with side by side comparison against the final render
  55319. * This defaults to -1
  55320. */
  55321. private debugLimit;
  55322. /**
  55323. * @hidden
  55324. * This is reserved for the inspector.
  55325. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55326. * You can use the factor to better multiply the final value.
  55327. */
  55328. private debugFactor;
  55329. /**
  55330. * Defines the clear coat layer parameters for the material.
  55331. */
  55332. readonly clearCoat: PBRClearCoatConfiguration;
  55333. /**
  55334. * Defines the anisotropic parameters for the material.
  55335. */
  55336. readonly anisotropy: PBRAnisotropicConfiguration;
  55337. /**
  55338. * Defines the BRDF parameters for the material.
  55339. */
  55340. readonly brdf: PBRBRDFConfiguration;
  55341. /**
  55342. * Defines the Sheen parameters for the material.
  55343. */
  55344. readonly sheen: PBRSheenConfiguration;
  55345. /**
  55346. * Defines the SubSurface parameters for the material.
  55347. */
  55348. readonly subSurface: PBRSubSurfaceConfiguration;
  55349. protected _rebuildInParallel: boolean;
  55350. /**
  55351. * Instantiates a new PBRMaterial instance.
  55352. *
  55353. * @param name The material name
  55354. * @param scene The scene the material will be use in.
  55355. */
  55356. constructor(name: string, scene: Scene);
  55357. /**
  55358. * Gets a boolean indicating that current material needs to register RTT
  55359. */
  55360. get hasRenderTargetTextures(): boolean;
  55361. /**
  55362. * Gets the name of the material class.
  55363. */
  55364. getClassName(): string;
  55365. /**
  55366. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55367. */
  55368. get useLogarithmicDepth(): boolean;
  55369. /**
  55370. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55371. */
  55372. set useLogarithmicDepth(value: boolean);
  55373. /**
  55374. * Returns true if alpha blending should be disabled.
  55375. */
  55376. protected get _disableAlphaBlending(): boolean;
  55377. /**
  55378. * Specifies whether or not this material should be rendered in alpha blend mode.
  55379. */
  55380. needAlphaBlending(): boolean;
  55381. /**
  55382. * Specifies whether or not this material should be rendered in alpha test mode.
  55383. */
  55384. needAlphaTesting(): boolean;
  55385. /**
  55386. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55387. */
  55388. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55389. /**
  55390. * Gets the texture used for the alpha test.
  55391. */
  55392. getAlphaTestTexture(): Nullable<BaseTexture>;
  55393. /**
  55394. * Specifies that the submesh is ready to be used.
  55395. * @param mesh - BJS mesh.
  55396. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55397. * @param useInstances - Specifies that instances should be used.
  55398. * @returns - boolean indicating that the submesh is ready or not.
  55399. */
  55400. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55401. /**
  55402. * Specifies if the material uses metallic roughness workflow.
  55403. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55404. */
  55405. isMetallicWorkflow(): boolean;
  55406. private _prepareEffect;
  55407. private _prepareDefines;
  55408. /**
  55409. * Force shader compilation
  55410. */
  55411. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55412. /**
  55413. * Initializes the uniform buffer layout for the shader.
  55414. */
  55415. buildUniformLayout(): void;
  55416. /**
  55417. * Unbinds the material from the mesh
  55418. */
  55419. unbind(): void;
  55420. /**
  55421. * Binds the submesh data.
  55422. * @param world - The world matrix.
  55423. * @param mesh - The BJS mesh.
  55424. * @param subMesh - A submesh of the BJS mesh.
  55425. */
  55426. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55427. /**
  55428. * Returns the animatable textures.
  55429. * @returns - Array of animatable textures.
  55430. */
  55431. getAnimatables(): IAnimatable[];
  55432. /**
  55433. * Returns the texture used for reflections.
  55434. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55435. */
  55436. private _getReflectionTexture;
  55437. /**
  55438. * Returns an array of the actively used textures.
  55439. * @returns - Array of BaseTextures
  55440. */
  55441. getActiveTextures(): BaseTexture[];
  55442. /**
  55443. * Checks to see if a texture is used in the material.
  55444. * @param texture - Base texture to use.
  55445. * @returns - Boolean specifying if a texture is used in the material.
  55446. */
  55447. hasTexture(texture: BaseTexture): boolean;
  55448. /**
  55449. * Disposes the resources of the material.
  55450. * @param forceDisposeEffect - Forces the disposal of effects.
  55451. * @param forceDisposeTextures - Forces the disposal of all textures.
  55452. */
  55453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55454. }
  55455. }
  55456. declare module BABYLON {
  55457. /**
  55458. * The Physically based material of BJS.
  55459. *
  55460. * This offers the main features of a standard PBR material.
  55461. * For more information, please refer to the documentation :
  55462. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55463. */
  55464. export class PBRMaterial extends PBRBaseMaterial {
  55465. /**
  55466. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55467. */
  55468. static readonly PBRMATERIAL_OPAQUE: number;
  55469. /**
  55470. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55471. */
  55472. static readonly PBRMATERIAL_ALPHATEST: number;
  55473. /**
  55474. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55475. */
  55476. static readonly PBRMATERIAL_ALPHABLEND: number;
  55477. /**
  55478. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55479. * They are also discarded below the alpha cutoff threshold to improve performances.
  55480. */
  55481. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55482. /**
  55483. * Defines the default value of how much AO map is occluding the analytical lights
  55484. * (point spot...).
  55485. */
  55486. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55487. /**
  55488. * Intensity of the direct lights e.g. the four lights available in your scene.
  55489. * This impacts both the direct diffuse and specular highlights.
  55490. */
  55491. directIntensity: number;
  55492. /**
  55493. * Intensity of the emissive part of the material.
  55494. * This helps controlling the emissive effect without modifying the emissive color.
  55495. */
  55496. emissiveIntensity: number;
  55497. /**
  55498. * Intensity of the environment e.g. how much the environment will light the object
  55499. * either through harmonics for rough material or through the refelction for shiny ones.
  55500. */
  55501. environmentIntensity: number;
  55502. /**
  55503. * This is a special control allowing the reduction of the specular highlights coming from the
  55504. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55505. */
  55506. specularIntensity: number;
  55507. /**
  55508. * Debug Control allowing disabling the bump map on this material.
  55509. */
  55510. disableBumpMap: boolean;
  55511. /**
  55512. * AKA Diffuse Texture in standard nomenclature.
  55513. */
  55514. albedoTexture: BaseTexture;
  55515. /**
  55516. * AKA Occlusion Texture in other nomenclature.
  55517. */
  55518. ambientTexture: BaseTexture;
  55519. /**
  55520. * AKA Occlusion Texture Intensity in other nomenclature.
  55521. */
  55522. ambientTextureStrength: number;
  55523. /**
  55524. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55525. * 1 means it completely occludes it
  55526. * 0 mean it has no impact
  55527. */
  55528. ambientTextureImpactOnAnalyticalLights: number;
  55529. /**
  55530. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55531. */
  55532. opacityTexture: BaseTexture;
  55533. /**
  55534. * Stores the reflection values in a texture.
  55535. */
  55536. reflectionTexture: Nullable<BaseTexture>;
  55537. /**
  55538. * Stores the emissive values in a texture.
  55539. */
  55540. emissiveTexture: BaseTexture;
  55541. /**
  55542. * AKA Specular texture in other nomenclature.
  55543. */
  55544. reflectivityTexture: BaseTexture;
  55545. /**
  55546. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55547. */
  55548. metallicTexture: BaseTexture;
  55549. /**
  55550. * Specifies the metallic scalar of the metallic/roughness workflow.
  55551. * Can also be used to scale the metalness values of the metallic texture.
  55552. */
  55553. metallic: Nullable<number>;
  55554. /**
  55555. * Specifies the roughness scalar of the metallic/roughness workflow.
  55556. * Can also be used to scale the roughness values of the metallic texture.
  55557. */
  55558. roughness: Nullable<number>;
  55559. /**
  55560. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55561. * By default the indexOfrefraction is used to compute F0;
  55562. *
  55563. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55564. *
  55565. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55566. * F90 = metallicReflectanceColor;
  55567. */
  55568. metallicF0Factor: number;
  55569. /**
  55570. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55571. * By default the F90 is always 1;
  55572. *
  55573. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55574. *
  55575. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55576. * F90 = metallicReflectanceColor;
  55577. */
  55578. metallicReflectanceColor: Color3;
  55579. /**
  55580. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55581. * This is multiply against the scalar values defined in the material.
  55582. */
  55583. metallicReflectanceTexture: Nullable<BaseTexture>;
  55584. /**
  55585. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55586. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55587. */
  55588. microSurfaceTexture: BaseTexture;
  55589. /**
  55590. * Stores surface normal data used to displace a mesh in a texture.
  55591. */
  55592. bumpTexture: BaseTexture;
  55593. /**
  55594. * Stores the pre-calculated light information of a mesh in a texture.
  55595. */
  55596. lightmapTexture: BaseTexture;
  55597. /**
  55598. * Stores the refracted light information in a texture.
  55599. */
  55600. get refractionTexture(): Nullable<BaseTexture>;
  55601. set refractionTexture(value: Nullable<BaseTexture>);
  55602. /**
  55603. * The color of a material in ambient lighting.
  55604. */
  55605. ambientColor: Color3;
  55606. /**
  55607. * AKA Diffuse Color in other nomenclature.
  55608. */
  55609. albedoColor: Color3;
  55610. /**
  55611. * AKA Specular Color in other nomenclature.
  55612. */
  55613. reflectivityColor: Color3;
  55614. /**
  55615. * The color reflected from the material.
  55616. */
  55617. reflectionColor: Color3;
  55618. /**
  55619. * The color emitted from the material.
  55620. */
  55621. emissiveColor: Color3;
  55622. /**
  55623. * AKA Glossiness in other nomenclature.
  55624. */
  55625. microSurface: number;
  55626. /**
  55627. * Index of refraction of the material base layer.
  55628. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55629. *
  55630. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55631. *
  55632. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55633. */
  55634. get indexOfRefraction(): number;
  55635. set indexOfRefraction(value: number);
  55636. /**
  55637. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55638. */
  55639. get invertRefractionY(): boolean;
  55640. set invertRefractionY(value: boolean);
  55641. /**
  55642. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55643. * Materials half opaque for instance using refraction could benefit from this control.
  55644. */
  55645. get linkRefractionWithTransparency(): boolean;
  55646. set linkRefractionWithTransparency(value: boolean);
  55647. /**
  55648. * If true, the light map contains occlusion information instead of lighting info.
  55649. */
  55650. useLightmapAsShadowmap: boolean;
  55651. /**
  55652. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55653. */
  55654. useAlphaFromAlbedoTexture: boolean;
  55655. /**
  55656. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55657. */
  55658. forceAlphaTest: boolean;
  55659. /**
  55660. * Defines the alpha limits in alpha test mode.
  55661. */
  55662. alphaCutOff: number;
  55663. /**
  55664. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55665. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55666. */
  55667. useSpecularOverAlpha: boolean;
  55668. /**
  55669. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55670. */
  55671. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55672. /**
  55673. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55674. */
  55675. useRoughnessFromMetallicTextureAlpha: boolean;
  55676. /**
  55677. * Specifies if the metallic texture contains the roughness information in its green channel.
  55678. */
  55679. useRoughnessFromMetallicTextureGreen: boolean;
  55680. /**
  55681. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55682. */
  55683. useMetallnessFromMetallicTextureBlue: boolean;
  55684. /**
  55685. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55686. */
  55687. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55688. /**
  55689. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55690. */
  55691. useAmbientInGrayScale: boolean;
  55692. /**
  55693. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55694. * The material will try to infer what glossiness each pixel should be.
  55695. */
  55696. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55697. /**
  55698. * BJS is using an harcoded light falloff based on a manually sets up range.
  55699. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55700. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55701. */
  55702. get usePhysicalLightFalloff(): boolean;
  55703. /**
  55704. * BJS is using an harcoded light falloff based on a manually sets up range.
  55705. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55706. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55707. */
  55708. set usePhysicalLightFalloff(value: boolean);
  55709. /**
  55710. * In order to support the falloff compatibility with gltf, a special mode has been added
  55711. * to reproduce the gltf light falloff.
  55712. */
  55713. get useGLTFLightFalloff(): boolean;
  55714. /**
  55715. * In order to support the falloff compatibility with gltf, a special mode has been added
  55716. * to reproduce the gltf light falloff.
  55717. */
  55718. set useGLTFLightFalloff(value: boolean);
  55719. /**
  55720. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55721. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55722. */
  55723. useRadianceOverAlpha: boolean;
  55724. /**
  55725. * Allows using an object space normal map (instead of tangent space).
  55726. */
  55727. useObjectSpaceNormalMap: boolean;
  55728. /**
  55729. * Allows using the bump map in parallax mode.
  55730. */
  55731. useParallax: boolean;
  55732. /**
  55733. * Allows using the bump map in parallax occlusion mode.
  55734. */
  55735. useParallaxOcclusion: boolean;
  55736. /**
  55737. * Controls the scale bias of the parallax mode.
  55738. */
  55739. parallaxScaleBias: number;
  55740. /**
  55741. * If sets to true, disables all the lights affecting the material.
  55742. */
  55743. disableLighting: boolean;
  55744. /**
  55745. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55746. */
  55747. forceIrradianceInFragment: boolean;
  55748. /**
  55749. * Number of Simultaneous lights allowed on the material.
  55750. */
  55751. maxSimultaneousLights: number;
  55752. /**
  55753. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55754. */
  55755. invertNormalMapX: boolean;
  55756. /**
  55757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55758. */
  55759. invertNormalMapY: boolean;
  55760. /**
  55761. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55762. */
  55763. twoSidedLighting: boolean;
  55764. /**
  55765. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55766. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55767. */
  55768. useAlphaFresnel: boolean;
  55769. /**
  55770. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55771. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55772. */
  55773. useLinearAlphaFresnel: boolean;
  55774. /**
  55775. * Let user defines the brdf lookup texture used for IBL.
  55776. * A default 8bit version is embedded but you could point at :
  55777. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55778. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55779. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55780. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55781. */
  55782. environmentBRDFTexture: Nullable<BaseTexture>;
  55783. /**
  55784. * Force normal to face away from face.
  55785. */
  55786. forceNormalForward: boolean;
  55787. /**
  55788. * Enables specular anti aliasing in the PBR shader.
  55789. * It will both interacts on the Geometry for analytical and IBL lighting.
  55790. * It also prefilter the roughness map based on the bump values.
  55791. */
  55792. enableSpecularAntiAliasing: boolean;
  55793. /**
  55794. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55795. * makes the reflect vector face the model (under horizon).
  55796. */
  55797. useHorizonOcclusion: boolean;
  55798. /**
  55799. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55800. * too much the area relying on ambient texture to define their ambient occlusion.
  55801. */
  55802. useRadianceOcclusion: boolean;
  55803. /**
  55804. * If set to true, no lighting calculations will be applied.
  55805. */
  55806. unlit: boolean;
  55807. /**
  55808. * Gets the image processing configuration used either in this material.
  55809. */
  55810. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55811. /**
  55812. * Sets the Default image processing configuration used either in the this material.
  55813. *
  55814. * If sets to null, the scene one is in use.
  55815. */
  55816. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55817. /**
  55818. * Gets wether the color curves effect is enabled.
  55819. */
  55820. get cameraColorCurvesEnabled(): boolean;
  55821. /**
  55822. * Sets wether the color curves effect is enabled.
  55823. */
  55824. set cameraColorCurvesEnabled(value: boolean);
  55825. /**
  55826. * Gets wether the color grading effect is enabled.
  55827. */
  55828. get cameraColorGradingEnabled(): boolean;
  55829. /**
  55830. * Gets wether the color grading effect is enabled.
  55831. */
  55832. set cameraColorGradingEnabled(value: boolean);
  55833. /**
  55834. * Gets wether tonemapping is enabled or not.
  55835. */
  55836. get cameraToneMappingEnabled(): boolean;
  55837. /**
  55838. * Sets wether tonemapping is enabled or not
  55839. */
  55840. set cameraToneMappingEnabled(value: boolean);
  55841. /**
  55842. * The camera exposure used on this material.
  55843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55844. * This corresponds to a photographic exposure.
  55845. */
  55846. get cameraExposure(): number;
  55847. /**
  55848. * The camera exposure used on this material.
  55849. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55850. * This corresponds to a photographic exposure.
  55851. */
  55852. set cameraExposure(value: number);
  55853. /**
  55854. * Gets The camera contrast used on this material.
  55855. */
  55856. get cameraContrast(): number;
  55857. /**
  55858. * Sets The camera contrast used on this material.
  55859. */
  55860. set cameraContrast(value: number);
  55861. /**
  55862. * Gets the Color Grading 2D Lookup Texture.
  55863. */
  55864. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55865. /**
  55866. * Sets the Color Grading 2D Lookup Texture.
  55867. */
  55868. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55869. /**
  55870. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55871. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55872. * 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;
  55873. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55874. */
  55875. get cameraColorCurves(): Nullable<ColorCurves>;
  55876. /**
  55877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55879. * 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;
  55880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55881. */
  55882. set cameraColorCurves(value: Nullable<ColorCurves>);
  55883. /**
  55884. * Instantiates a new PBRMaterial instance.
  55885. *
  55886. * @param name The material name
  55887. * @param scene The scene the material will be use in.
  55888. */
  55889. constructor(name: string, scene: Scene);
  55890. /**
  55891. * Returns the name of this material class.
  55892. */
  55893. getClassName(): string;
  55894. /**
  55895. * Makes a duplicate of the current material.
  55896. * @param name - name to use for the new material.
  55897. */
  55898. clone(name: string): PBRMaterial;
  55899. /**
  55900. * Serializes this PBR Material.
  55901. * @returns - An object with the serialized material.
  55902. */
  55903. serialize(): any;
  55904. /**
  55905. * Parses a PBR Material from a serialized object.
  55906. * @param source - Serialized object.
  55907. * @param scene - BJS scene instance.
  55908. * @param rootUrl - url for the scene object
  55909. * @returns - PBRMaterial
  55910. */
  55911. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55912. }
  55913. }
  55914. declare module BABYLON {
  55915. /**
  55916. * Direct draw surface info
  55917. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55918. */
  55919. export interface DDSInfo {
  55920. /**
  55921. * Width of the texture
  55922. */
  55923. width: number;
  55924. /**
  55925. * Width of the texture
  55926. */
  55927. height: number;
  55928. /**
  55929. * Number of Mipmaps for the texture
  55930. * @see https://en.wikipedia.org/wiki/Mipmap
  55931. */
  55932. mipmapCount: number;
  55933. /**
  55934. * If the textures format is a known fourCC format
  55935. * @see https://www.fourcc.org/
  55936. */
  55937. isFourCC: boolean;
  55938. /**
  55939. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55940. */
  55941. isRGB: boolean;
  55942. /**
  55943. * If the texture is a lumincance format
  55944. */
  55945. isLuminance: boolean;
  55946. /**
  55947. * If this is a cube texture
  55948. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55949. */
  55950. isCube: boolean;
  55951. /**
  55952. * If the texture is a compressed format eg. FOURCC_DXT1
  55953. */
  55954. isCompressed: boolean;
  55955. /**
  55956. * The dxgiFormat of the texture
  55957. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55958. */
  55959. dxgiFormat: number;
  55960. /**
  55961. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55962. */
  55963. textureType: number;
  55964. /**
  55965. * Sphericle polynomial created for the dds texture
  55966. */
  55967. sphericalPolynomial?: SphericalPolynomial;
  55968. }
  55969. /**
  55970. * Class used to provide DDS decompression tools
  55971. */
  55972. export class DDSTools {
  55973. /**
  55974. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55975. */
  55976. static StoreLODInAlphaChannel: boolean;
  55977. /**
  55978. * Gets DDS information from an array buffer
  55979. * @param data defines the array buffer view to read data from
  55980. * @returns the DDS information
  55981. */
  55982. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55983. private static _FloatView;
  55984. private static _Int32View;
  55985. private static _ToHalfFloat;
  55986. private static _FromHalfFloat;
  55987. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55988. private static _GetHalfFloatRGBAArrayBuffer;
  55989. private static _GetFloatRGBAArrayBuffer;
  55990. private static _GetFloatAsUIntRGBAArrayBuffer;
  55991. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55992. private static _GetRGBAArrayBuffer;
  55993. private static _ExtractLongWordOrder;
  55994. private static _GetRGBArrayBuffer;
  55995. private static _GetLuminanceArrayBuffer;
  55996. /**
  55997. * Uploads DDS Levels to a Babylon Texture
  55998. * @hidden
  55999. */
  56000. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56001. }
  56002. interface ThinEngine {
  56003. /**
  56004. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56005. * @param rootUrl defines the url where the file to load is located
  56006. * @param scene defines the current scene
  56007. * @param lodScale defines scale to apply to the mip map selection
  56008. * @param lodOffset defines offset to apply to the mip map selection
  56009. * @param onLoad defines an optional callback raised when the texture is loaded
  56010. * @param onError defines an optional callback raised if there is an issue to load the texture
  56011. * @param format defines the format of the data
  56012. * @param forcedExtension defines the extension to use to pick the right loader
  56013. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56014. * @returns the cube texture as an InternalTexture
  56015. */
  56016. 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;
  56017. }
  56018. }
  56019. declare module BABYLON {
  56020. /**
  56021. * Implementation of the DDS Texture Loader.
  56022. * @hidden
  56023. */
  56024. export class _DDSTextureLoader implements IInternalTextureLoader {
  56025. /**
  56026. * Defines wether the loader supports cascade loading the different faces.
  56027. */
  56028. readonly supportCascades: boolean;
  56029. /**
  56030. * This returns if the loader support the current file information.
  56031. * @param extension defines the file extension of the file being loaded
  56032. * @returns true if the loader can load the specified file
  56033. */
  56034. canLoad(extension: string): boolean;
  56035. /**
  56036. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56037. * @param data contains the texture data
  56038. * @param texture defines the BabylonJS internal texture
  56039. * @param createPolynomials will be true if polynomials have been requested
  56040. * @param onLoad defines the callback to trigger once the texture is ready
  56041. * @param onError defines the callback to trigger in case of error
  56042. */
  56043. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56044. /**
  56045. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56046. * @param data contains the texture data
  56047. * @param texture defines the BabylonJS internal texture
  56048. * @param callback defines the method to call once ready to upload
  56049. */
  56050. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56051. }
  56052. }
  56053. declare module BABYLON {
  56054. /**
  56055. * Implementation of the ENV Texture Loader.
  56056. * @hidden
  56057. */
  56058. export class _ENVTextureLoader implements IInternalTextureLoader {
  56059. /**
  56060. * Defines wether the loader supports cascade loading the different faces.
  56061. */
  56062. readonly supportCascades: boolean;
  56063. /**
  56064. * This returns if the loader support the current file information.
  56065. * @param extension defines the file extension of the file being loaded
  56066. * @returns true if the loader can load the specified file
  56067. */
  56068. canLoad(extension: string): boolean;
  56069. /**
  56070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56071. * @param data contains the texture data
  56072. * @param texture defines the BabylonJS internal texture
  56073. * @param createPolynomials will be true if polynomials have been requested
  56074. * @param onLoad defines the callback to trigger once the texture is ready
  56075. * @param onError defines the callback to trigger in case of error
  56076. */
  56077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56078. /**
  56079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56080. * @param data contains the texture data
  56081. * @param texture defines the BabylonJS internal texture
  56082. * @param callback defines the method to call once ready to upload
  56083. */
  56084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56085. }
  56086. }
  56087. declare module BABYLON {
  56088. /**
  56089. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56090. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56091. */
  56092. export class KhronosTextureContainer {
  56093. /** contents of the KTX container file */
  56094. data: ArrayBufferView;
  56095. private static HEADER_LEN;
  56096. private static COMPRESSED_2D;
  56097. private static COMPRESSED_3D;
  56098. private static TEX_2D;
  56099. private static TEX_3D;
  56100. /**
  56101. * Gets the openGL type
  56102. */
  56103. glType: number;
  56104. /**
  56105. * Gets the openGL type size
  56106. */
  56107. glTypeSize: number;
  56108. /**
  56109. * Gets the openGL format
  56110. */
  56111. glFormat: number;
  56112. /**
  56113. * Gets the openGL internal format
  56114. */
  56115. glInternalFormat: number;
  56116. /**
  56117. * Gets the base internal format
  56118. */
  56119. glBaseInternalFormat: number;
  56120. /**
  56121. * Gets image width in pixel
  56122. */
  56123. pixelWidth: number;
  56124. /**
  56125. * Gets image height in pixel
  56126. */
  56127. pixelHeight: number;
  56128. /**
  56129. * Gets image depth in pixels
  56130. */
  56131. pixelDepth: number;
  56132. /**
  56133. * Gets the number of array elements
  56134. */
  56135. numberOfArrayElements: number;
  56136. /**
  56137. * Gets the number of faces
  56138. */
  56139. numberOfFaces: number;
  56140. /**
  56141. * Gets the number of mipmap levels
  56142. */
  56143. numberOfMipmapLevels: number;
  56144. /**
  56145. * Gets the bytes of key value data
  56146. */
  56147. bytesOfKeyValueData: number;
  56148. /**
  56149. * Gets the load type
  56150. */
  56151. loadType: number;
  56152. /**
  56153. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56154. */
  56155. isInvalid: boolean;
  56156. /**
  56157. * Creates a new KhronosTextureContainer
  56158. * @param data contents of the KTX container file
  56159. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56160. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56161. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56162. */
  56163. constructor(
  56164. /** contents of the KTX container file */
  56165. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56166. /**
  56167. * Uploads KTX content to a Babylon Texture.
  56168. * It is assumed that the texture has already been created & is currently bound
  56169. * @hidden
  56170. */
  56171. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56172. private _upload2DCompressedLevels;
  56173. /**
  56174. * Checks if the given data starts with a KTX file identifier.
  56175. * @param data the data to check
  56176. * @returns true if the data is a KTX file or false otherwise
  56177. */
  56178. static IsValid(data: ArrayBufferView): boolean;
  56179. }
  56180. }
  56181. declare module BABYLON {
  56182. /**
  56183. * Class for loading KTX2 files
  56184. * !!! Experimental Extension Subject to Changes !!!
  56185. * @hidden
  56186. */
  56187. export class KhronosTextureContainer2 {
  56188. private static _ModulePromise;
  56189. private static _TranscodeFormat;
  56190. constructor(engine: ThinEngine);
  56191. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56192. private _determineTranscodeFormat;
  56193. /**
  56194. * Checks if the given data starts with a KTX2 file identifier.
  56195. * @param data the data to check
  56196. * @returns true if the data is a KTX2 file or false otherwise
  56197. */
  56198. static IsValid(data: ArrayBufferView): boolean;
  56199. }
  56200. }
  56201. declare module BABYLON {
  56202. /**
  56203. * Implementation of the KTX Texture Loader.
  56204. * @hidden
  56205. */
  56206. export class _KTXTextureLoader implements IInternalTextureLoader {
  56207. /**
  56208. * Defines wether the loader supports cascade loading the different faces.
  56209. */
  56210. readonly supportCascades: boolean;
  56211. /**
  56212. * This returns if the loader support the current file information.
  56213. * @param extension defines the file extension of the file being loaded
  56214. * @returns true if the loader can load the specified file
  56215. */
  56216. canLoad(extension: string): boolean;
  56217. /**
  56218. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56219. * @param data contains the texture data
  56220. * @param texture defines the BabylonJS internal texture
  56221. * @param createPolynomials will be true if polynomials have been requested
  56222. * @param onLoad defines the callback to trigger once the texture is ready
  56223. * @param onError defines the callback to trigger in case of error
  56224. */
  56225. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56226. /**
  56227. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56228. * @param data contains the texture data
  56229. * @param texture defines the BabylonJS internal texture
  56230. * @param callback defines the method to call once ready to upload
  56231. */
  56232. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56233. }
  56234. }
  56235. declare module BABYLON {
  56236. /** @hidden */
  56237. export var _forceSceneHelpersToBundle: boolean;
  56238. interface Scene {
  56239. /**
  56240. * Creates a default light for the scene.
  56241. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56242. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56243. */
  56244. createDefaultLight(replace?: boolean): void;
  56245. /**
  56246. * Creates a default camera for the scene.
  56247. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56248. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56249. * @param replace has default false, when true replaces the active camera in the scene
  56250. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56251. */
  56252. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56253. /**
  56254. * Creates a default camera and a default light.
  56255. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56256. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56257. * @param replace has the default false, when true replaces the active camera/light in the scene
  56258. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56259. */
  56260. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56261. /**
  56262. * Creates a new sky box
  56263. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56264. * @param environmentTexture defines the texture to use as environment texture
  56265. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56266. * @param scale defines the overall scale of the skybox
  56267. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56268. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56269. * @returns a new mesh holding the sky box
  56270. */
  56271. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56272. /**
  56273. * Creates a new environment
  56274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56275. * @param options defines the options you can use to configure the environment
  56276. * @returns the new EnvironmentHelper
  56277. */
  56278. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56279. /**
  56280. * Creates a new VREXperienceHelper
  56281. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56282. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56283. * @returns a new VREXperienceHelper
  56284. */
  56285. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56286. /**
  56287. * Creates a new WebXRDefaultExperience
  56288. * @see http://doc.babylonjs.com/how_to/webxr
  56289. * @param options experience options
  56290. * @returns a promise for a new WebXRDefaultExperience
  56291. */
  56292. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56293. }
  56294. }
  56295. declare module BABYLON {
  56296. /**
  56297. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56298. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56299. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56300. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56301. */
  56302. export class VideoDome extends TransformNode {
  56303. /**
  56304. * Define the video source as a Monoscopic panoramic 360 video.
  56305. */
  56306. static readonly MODE_MONOSCOPIC: number;
  56307. /**
  56308. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56309. */
  56310. static readonly MODE_TOPBOTTOM: number;
  56311. /**
  56312. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56313. */
  56314. static readonly MODE_SIDEBYSIDE: number;
  56315. private _halfDome;
  56316. private _useDirectMapping;
  56317. /**
  56318. * The video texture being displayed on the sphere
  56319. */
  56320. protected _videoTexture: VideoTexture;
  56321. /**
  56322. * Gets the video texture being displayed on the sphere
  56323. */
  56324. get videoTexture(): VideoTexture;
  56325. /**
  56326. * The skybox material
  56327. */
  56328. protected _material: BackgroundMaterial;
  56329. /**
  56330. * The surface used for the skybox
  56331. */
  56332. protected _mesh: Mesh;
  56333. /**
  56334. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56335. */
  56336. private _halfDomeMask;
  56337. /**
  56338. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56339. * Also see the options.resolution property.
  56340. */
  56341. get fovMultiplier(): number;
  56342. set fovMultiplier(value: number);
  56343. private _videoMode;
  56344. /**
  56345. * Gets or set the current video mode for the video. It can be:
  56346. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56347. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56348. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56349. */
  56350. get videoMode(): number;
  56351. set videoMode(value: number);
  56352. /**
  56353. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56354. *
  56355. */
  56356. get halfDome(): boolean;
  56357. /**
  56358. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56359. */
  56360. set halfDome(enabled: boolean);
  56361. /**
  56362. * Oberserver used in Stereoscopic VR Mode.
  56363. */
  56364. private _onBeforeCameraRenderObserver;
  56365. /**
  56366. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56367. * @param name Element's name, child elements will append suffixes for their own names.
  56368. * @param urlsOrVideo defines the url(s) or the video element to use
  56369. * @param options An object containing optional or exposed sub element properties
  56370. */
  56371. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56372. resolution?: number;
  56373. clickToPlay?: boolean;
  56374. autoPlay?: boolean;
  56375. loop?: boolean;
  56376. size?: number;
  56377. poster?: string;
  56378. faceForward?: boolean;
  56379. useDirectMapping?: boolean;
  56380. halfDomeMode?: boolean;
  56381. }, scene: Scene);
  56382. private _changeVideoMode;
  56383. /**
  56384. * Releases resources associated with this node.
  56385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56387. */
  56388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * This class can be used to get instrumentation data from a Babylon engine
  56394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56395. */
  56396. export class EngineInstrumentation implements IDisposable {
  56397. /**
  56398. * Define the instrumented engine.
  56399. */
  56400. engine: Engine;
  56401. private _captureGPUFrameTime;
  56402. private _gpuFrameTimeToken;
  56403. private _gpuFrameTime;
  56404. private _captureShaderCompilationTime;
  56405. private _shaderCompilationTime;
  56406. private _onBeginFrameObserver;
  56407. private _onEndFrameObserver;
  56408. private _onBeforeShaderCompilationObserver;
  56409. private _onAfterShaderCompilationObserver;
  56410. /**
  56411. * Gets the perf counter used for GPU frame time
  56412. */
  56413. get gpuFrameTimeCounter(): PerfCounter;
  56414. /**
  56415. * Gets the GPU frame time capture status
  56416. */
  56417. get captureGPUFrameTime(): boolean;
  56418. /**
  56419. * Enable or disable the GPU frame time capture
  56420. */
  56421. set captureGPUFrameTime(value: boolean);
  56422. /**
  56423. * Gets the perf counter used for shader compilation time
  56424. */
  56425. get shaderCompilationTimeCounter(): PerfCounter;
  56426. /**
  56427. * Gets the shader compilation time capture status
  56428. */
  56429. get captureShaderCompilationTime(): boolean;
  56430. /**
  56431. * Enable or disable the shader compilation time capture
  56432. */
  56433. set captureShaderCompilationTime(value: boolean);
  56434. /**
  56435. * Instantiates a new engine instrumentation.
  56436. * This class can be used to get instrumentation data from a Babylon engine
  56437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56438. * @param engine Defines the engine to instrument
  56439. */
  56440. constructor(
  56441. /**
  56442. * Define the instrumented engine.
  56443. */
  56444. engine: Engine);
  56445. /**
  56446. * Dispose and release associated resources.
  56447. */
  56448. dispose(): void;
  56449. }
  56450. }
  56451. declare module BABYLON {
  56452. /**
  56453. * This class can be used to get instrumentation data from a Babylon engine
  56454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56455. */
  56456. export class SceneInstrumentation implements IDisposable {
  56457. /**
  56458. * Defines the scene to instrument
  56459. */
  56460. scene: Scene;
  56461. private _captureActiveMeshesEvaluationTime;
  56462. private _activeMeshesEvaluationTime;
  56463. private _captureRenderTargetsRenderTime;
  56464. private _renderTargetsRenderTime;
  56465. private _captureFrameTime;
  56466. private _frameTime;
  56467. private _captureRenderTime;
  56468. private _renderTime;
  56469. private _captureInterFrameTime;
  56470. private _interFrameTime;
  56471. private _captureParticlesRenderTime;
  56472. private _particlesRenderTime;
  56473. private _captureSpritesRenderTime;
  56474. private _spritesRenderTime;
  56475. private _capturePhysicsTime;
  56476. private _physicsTime;
  56477. private _captureAnimationsTime;
  56478. private _animationsTime;
  56479. private _captureCameraRenderTime;
  56480. private _cameraRenderTime;
  56481. private _onBeforeActiveMeshesEvaluationObserver;
  56482. private _onAfterActiveMeshesEvaluationObserver;
  56483. private _onBeforeRenderTargetsRenderObserver;
  56484. private _onAfterRenderTargetsRenderObserver;
  56485. private _onAfterRenderObserver;
  56486. private _onBeforeDrawPhaseObserver;
  56487. private _onAfterDrawPhaseObserver;
  56488. private _onBeforeAnimationsObserver;
  56489. private _onBeforeParticlesRenderingObserver;
  56490. private _onAfterParticlesRenderingObserver;
  56491. private _onBeforeSpritesRenderingObserver;
  56492. private _onAfterSpritesRenderingObserver;
  56493. private _onBeforePhysicsObserver;
  56494. private _onAfterPhysicsObserver;
  56495. private _onAfterAnimationsObserver;
  56496. private _onBeforeCameraRenderObserver;
  56497. private _onAfterCameraRenderObserver;
  56498. /**
  56499. * Gets the perf counter used for active meshes evaluation time
  56500. */
  56501. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56502. /**
  56503. * Gets the active meshes evaluation time capture status
  56504. */
  56505. get captureActiveMeshesEvaluationTime(): boolean;
  56506. /**
  56507. * Enable or disable the active meshes evaluation time capture
  56508. */
  56509. set captureActiveMeshesEvaluationTime(value: boolean);
  56510. /**
  56511. * Gets the perf counter used for render targets render time
  56512. */
  56513. get renderTargetsRenderTimeCounter(): PerfCounter;
  56514. /**
  56515. * Gets the render targets render time capture status
  56516. */
  56517. get captureRenderTargetsRenderTime(): boolean;
  56518. /**
  56519. * Enable or disable the render targets render time capture
  56520. */
  56521. set captureRenderTargetsRenderTime(value: boolean);
  56522. /**
  56523. * Gets the perf counter used for particles render time
  56524. */
  56525. get particlesRenderTimeCounter(): PerfCounter;
  56526. /**
  56527. * Gets the particles render time capture status
  56528. */
  56529. get captureParticlesRenderTime(): boolean;
  56530. /**
  56531. * Enable or disable the particles render time capture
  56532. */
  56533. set captureParticlesRenderTime(value: boolean);
  56534. /**
  56535. * Gets the perf counter used for sprites render time
  56536. */
  56537. get spritesRenderTimeCounter(): PerfCounter;
  56538. /**
  56539. * Gets the sprites render time capture status
  56540. */
  56541. get captureSpritesRenderTime(): boolean;
  56542. /**
  56543. * Enable or disable the sprites render time capture
  56544. */
  56545. set captureSpritesRenderTime(value: boolean);
  56546. /**
  56547. * Gets the perf counter used for physics time
  56548. */
  56549. get physicsTimeCounter(): PerfCounter;
  56550. /**
  56551. * Gets the physics time capture status
  56552. */
  56553. get capturePhysicsTime(): boolean;
  56554. /**
  56555. * Enable or disable the physics time capture
  56556. */
  56557. set capturePhysicsTime(value: boolean);
  56558. /**
  56559. * Gets the perf counter used for animations time
  56560. */
  56561. get animationsTimeCounter(): PerfCounter;
  56562. /**
  56563. * Gets the animations time capture status
  56564. */
  56565. get captureAnimationsTime(): boolean;
  56566. /**
  56567. * Enable or disable the animations time capture
  56568. */
  56569. set captureAnimationsTime(value: boolean);
  56570. /**
  56571. * Gets the perf counter used for frame time capture
  56572. */
  56573. get frameTimeCounter(): PerfCounter;
  56574. /**
  56575. * Gets the frame time capture status
  56576. */
  56577. get captureFrameTime(): boolean;
  56578. /**
  56579. * Enable or disable the frame time capture
  56580. */
  56581. set captureFrameTime(value: boolean);
  56582. /**
  56583. * Gets the perf counter used for inter-frames time capture
  56584. */
  56585. get interFrameTimeCounter(): PerfCounter;
  56586. /**
  56587. * Gets the inter-frames time capture status
  56588. */
  56589. get captureInterFrameTime(): boolean;
  56590. /**
  56591. * Enable or disable the inter-frames time capture
  56592. */
  56593. set captureInterFrameTime(value: boolean);
  56594. /**
  56595. * Gets the perf counter used for render time capture
  56596. */
  56597. get renderTimeCounter(): PerfCounter;
  56598. /**
  56599. * Gets the render time capture status
  56600. */
  56601. get captureRenderTime(): boolean;
  56602. /**
  56603. * Enable or disable the render time capture
  56604. */
  56605. set captureRenderTime(value: boolean);
  56606. /**
  56607. * Gets the perf counter used for camera render time capture
  56608. */
  56609. get cameraRenderTimeCounter(): PerfCounter;
  56610. /**
  56611. * Gets the camera render time capture status
  56612. */
  56613. get captureCameraRenderTime(): boolean;
  56614. /**
  56615. * Enable or disable the camera render time capture
  56616. */
  56617. set captureCameraRenderTime(value: boolean);
  56618. /**
  56619. * Gets the perf counter used for draw calls
  56620. */
  56621. get drawCallsCounter(): PerfCounter;
  56622. /**
  56623. * Instantiates a new scene instrumentation.
  56624. * This class can be used to get instrumentation data from a Babylon engine
  56625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56626. * @param scene Defines the scene to instrument
  56627. */
  56628. constructor(
  56629. /**
  56630. * Defines the scene to instrument
  56631. */
  56632. scene: Scene);
  56633. /**
  56634. * Dispose and release associated resources.
  56635. */
  56636. dispose(): void;
  56637. }
  56638. }
  56639. declare module BABYLON {
  56640. /** @hidden */
  56641. export var glowMapGenerationPixelShader: {
  56642. name: string;
  56643. shader: string;
  56644. };
  56645. }
  56646. declare module BABYLON {
  56647. /** @hidden */
  56648. export var glowMapGenerationVertexShader: {
  56649. name: string;
  56650. shader: string;
  56651. };
  56652. }
  56653. declare module BABYLON {
  56654. /**
  56655. * Effect layer options. This helps customizing the behaviour
  56656. * of the effect layer.
  56657. */
  56658. export interface IEffectLayerOptions {
  56659. /**
  56660. * Multiplication factor apply to the canvas size to compute the render target size
  56661. * used to generated the objects (the smaller the faster).
  56662. */
  56663. mainTextureRatio: number;
  56664. /**
  56665. * Enforces a fixed size texture to ensure effect stability across devices.
  56666. */
  56667. mainTextureFixedSize?: number;
  56668. /**
  56669. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56670. */
  56671. alphaBlendingMode: number;
  56672. /**
  56673. * The camera attached to the layer.
  56674. */
  56675. camera: Nullable<Camera>;
  56676. /**
  56677. * The rendering group to draw the layer in.
  56678. */
  56679. renderingGroupId: number;
  56680. }
  56681. /**
  56682. * The effect layer Helps adding post process effect blended with the main pass.
  56683. *
  56684. * This can be for instance use to generate glow or higlight effects on the scene.
  56685. *
  56686. * The effect layer class can not be used directly and is intented to inherited from to be
  56687. * customized per effects.
  56688. */
  56689. export abstract class EffectLayer {
  56690. private _vertexBuffers;
  56691. private _indexBuffer;
  56692. private _cachedDefines;
  56693. private _effectLayerMapGenerationEffect;
  56694. private _effectLayerOptions;
  56695. private _mergeEffect;
  56696. protected _scene: Scene;
  56697. protected _engine: Engine;
  56698. protected _maxSize: number;
  56699. protected _mainTextureDesiredSize: ISize;
  56700. protected _mainTexture: RenderTargetTexture;
  56701. protected _shouldRender: boolean;
  56702. protected _postProcesses: PostProcess[];
  56703. protected _textures: BaseTexture[];
  56704. protected _emissiveTextureAndColor: {
  56705. texture: Nullable<BaseTexture>;
  56706. color: Color4;
  56707. };
  56708. /**
  56709. * The name of the layer
  56710. */
  56711. name: string;
  56712. /**
  56713. * The clear color of the texture used to generate the glow map.
  56714. */
  56715. neutralColor: Color4;
  56716. /**
  56717. * Specifies whether the highlight layer is enabled or not.
  56718. */
  56719. isEnabled: boolean;
  56720. /**
  56721. * Gets the camera attached to the layer.
  56722. */
  56723. get camera(): Nullable<Camera>;
  56724. /**
  56725. * Gets the rendering group id the layer should render in.
  56726. */
  56727. get renderingGroupId(): number;
  56728. set renderingGroupId(renderingGroupId: number);
  56729. /**
  56730. * An event triggered when the effect layer has been disposed.
  56731. */
  56732. onDisposeObservable: Observable<EffectLayer>;
  56733. /**
  56734. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56735. */
  56736. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56737. /**
  56738. * An event triggered when the generated texture is being merged in the scene.
  56739. */
  56740. onBeforeComposeObservable: Observable<EffectLayer>;
  56741. /**
  56742. * An event triggered when the mesh is rendered into the effect render target.
  56743. */
  56744. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56745. /**
  56746. * An event triggered after the mesh has been rendered into the effect render target.
  56747. */
  56748. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56749. /**
  56750. * An event triggered when the generated texture has been merged in the scene.
  56751. */
  56752. onAfterComposeObservable: Observable<EffectLayer>;
  56753. /**
  56754. * An event triggered when the efffect layer changes its size.
  56755. */
  56756. onSizeChangedObservable: Observable<EffectLayer>;
  56757. /** @hidden */
  56758. static _SceneComponentInitialization: (scene: Scene) => void;
  56759. /**
  56760. * Instantiates a new effect Layer and references it in the scene.
  56761. * @param name The name of the layer
  56762. * @param scene The scene to use the layer in
  56763. */
  56764. constructor(
  56765. /** The Friendly of the effect in the scene */
  56766. name: string, scene: Scene);
  56767. /**
  56768. * Get the effect name of the layer.
  56769. * @return The effect name
  56770. */
  56771. abstract getEffectName(): string;
  56772. /**
  56773. * Checks for the readiness of the element composing the layer.
  56774. * @param subMesh the mesh to check for
  56775. * @param useInstances specify whether or not to use instances to render the mesh
  56776. * @return true if ready otherwise, false
  56777. */
  56778. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56779. /**
  56780. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56781. * @returns true if the effect requires stencil during the main canvas render pass.
  56782. */
  56783. abstract needStencil(): boolean;
  56784. /**
  56785. * Create the merge effect. This is the shader use to blit the information back
  56786. * to the main canvas at the end of the scene rendering.
  56787. * @returns The effect containing the shader used to merge the effect on the main canvas
  56788. */
  56789. protected abstract _createMergeEffect(): Effect;
  56790. /**
  56791. * Creates the render target textures and post processes used in the effect layer.
  56792. */
  56793. protected abstract _createTextureAndPostProcesses(): void;
  56794. /**
  56795. * Implementation specific of rendering the generating effect on the main canvas.
  56796. * @param effect The effect used to render through
  56797. */
  56798. protected abstract _internalRender(effect: Effect): void;
  56799. /**
  56800. * Sets the required values for both the emissive texture and and the main color.
  56801. */
  56802. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56803. /**
  56804. * Free any resources and references associated to a mesh.
  56805. * Internal use
  56806. * @param mesh The mesh to free.
  56807. */
  56808. abstract _disposeMesh(mesh: Mesh): void;
  56809. /**
  56810. * Serializes this layer (Glow or Highlight for example)
  56811. * @returns a serialized layer object
  56812. */
  56813. abstract serialize?(): any;
  56814. /**
  56815. * Initializes the effect layer with the required options.
  56816. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56817. */
  56818. protected _init(options: Partial<IEffectLayerOptions>): void;
  56819. /**
  56820. * Generates the index buffer of the full screen quad blending to the main canvas.
  56821. */
  56822. private _generateIndexBuffer;
  56823. /**
  56824. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56825. */
  56826. private _generateVertexBuffer;
  56827. /**
  56828. * Sets the main texture desired size which is the closest power of two
  56829. * of the engine canvas size.
  56830. */
  56831. private _setMainTextureSize;
  56832. /**
  56833. * Creates the main texture for the effect layer.
  56834. */
  56835. protected _createMainTexture(): void;
  56836. /**
  56837. * Adds specific effects defines.
  56838. * @param defines The defines to add specifics to.
  56839. */
  56840. protected _addCustomEffectDefines(defines: string[]): void;
  56841. /**
  56842. * Checks for the readiness of the element composing the layer.
  56843. * @param subMesh the mesh to check for
  56844. * @param useInstances specify whether or not to use instances to render the mesh
  56845. * @param emissiveTexture the associated emissive texture used to generate the glow
  56846. * @return true if ready otherwise, false
  56847. */
  56848. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56849. /**
  56850. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56851. */
  56852. render(): void;
  56853. /**
  56854. * Determine if a given mesh will be used in the current effect.
  56855. * @param mesh mesh to test
  56856. * @returns true if the mesh will be used
  56857. */
  56858. hasMesh(mesh: AbstractMesh): boolean;
  56859. /**
  56860. * Returns true if the layer contains information to display, otherwise false.
  56861. * @returns true if the glow layer should be rendered
  56862. */
  56863. shouldRender(): boolean;
  56864. /**
  56865. * Returns true if the mesh should render, otherwise false.
  56866. * @param mesh The mesh to render
  56867. * @returns true if it should render otherwise false
  56868. */
  56869. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56870. /**
  56871. * Returns true if the mesh can be rendered, otherwise false.
  56872. * @param mesh The mesh to render
  56873. * @param material The material used on the mesh
  56874. * @returns true if it can be rendered otherwise false
  56875. */
  56876. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56877. /**
  56878. * Returns true if the mesh should render, otherwise false.
  56879. * @param mesh The mesh to render
  56880. * @returns true if it should render otherwise false
  56881. */
  56882. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56883. /**
  56884. * Renders the submesh passed in parameter to the generation map.
  56885. */
  56886. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56887. /**
  56888. * Defines whether the current material of the mesh should be use to render the effect.
  56889. * @param mesh defines the current mesh to render
  56890. */
  56891. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56892. /**
  56893. * Rebuild the required buffers.
  56894. * @hidden Internal use only.
  56895. */
  56896. _rebuild(): void;
  56897. /**
  56898. * Dispose only the render target textures and post process.
  56899. */
  56900. private _disposeTextureAndPostProcesses;
  56901. /**
  56902. * Dispose the highlight layer and free resources.
  56903. */
  56904. dispose(): void;
  56905. /**
  56906. * Gets the class name of the effect layer
  56907. * @returns the string with the class name of the effect layer
  56908. */
  56909. getClassName(): string;
  56910. /**
  56911. * Creates an effect layer from parsed effect layer data
  56912. * @param parsedEffectLayer defines effect layer data
  56913. * @param scene defines the current scene
  56914. * @param rootUrl defines the root URL containing the effect layer information
  56915. * @returns a parsed effect Layer
  56916. */
  56917. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56918. }
  56919. }
  56920. declare module BABYLON {
  56921. interface AbstractScene {
  56922. /**
  56923. * The list of effect layers (highlights/glow) added to the scene
  56924. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56925. * @see http://doc.babylonjs.com/how_to/glow_layer
  56926. */
  56927. effectLayers: Array<EffectLayer>;
  56928. /**
  56929. * Removes the given effect layer from this scene.
  56930. * @param toRemove defines the effect layer to remove
  56931. * @returns the index of the removed effect layer
  56932. */
  56933. removeEffectLayer(toRemove: EffectLayer): number;
  56934. /**
  56935. * Adds the given effect layer to this scene
  56936. * @param newEffectLayer defines the effect layer to add
  56937. */
  56938. addEffectLayer(newEffectLayer: EffectLayer): void;
  56939. }
  56940. /**
  56941. * Defines the layer scene component responsible to manage any effect layers
  56942. * in a given scene.
  56943. */
  56944. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56945. /**
  56946. * The component name helpfull to identify the component in the list of scene components.
  56947. */
  56948. readonly name: string;
  56949. /**
  56950. * The scene the component belongs to.
  56951. */
  56952. scene: Scene;
  56953. private _engine;
  56954. private _renderEffects;
  56955. private _needStencil;
  56956. private _previousStencilState;
  56957. /**
  56958. * Creates a new instance of the component for the given scene
  56959. * @param scene Defines the scene to register the component in
  56960. */
  56961. constructor(scene: Scene);
  56962. /**
  56963. * Registers the component in a given scene
  56964. */
  56965. register(): void;
  56966. /**
  56967. * Rebuilds the elements related to this component in case of
  56968. * context lost for instance.
  56969. */
  56970. rebuild(): void;
  56971. /**
  56972. * Serializes the component data to the specified json object
  56973. * @param serializationObject The object to serialize to
  56974. */
  56975. serialize(serializationObject: any): void;
  56976. /**
  56977. * Adds all the elements from the container to the scene
  56978. * @param container the container holding the elements
  56979. */
  56980. addFromContainer(container: AbstractScene): void;
  56981. /**
  56982. * Removes all the elements in the container from the scene
  56983. * @param container contains the elements to remove
  56984. * @param dispose if the removed element should be disposed (default: false)
  56985. */
  56986. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56987. /**
  56988. * Disposes the component and the associated ressources.
  56989. */
  56990. dispose(): void;
  56991. private _isReadyForMesh;
  56992. private _renderMainTexture;
  56993. private _setStencil;
  56994. private _setStencilBack;
  56995. private _draw;
  56996. private _drawCamera;
  56997. private _drawRenderingGroup;
  56998. }
  56999. }
  57000. declare module BABYLON {
  57001. /** @hidden */
  57002. export var glowMapMergePixelShader: {
  57003. name: string;
  57004. shader: string;
  57005. };
  57006. }
  57007. declare module BABYLON {
  57008. /** @hidden */
  57009. export var glowMapMergeVertexShader: {
  57010. name: string;
  57011. shader: string;
  57012. };
  57013. }
  57014. declare module BABYLON {
  57015. interface AbstractScene {
  57016. /**
  57017. * Return a the first highlight layer of the scene with a given name.
  57018. * @param name The name of the highlight layer to look for.
  57019. * @return The highlight layer if found otherwise null.
  57020. */
  57021. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57022. }
  57023. /**
  57024. * Glow layer options. This helps customizing the behaviour
  57025. * of the glow layer.
  57026. */
  57027. export interface IGlowLayerOptions {
  57028. /**
  57029. * Multiplication factor apply to the canvas size to compute the render target size
  57030. * used to generated the glowing objects (the smaller the faster).
  57031. */
  57032. mainTextureRatio: number;
  57033. /**
  57034. * Enforces a fixed size texture to ensure resize independant blur.
  57035. */
  57036. mainTextureFixedSize?: number;
  57037. /**
  57038. * How big is the kernel of the blur texture.
  57039. */
  57040. blurKernelSize: number;
  57041. /**
  57042. * The camera attached to the layer.
  57043. */
  57044. camera: Nullable<Camera>;
  57045. /**
  57046. * Enable MSAA by chosing the number of samples.
  57047. */
  57048. mainTextureSamples?: number;
  57049. /**
  57050. * The rendering group to draw the layer in.
  57051. */
  57052. renderingGroupId: number;
  57053. }
  57054. /**
  57055. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57056. *
  57057. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57058. *
  57059. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57060. */
  57061. export class GlowLayer extends EffectLayer {
  57062. /**
  57063. * Effect Name of the layer.
  57064. */
  57065. static readonly EffectName: string;
  57066. /**
  57067. * The default blur kernel size used for the glow.
  57068. */
  57069. static DefaultBlurKernelSize: number;
  57070. /**
  57071. * The default texture size ratio used for the glow.
  57072. */
  57073. static DefaultTextureRatio: number;
  57074. /**
  57075. * Sets the kernel size of the blur.
  57076. */
  57077. set blurKernelSize(value: number);
  57078. /**
  57079. * Gets the kernel size of the blur.
  57080. */
  57081. get blurKernelSize(): number;
  57082. /**
  57083. * Sets the glow intensity.
  57084. */
  57085. set intensity(value: number);
  57086. /**
  57087. * Gets the glow intensity.
  57088. */
  57089. get intensity(): number;
  57090. private _options;
  57091. private _intensity;
  57092. private _horizontalBlurPostprocess1;
  57093. private _verticalBlurPostprocess1;
  57094. private _horizontalBlurPostprocess2;
  57095. private _verticalBlurPostprocess2;
  57096. private _blurTexture1;
  57097. private _blurTexture2;
  57098. private _postProcesses1;
  57099. private _postProcesses2;
  57100. private _includedOnlyMeshes;
  57101. private _excludedMeshes;
  57102. private _meshesUsingTheirOwnMaterials;
  57103. /**
  57104. * Callback used to let the user override the color selection on a per mesh basis
  57105. */
  57106. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57107. /**
  57108. * Callback used to let the user override the texture selection on a per mesh basis
  57109. */
  57110. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57111. /**
  57112. * Instantiates a new glow Layer and references it to the scene.
  57113. * @param name The name of the layer
  57114. * @param scene The scene to use the layer in
  57115. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57116. */
  57117. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57118. /**
  57119. * Get the effect name of the layer.
  57120. * @return The effect name
  57121. */
  57122. getEffectName(): string;
  57123. /**
  57124. * Create the merge effect. This is the shader use to blit the information back
  57125. * to the main canvas at the end of the scene rendering.
  57126. */
  57127. protected _createMergeEffect(): Effect;
  57128. /**
  57129. * Creates the render target textures and post processes used in the glow layer.
  57130. */
  57131. protected _createTextureAndPostProcesses(): void;
  57132. /**
  57133. * Checks for the readiness of the element composing the layer.
  57134. * @param subMesh the mesh to check for
  57135. * @param useInstances specify wether or not to use instances to render the mesh
  57136. * @param emissiveTexture the associated emissive texture used to generate the glow
  57137. * @return true if ready otherwise, false
  57138. */
  57139. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57140. /**
  57141. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57142. */
  57143. needStencil(): boolean;
  57144. /**
  57145. * Returns true if the mesh can be rendered, otherwise false.
  57146. * @param mesh The mesh to render
  57147. * @param material The material used on the mesh
  57148. * @returns true if it can be rendered otherwise false
  57149. */
  57150. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57151. /**
  57152. * Implementation specific of rendering the generating effect on the main canvas.
  57153. * @param effect The effect used to render through
  57154. */
  57155. protected _internalRender(effect: Effect): void;
  57156. /**
  57157. * Sets the required values for both the emissive texture and and the main color.
  57158. */
  57159. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57160. /**
  57161. * Returns true if the mesh should render, otherwise false.
  57162. * @param mesh The mesh to render
  57163. * @returns true if it should render otherwise false
  57164. */
  57165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57166. /**
  57167. * Adds specific effects defines.
  57168. * @param defines The defines to add specifics to.
  57169. */
  57170. protected _addCustomEffectDefines(defines: string[]): void;
  57171. /**
  57172. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57173. * @param mesh The mesh to exclude from the glow layer
  57174. */
  57175. addExcludedMesh(mesh: Mesh): void;
  57176. /**
  57177. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57178. * @param mesh The mesh to remove
  57179. */
  57180. removeExcludedMesh(mesh: Mesh): void;
  57181. /**
  57182. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57183. * @param mesh The mesh to include in the glow layer
  57184. */
  57185. addIncludedOnlyMesh(mesh: Mesh): void;
  57186. /**
  57187. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57188. * @param mesh The mesh to remove
  57189. */
  57190. removeIncludedOnlyMesh(mesh: Mesh): void;
  57191. /**
  57192. * Determine if a given mesh will be used in the glow layer
  57193. * @param mesh The mesh to test
  57194. * @returns true if the mesh will be highlighted by the current glow layer
  57195. */
  57196. hasMesh(mesh: AbstractMesh): boolean;
  57197. /**
  57198. * Defines whether the current material of the mesh should be use to render the effect.
  57199. * @param mesh defines the current mesh to render
  57200. */
  57201. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57202. /**
  57203. * Add a mesh to be rendered through its own material and not with emissive only.
  57204. * @param mesh The mesh for which we need to use its material
  57205. */
  57206. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57207. /**
  57208. * Remove a mesh from being rendered through its own material and not with emissive only.
  57209. * @param mesh The mesh for which we need to not use its material
  57210. */
  57211. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57212. /**
  57213. * Free any resources and references associated to a mesh.
  57214. * Internal use
  57215. * @param mesh The mesh to free.
  57216. * @hidden
  57217. */
  57218. _disposeMesh(mesh: Mesh): void;
  57219. /**
  57220. * Gets the class name of the effect layer
  57221. * @returns the string with the class name of the effect layer
  57222. */
  57223. getClassName(): string;
  57224. /**
  57225. * Serializes this glow layer
  57226. * @returns a serialized glow layer object
  57227. */
  57228. serialize(): any;
  57229. /**
  57230. * Creates a Glow Layer from parsed glow layer data
  57231. * @param parsedGlowLayer defines glow layer data
  57232. * @param scene defines the current scene
  57233. * @param rootUrl defines the root URL containing the glow layer information
  57234. * @returns a parsed Glow Layer
  57235. */
  57236. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57237. }
  57238. }
  57239. declare module BABYLON {
  57240. /** @hidden */
  57241. export var glowBlurPostProcessPixelShader: {
  57242. name: string;
  57243. shader: string;
  57244. };
  57245. }
  57246. declare module BABYLON {
  57247. interface AbstractScene {
  57248. /**
  57249. * Return a the first highlight layer of the scene with a given name.
  57250. * @param name The name of the highlight layer to look for.
  57251. * @return The highlight layer if found otherwise null.
  57252. */
  57253. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57254. }
  57255. /**
  57256. * Highlight layer options. This helps customizing the behaviour
  57257. * of the highlight layer.
  57258. */
  57259. export interface IHighlightLayerOptions {
  57260. /**
  57261. * Multiplication factor apply to the canvas size to compute the render target size
  57262. * used to generated the glowing objects (the smaller the faster).
  57263. */
  57264. mainTextureRatio: number;
  57265. /**
  57266. * Enforces a fixed size texture to ensure resize independant blur.
  57267. */
  57268. mainTextureFixedSize?: number;
  57269. /**
  57270. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57271. * of the picture to blur (the smaller the faster).
  57272. */
  57273. blurTextureSizeRatio: number;
  57274. /**
  57275. * How big in texel of the blur texture is the vertical blur.
  57276. */
  57277. blurVerticalSize: number;
  57278. /**
  57279. * How big in texel of the blur texture is the horizontal blur.
  57280. */
  57281. blurHorizontalSize: number;
  57282. /**
  57283. * Alpha blending mode used to apply the blur. Default is combine.
  57284. */
  57285. alphaBlendingMode: number;
  57286. /**
  57287. * The camera attached to the layer.
  57288. */
  57289. camera: Nullable<Camera>;
  57290. /**
  57291. * Should we display highlight as a solid stroke?
  57292. */
  57293. isStroke?: boolean;
  57294. /**
  57295. * The rendering group to draw the layer in.
  57296. */
  57297. renderingGroupId: number;
  57298. }
  57299. /**
  57300. * The highlight layer Helps adding a glow effect around a mesh.
  57301. *
  57302. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57303. * glowy meshes to your scene.
  57304. *
  57305. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57306. */
  57307. export class HighlightLayer extends EffectLayer {
  57308. name: string;
  57309. /**
  57310. * Effect Name of the highlight layer.
  57311. */
  57312. static readonly EffectName: string;
  57313. /**
  57314. * The neutral color used during the preparation of the glow effect.
  57315. * This is black by default as the blend operation is a blend operation.
  57316. */
  57317. static NeutralColor: Color4;
  57318. /**
  57319. * Stencil value used for glowing meshes.
  57320. */
  57321. static GlowingMeshStencilReference: number;
  57322. /**
  57323. * Stencil value used for the other meshes in the scene.
  57324. */
  57325. static NormalMeshStencilReference: number;
  57326. /**
  57327. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57328. */
  57329. innerGlow: boolean;
  57330. /**
  57331. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57332. */
  57333. outerGlow: boolean;
  57334. /**
  57335. * Specifies the horizontal size of the blur.
  57336. */
  57337. set blurHorizontalSize(value: number);
  57338. /**
  57339. * Specifies the vertical size of the blur.
  57340. */
  57341. set blurVerticalSize(value: number);
  57342. /**
  57343. * Gets the horizontal size of the blur.
  57344. */
  57345. get blurHorizontalSize(): number;
  57346. /**
  57347. * Gets the vertical size of the blur.
  57348. */
  57349. get blurVerticalSize(): number;
  57350. /**
  57351. * An event triggered when the highlight layer is being blurred.
  57352. */
  57353. onBeforeBlurObservable: Observable<HighlightLayer>;
  57354. /**
  57355. * An event triggered when the highlight layer has been blurred.
  57356. */
  57357. onAfterBlurObservable: Observable<HighlightLayer>;
  57358. private _instanceGlowingMeshStencilReference;
  57359. private _options;
  57360. private _downSamplePostprocess;
  57361. private _horizontalBlurPostprocess;
  57362. private _verticalBlurPostprocess;
  57363. private _blurTexture;
  57364. private _meshes;
  57365. private _excludedMeshes;
  57366. /**
  57367. * Instantiates a new highlight Layer and references it to the scene..
  57368. * @param name The name of the layer
  57369. * @param scene The scene to use the layer in
  57370. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57371. */
  57372. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57373. /**
  57374. * Get the effect name of the layer.
  57375. * @return The effect name
  57376. */
  57377. getEffectName(): string;
  57378. /**
  57379. * Create the merge effect. This is the shader use to blit the information back
  57380. * to the main canvas at the end of the scene rendering.
  57381. */
  57382. protected _createMergeEffect(): Effect;
  57383. /**
  57384. * Creates the render target textures and post processes used in the highlight layer.
  57385. */
  57386. protected _createTextureAndPostProcesses(): void;
  57387. /**
  57388. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57389. */
  57390. needStencil(): boolean;
  57391. /**
  57392. * Checks for the readiness of the element composing the layer.
  57393. * @param subMesh the mesh to check for
  57394. * @param useInstances specify wether or not to use instances to render the mesh
  57395. * @param emissiveTexture the associated emissive texture used to generate the glow
  57396. * @return true if ready otherwise, false
  57397. */
  57398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57399. /**
  57400. * Implementation specific of rendering the generating effect on the main canvas.
  57401. * @param effect The effect used to render through
  57402. */
  57403. protected _internalRender(effect: Effect): void;
  57404. /**
  57405. * Returns true if the layer contains information to display, otherwise false.
  57406. */
  57407. shouldRender(): boolean;
  57408. /**
  57409. * Returns true if the mesh should render, otherwise false.
  57410. * @param mesh The mesh to render
  57411. * @returns true if it should render otherwise false
  57412. */
  57413. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57414. /**
  57415. * Adds specific effects defines.
  57416. * @param defines The defines to add specifics to.
  57417. */
  57418. protected _addCustomEffectDefines(defines: string[]): void;
  57419. /**
  57420. * Sets the required values for both the emissive texture and and the main color.
  57421. */
  57422. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57423. /**
  57424. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57425. * @param mesh The mesh to exclude from the highlight layer
  57426. */
  57427. addExcludedMesh(mesh: Mesh): void;
  57428. /**
  57429. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57430. * @param mesh The mesh to highlight
  57431. */
  57432. removeExcludedMesh(mesh: Mesh): void;
  57433. /**
  57434. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57435. * @param mesh mesh to test
  57436. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57437. */
  57438. hasMesh(mesh: AbstractMesh): boolean;
  57439. /**
  57440. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57441. * @param mesh The mesh to highlight
  57442. * @param color The color of the highlight
  57443. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57444. */
  57445. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57446. /**
  57447. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57448. * @param mesh The mesh to highlight
  57449. */
  57450. removeMesh(mesh: Mesh): void;
  57451. /**
  57452. * Remove all the meshes currently referenced in the highlight layer
  57453. */
  57454. removeAllMeshes(): void;
  57455. /**
  57456. * Force the stencil to the normal expected value for none glowing parts
  57457. */
  57458. private _defaultStencilReference;
  57459. /**
  57460. * Free any resources and references associated to a mesh.
  57461. * Internal use
  57462. * @param mesh The mesh to free.
  57463. * @hidden
  57464. */
  57465. _disposeMesh(mesh: Mesh): void;
  57466. /**
  57467. * Dispose the highlight layer and free resources.
  57468. */
  57469. dispose(): void;
  57470. /**
  57471. * Gets the class name of the effect layer
  57472. * @returns the string with the class name of the effect layer
  57473. */
  57474. getClassName(): string;
  57475. /**
  57476. * Serializes this Highlight layer
  57477. * @returns a serialized Highlight layer object
  57478. */
  57479. serialize(): any;
  57480. /**
  57481. * Creates a Highlight layer from parsed Highlight layer data
  57482. * @param parsedHightlightLayer defines the Highlight layer data
  57483. * @param scene defines the current scene
  57484. * @param rootUrl defines the root URL containing the Highlight layer information
  57485. * @returns a parsed Highlight layer
  57486. */
  57487. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57488. }
  57489. }
  57490. declare module BABYLON {
  57491. interface AbstractScene {
  57492. /**
  57493. * The list of layers (background and foreground) of the scene
  57494. */
  57495. layers: Array<Layer>;
  57496. }
  57497. /**
  57498. * Defines the layer scene component responsible to manage any layers
  57499. * in a given scene.
  57500. */
  57501. export class LayerSceneComponent implements ISceneComponent {
  57502. /**
  57503. * The component name helpfull to identify the component in the list of scene components.
  57504. */
  57505. readonly name: string;
  57506. /**
  57507. * The scene the component belongs to.
  57508. */
  57509. scene: Scene;
  57510. private _engine;
  57511. /**
  57512. * Creates a new instance of the component for the given scene
  57513. * @param scene Defines the scene to register the component in
  57514. */
  57515. constructor(scene: Scene);
  57516. /**
  57517. * Registers the component in a given scene
  57518. */
  57519. register(): void;
  57520. /**
  57521. * Rebuilds the elements related to this component in case of
  57522. * context lost for instance.
  57523. */
  57524. rebuild(): void;
  57525. /**
  57526. * Disposes the component and the associated ressources.
  57527. */
  57528. dispose(): void;
  57529. private _draw;
  57530. private _drawCameraPredicate;
  57531. private _drawCameraBackground;
  57532. private _drawCameraForeground;
  57533. private _drawRenderTargetPredicate;
  57534. private _drawRenderTargetBackground;
  57535. private _drawRenderTargetForeground;
  57536. /**
  57537. * Adds all the elements from the container to the scene
  57538. * @param container the container holding the elements
  57539. */
  57540. addFromContainer(container: AbstractScene): void;
  57541. /**
  57542. * Removes all the elements in the container from the scene
  57543. * @param container contains the elements to remove
  57544. * @param dispose if the removed element should be disposed (default: false)
  57545. */
  57546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57547. }
  57548. }
  57549. declare module BABYLON {
  57550. /** @hidden */
  57551. export var layerPixelShader: {
  57552. name: string;
  57553. shader: string;
  57554. };
  57555. }
  57556. declare module BABYLON {
  57557. /** @hidden */
  57558. export var layerVertexShader: {
  57559. name: string;
  57560. shader: string;
  57561. };
  57562. }
  57563. declare module BABYLON {
  57564. /**
  57565. * This represents a full screen 2d layer.
  57566. * This can be useful to display a picture in the background of your scene for instance.
  57567. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57568. */
  57569. export class Layer {
  57570. /**
  57571. * Define the name of the layer.
  57572. */
  57573. name: string;
  57574. /**
  57575. * Define the texture the layer should display.
  57576. */
  57577. texture: Nullable<Texture>;
  57578. /**
  57579. * Is the layer in background or foreground.
  57580. */
  57581. isBackground: boolean;
  57582. /**
  57583. * Define the color of the layer (instead of texture).
  57584. */
  57585. color: Color4;
  57586. /**
  57587. * Define the scale of the layer in order to zoom in out of the texture.
  57588. */
  57589. scale: Vector2;
  57590. /**
  57591. * Define an offset for the layer in order to shift the texture.
  57592. */
  57593. offset: Vector2;
  57594. /**
  57595. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57596. */
  57597. alphaBlendingMode: number;
  57598. /**
  57599. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57600. * Alpha test will not mix with the background color in case of transparency.
  57601. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57602. */
  57603. alphaTest: boolean;
  57604. /**
  57605. * Define a mask to restrict the layer to only some of the scene cameras.
  57606. */
  57607. layerMask: number;
  57608. /**
  57609. * Define the list of render target the layer is visible into.
  57610. */
  57611. renderTargetTextures: RenderTargetTexture[];
  57612. /**
  57613. * Define if the layer is only used in renderTarget or if it also
  57614. * renders in the main frame buffer of the canvas.
  57615. */
  57616. renderOnlyInRenderTargetTextures: boolean;
  57617. private _scene;
  57618. private _vertexBuffers;
  57619. private _indexBuffer;
  57620. private _effect;
  57621. private _previousDefines;
  57622. /**
  57623. * An event triggered when the layer is disposed.
  57624. */
  57625. onDisposeObservable: Observable<Layer>;
  57626. private _onDisposeObserver;
  57627. /**
  57628. * Back compatibility with callback before the onDisposeObservable existed.
  57629. * The set callback will be triggered when the layer has been disposed.
  57630. */
  57631. set onDispose(callback: () => void);
  57632. /**
  57633. * An event triggered before rendering the scene
  57634. */
  57635. onBeforeRenderObservable: Observable<Layer>;
  57636. private _onBeforeRenderObserver;
  57637. /**
  57638. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57639. * The set callback will be triggered just before rendering the layer.
  57640. */
  57641. set onBeforeRender(callback: () => void);
  57642. /**
  57643. * An event triggered after rendering the scene
  57644. */
  57645. onAfterRenderObservable: Observable<Layer>;
  57646. private _onAfterRenderObserver;
  57647. /**
  57648. * Back compatibility with callback before the onAfterRenderObservable existed.
  57649. * The set callback will be triggered just after rendering the layer.
  57650. */
  57651. set onAfterRender(callback: () => void);
  57652. /**
  57653. * Instantiates a new layer.
  57654. * This represents a full screen 2d layer.
  57655. * This can be useful to display a picture in the background of your scene for instance.
  57656. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57657. * @param name Define the name of the layer in the scene
  57658. * @param imgUrl Define the url of the texture to display in the layer
  57659. * @param scene Define the scene the layer belongs to
  57660. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57661. * @param color Defines a color for the layer
  57662. */
  57663. constructor(
  57664. /**
  57665. * Define the name of the layer.
  57666. */
  57667. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57668. private _createIndexBuffer;
  57669. /** @hidden */
  57670. _rebuild(): void;
  57671. /**
  57672. * Renders the layer in the scene.
  57673. */
  57674. render(): void;
  57675. /**
  57676. * Disposes and releases the associated ressources.
  57677. */
  57678. dispose(): void;
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /** @hidden */
  57683. export var lensFlarePixelShader: {
  57684. name: string;
  57685. shader: string;
  57686. };
  57687. }
  57688. declare module BABYLON {
  57689. /** @hidden */
  57690. export var lensFlareVertexShader: {
  57691. name: string;
  57692. shader: string;
  57693. };
  57694. }
  57695. declare module BABYLON {
  57696. /**
  57697. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57698. * It is usually composed of several `lensFlare`.
  57699. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57700. */
  57701. export class LensFlareSystem {
  57702. /**
  57703. * Define the name of the lens flare system
  57704. */
  57705. name: string;
  57706. /**
  57707. * List of lens flares used in this system.
  57708. */
  57709. lensFlares: LensFlare[];
  57710. /**
  57711. * Define a limit from the border the lens flare can be visible.
  57712. */
  57713. borderLimit: number;
  57714. /**
  57715. * Define a viewport border we do not want to see the lens flare in.
  57716. */
  57717. viewportBorder: number;
  57718. /**
  57719. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57720. */
  57721. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57722. /**
  57723. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57724. */
  57725. layerMask: number;
  57726. /**
  57727. * Define the id of the lens flare system in the scene.
  57728. * (equal to name by default)
  57729. */
  57730. id: string;
  57731. private _scene;
  57732. private _emitter;
  57733. private _vertexBuffers;
  57734. private _indexBuffer;
  57735. private _effect;
  57736. private _positionX;
  57737. private _positionY;
  57738. private _isEnabled;
  57739. /** @hidden */
  57740. static _SceneComponentInitialization: (scene: Scene) => void;
  57741. /**
  57742. * Instantiates a lens flare system.
  57743. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57744. * It is usually composed of several `lensFlare`.
  57745. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57746. * @param name Define the name of the lens flare system in the scene
  57747. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57748. * @param scene Define the scene the lens flare system belongs to
  57749. */
  57750. constructor(
  57751. /**
  57752. * Define the name of the lens flare system
  57753. */
  57754. name: string, emitter: any, scene: Scene);
  57755. /**
  57756. * Define if the lens flare system is enabled.
  57757. */
  57758. get isEnabled(): boolean;
  57759. set isEnabled(value: boolean);
  57760. /**
  57761. * Get the scene the effects belongs to.
  57762. * @returns the scene holding the lens flare system
  57763. */
  57764. getScene(): Scene;
  57765. /**
  57766. * Get the emitter of the lens flare system.
  57767. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57768. * @returns the emitter of the lens flare system
  57769. */
  57770. getEmitter(): any;
  57771. /**
  57772. * Set the emitter of the lens flare system.
  57773. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57774. * @param newEmitter Define the new emitter of the system
  57775. */
  57776. setEmitter(newEmitter: any): void;
  57777. /**
  57778. * Get the lens flare system emitter position.
  57779. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57780. * @returns the position
  57781. */
  57782. getEmitterPosition(): Vector3;
  57783. /**
  57784. * @hidden
  57785. */
  57786. computeEffectivePosition(globalViewport: Viewport): boolean;
  57787. /** @hidden */
  57788. _isVisible(): boolean;
  57789. /**
  57790. * @hidden
  57791. */
  57792. render(): boolean;
  57793. /**
  57794. * Dispose and release the lens flare with its associated resources.
  57795. */
  57796. dispose(): void;
  57797. /**
  57798. * Parse a lens flare system from a JSON repressentation
  57799. * @param parsedLensFlareSystem Define the JSON to parse
  57800. * @param scene Define the scene the parsed system should be instantiated in
  57801. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57802. * @returns the parsed system
  57803. */
  57804. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57805. /**
  57806. * Serialize the current Lens Flare System into a JSON representation.
  57807. * @returns the serialized JSON
  57808. */
  57809. serialize(): any;
  57810. }
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * This represents one of the lens effect in a `lensFlareSystem`.
  57815. * It controls one of the indiviual texture used in the effect.
  57816. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57817. */
  57818. export class LensFlare {
  57819. /**
  57820. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57821. */
  57822. size: number;
  57823. /**
  57824. * 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.
  57825. */
  57826. position: number;
  57827. /**
  57828. * Define the lens color.
  57829. */
  57830. color: Color3;
  57831. /**
  57832. * Define the lens texture.
  57833. */
  57834. texture: Nullable<Texture>;
  57835. /**
  57836. * Define the alpha mode to render this particular lens.
  57837. */
  57838. alphaMode: number;
  57839. private _system;
  57840. /**
  57841. * Creates a new Lens Flare.
  57842. * This represents one of the lens effect in a `lensFlareSystem`.
  57843. * It controls one of the indiviual texture used in the effect.
  57844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57845. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57846. * @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.
  57847. * @param color Define the lens color
  57848. * @param imgUrl Define the lens texture url
  57849. * @param system Define the `lensFlareSystem` this flare is part of
  57850. * @returns The newly created Lens Flare
  57851. */
  57852. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57853. /**
  57854. * Instantiates a new Lens Flare.
  57855. * This represents one of the lens effect in a `lensFlareSystem`.
  57856. * It controls one of the indiviual texture used in the effect.
  57857. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57858. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57859. * @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.
  57860. * @param color Define the lens color
  57861. * @param imgUrl Define the lens texture url
  57862. * @param system Define the `lensFlareSystem` this flare is part of
  57863. */
  57864. constructor(
  57865. /**
  57866. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57867. */
  57868. size: number,
  57869. /**
  57870. * 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.
  57871. */
  57872. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57873. /**
  57874. * Dispose and release the lens flare with its associated resources.
  57875. */
  57876. dispose(): void;
  57877. }
  57878. }
  57879. declare module BABYLON {
  57880. interface AbstractScene {
  57881. /**
  57882. * The list of lens flare system added to the scene
  57883. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57884. */
  57885. lensFlareSystems: Array<LensFlareSystem>;
  57886. /**
  57887. * Removes the given lens flare system from this scene.
  57888. * @param toRemove The lens flare system to remove
  57889. * @returns The index of the removed lens flare system
  57890. */
  57891. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57892. /**
  57893. * Adds the given lens flare system to this scene
  57894. * @param newLensFlareSystem The lens flare system to add
  57895. */
  57896. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57897. /**
  57898. * Gets a lens flare system using its name
  57899. * @param name defines the name to look for
  57900. * @returns the lens flare system or null if not found
  57901. */
  57902. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57903. /**
  57904. * Gets a lens flare system using its id
  57905. * @param id defines the id to look for
  57906. * @returns the lens flare system or null if not found
  57907. */
  57908. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57909. }
  57910. /**
  57911. * Defines the lens flare scene component responsible to manage any lens flares
  57912. * in a given scene.
  57913. */
  57914. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57915. /**
  57916. * The component name helpfull to identify the component in the list of scene components.
  57917. */
  57918. readonly name: string;
  57919. /**
  57920. * The scene the component belongs to.
  57921. */
  57922. scene: Scene;
  57923. /**
  57924. * Creates a new instance of the component for the given scene
  57925. * @param scene Defines the scene to register the component in
  57926. */
  57927. constructor(scene: Scene);
  57928. /**
  57929. * Registers the component in a given scene
  57930. */
  57931. register(): void;
  57932. /**
  57933. * Rebuilds the elements related to this component in case of
  57934. * context lost for instance.
  57935. */
  57936. rebuild(): void;
  57937. /**
  57938. * Adds all the elements from the container to the scene
  57939. * @param container the container holding the elements
  57940. */
  57941. addFromContainer(container: AbstractScene): void;
  57942. /**
  57943. * Removes all the elements in the container from the scene
  57944. * @param container contains the elements to remove
  57945. * @param dispose if the removed element should be disposed (default: false)
  57946. */
  57947. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57948. /**
  57949. * Serializes the component data to the specified json object
  57950. * @param serializationObject The object to serialize to
  57951. */
  57952. serialize(serializationObject: any): void;
  57953. /**
  57954. * Disposes the component and the associated ressources.
  57955. */
  57956. dispose(): void;
  57957. private _draw;
  57958. }
  57959. }
  57960. declare module BABYLON {
  57961. /** @hidden */
  57962. export var depthPixelShader: {
  57963. name: string;
  57964. shader: string;
  57965. };
  57966. }
  57967. declare module BABYLON {
  57968. /** @hidden */
  57969. export var depthVertexShader: {
  57970. name: string;
  57971. shader: string;
  57972. };
  57973. }
  57974. declare module BABYLON {
  57975. /**
  57976. * This represents a depth renderer in Babylon.
  57977. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57978. */
  57979. export class DepthRenderer {
  57980. private _scene;
  57981. private _depthMap;
  57982. private _effect;
  57983. private readonly _storeNonLinearDepth;
  57984. private readonly _clearColor;
  57985. /** Get if the depth renderer is using packed depth or not */
  57986. readonly isPacked: boolean;
  57987. private _cachedDefines;
  57988. private _camera;
  57989. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57990. enabled: boolean;
  57991. /**
  57992. * Specifiess that the depth renderer will only be used within
  57993. * the camera it is created for.
  57994. * This can help forcing its rendering during the camera processing.
  57995. */
  57996. useOnlyInActiveCamera: boolean;
  57997. /** @hidden */
  57998. static _SceneComponentInitialization: (scene: Scene) => void;
  57999. /**
  58000. * Instantiates a depth renderer
  58001. * @param scene The scene the renderer belongs to
  58002. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58003. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58004. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58005. */
  58006. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58007. /**
  58008. * Creates the depth rendering effect and checks if the effect is ready.
  58009. * @param subMesh The submesh to be used to render the depth map of
  58010. * @param useInstances If multiple world instances should be used
  58011. * @returns if the depth renderer is ready to render the depth map
  58012. */
  58013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58014. /**
  58015. * Gets the texture which the depth map will be written to.
  58016. * @returns The depth map texture
  58017. */
  58018. getDepthMap(): RenderTargetTexture;
  58019. /**
  58020. * Disposes of the depth renderer.
  58021. */
  58022. dispose(): void;
  58023. }
  58024. }
  58025. declare module BABYLON {
  58026. /** @hidden */
  58027. export var minmaxReduxPixelShader: {
  58028. name: string;
  58029. shader: string;
  58030. };
  58031. }
  58032. declare module BABYLON {
  58033. /**
  58034. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58035. * and maximum values from all values of the texture.
  58036. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58037. * The source values are read from the red channel of the texture.
  58038. */
  58039. export class MinMaxReducer {
  58040. /**
  58041. * Observable triggered when the computation has been performed
  58042. */
  58043. onAfterReductionPerformed: Observable<{
  58044. min: number;
  58045. max: number;
  58046. }>;
  58047. protected _camera: Camera;
  58048. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58049. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58050. protected _postProcessManager: PostProcessManager;
  58051. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58052. protected _forceFullscreenViewport: boolean;
  58053. /**
  58054. * Creates a min/max reducer
  58055. * @param camera The camera to use for the post processes
  58056. */
  58057. constructor(camera: Camera);
  58058. /**
  58059. * Gets the texture used to read the values from.
  58060. */
  58061. get sourceTexture(): Nullable<RenderTargetTexture>;
  58062. /**
  58063. * Sets the source texture to read the values from.
  58064. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58065. * because in such textures '1' value must not be taken into account to compute the maximum
  58066. * as this value is used to clear the texture.
  58067. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58068. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58069. * @param depthRedux Indicates if the texture is a depth texture or not
  58070. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58071. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58072. */
  58073. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58074. /**
  58075. * Defines the refresh rate of the computation.
  58076. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58077. */
  58078. get refreshRate(): number;
  58079. set refreshRate(value: number);
  58080. protected _activated: boolean;
  58081. /**
  58082. * Gets the activation status of the reducer
  58083. */
  58084. get activated(): boolean;
  58085. /**
  58086. * Activates the reduction computation.
  58087. * When activated, the observers registered in onAfterReductionPerformed are
  58088. * called after the compuation is performed
  58089. */
  58090. activate(): void;
  58091. /**
  58092. * Deactivates the reduction computation.
  58093. */
  58094. deactivate(): void;
  58095. /**
  58096. * Disposes the min/max reducer
  58097. * @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.
  58098. */
  58099. dispose(disposeAll?: boolean): void;
  58100. }
  58101. }
  58102. declare module BABYLON {
  58103. /**
  58104. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58105. */
  58106. export class DepthReducer extends MinMaxReducer {
  58107. private _depthRenderer;
  58108. private _depthRendererId;
  58109. /**
  58110. * Gets the depth renderer used for the computation.
  58111. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58112. */
  58113. get depthRenderer(): Nullable<DepthRenderer>;
  58114. /**
  58115. * Creates a depth reducer
  58116. * @param camera The camera used to render the depth texture
  58117. */
  58118. constructor(camera: Camera);
  58119. /**
  58120. * Sets the depth renderer to use to generate the depth map
  58121. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58122. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58123. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58124. */
  58125. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58126. /** @hidden */
  58127. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58128. /**
  58129. * Activates the reduction computation.
  58130. * When activated, the observers registered in onAfterReductionPerformed are
  58131. * called after the compuation is performed
  58132. */
  58133. activate(): void;
  58134. /**
  58135. * Deactivates the reduction computation.
  58136. */
  58137. deactivate(): void;
  58138. /**
  58139. * Disposes the depth reducer
  58140. * @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.
  58141. */
  58142. dispose(disposeAll?: boolean): void;
  58143. }
  58144. }
  58145. declare module BABYLON {
  58146. /**
  58147. * A CSM implementation allowing casting shadows on large scenes.
  58148. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58149. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58150. */
  58151. export class CascadedShadowGenerator extends ShadowGenerator {
  58152. private static readonly frustumCornersNDCSpace;
  58153. /**
  58154. * Name of the CSM class
  58155. */
  58156. static CLASSNAME: string;
  58157. /**
  58158. * Defines the default number of cascades used by the CSM.
  58159. */
  58160. static readonly DEFAULT_CASCADES_COUNT: number;
  58161. /**
  58162. * Defines the minimum number of cascades used by the CSM.
  58163. */
  58164. static readonly MIN_CASCADES_COUNT: number;
  58165. /**
  58166. * Defines the maximum number of cascades used by the CSM.
  58167. */
  58168. static readonly MAX_CASCADES_COUNT: number;
  58169. protected _validateFilter(filter: number): number;
  58170. /**
  58171. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58172. */
  58173. penumbraDarkness: number;
  58174. private _numCascades;
  58175. /**
  58176. * Gets or set the number of cascades used by the CSM.
  58177. */
  58178. get numCascades(): number;
  58179. set numCascades(value: number);
  58180. /**
  58181. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58182. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58183. */
  58184. stabilizeCascades: boolean;
  58185. private _freezeShadowCastersBoundingInfo;
  58186. private _freezeShadowCastersBoundingInfoObservable;
  58187. /**
  58188. * Enables or disables the shadow casters bounding info computation.
  58189. * If your shadow casters don't move, you can disable this feature.
  58190. * If it is enabled, the bounding box computation is done every frame.
  58191. */
  58192. get freezeShadowCastersBoundingInfo(): boolean;
  58193. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58194. private _scbiMin;
  58195. private _scbiMax;
  58196. protected _computeShadowCastersBoundingInfo(): void;
  58197. protected _shadowCastersBoundingInfo: BoundingInfo;
  58198. /**
  58199. * Gets or sets the shadow casters bounding info.
  58200. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58201. * so that the system won't overwrite the bounds you provide
  58202. */
  58203. get shadowCastersBoundingInfo(): BoundingInfo;
  58204. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58205. protected _breaksAreDirty: boolean;
  58206. protected _minDistance: number;
  58207. protected _maxDistance: number;
  58208. /**
  58209. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58210. *
  58211. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58212. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58213. * @param min minimal distance for the breaks (default to 0.)
  58214. * @param max maximal distance for the breaks (default to 1.)
  58215. */
  58216. setMinMaxDistance(min: number, max: number): void;
  58217. /** Gets the minimal distance used in the cascade break computation */
  58218. get minDistance(): number;
  58219. /** Gets the maximal distance used in the cascade break computation */
  58220. get maxDistance(): number;
  58221. /**
  58222. * Gets the class name of that object
  58223. * @returns "CascadedShadowGenerator"
  58224. */
  58225. getClassName(): string;
  58226. private _cascadeMinExtents;
  58227. private _cascadeMaxExtents;
  58228. /**
  58229. * Gets a cascade minimum extents
  58230. * @param cascadeIndex index of the cascade
  58231. * @returns the minimum cascade extents
  58232. */
  58233. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58234. /**
  58235. * Gets a cascade maximum extents
  58236. * @param cascadeIndex index of the cascade
  58237. * @returns the maximum cascade extents
  58238. */
  58239. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58240. private _cascades;
  58241. private _currentLayer;
  58242. private _viewSpaceFrustumsZ;
  58243. private _viewMatrices;
  58244. private _projectionMatrices;
  58245. private _transformMatrices;
  58246. private _transformMatricesAsArray;
  58247. private _frustumLengths;
  58248. private _lightSizeUVCorrection;
  58249. private _depthCorrection;
  58250. private _frustumCornersWorldSpace;
  58251. private _frustumCenter;
  58252. private _shadowCameraPos;
  58253. private _shadowMaxZ;
  58254. /**
  58255. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58256. * It defaults to camera.maxZ
  58257. */
  58258. get shadowMaxZ(): number;
  58259. /**
  58260. * Sets the shadow max z distance.
  58261. */
  58262. set shadowMaxZ(value: number);
  58263. protected _debug: boolean;
  58264. /**
  58265. * Gets or sets the debug flag.
  58266. * When enabled, the cascades are materialized by different colors on the screen.
  58267. */
  58268. get debug(): boolean;
  58269. set debug(dbg: boolean);
  58270. private _depthClamp;
  58271. /**
  58272. * Gets or sets the depth clamping value.
  58273. *
  58274. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58275. * to account for the shadow casters far away.
  58276. *
  58277. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58278. */
  58279. get depthClamp(): boolean;
  58280. set depthClamp(value: boolean);
  58281. private _cascadeBlendPercentage;
  58282. /**
  58283. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58284. * It defaults to 0.1 (10% blending).
  58285. */
  58286. get cascadeBlendPercentage(): number;
  58287. set cascadeBlendPercentage(value: number);
  58288. private _lambda;
  58289. /**
  58290. * Gets or set the lambda parameter.
  58291. * This parameter is used to split the camera frustum and create the cascades.
  58292. * 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.
  58293. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58294. */
  58295. get lambda(): number;
  58296. set lambda(value: number);
  58297. /**
  58298. * Gets the view matrix corresponding to a given cascade
  58299. * @param cascadeNum cascade to retrieve the view matrix from
  58300. * @returns the cascade view matrix
  58301. */
  58302. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58303. /**
  58304. * Gets the projection matrix corresponding to a given cascade
  58305. * @param cascadeNum cascade to retrieve the projection matrix from
  58306. * @returns the cascade projection matrix
  58307. */
  58308. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58309. /**
  58310. * Gets the transformation matrix corresponding to a given cascade
  58311. * @param cascadeNum cascade to retrieve the transformation matrix from
  58312. * @returns the cascade transformation matrix
  58313. */
  58314. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58315. private _depthRenderer;
  58316. /**
  58317. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58318. *
  58319. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58320. *
  58321. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58322. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58323. * @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
  58324. */
  58325. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58326. private _depthReducer;
  58327. private _autoCalcDepthBounds;
  58328. /**
  58329. * Gets or sets the autoCalcDepthBounds property.
  58330. *
  58331. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58332. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58333. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58334. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58335. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58336. */
  58337. get autoCalcDepthBounds(): boolean;
  58338. set autoCalcDepthBounds(value: boolean);
  58339. /**
  58340. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58341. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58342. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58343. * for setting the refresh rate on the renderer yourself!
  58344. */
  58345. get autoCalcDepthBoundsRefreshRate(): number;
  58346. set autoCalcDepthBoundsRefreshRate(value: number);
  58347. /**
  58348. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58349. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58350. * you change the camera near/far planes!
  58351. */
  58352. splitFrustum(): void;
  58353. private _splitFrustum;
  58354. private _computeMatrices;
  58355. private _computeFrustumInWorldSpace;
  58356. private _computeCascadeFrustum;
  58357. /**
  58358. * Support test.
  58359. */
  58360. static get IsSupported(): boolean;
  58361. /** @hidden */
  58362. static _SceneComponentInitialization: (scene: Scene) => void;
  58363. /**
  58364. * Creates a Cascaded Shadow Generator object.
  58365. * A ShadowGenerator is the required tool to use the shadows.
  58366. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58367. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58368. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58369. * @param light The directional light object generating the shadows.
  58370. * @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.
  58371. */
  58372. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58373. protected _initializeGenerator(): void;
  58374. protected _createTargetRenderTexture(): void;
  58375. protected _initializeShadowMap(): void;
  58376. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58377. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58378. /**
  58379. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58380. * @param defines Defines of the material we want to update
  58381. * @param lightIndex Index of the light in the enabled light list of the material
  58382. */
  58383. prepareDefines(defines: any, lightIndex: number): void;
  58384. /**
  58385. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58386. * defined in the generator but impacting the effect).
  58387. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58388. * @param effect The effect we are binfing the information for
  58389. */
  58390. bindShadowLight(lightIndex: string, effect: Effect): void;
  58391. /**
  58392. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58393. * (eq to view projection * shadow projection matrices)
  58394. * @returns The transform matrix used to create the shadow map
  58395. */
  58396. getTransformMatrix(): Matrix;
  58397. /**
  58398. * Disposes the ShadowGenerator.
  58399. * Returns nothing.
  58400. */
  58401. dispose(): void;
  58402. /**
  58403. * Serializes the shadow generator setup to a json object.
  58404. * @returns The serialized JSON object
  58405. */
  58406. serialize(): any;
  58407. /**
  58408. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58409. * @param parsedShadowGenerator The JSON object to parse
  58410. * @param scene The scene to create the shadow map for
  58411. * @returns The parsed shadow generator
  58412. */
  58413. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58414. }
  58415. }
  58416. declare module BABYLON {
  58417. /**
  58418. * Defines the shadow generator component responsible to manage any shadow generators
  58419. * in a given scene.
  58420. */
  58421. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58422. /**
  58423. * The component name helpfull to identify the component in the list of scene components.
  58424. */
  58425. readonly name: string;
  58426. /**
  58427. * The scene the component belongs to.
  58428. */
  58429. scene: Scene;
  58430. /**
  58431. * Creates a new instance of the component for the given scene
  58432. * @param scene Defines the scene to register the component in
  58433. */
  58434. constructor(scene: Scene);
  58435. /**
  58436. * Registers the component in a given scene
  58437. */
  58438. register(): void;
  58439. /**
  58440. * Rebuilds the elements related to this component in case of
  58441. * context lost for instance.
  58442. */
  58443. rebuild(): void;
  58444. /**
  58445. * Serializes the component data to the specified json object
  58446. * @param serializationObject The object to serialize to
  58447. */
  58448. serialize(serializationObject: any): void;
  58449. /**
  58450. * Adds all the elements from the container to the scene
  58451. * @param container the container holding the elements
  58452. */
  58453. addFromContainer(container: AbstractScene): void;
  58454. /**
  58455. * Removes all the elements in the container from the scene
  58456. * @param container contains the elements to remove
  58457. * @param dispose if the removed element should be disposed (default: false)
  58458. */
  58459. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58460. /**
  58461. * Rebuilds the elements related to this component in case of
  58462. * context lost for instance.
  58463. */
  58464. dispose(): void;
  58465. private _gatherRenderTargets;
  58466. }
  58467. }
  58468. declare module BABYLON {
  58469. /**
  58470. * A point light is a light defined by an unique point in world space.
  58471. * The light is emitted in every direction from this point.
  58472. * A good example of a point light is a standard light bulb.
  58473. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58474. */
  58475. export class PointLight extends ShadowLight {
  58476. private _shadowAngle;
  58477. /**
  58478. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58479. * This specifies what angle the shadow will use to be created.
  58480. *
  58481. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58482. */
  58483. get shadowAngle(): number;
  58484. /**
  58485. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58486. * This specifies what angle the shadow will use to be created.
  58487. *
  58488. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58489. */
  58490. set shadowAngle(value: number);
  58491. /**
  58492. * Gets the direction if it has been set.
  58493. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58494. */
  58495. get direction(): Vector3;
  58496. /**
  58497. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58498. */
  58499. set direction(value: Vector3);
  58500. /**
  58501. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58502. * A PointLight emits the light in every direction.
  58503. * It can cast shadows.
  58504. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58505. * ```javascript
  58506. * var pointLight = new PointLight("pl", camera.position, scene);
  58507. * ```
  58508. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58509. * @param name The light friendly name
  58510. * @param position The position of the point light in the scene
  58511. * @param scene The scene the lights belongs to
  58512. */
  58513. constructor(name: string, position: Vector3, scene: Scene);
  58514. /**
  58515. * Returns the string "PointLight"
  58516. * @returns the class name
  58517. */
  58518. getClassName(): string;
  58519. /**
  58520. * Returns the integer 0.
  58521. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58522. */
  58523. getTypeID(): number;
  58524. /**
  58525. * Specifies wether or not the shadowmap should be a cube texture.
  58526. * @returns true if the shadowmap needs to be a cube texture.
  58527. */
  58528. needCube(): boolean;
  58529. /**
  58530. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58531. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58532. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58533. */
  58534. getShadowDirection(faceIndex?: number): Vector3;
  58535. /**
  58536. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58537. * - fov = PI / 2
  58538. * - aspect ratio : 1.0
  58539. * - z-near and far equal to the active camera minZ and maxZ.
  58540. * Returns the PointLight.
  58541. */
  58542. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58543. protected _buildUniformLayout(): void;
  58544. /**
  58545. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58546. * @param effect The effect to update
  58547. * @param lightIndex The index of the light in the effect to update
  58548. * @returns The point light
  58549. */
  58550. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58551. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58552. /**
  58553. * Prepares the list of defines specific to the light type.
  58554. * @param defines the list of defines
  58555. * @param lightIndex defines the index of the light for the effect
  58556. */
  58557. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /**
  58562. * Header information of HDR texture files.
  58563. */
  58564. export interface HDRInfo {
  58565. /**
  58566. * The height of the texture in pixels.
  58567. */
  58568. height: number;
  58569. /**
  58570. * The width of the texture in pixels.
  58571. */
  58572. width: number;
  58573. /**
  58574. * The index of the beginning of the data in the binary file.
  58575. */
  58576. dataPosition: number;
  58577. }
  58578. /**
  58579. * This groups tools to convert HDR texture to native colors array.
  58580. */
  58581. export class HDRTools {
  58582. private static Ldexp;
  58583. private static Rgbe2float;
  58584. private static readStringLine;
  58585. /**
  58586. * Reads header information from an RGBE texture stored in a native array.
  58587. * More information on this format are available here:
  58588. * https://en.wikipedia.org/wiki/RGBE_image_format
  58589. *
  58590. * @param uint8array The binary file stored in native array.
  58591. * @return The header information.
  58592. */
  58593. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58594. /**
  58595. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58596. * This RGBE texture needs to store the information as a panorama.
  58597. *
  58598. * More information on this format are available here:
  58599. * https://en.wikipedia.org/wiki/RGBE_image_format
  58600. *
  58601. * @param buffer The binary file stored in an array buffer.
  58602. * @param size The expected size of the extracted cubemap.
  58603. * @return The Cube Map information.
  58604. */
  58605. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58606. /**
  58607. * Returns the pixels data extracted from an RGBE texture.
  58608. * This pixels will be stored left to right up to down in the R G B order in one array.
  58609. *
  58610. * More information on this format are available here:
  58611. * https://en.wikipedia.org/wiki/RGBE_image_format
  58612. *
  58613. * @param uint8array The binary file stored in an array buffer.
  58614. * @param hdrInfo The header information of the file.
  58615. * @return The pixels data in RGB right to left up to down order.
  58616. */
  58617. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58618. private static RGBE_ReadPixels_RLE;
  58619. }
  58620. }
  58621. declare module BABYLON {
  58622. /**
  58623. * Effect Render Options
  58624. */
  58625. export interface IEffectRendererOptions {
  58626. /**
  58627. * Defines the vertices positions.
  58628. */
  58629. positions?: number[];
  58630. /**
  58631. * Defines the indices.
  58632. */
  58633. indices?: number[];
  58634. }
  58635. /**
  58636. * Helper class to render one or more effects.
  58637. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58638. */
  58639. export class EffectRenderer {
  58640. private engine;
  58641. private static _DefaultOptions;
  58642. private _vertexBuffers;
  58643. private _indexBuffer;
  58644. private _fullscreenViewport;
  58645. /**
  58646. * Creates an effect renderer
  58647. * @param engine the engine to use for rendering
  58648. * @param options defines the options of the effect renderer
  58649. */
  58650. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58651. /**
  58652. * Sets the current viewport in normalized coordinates 0-1
  58653. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58654. */
  58655. setViewport(viewport?: Viewport): void;
  58656. /**
  58657. * Binds the embedded attributes buffer to the effect.
  58658. * @param effect Defines the effect to bind the attributes for
  58659. */
  58660. bindBuffers(effect: Effect): void;
  58661. /**
  58662. * Sets the current effect wrapper to use during draw.
  58663. * The effect needs to be ready before calling this api.
  58664. * This also sets the default full screen position attribute.
  58665. * @param effectWrapper Defines the effect to draw with
  58666. */
  58667. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58668. /**
  58669. * Restores engine states
  58670. */
  58671. restoreStates(): void;
  58672. /**
  58673. * Draws a full screen quad.
  58674. */
  58675. draw(): void;
  58676. private isRenderTargetTexture;
  58677. /**
  58678. * renders one or more effects to a specified texture
  58679. * @param effectWrapper the effect to renderer
  58680. * @param outputTexture texture to draw to, if null it will render to the screen.
  58681. */
  58682. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58683. /**
  58684. * Disposes of the effect renderer
  58685. */
  58686. dispose(): void;
  58687. }
  58688. /**
  58689. * Options to create an EffectWrapper
  58690. */
  58691. interface EffectWrapperCreationOptions {
  58692. /**
  58693. * Engine to use to create the effect
  58694. */
  58695. engine: ThinEngine;
  58696. /**
  58697. * Fragment shader for the effect
  58698. */
  58699. fragmentShader: string;
  58700. /**
  58701. * Use the shader store instead of direct source code
  58702. */
  58703. useShaderStore?: boolean;
  58704. /**
  58705. * Vertex shader for the effect
  58706. */
  58707. vertexShader?: string;
  58708. /**
  58709. * Attributes to use in the shader
  58710. */
  58711. attributeNames?: Array<string>;
  58712. /**
  58713. * Uniforms to use in the shader
  58714. */
  58715. uniformNames?: Array<string>;
  58716. /**
  58717. * Texture sampler names to use in the shader
  58718. */
  58719. samplerNames?: Array<string>;
  58720. /**
  58721. * Defines to use in the shader
  58722. */
  58723. defines?: Array<string>;
  58724. /**
  58725. * Callback when effect is compiled
  58726. */
  58727. onCompiled?: Nullable<(effect: Effect) => void>;
  58728. /**
  58729. * The friendly name of the effect displayed in Spector.
  58730. */
  58731. name?: string;
  58732. }
  58733. /**
  58734. * Wraps an effect to be used for rendering
  58735. */
  58736. export class EffectWrapper {
  58737. /**
  58738. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58739. */
  58740. onApplyObservable: Observable<{}>;
  58741. /**
  58742. * The underlying effect
  58743. */
  58744. effect: Effect;
  58745. /**
  58746. * Creates an effect to be renderer
  58747. * @param creationOptions options to create the effect
  58748. */
  58749. constructor(creationOptions: EffectWrapperCreationOptions);
  58750. /**
  58751. * Disposes of the effect wrapper
  58752. */
  58753. dispose(): void;
  58754. }
  58755. }
  58756. declare module BABYLON {
  58757. /** @hidden */
  58758. export var hdrFilteringVertexShader: {
  58759. name: string;
  58760. shader: string;
  58761. };
  58762. }
  58763. declare module BABYLON {
  58764. /** @hidden */
  58765. export var hdrFilteringPixelShader: {
  58766. name: string;
  58767. shader: string;
  58768. };
  58769. }
  58770. declare module BABYLON {
  58771. /**
  58772. * Options for texture filtering
  58773. */
  58774. interface IHDRFilteringOptions {
  58775. /**
  58776. * Scales pixel intensity for the input HDR map.
  58777. */
  58778. hdrScale?: number;
  58779. /**
  58780. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58781. */
  58782. quality?: number;
  58783. }
  58784. /**
  58785. * Filters HDR maps to get correct renderings of PBR reflections
  58786. */
  58787. export class HDRFiltering {
  58788. private _engine;
  58789. private _effectRenderer;
  58790. private _effectWrapper;
  58791. private _lodGenerationOffset;
  58792. private _lodGenerationScale;
  58793. /**
  58794. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58795. * you care about baking speed.
  58796. */
  58797. quality: number;
  58798. /**
  58799. * Scales pixel intensity for the input HDR map.
  58800. */
  58801. hdrScale: number;
  58802. /**
  58803. * Instantiates HDR filter for reflection maps
  58804. *
  58805. * @param engine Thin engine
  58806. * @param options Options
  58807. */
  58808. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58809. private _createRenderTarget;
  58810. private _prefilterInternal;
  58811. private _createEffect;
  58812. /**
  58813. * Get a value indicating if the filter is ready to be used
  58814. * @param texture Texture to filter
  58815. * @returns true if the filter is ready
  58816. */
  58817. isReady(texture: BaseTexture): boolean;
  58818. /**
  58819. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58820. * Prefiltering will be invoked at the end of next rendering pass.
  58821. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58822. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58823. * @param texture Texture to filter
  58824. * @param onFinished Callback when filtering is done
  58825. * @return Promise called when prefiltering is done
  58826. */
  58827. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58828. }
  58829. }
  58830. declare module BABYLON {
  58831. /**
  58832. * This represents a texture coming from an HDR input.
  58833. *
  58834. * The only supported format is currently panorama picture stored in RGBE format.
  58835. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58836. */
  58837. export class HDRCubeTexture extends BaseTexture {
  58838. private static _facesMapping;
  58839. private _generateHarmonics;
  58840. private _noMipmap;
  58841. private _prefilterOnLoad;
  58842. private _textureMatrix;
  58843. private _size;
  58844. private _onLoad;
  58845. private _onError;
  58846. /**
  58847. * The texture URL.
  58848. */
  58849. url: string;
  58850. /**
  58851. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58852. */
  58853. coordinatesMode: number;
  58854. protected _isBlocking: boolean;
  58855. /**
  58856. * Sets wether or not the texture is blocking during loading.
  58857. */
  58858. set isBlocking(value: boolean);
  58859. /**
  58860. * Gets wether or not the texture is blocking during loading.
  58861. */
  58862. get isBlocking(): boolean;
  58863. protected _rotationY: number;
  58864. /**
  58865. * Sets texture matrix rotation angle around Y axis in radians.
  58866. */
  58867. set rotationY(value: number);
  58868. /**
  58869. * Gets texture matrix rotation angle around Y axis radians.
  58870. */
  58871. get rotationY(): number;
  58872. /**
  58873. * Gets or sets the center of the bounding box associated with the cube texture
  58874. * It must define where the camera used to render the texture was set
  58875. */
  58876. boundingBoxPosition: Vector3;
  58877. private _boundingBoxSize;
  58878. /**
  58879. * Gets or sets the size of the bounding box associated with the cube texture
  58880. * When defined, the cubemap will switch to local mode
  58881. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58882. * @example https://www.babylonjs-playground.com/#RNASML
  58883. */
  58884. set boundingBoxSize(value: Vector3);
  58885. get boundingBoxSize(): Vector3;
  58886. /**
  58887. * Instantiates an HDRTexture from the following parameters.
  58888. *
  58889. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58890. * @param sceneOrEngine The scene or engine the texture will be used in
  58891. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58892. * @param noMipmap Forces to not generate the mipmap if true
  58893. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58894. * @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)
  58895. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58896. */
  58897. 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>);
  58898. /**
  58899. * Get the current class name of the texture useful for serialization or dynamic coding.
  58900. * @returns "HDRCubeTexture"
  58901. */
  58902. getClassName(): string;
  58903. /**
  58904. * Occurs when the file is raw .hdr file.
  58905. */
  58906. private loadTexture;
  58907. clone(): HDRCubeTexture;
  58908. delayLoad(): void;
  58909. /**
  58910. * Get the texture reflection matrix used to rotate/transform the reflection.
  58911. * @returns the reflection matrix
  58912. */
  58913. getReflectionTextureMatrix(): Matrix;
  58914. /**
  58915. * Set the texture reflection matrix used to rotate/transform the reflection.
  58916. * @param value Define the reflection matrix to set
  58917. */
  58918. setReflectionTextureMatrix(value: Matrix): void;
  58919. /**
  58920. * Parses a JSON representation of an HDR Texture in order to create the texture
  58921. * @param parsedTexture Define the JSON representation
  58922. * @param scene Define the scene the texture should be created in
  58923. * @param rootUrl Define the root url in case we need to load relative dependencies
  58924. * @returns the newly created texture after parsing
  58925. */
  58926. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58927. serialize(): any;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /**
  58932. * Class used to control physics engine
  58933. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58934. */
  58935. export class PhysicsEngine implements IPhysicsEngine {
  58936. private _physicsPlugin;
  58937. /**
  58938. * Global value used to control the smallest number supported by the simulation
  58939. */
  58940. static Epsilon: number;
  58941. private _impostors;
  58942. private _joints;
  58943. private _subTimeStep;
  58944. /**
  58945. * Gets the gravity vector used by the simulation
  58946. */
  58947. gravity: Vector3;
  58948. /**
  58949. * Factory used to create the default physics plugin.
  58950. * @returns The default physics plugin
  58951. */
  58952. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58953. /**
  58954. * Creates a new Physics Engine
  58955. * @param gravity defines the gravity vector used by the simulation
  58956. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58957. */
  58958. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58959. /**
  58960. * Sets the gravity vector used by the simulation
  58961. * @param gravity defines the gravity vector to use
  58962. */
  58963. setGravity(gravity: Vector3): void;
  58964. /**
  58965. * Set the time step of the physics engine.
  58966. * Default is 1/60.
  58967. * To slow it down, enter 1/600 for example.
  58968. * To speed it up, 1/30
  58969. * @param newTimeStep defines the new timestep to apply to this world.
  58970. */
  58971. setTimeStep(newTimeStep?: number): void;
  58972. /**
  58973. * Get the time step of the physics engine.
  58974. * @returns the current time step
  58975. */
  58976. getTimeStep(): number;
  58977. /**
  58978. * Set the sub time step of the physics engine.
  58979. * Default is 0 meaning there is no sub steps
  58980. * To increase physics resolution precision, set a small value (like 1 ms)
  58981. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58982. */
  58983. setSubTimeStep(subTimeStep?: number): void;
  58984. /**
  58985. * Get the sub time step of the physics engine.
  58986. * @returns the current sub time step
  58987. */
  58988. getSubTimeStep(): number;
  58989. /**
  58990. * Release all resources
  58991. */
  58992. dispose(): void;
  58993. /**
  58994. * Gets the name of the current physics plugin
  58995. * @returns the name of the plugin
  58996. */
  58997. getPhysicsPluginName(): string;
  58998. /**
  58999. * Adding a new impostor for the impostor tracking.
  59000. * This will be done by the impostor itself.
  59001. * @param impostor the impostor to add
  59002. */
  59003. addImpostor(impostor: PhysicsImpostor): void;
  59004. /**
  59005. * Remove an impostor from the engine.
  59006. * This impostor and its mesh will not longer be updated by the physics engine.
  59007. * @param impostor the impostor to remove
  59008. */
  59009. removeImpostor(impostor: PhysicsImpostor): void;
  59010. /**
  59011. * Add a joint to the physics engine
  59012. * @param mainImpostor defines the main impostor to which the joint is added.
  59013. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59014. * @param joint defines the joint that will connect both impostors.
  59015. */
  59016. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59017. /**
  59018. * Removes a joint from the simulation
  59019. * @param mainImpostor defines the impostor used with the joint
  59020. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59021. * @param joint defines the joint to remove
  59022. */
  59023. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59024. /**
  59025. * Called by the scene. No need to call it.
  59026. * @param delta defines the timespam between frames
  59027. */
  59028. _step(delta: number): void;
  59029. /**
  59030. * Gets the current plugin used to run the simulation
  59031. * @returns current plugin
  59032. */
  59033. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59034. /**
  59035. * Gets the list of physic impostors
  59036. * @returns an array of PhysicsImpostor
  59037. */
  59038. getImpostors(): Array<PhysicsImpostor>;
  59039. /**
  59040. * Gets the impostor for a physics enabled object
  59041. * @param object defines the object impersonated by the impostor
  59042. * @returns the PhysicsImpostor or null if not found
  59043. */
  59044. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59045. /**
  59046. * Gets the impostor for a physics body object
  59047. * @param body defines physics body used by the impostor
  59048. * @returns the PhysicsImpostor or null if not found
  59049. */
  59050. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59051. /**
  59052. * Does a raycast in the physics world
  59053. * @param from when should the ray start?
  59054. * @param to when should the ray end?
  59055. * @returns PhysicsRaycastResult
  59056. */
  59057. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /** @hidden */
  59062. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59063. private _useDeltaForWorldStep;
  59064. world: any;
  59065. name: string;
  59066. private _physicsMaterials;
  59067. private _fixedTimeStep;
  59068. private _cannonRaycastResult;
  59069. private _raycastResult;
  59070. private _physicsBodysToRemoveAfterStep;
  59071. private _firstFrame;
  59072. BJSCANNON: any;
  59073. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59074. setGravity(gravity: Vector3): void;
  59075. setTimeStep(timeStep: number): void;
  59076. getTimeStep(): number;
  59077. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59078. private _removeMarkedPhysicsBodiesFromWorld;
  59079. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59080. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59081. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59082. private _processChildMeshes;
  59083. removePhysicsBody(impostor: PhysicsImpostor): void;
  59084. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59085. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59086. private _addMaterial;
  59087. private _checkWithEpsilon;
  59088. private _createShape;
  59089. private _createHeightmap;
  59090. private _minus90X;
  59091. private _plus90X;
  59092. private _tmpPosition;
  59093. private _tmpDeltaPosition;
  59094. private _tmpUnityRotation;
  59095. private _updatePhysicsBodyTransformation;
  59096. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59097. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59098. isSupported(): boolean;
  59099. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59100. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59101. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59102. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59103. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59104. getBodyMass(impostor: PhysicsImpostor): number;
  59105. getBodyFriction(impostor: PhysicsImpostor): number;
  59106. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59107. getBodyRestitution(impostor: PhysicsImpostor): number;
  59108. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59109. sleepBody(impostor: PhysicsImpostor): void;
  59110. wakeUpBody(impostor: PhysicsImpostor): void;
  59111. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59112. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59113. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59114. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59115. getRadius(impostor: PhysicsImpostor): number;
  59116. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59117. dispose(): void;
  59118. private _extendNamespace;
  59119. /**
  59120. * Does a raycast in the physics world
  59121. * @param from when should the ray start?
  59122. * @param to when should the ray end?
  59123. * @returns PhysicsRaycastResult
  59124. */
  59125. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59126. }
  59127. }
  59128. declare module BABYLON {
  59129. /** @hidden */
  59130. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59131. private _useDeltaForWorldStep;
  59132. world: any;
  59133. name: string;
  59134. BJSOIMO: any;
  59135. private _raycastResult;
  59136. private _fixedTimeStep;
  59137. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59138. setGravity(gravity: Vector3): void;
  59139. setTimeStep(timeStep: number): void;
  59140. getTimeStep(): number;
  59141. private _tmpImpostorsArray;
  59142. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59143. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59145. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59146. private _tmpPositionVector;
  59147. removePhysicsBody(impostor: PhysicsImpostor): void;
  59148. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59149. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59150. isSupported(): boolean;
  59151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59153. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59154. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59155. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59156. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59157. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59158. getBodyMass(impostor: PhysicsImpostor): number;
  59159. getBodyFriction(impostor: PhysicsImpostor): number;
  59160. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59161. getBodyRestitution(impostor: PhysicsImpostor): number;
  59162. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59163. sleepBody(impostor: PhysicsImpostor): void;
  59164. wakeUpBody(impostor: PhysicsImpostor): void;
  59165. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59166. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59167. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59168. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59169. getRadius(impostor: PhysicsImpostor): number;
  59170. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59171. dispose(): void;
  59172. /**
  59173. * Does a raycast in the physics world
  59174. * @param from when should the ray start?
  59175. * @param to when should the ray end?
  59176. * @returns PhysicsRaycastResult
  59177. */
  59178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59179. }
  59180. }
  59181. declare module BABYLON {
  59182. /**
  59183. * Class containing static functions to help procedurally build meshes
  59184. */
  59185. export class RibbonBuilder {
  59186. /**
  59187. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59188. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59189. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59190. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59191. * * 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
  59192. * * 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
  59193. * * 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
  59194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59195. * * 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
  59196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59197. * * 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
  59198. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59199. * * 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
  59200. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59202. * @param name defines the name of the mesh
  59203. * @param options defines the options used to create the mesh
  59204. * @param scene defines the hosting scene
  59205. * @returns the ribbon mesh
  59206. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59208. */
  59209. static CreateRibbon(name: string, options: {
  59210. pathArray: Vector3[][];
  59211. closeArray?: boolean;
  59212. closePath?: boolean;
  59213. offset?: number;
  59214. updatable?: boolean;
  59215. sideOrientation?: number;
  59216. frontUVs?: Vector4;
  59217. backUVs?: Vector4;
  59218. instance?: Mesh;
  59219. invertUV?: boolean;
  59220. uvs?: Vector2[];
  59221. colors?: Color4[];
  59222. }, scene?: Nullable<Scene>): Mesh;
  59223. }
  59224. }
  59225. declare module BABYLON {
  59226. /**
  59227. * Class containing static functions to help procedurally build meshes
  59228. */
  59229. export class ShapeBuilder {
  59230. /**
  59231. * 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.
  59232. * * 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.
  59233. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59234. * * 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.
  59235. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59236. * * 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
  59237. * * 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
  59238. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59240. * * 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
  59241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59243. * @param name defines the name of the mesh
  59244. * @param options defines the options used to create the mesh
  59245. * @param scene defines the hosting scene
  59246. * @returns the extruded shape mesh
  59247. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59249. */
  59250. static ExtrudeShape(name: string, options: {
  59251. shape: Vector3[];
  59252. path: Vector3[];
  59253. scale?: number;
  59254. rotation?: number;
  59255. cap?: number;
  59256. updatable?: boolean;
  59257. sideOrientation?: number;
  59258. frontUVs?: Vector4;
  59259. backUVs?: Vector4;
  59260. instance?: Mesh;
  59261. invertUV?: boolean;
  59262. }, scene?: Nullable<Scene>): Mesh;
  59263. /**
  59264. * Creates an custom extruded shape mesh.
  59265. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59266. * * 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.
  59267. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59268. * * 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
  59269. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59270. * * 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
  59271. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59272. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59273. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59274. * * 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
  59275. * * 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
  59276. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59278. * * 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
  59279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59281. * @param name defines the name of the mesh
  59282. * @param options defines the options used to create the mesh
  59283. * @param scene defines the hosting scene
  59284. * @returns the custom extruded shape mesh
  59285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59286. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59288. */
  59289. static ExtrudeShapeCustom(name: string, options: {
  59290. shape: Vector3[];
  59291. path: Vector3[];
  59292. scaleFunction?: any;
  59293. rotationFunction?: any;
  59294. ribbonCloseArray?: boolean;
  59295. ribbonClosePath?: boolean;
  59296. cap?: number;
  59297. updatable?: boolean;
  59298. sideOrientation?: number;
  59299. frontUVs?: Vector4;
  59300. backUVs?: Vector4;
  59301. instance?: Mesh;
  59302. invertUV?: boolean;
  59303. }, scene?: Nullable<Scene>): Mesh;
  59304. private static _ExtrudeShapeGeneric;
  59305. }
  59306. }
  59307. declare module BABYLON {
  59308. /**
  59309. * AmmoJS Physics plugin
  59310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59311. * @see https://github.com/kripken/ammo.js/
  59312. */
  59313. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59314. private _useDeltaForWorldStep;
  59315. /**
  59316. * Reference to the Ammo library
  59317. */
  59318. bjsAMMO: any;
  59319. /**
  59320. * Created ammoJS world which physics bodies are added to
  59321. */
  59322. world: any;
  59323. /**
  59324. * Name of the plugin
  59325. */
  59326. name: string;
  59327. private _timeStep;
  59328. private _fixedTimeStep;
  59329. private _maxSteps;
  59330. private _tmpQuaternion;
  59331. private _tmpAmmoTransform;
  59332. private _tmpAmmoQuaternion;
  59333. private _tmpAmmoConcreteContactResultCallback;
  59334. private _collisionConfiguration;
  59335. private _dispatcher;
  59336. private _overlappingPairCache;
  59337. private _solver;
  59338. private _softBodySolver;
  59339. private _tmpAmmoVectorA;
  59340. private _tmpAmmoVectorB;
  59341. private _tmpAmmoVectorC;
  59342. private _tmpAmmoVectorD;
  59343. private _tmpContactCallbackResult;
  59344. private _tmpAmmoVectorRCA;
  59345. private _tmpAmmoVectorRCB;
  59346. private _raycastResult;
  59347. private static readonly DISABLE_COLLISION_FLAG;
  59348. private static readonly KINEMATIC_FLAG;
  59349. private static readonly DISABLE_DEACTIVATION_FLAG;
  59350. /**
  59351. * Initializes the ammoJS plugin
  59352. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59353. * @param ammoInjection can be used to inject your own ammo reference
  59354. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59355. */
  59356. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59357. /**
  59358. * Sets the gravity of the physics world (m/(s^2))
  59359. * @param gravity Gravity to set
  59360. */
  59361. setGravity(gravity: Vector3): void;
  59362. /**
  59363. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59364. * @param timeStep timestep to use in seconds
  59365. */
  59366. setTimeStep(timeStep: number): void;
  59367. /**
  59368. * 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)
  59369. * @param fixedTimeStep fixedTimeStep to use in seconds
  59370. */
  59371. setFixedTimeStep(fixedTimeStep: number): void;
  59372. /**
  59373. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59374. * @param maxSteps the maximum number of steps by the physics engine per frame
  59375. */
  59376. setMaxSteps(maxSteps: number): void;
  59377. /**
  59378. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59379. * @returns the current timestep in seconds
  59380. */
  59381. getTimeStep(): number;
  59382. /**
  59383. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59384. */
  59385. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59386. private _isImpostorInContact;
  59387. private _isImpostorPairInContact;
  59388. private _stepSimulation;
  59389. /**
  59390. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59391. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59392. * After the step the babylon meshes are set to the position of the physics imposters
  59393. * @param delta amount of time to step forward
  59394. * @param impostors array of imposters to update before/after the step
  59395. */
  59396. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59397. /**
  59398. * Update babylon mesh to match physics world object
  59399. * @param impostor imposter to match
  59400. */
  59401. private _afterSoftStep;
  59402. /**
  59403. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59404. * @param impostor imposter to match
  59405. */
  59406. private _ropeStep;
  59407. /**
  59408. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59409. * @param impostor imposter to match
  59410. */
  59411. private _softbodyOrClothStep;
  59412. private _tmpMatrix;
  59413. /**
  59414. * Applies an impulse on the imposter
  59415. * @param impostor imposter to apply impulse to
  59416. * @param force amount of force to be applied to the imposter
  59417. * @param contactPoint the location to apply the impulse on the imposter
  59418. */
  59419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59420. /**
  59421. * Applies a force on the imposter
  59422. * @param impostor imposter to apply force
  59423. * @param force amount of force to be applied to the imposter
  59424. * @param contactPoint the location to apply the force on the imposter
  59425. */
  59426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59427. /**
  59428. * Creates a physics body using the plugin
  59429. * @param impostor the imposter to create the physics body on
  59430. */
  59431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59432. /**
  59433. * Removes the physics body from the imposter and disposes of the body's memory
  59434. * @param impostor imposter to remove the physics body from
  59435. */
  59436. removePhysicsBody(impostor: PhysicsImpostor): void;
  59437. /**
  59438. * Generates a joint
  59439. * @param impostorJoint the imposter joint to create the joint with
  59440. */
  59441. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59442. /**
  59443. * Removes a joint
  59444. * @param impostorJoint the imposter joint to remove the joint from
  59445. */
  59446. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59447. private _addMeshVerts;
  59448. /**
  59449. * Initialise the soft body vertices to match its object's (mesh) vertices
  59450. * Softbody vertices (nodes) are in world space and to match this
  59451. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59452. * @param impostor to create the softbody for
  59453. */
  59454. private _softVertexData;
  59455. /**
  59456. * Create an impostor's soft body
  59457. * @param impostor to create the softbody for
  59458. */
  59459. private _createSoftbody;
  59460. /**
  59461. * Create cloth for an impostor
  59462. * @param impostor to create the softbody for
  59463. */
  59464. private _createCloth;
  59465. /**
  59466. * Create rope for an impostor
  59467. * @param impostor to create the softbody for
  59468. */
  59469. private _createRope;
  59470. /**
  59471. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59472. * @param impostor to create the custom physics shape for
  59473. */
  59474. private _createCustom;
  59475. private _addHullVerts;
  59476. private _createShape;
  59477. /**
  59478. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59479. * @param impostor imposter containing the physics body and babylon object
  59480. */
  59481. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59482. /**
  59483. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59484. * @param impostor imposter containing the physics body and babylon object
  59485. * @param newPosition new position
  59486. * @param newRotation new rotation
  59487. */
  59488. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59489. /**
  59490. * If this plugin is supported
  59491. * @returns true if its supported
  59492. */
  59493. isSupported(): boolean;
  59494. /**
  59495. * Sets the linear velocity of the physics body
  59496. * @param impostor imposter to set the velocity on
  59497. * @param velocity velocity to set
  59498. */
  59499. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59500. /**
  59501. * Sets the angular velocity of the physics body
  59502. * @param impostor imposter to set the velocity on
  59503. * @param velocity velocity to set
  59504. */
  59505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59506. /**
  59507. * gets the linear velocity
  59508. * @param impostor imposter to get linear velocity from
  59509. * @returns linear velocity
  59510. */
  59511. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59512. /**
  59513. * gets the angular velocity
  59514. * @param impostor imposter to get angular velocity from
  59515. * @returns angular velocity
  59516. */
  59517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59518. /**
  59519. * Sets the mass of physics body
  59520. * @param impostor imposter to set the mass on
  59521. * @param mass mass to set
  59522. */
  59523. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59524. /**
  59525. * Gets the mass of the physics body
  59526. * @param impostor imposter to get the mass from
  59527. * @returns mass
  59528. */
  59529. getBodyMass(impostor: PhysicsImpostor): number;
  59530. /**
  59531. * Gets friction of the impostor
  59532. * @param impostor impostor to get friction from
  59533. * @returns friction value
  59534. */
  59535. getBodyFriction(impostor: PhysicsImpostor): number;
  59536. /**
  59537. * Sets friction of the impostor
  59538. * @param impostor impostor to set friction on
  59539. * @param friction friction value
  59540. */
  59541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59542. /**
  59543. * Gets restitution of the impostor
  59544. * @param impostor impostor to get restitution from
  59545. * @returns restitution value
  59546. */
  59547. getBodyRestitution(impostor: PhysicsImpostor): number;
  59548. /**
  59549. * Sets resitution of the impostor
  59550. * @param impostor impostor to set resitution on
  59551. * @param restitution resitution value
  59552. */
  59553. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59554. /**
  59555. * Gets pressure inside the impostor
  59556. * @param impostor impostor to get pressure from
  59557. * @returns pressure value
  59558. */
  59559. getBodyPressure(impostor: PhysicsImpostor): number;
  59560. /**
  59561. * Sets pressure inside a soft body impostor
  59562. * Cloth and rope must remain 0 pressure
  59563. * @param impostor impostor to set pressure on
  59564. * @param pressure pressure value
  59565. */
  59566. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59567. /**
  59568. * Gets stiffness of the impostor
  59569. * @param impostor impostor to get stiffness from
  59570. * @returns pressure value
  59571. */
  59572. getBodyStiffness(impostor: PhysicsImpostor): number;
  59573. /**
  59574. * Sets stiffness of the impostor
  59575. * @param impostor impostor to set stiffness on
  59576. * @param stiffness stiffness value from 0 to 1
  59577. */
  59578. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59579. /**
  59580. * Gets velocityIterations of the impostor
  59581. * @param impostor impostor to get velocity iterations from
  59582. * @returns velocityIterations value
  59583. */
  59584. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59585. /**
  59586. * Sets velocityIterations of the impostor
  59587. * @param impostor impostor to set velocity iterations on
  59588. * @param velocityIterations velocityIterations value
  59589. */
  59590. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59591. /**
  59592. * Gets positionIterations of the impostor
  59593. * @param impostor impostor to get position iterations from
  59594. * @returns positionIterations value
  59595. */
  59596. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59597. /**
  59598. * Sets positionIterations of the impostor
  59599. * @param impostor impostor to set position on
  59600. * @param positionIterations positionIterations value
  59601. */
  59602. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59603. /**
  59604. * Append an anchor to a cloth object
  59605. * @param impostor is the cloth impostor to add anchor to
  59606. * @param otherImpostor is the rigid impostor to anchor to
  59607. * @param width ratio across width from 0 to 1
  59608. * @param height ratio up height from 0 to 1
  59609. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59610. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59611. */
  59612. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59613. /**
  59614. * Append an hook to a rope object
  59615. * @param impostor is the rope impostor to add hook to
  59616. * @param otherImpostor is the rigid impostor to hook to
  59617. * @param length ratio along the rope from 0 to 1
  59618. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59619. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59620. */
  59621. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59622. /**
  59623. * Sleeps the physics body and stops it from being active
  59624. * @param impostor impostor to sleep
  59625. */
  59626. sleepBody(impostor: PhysicsImpostor): void;
  59627. /**
  59628. * Activates the physics body
  59629. * @param impostor impostor to activate
  59630. */
  59631. wakeUpBody(impostor: PhysicsImpostor): void;
  59632. /**
  59633. * Updates the distance parameters of the joint
  59634. * @param joint joint to update
  59635. * @param maxDistance maximum distance of the joint
  59636. * @param minDistance minimum distance of the joint
  59637. */
  59638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59639. /**
  59640. * Sets a motor on the joint
  59641. * @param joint joint to set motor on
  59642. * @param speed speed of the motor
  59643. * @param maxForce maximum force of the motor
  59644. * @param motorIndex index of the motor
  59645. */
  59646. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59647. /**
  59648. * Sets the motors limit
  59649. * @param joint joint to set limit on
  59650. * @param upperLimit upper limit
  59651. * @param lowerLimit lower limit
  59652. */
  59653. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59654. /**
  59655. * Syncs the position and rotation of a mesh with the impostor
  59656. * @param mesh mesh to sync
  59657. * @param impostor impostor to update the mesh with
  59658. */
  59659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59660. /**
  59661. * Gets the radius of the impostor
  59662. * @param impostor impostor to get radius from
  59663. * @returns the radius
  59664. */
  59665. getRadius(impostor: PhysicsImpostor): number;
  59666. /**
  59667. * Gets the box size of the impostor
  59668. * @param impostor impostor to get box size from
  59669. * @param result the resulting box size
  59670. */
  59671. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59672. /**
  59673. * Disposes of the impostor
  59674. */
  59675. dispose(): void;
  59676. /**
  59677. * Does a raycast in the physics world
  59678. * @param from when should the ray start?
  59679. * @param to when should the ray end?
  59680. * @returns PhysicsRaycastResult
  59681. */
  59682. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59683. }
  59684. }
  59685. declare module BABYLON {
  59686. interface AbstractScene {
  59687. /**
  59688. * The list of reflection probes added to the scene
  59689. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59690. */
  59691. reflectionProbes: Array<ReflectionProbe>;
  59692. /**
  59693. * Removes the given reflection probe from this scene.
  59694. * @param toRemove The reflection probe to remove
  59695. * @returns The index of the removed reflection probe
  59696. */
  59697. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59698. /**
  59699. * Adds the given reflection probe to this scene.
  59700. * @param newReflectionProbe The reflection probe to add
  59701. */
  59702. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59703. }
  59704. /**
  59705. * Class used to generate realtime reflection / refraction cube textures
  59706. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59707. */
  59708. export class ReflectionProbe {
  59709. /** defines the name of the probe */
  59710. name: string;
  59711. private _scene;
  59712. private _renderTargetTexture;
  59713. private _projectionMatrix;
  59714. private _viewMatrix;
  59715. private _target;
  59716. private _add;
  59717. private _attachedMesh;
  59718. private _invertYAxis;
  59719. /** Gets or sets probe position (center of the cube map) */
  59720. position: Vector3;
  59721. /**
  59722. * Creates a new reflection probe
  59723. * @param name defines the name of the probe
  59724. * @param size defines the texture resolution (for each face)
  59725. * @param scene defines the hosting scene
  59726. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59727. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59728. */
  59729. constructor(
  59730. /** defines the name of the probe */
  59731. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59732. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59733. get samples(): number;
  59734. set samples(value: number);
  59735. /** Gets or sets the refresh rate to use (on every frame by default) */
  59736. get refreshRate(): number;
  59737. set refreshRate(value: number);
  59738. /**
  59739. * Gets the hosting scene
  59740. * @returns a Scene
  59741. */
  59742. getScene(): Scene;
  59743. /** Gets the internal CubeTexture used to render to */
  59744. get cubeTexture(): RenderTargetTexture;
  59745. /** Gets the list of meshes to render */
  59746. get renderList(): Nullable<AbstractMesh[]>;
  59747. /**
  59748. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59749. * @param mesh defines the mesh to attach to
  59750. */
  59751. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59752. /**
  59753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59754. * @param renderingGroupId The rendering group id corresponding to its index
  59755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59756. */
  59757. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59758. /**
  59759. * Clean all associated resources
  59760. */
  59761. dispose(): void;
  59762. /**
  59763. * Converts the reflection probe information to a readable string for debug purpose.
  59764. * @param fullDetails Supports for multiple levels of logging within scene loading
  59765. * @returns the human readable reflection probe info
  59766. */
  59767. toString(fullDetails?: boolean): string;
  59768. /**
  59769. * Get the class name of the relfection probe.
  59770. * @returns "ReflectionProbe"
  59771. */
  59772. getClassName(): string;
  59773. /**
  59774. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59775. * @returns The JSON representation of the texture
  59776. */
  59777. serialize(): any;
  59778. /**
  59779. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59780. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59781. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59783. * @returns The parsed reflection probe if successful
  59784. */
  59785. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59786. }
  59787. }
  59788. declare module BABYLON {
  59789. /** @hidden */
  59790. export var _BabylonLoaderRegistered: boolean;
  59791. /**
  59792. * Helps setting up some configuration for the babylon file loader.
  59793. */
  59794. export class BabylonFileLoaderConfiguration {
  59795. /**
  59796. * The loader does not allow injecting custom physix engine into the plugins.
  59797. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59798. * So you could set this variable to your engine import to make it work.
  59799. */
  59800. static LoaderInjectedPhysicsEngine: any;
  59801. }
  59802. }
  59803. declare module BABYLON {
  59804. /**
  59805. * The Physically based simple base material of BJS.
  59806. *
  59807. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59808. * It is used as the base class for both the specGloss and metalRough conventions.
  59809. */
  59810. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59811. /**
  59812. * Number of Simultaneous lights allowed on the material.
  59813. */
  59814. maxSimultaneousLights: number;
  59815. /**
  59816. * If sets to true, disables all the lights affecting the material.
  59817. */
  59818. disableLighting: boolean;
  59819. /**
  59820. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59821. */
  59822. environmentTexture: BaseTexture;
  59823. /**
  59824. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59825. */
  59826. invertNormalMapX: boolean;
  59827. /**
  59828. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59829. */
  59830. invertNormalMapY: boolean;
  59831. /**
  59832. * Normal map used in the model.
  59833. */
  59834. normalTexture: BaseTexture;
  59835. /**
  59836. * Emissivie color used to self-illuminate the model.
  59837. */
  59838. emissiveColor: Color3;
  59839. /**
  59840. * Emissivie texture used to self-illuminate the model.
  59841. */
  59842. emissiveTexture: BaseTexture;
  59843. /**
  59844. * Occlusion Channel Strenght.
  59845. */
  59846. occlusionStrength: number;
  59847. /**
  59848. * Occlusion Texture of the material (adding extra occlusion effects).
  59849. */
  59850. occlusionTexture: BaseTexture;
  59851. /**
  59852. * Defines the alpha limits in alpha test mode.
  59853. */
  59854. alphaCutOff: number;
  59855. /**
  59856. * Gets the current double sided mode.
  59857. */
  59858. get doubleSided(): boolean;
  59859. /**
  59860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59861. */
  59862. set doubleSided(value: boolean);
  59863. /**
  59864. * Stores the pre-calculated light information of a mesh in a texture.
  59865. */
  59866. lightmapTexture: BaseTexture;
  59867. /**
  59868. * If true, the light map contains occlusion information instead of lighting info.
  59869. */
  59870. useLightmapAsShadowmap: boolean;
  59871. /**
  59872. * Instantiates a new PBRMaterial instance.
  59873. *
  59874. * @param name The material name
  59875. * @param scene The scene the material will be use in.
  59876. */
  59877. constructor(name: string, scene: Scene);
  59878. getClassName(): string;
  59879. }
  59880. }
  59881. declare module BABYLON {
  59882. /**
  59883. * The PBR material of BJS following the metal roughness convention.
  59884. *
  59885. * This fits to the PBR convention in the GLTF definition:
  59886. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59887. */
  59888. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59889. /**
  59890. * The base color has two different interpretations depending on the value of metalness.
  59891. * When the material is a metal, the base color is the specific measured reflectance value
  59892. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59893. * of the material.
  59894. */
  59895. baseColor: Color3;
  59896. /**
  59897. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59898. * well as opacity information in the alpha channel.
  59899. */
  59900. baseTexture: BaseTexture;
  59901. /**
  59902. * Specifies the metallic scalar value of the material.
  59903. * Can also be used to scale the metalness values of the metallic texture.
  59904. */
  59905. metallic: number;
  59906. /**
  59907. * Specifies the roughness scalar value of the material.
  59908. * Can also be used to scale the roughness values of the metallic texture.
  59909. */
  59910. roughness: number;
  59911. /**
  59912. * Texture containing both the metallic value in the B channel and the
  59913. * roughness value in the G channel to keep better precision.
  59914. */
  59915. metallicRoughnessTexture: BaseTexture;
  59916. /**
  59917. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59918. *
  59919. * @param name The material name
  59920. * @param scene The scene the material will be use in.
  59921. */
  59922. constructor(name: string, scene: Scene);
  59923. /**
  59924. * Return the currrent class name of the material.
  59925. */
  59926. getClassName(): string;
  59927. /**
  59928. * Makes a duplicate of the current material.
  59929. * @param name - name to use for the new material.
  59930. */
  59931. clone(name: string): PBRMetallicRoughnessMaterial;
  59932. /**
  59933. * Serialize the material to a parsable JSON object.
  59934. */
  59935. serialize(): any;
  59936. /**
  59937. * Parses a JSON object correponding to the serialize function.
  59938. */
  59939. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59940. }
  59941. }
  59942. declare module BABYLON {
  59943. /**
  59944. * The PBR material of BJS following the specular glossiness convention.
  59945. *
  59946. * This fits to the PBR convention in the GLTF definition:
  59947. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59948. */
  59949. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59950. /**
  59951. * Specifies the diffuse color of the material.
  59952. */
  59953. diffuseColor: Color3;
  59954. /**
  59955. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59956. * channel.
  59957. */
  59958. diffuseTexture: BaseTexture;
  59959. /**
  59960. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59961. */
  59962. specularColor: Color3;
  59963. /**
  59964. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59965. */
  59966. glossiness: number;
  59967. /**
  59968. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59969. */
  59970. specularGlossinessTexture: BaseTexture;
  59971. /**
  59972. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59973. *
  59974. * @param name The material name
  59975. * @param scene The scene the material will be use in.
  59976. */
  59977. constructor(name: string, scene: Scene);
  59978. /**
  59979. * Return the currrent class name of the material.
  59980. */
  59981. getClassName(): string;
  59982. /**
  59983. * Makes a duplicate of the current material.
  59984. * @param name - name to use for the new material.
  59985. */
  59986. clone(name: string): PBRSpecularGlossinessMaterial;
  59987. /**
  59988. * Serialize the material to a parsable JSON object.
  59989. */
  59990. serialize(): any;
  59991. /**
  59992. * Parses a JSON object correponding to the serialize function.
  59993. */
  59994. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. /**
  59999. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60000. * It can help converting any input color in a desired output one. This can then be used to create effects
  60001. * from sepia, black and white to sixties or futuristic rendering...
  60002. *
  60003. * The only supported format is currently 3dl.
  60004. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60005. */
  60006. export class ColorGradingTexture extends BaseTexture {
  60007. /**
  60008. * The texture URL.
  60009. */
  60010. url: string;
  60011. /**
  60012. * Empty line regex stored for GC.
  60013. */
  60014. private static _noneEmptyLineRegex;
  60015. private _textureMatrix;
  60016. private _onLoad;
  60017. /**
  60018. * Instantiates a ColorGradingTexture from the following parameters.
  60019. *
  60020. * @param url The location of the color gradind data (currently only supporting 3dl)
  60021. * @param sceneOrEngine The scene or engine the texture will be used in
  60022. * @param onLoad defines a callback triggered when the texture has been loaded
  60023. */
  60024. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60025. /**
  60026. * Fires the onload event from the constructor if requested.
  60027. */
  60028. private _triggerOnLoad;
  60029. /**
  60030. * Returns the texture matrix used in most of the material.
  60031. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60032. */
  60033. getTextureMatrix(): Matrix;
  60034. /**
  60035. * Occurs when the file being loaded is a .3dl LUT file.
  60036. */
  60037. private load3dlTexture;
  60038. /**
  60039. * Starts the loading process of the texture.
  60040. */
  60041. private loadTexture;
  60042. /**
  60043. * Clones the color gradind texture.
  60044. */
  60045. clone(): ColorGradingTexture;
  60046. /**
  60047. * Called during delayed load for textures.
  60048. */
  60049. delayLoad(): void;
  60050. /**
  60051. * Parses a color grading texture serialized by Babylon.
  60052. * @param parsedTexture The texture information being parsedTexture
  60053. * @param scene The scene to load the texture in
  60054. * @param rootUrl The root url of the data assets to load
  60055. * @return A color gradind texture
  60056. */
  60057. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60058. /**
  60059. * Serializes the LUT texture to json format.
  60060. */
  60061. serialize(): any;
  60062. }
  60063. }
  60064. declare module BABYLON {
  60065. /**
  60066. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60067. */
  60068. export class EquiRectangularCubeTexture extends BaseTexture {
  60069. /** The six faces of the cube. */
  60070. private static _FacesMapping;
  60071. private _noMipmap;
  60072. private _onLoad;
  60073. private _onError;
  60074. /** The size of the cubemap. */
  60075. private _size;
  60076. /** The buffer of the image. */
  60077. private _buffer;
  60078. /** The width of the input image. */
  60079. private _width;
  60080. /** The height of the input image. */
  60081. private _height;
  60082. /** The URL to the image. */
  60083. url: string;
  60084. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60085. coordinatesMode: number;
  60086. /**
  60087. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60088. * @param url The location of the image
  60089. * @param scene The scene the texture will be used in
  60090. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60091. * @param noMipmap Forces to not generate the mipmap if true
  60092. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60093. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60094. * @param onLoad — defines a callback called when texture is loaded
  60095. * @param onError — defines a callback called if there is an error
  60096. */
  60097. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60098. /**
  60099. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60100. */
  60101. private loadImage;
  60102. /**
  60103. * Convert the image buffer into a cubemap and create a CubeTexture.
  60104. */
  60105. private loadTexture;
  60106. /**
  60107. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60108. * @param buffer The ArrayBuffer that should be converted.
  60109. * @returns The buffer as Float32Array.
  60110. */
  60111. private getFloat32ArrayFromArrayBuffer;
  60112. /**
  60113. * Get the current class name of the texture useful for serialization or dynamic coding.
  60114. * @returns "EquiRectangularCubeTexture"
  60115. */
  60116. getClassName(): string;
  60117. /**
  60118. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60119. * @returns A clone of the current EquiRectangularCubeTexture.
  60120. */
  60121. clone(): EquiRectangularCubeTexture;
  60122. }
  60123. }
  60124. declare module BABYLON {
  60125. /**
  60126. * Defines the options related to the creation of an HtmlElementTexture
  60127. */
  60128. export interface IHtmlElementTextureOptions {
  60129. /**
  60130. * Defines wether mip maps should be created or not.
  60131. */
  60132. generateMipMaps?: boolean;
  60133. /**
  60134. * Defines the sampling mode of the texture.
  60135. */
  60136. samplingMode?: number;
  60137. /**
  60138. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60139. */
  60140. engine: Nullable<ThinEngine>;
  60141. /**
  60142. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60143. */
  60144. scene: Nullable<Scene>;
  60145. }
  60146. /**
  60147. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60148. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60149. * is automatically managed.
  60150. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60151. * in your application.
  60152. *
  60153. * As the update is not automatic, you need to call them manually.
  60154. */
  60155. export class HtmlElementTexture extends BaseTexture {
  60156. /**
  60157. * The texture URL.
  60158. */
  60159. element: HTMLVideoElement | HTMLCanvasElement;
  60160. private static readonly DefaultOptions;
  60161. private _textureMatrix;
  60162. private _isVideo;
  60163. private _generateMipMaps;
  60164. private _samplingMode;
  60165. /**
  60166. * Instantiates a HtmlElementTexture from the following parameters.
  60167. *
  60168. * @param name Defines the name of the texture
  60169. * @param element Defines the video or canvas the texture is filled with
  60170. * @param options Defines the other none mandatory texture creation options
  60171. */
  60172. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60173. private _createInternalTexture;
  60174. /**
  60175. * Returns the texture matrix used in most of the material.
  60176. */
  60177. getTextureMatrix(): Matrix;
  60178. /**
  60179. * Updates the content of the texture.
  60180. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60181. */
  60182. update(invertY?: Nullable<boolean>): void;
  60183. }
  60184. }
  60185. declare module BABYLON {
  60186. /**
  60187. * Based on jsTGALoader - Javascript loader for TGA file
  60188. * By Vincent Thibault
  60189. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60190. */
  60191. export class TGATools {
  60192. private static _TYPE_INDEXED;
  60193. private static _TYPE_RGB;
  60194. private static _TYPE_GREY;
  60195. private static _TYPE_RLE_INDEXED;
  60196. private static _TYPE_RLE_RGB;
  60197. private static _TYPE_RLE_GREY;
  60198. private static _ORIGIN_MASK;
  60199. private static _ORIGIN_SHIFT;
  60200. private static _ORIGIN_BL;
  60201. private static _ORIGIN_BR;
  60202. private static _ORIGIN_UL;
  60203. private static _ORIGIN_UR;
  60204. /**
  60205. * Gets the header of a TGA file
  60206. * @param data defines the TGA data
  60207. * @returns the header
  60208. */
  60209. static GetTGAHeader(data: Uint8Array): any;
  60210. /**
  60211. * Uploads TGA content to a Babylon Texture
  60212. * @hidden
  60213. */
  60214. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60215. /** @hidden */
  60216. 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;
  60217. /** @hidden */
  60218. 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;
  60219. /** @hidden */
  60220. 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;
  60221. /** @hidden */
  60222. 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;
  60223. /** @hidden */
  60224. 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;
  60225. /** @hidden */
  60226. 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;
  60227. }
  60228. }
  60229. declare module BABYLON {
  60230. /**
  60231. * Implementation of the TGA Texture Loader.
  60232. * @hidden
  60233. */
  60234. export class _TGATextureLoader implements IInternalTextureLoader {
  60235. /**
  60236. * Defines wether the loader supports cascade loading the different faces.
  60237. */
  60238. readonly supportCascades: boolean;
  60239. /**
  60240. * This returns if the loader support the current file information.
  60241. * @param extension defines the file extension of the file being loaded
  60242. * @returns true if the loader can load the specified file
  60243. */
  60244. canLoad(extension: string): boolean;
  60245. /**
  60246. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60247. * @param data contains the texture data
  60248. * @param texture defines the BabylonJS internal texture
  60249. * @param createPolynomials will be true if polynomials have been requested
  60250. * @param onLoad defines the callback to trigger once the texture is ready
  60251. * @param onError defines the callback to trigger in case of error
  60252. */
  60253. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60254. /**
  60255. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60256. * @param data contains the texture data
  60257. * @param texture defines the BabylonJS internal texture
  60258. * @param callback defines the method to call once ready to upload
  60259. */
  60260. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60261. }
  60262. }
  60263. declare module BABYLON {
  60264. /**
  60265. * Info about the .basis files
  60266. */
  60267. class BasisFileInfo {
  60268. /**
  60269. * If the file has alpha
  60270. */
  60271. hasAlpha: boolean;
  60272. /**
  60273. * Info about each image of the basis file
  60274. */
  60275. images: Array<{
  60276. levels: Array<{
  60277. width: number;
  60278. height: number;
  60279. transcodedPixels: ArrayBufferView;
  60280. }>;
  60281. }>;
  60282. }
  60283. /**
  60284. * Result of transcoding a basis file
  60285. */
  60286. class TranscodeResult {
  60287. /**
  60288. * Info about the .basis file
  60289. */
  60290. fileInfo: BasisFileInfo;
  60291. /**
  60292. * Format to use when loading the file
  60293. */
  60294. format: number;
  60295. }
  60296. /**
  60297. * Configuration options for the Basis transcoder
  60298. */
  60299. export class BasisTranscodeConfiguration {
  60300. /**
  60301. * Supported compression formats used to determine the supported output format of the transcoder
  60302. */
  60303. supportedCompressionFormats?: {
  60304. /**
  60305. * etc1 compression format
  60306. */
  60307. etc1?: boolean;
  60308. /**
  60309. * s3tc compression format
  60310. */
  60311. s3tc?: boolean;
  60312. /**
  60313. * pvrtc compression format
  60314. */
  60315. pvrtc?: boolean;
  60316. /**
  60317. * etc2 compression format
  60318. */
  60319. etc2?: boolean;
  60320. };
  60321. /**
  60322. * If mipmap levels should be loaded for transcoded images (Default: true)
  60323. */
  60324. loadMipmapLevels?: boolean;
  60325. /**
  60326. * Index of a single image to load (Default: all images)
  60327. */
  60328. loadSingleImage?: number;
  60329. }
  60330. /**
  60331. * Used to load .Basis files
  60332. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60333. */
  60334. export class BasisTools {
  60335. private static _IgnoreSupportedFormats;
  60336. /**
  60337. * URL to use when loading the basis transcoder
  60338. */
  60339. static JSModuleURL: string;
  60340. /**
  60341. * URL to use when loading the wasm module for the transcoder
  60342. */
  60343. static WasmModuleURL: string;
  60344. /**
  60345. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60346. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60347. * @returns internal format corresponding to the Basis format
  60348. */
  60349. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60350. private static _WorkerPromise;
  60351. private static _Worker;
  60352. private static _actionId;
  60353. private static _CreateWorkerAsync;
  60354. /**
  60355. * Transcodes a loaded image file to compressed pixel data
  60356. * @param data image data to transcode
  60357. * @param config configuration options for the transcoding
  60358. * @returns a promise resulting in the transcoded image
  60359. */
  60360. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60361. /**
  60362. * Loads a texture from the transcode result
  60363. * @param texture texture load to
  60364. * @param transcodeResult the result of transcoding the basis file to load from
  60365. */
  60366. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60367. }
  60368. }
  60369. declare module BABYLON {
  60370. /**
  60371. * Loader for .basis file format
  60372. */
  60373. export class _BasisTextureLoader implements IInternalTextureLoader {
  60374. /**
  60375. * Defines whether the loader supports cascade loading the different faces.
  60376. */
  60377. readonly supportCascades: boolean;
  60378. /**
  60379. * This returns if the loader support the current file information.
  60380. * @param extension defines the file extension of the file being loaded
  60381. * @returns true if the loader can load the specified file
  60382. */
  60383. canLoad(extension: string): boolean;
  60384. /**
  60385. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60386. * @param data contains the texture data
  60387. * @param texture defines the BabylonJS internal texture
  60388. * @param createPolynomials will be true if polynomials have been requested
  60389. * @param onLoad defines the callback to trigger once the texture is ready
  60390. * @param onError defines the callback to trigger in case of error
  60391. */
  60392. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60393. /**
  60394. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60395. * @param data contains the texture data
  60396. * @param texture defines the BabylonJS internal texture
  60397. * @param callback defines the method to call once ready to upload
  60398. */
  60399. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60400. }
  60401. }
  60402. declare module BABYLON {
  60403. /**
  60404. * Defines the basic options interface of a TexturePacker Frame
  60405. */
  60406. export interface ITexturePackerFrame {
  60407. /**
  60408. * The frame ID
  60409. */
  60410. id: number;
  60411. /**
  60412. * The frames Scale
  60413. */
  60414. scale: Vector2;
  60415. /**
  60416. * The Frames offset
  60417. */
  60418. offset: Vector2;
  60419. }
  60420. /**
  60421. * This is a support class for frame Data on texture packer sets.
  60422. */
  60423. export class TexturePackerFrame implements ITexturePackerFrame {
  60424. /**
  60425. * The frame ID
  60426. */
  60427. id: number;
  60428. /**
  60429. * The frames Scale
  60430. */
  60431. scale: Vector2;
  60432. /**
  60433. * The Frames offset
  60434. */
  60435. offset: Vector2;
  60436. /**
  60437. * Initializes a texture package frame.
  60438. * @param id The numerical frame identifier
  60439. * @param scale Scalar Vector2 for UV frame
  60440. * @param offset Vector2 for the frame position in UV units.
  60441. * @returns TexturePackerFrame
  60442. */
  60443. constructor(id: number, scale: Vector2, offset: Vector2);
  60444. }
  60445. }
  60446. declare module BABYLON {
  60447. /**
  60448. * Defines the basic options interface of a TexturePacker
  60449. */
  60450. export interface ITexturePackerOptions {
  60451. /**
  60452. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60453. */
  60454. map?: string[];
  60455. /**
  60456. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60457. */
  60458. uvsIn?: string;
  60459. /**
  60460. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60461. */
  60462. uvsOut?: string;
  60463. /**
  60464. * number representing the layout style. Defaults to LAYOUT_STRIP
  60465. */
  60466. layout?: number;
  60467. /**
  60468. * number of columns if using custom column count layout(2). This defaults to 4.
  60469. */
  60470. colnum?: number;
  60471. /**
  60472. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60473. */
  60474. updateInputMeshes?: boolean;
  60475. /**
  60476. * boolean flag to dispose all the source textures. Defaults to true.
  60477. */
  60478. disposeSources?: boolean;
  60479. /**
  60480. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60481. */
  60482. fillBlanks?: boolean;
  60483. /**
  60484. * string value representing the context fill style color. Defaults to 'black'.
  60485. */
  60486. customFillColor?: string;
  60487. /**
  60488. * Width and Height Value of each Frame in the TexturePacker Sets
  60489. */
  60490. frameSize?: number;
  60491. /**
  60492. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60493. */
  60494. paddingRatio?: number;
  60495. /**
  60496. * Number that declares the fill method for the padding gutter.
  60497. */
  60498. paddingMode?: number;
  60499. /**
  60500. * If in SUBUV_COLOR padding mode what color to use.
  60501. */
  60502. paddingColor?: Color3 | Color4;
  60503. }
  60504. /**
  60505. * Defines the basic interface of a TexturePacker JSON File
  60506. */
  60507. export interface ITexturePackerJSON {
  60508. /**
  60509. * The frame ID
  60510. */
  60511. name: string;
  60512. /**
  60513. * The base64 channel data
  60514. */
  60515. sets: any;
  60516. /**
  60517. * The options of the Packer
  60518. */
  60519. options: ITexturePackerOptions;
  60520. /**
  60521. * The frame data of the Packer
  60522. */
  60523. frames: Array<number>;
  60524. }
  60525. /**
  60526. * This is a support class that generates a series of packed texture sets.
  60527. * @see https://doc.babylonjs.com/babylon101/materials
  60528. */
  60529. export class TexturePacker {
  60530. /** Packer Layout Constant 0 */
  60531. static readonly LAYOUT_STRIP: number;
  60532. /** Packer Layout Constant 1 */
  60533. static readonly LAYOUT_POWER2: number;
  60534. /** Packer Layout Constant 2 */
  60535. static readonly LAYOUT_COLNUM: number;
  60536. /** Packer Layout Constant 0 */
  60537. static readonly SUBUV_WRAP: number;
  60538. /** Packer Layout Constant 1 */
  60539. static readonly SUBUV_EXTEND: number;
  60540. /** Packer Layout Constant 2 */
  60541. static readonly SUBUV_COLOR: number;
  60542. /** The Name of the Texture Package */
  60543. name: string;
  60544. /** The scene scope of the TexturePacker */
  60545. scene: Scene;
  60546. /** The Meshes to target */
  60547. meshes: AbstractMesh[];
  60548. /** Arguments passed with the Constructor */
  60549. options: ITexturePackerOptions;
  60550. /** The promise that is started upon initialization */
  60551. promise: Nullable<Promise<TexturePacker | string>>;
  60552. /** The Container object for the channel sets that are generated */
  60553. sets: object;
  60554. /** The Container array for the frames that are generated */
  60555. frames: TexturePackerFrame[];
  60556. /** The expected number of textures the system is parsing. */
  60557. private _expecting;
  60558. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60559. private _paddingValue;
  60560. /**
  60561. * Initializes a texture package series from an array of meshes or a single mesh.
  60562. * @param name The name of the package
  60563. * @param meshes The target meshes to compose the package from
  60564. * @param options The arguments that texture packer should follow while building.
  60565. * @param scene The scene which the textures are scoped to.
  60566. * @returns TexturePacker
  60567. */
  60568. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60569. /**
  60570. * Starts the package process
  60571. * @param resolve The promises resolution function
  60572. * @returns TexturePacker
  60573. */
  60574. private _createFrames;
  60575. /**
  60576. * Calculates the Size of the Channel Sets
  60577. * @returns Vector2
  60578. */
  60579. private _calculateSize;
  60580. /**
  60581. * Calculates the UV data for the frames.
  60582. * @param baseSize the base frameSize
  60583. * @param padding the base frame padding
  60584. * @param dtSize size of the Dynamic Texture for that channel
  60585. * @param dtUnits is 1/dtSize
  60586. * @param update flag to update the input meshes
  60587. */
  60588. private _calculateMeshUVFrames;
  60589. /**
  60590. * Calculates the frames Offset.
  60591. * @param index of the frame
  60592. * @returns Vector2
  60593. */
  60594. private _getFrameOffset;
  60595. /**
  60596. * Updates a Mesh to the frame data
  60597. * @param mesh that is the target
  60598. * @param frameID or the frame index
  60599. */
  60600. private _updateMeshUV;
  60601. /**
  60602. * Updates a Meshes materials to use the texture packer channels
  60603. * @param m is the mesh to target
  60604. * @param force all channels on the packer to be set.
  60605. */
  60606. private _updateTextureReferences;
  60607. /**
  60608. * Public method to set a Mesh to a frame
  60609. * @param m that is the target
  60610. * @param frameID or the frame index
  60611. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60612. */
  60613. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60614. /**
  60615. * Starts the async promise to compile the texture packer.
  60616. * @returns Promise<void>
  60617. */
  60618. processAsync(): Promise<void>;
  60619. /**
  60620. * Disposes all textures associated with this packer
  60621. */
  60622. dispose(): void;
  60623. /**
  60624. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60625. * @param imageType is the image type to use.
  60626. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60627. */
  60628. download(imageType?: string, quality?: number): void;
  60629. /**
  60630. * Public method to load a texturePacker JSON file.
  60631. * @param data of the JSON file in string format.
  60632. */
  60633. updateFromJSON(data: string): void;
  60634. }
  60635. }
  60636. declare module BABYLON {
  60637. /**
  60638. * 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.
  60639. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60640. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60641. */
  60642. export class CustomProceduralTexture extends ProceduralTexture {
  60643. private _animate;
  60644. private _time;
  60645. private _config;
  60646. private _texturePath;
  60647. /**
  60648. * Instantiates a new Custom Procedural Texture.
  60649. * 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.
  60650. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60651. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60652. * @param name Define the name of the texture
  60653. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60654. * @param size Define the size of the texture to create
  60655. * @param scene Define the scene the texture belongs to
  60656. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60657. * @param generateMipMaps Define if the texture should creates mip maps or not
  60658. */
  60659. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60660. private _loadJson;
  60661. /**
  60662. * Is the texture ready to be used ? (rendered at least once)
  60663. * @returns true if ready, otherwise, false.
  60664. */
  60665. isReady(): boolean;
  60666. /**
  60667. * Render the texture to its associated render target.
  60668. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60669. */
  60670. render(useCameraPostProcess?: boolean): void;
  60671. /**
  60672. * Update the list of dependant textures samplers in the shader.
  60673. */
  60674. updateTextures(): void;
  60675. /**
  60676. * Update the uniform values of the procedural texture in the shader.
  60677. */
  60678. updateShaderUniforms(): void;
  60679. /**
  60680. * Define if the texture animates or not.
  60681. */
  60682. get animate(): boolean;
  60683. set animate(value: boolean);
  60684. }
  60685. }
  60686. declare module BABYLON {
  60687. /** @hidden */
  60688. export var noisePixelShader: {
  60689. name: string;
  60690. shader: string;
  60691. };
  60692. }
  60693. declare module BABYLON {
  60694. /**
  60695. * Class used to generate noise procedural textures
  60696. */
  60697. export class NoiseProceduralTexture extends ProceduralTexture {
  60698. private _time;
  60699. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60700. brightness: number;
  60701. /** Defines the number of octaves to process */
  60702. octaves: number;
  60703. /** Defines the level of persistence (0.8 by default) */
  60704. persistence: number;
  60705. /** Gets or sets animation speed factor (default is 1) */
  60706. animationSpeedFactor: number;
  60707. /**
  60708. * Creates a new NoiseProceduralTexture
  60709. * @param name defines the name fo the texture
  60710. * @param size defines the size of the texture (default is 256)
  60711. * @param scene defines the hosting scene
  60712. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60713. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60714. */
  60715. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60716. private _updateShaderUniforms;
  60717. protected _getDefines(): string;
  60718. /** Generate the current state of the procedural texture */
  60719. render(useCameraPostProcess?: boolean): void;
  60720. /**
  60721. * Serializes this noise procedural texture
  60722. * @returns a serialized noise procedural texture object
  60723. */
  60724. serialize(): any;
  60725. /**
  60726. * Clone the texture.
  60727. * @returns the cloned texture
  60728. */
  60729. clone(): NoiseProceduralTexture;
  60730. /**
  60731. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60732. * @param parsedTexture defines parsed texture data
  60733. * @param scene defines the current scene
  60734. * @param rootUrl defines the root URL containing noise procedural texture information
  60735. * @returns a parsed NoiseProceduralTexture
  60736. */
  60737. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60738. }
  60739. }
  60740. declare module BABYLON {
  60741. /**
  60742. * Raw cube texture where the raw buffers are passed in
  60743. */
  60744. export class RawCubeTexture extends CubeTexture {
  60745. /**
  60746. * Creates a cube texture where the raw buffers are passed in.
  60747. * @param scene defines the scene the texture is attached to
  60748. * @param data defines the array of data to use to create each face
  60749. * @param size defines the size of the textures
  60750. * @param format defines the format of the data
  60751. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60752. * @param generateMipMaps defines if the engine should generate the mip levels
  60753. * @param invertY defines if data must be stored with Y axis inverted
  60754. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60755. * @param compression defines the compression used (null by default)
  60756. */
  60757. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60758. /**
  60759. * Updates the raw cube texture.
  60760. * @param data defines the data to store
  60761. * @param format defines the data format
  60762. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60763. * @param invertY defines if data must be stored with Y axis inverted
  60764. * @param compression defines the compression used (null by default)
  60765. * @param level defines which level of the texture to update
  60766. */
  60767. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60768. /**
  60769. * Updates a raw cube texture with RGBD encoded data.
  60770. * @param data defines the array of data [mipmap][face] to use to create each face
  60771. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60772. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60773. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60774. * @returns a promsie that resolves when the operation is complete
  60775. */
  60776. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60777. /**
  60778. * Clones the raw cube texture.
  60779. * @return a new cube texture
  60780. */
  60781. clone(): CubeTexture;
  60782. /** @hidden */
  60783. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60784. }
  60785. }
  60786. declare module BABYLON {
  60787. /**
  60788. * Class used to store 2D array textures containing user data
  60789. */
  60790. export class RawTexture2DArray extends Texture {
  60791. /** Gets or sets the texture format to use */
  60792. format: number;
  60793. /**
  60794. * Create a new RawTexture2DArray
  60795. * @param data defines the data of the texture
  60796. * @param width defines the width of the texture
  60797. * @param height defines the height of the texture
  60798. * @param depth defines the number of layers of the texture
  60799. * @param format defines the texture format to use
  60800. * @param scene defines the hosting scene
  60801. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60802. * @param invertY defines if texture must be stored with Y axis inverted
  60803. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60805. */
  60806. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60807. /** Gets or sets the texture format to use */
  60808. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60809. /**
  60810. * Update the texture with new data
  60811. * @param data defines the data to store in the texture
  60812. */
  60813. update(data: ArrayBufferView): void;
  60814. }
  60815. }
  60816. declare module BABYLON {
  60817. /**
  60818. * Class used to store 3D textures containing user data
  60819. */
  60820. export class RawTexture3D extends Texture {
  60821. /** Gets or sets the texture format to use */
  60822. format: number;
  60823. /**
  60824. * Create a new RawTexture3D
  60825. * @param data defines the data of the texture
  60826. * @param width defines the width of the texture
  60827. * @param height defines the height of the texture
  60828. * @param depth defines the depth of the texture
  60829. * @param format defines the texture format to use
  60830. * @param scene defines the hosting scene
  60831. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60832. * @param invertY defines if texture must be stored with Y axis inverted
  60833. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60834. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60835. */
  60836. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60837. /** Gets or sets the texture format to use */
  60838. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60839. /**
  60840. * Update the texture with new data
  60841. * @param data defines the data to store in the texture
  60842. */
  60843. update(data: ArrayBufferView): void;
  60844. }
  60845. }
  60846. declare module BABYLON {
  60847. /**
  60848. * Creates a refraction texture used by refraction channel of the standard material.
  60849. * It is like a mirror but to see through a material.
  60850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60851. */
  60852. export class RefractionTexture extends RenderTargetTexture {
  60853. /**
  60854. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60855. * 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.
  60856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60857. */
  60858. refractionPlane: Plane;
  60859. /**
  60860. * Define how deep under the surface we should see.
  60861. */
  60862. depth: number;
  60863. /**
  60864. * Creates a refraction texture used by refraction channel of the standard material.
  60865. * It is like a mirror but to see through a material.
  60866. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60867. * @param name Define the texture name
  60868. * @param size Define the size of the underlying texture
  60869. * @param scene Define the scene the refraction belongs to
  60870. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60871. */
  60872. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60873. /**
  60874. * Clone the refraction texture.
  60875. * @returns the cloned texture
  60876. */
  60877. clone(): RefractionTexture;
  60878. /**
  60879. * Serialize the texture to a JSON representation you could use in Parse later on
  60880. * @returns the serialized JSON representation
  60881. */
  60882. serialize(): any;
  60883. }
  60884. }
  60885. declare module BABYLON {
  60886. /**
  60887. * Block used to add support for vertex skinning (bones)
  60888. */
  60889. export class BonesBlock extends NodeMaterialBlock {
  60890. /**
  60891. * Creates a new BonesBlock
  60892. * @param name defines the block name
  60893. */
  60894. constructor(name: string);
  60895. /**
  60896. * Initialize the block and prepare the context for build
  60897. * @param state defines the state that will be used for the build
  60898. */
  60899. initialize(state: NodeMaterialBuildState): void;
  60900. /**
  60901. * Gets the current class name
  60902. * @returns the class name
  60903. */
  60904. getClassName(): string;
  60905. /**
  60906. * Gets the matrix indices input component
  60907. */
  60908. get matricesIndices(): NodeMaterialConnectionPoint;
  60909. /**
  60910. * Gets the matrix weights input component
  60911. */
  60912. get matricesWeights(): NodeMaterialConnectionPoint;
  60913. /**
  60914. * Gets the extra matrix indices input component
  60915. */
  60916. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60917. /**
  60918. * Gets the extra matrix weights input component
  60919. */
  60920. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60921. /**
  60922. * Gets the world input component
  60923. */
  60924. get world(): NodeMaterialConnectionPoint;
  60925. /**
  60926. * Gets the output component
  60927. */
  60928. get output(): NodeMaterialConnectionPoint;
  60929. autoConfigure(material: NodeMaterial): void;
  60930. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60933. protected _buildBlock(state: NodeMaterialBuildState): this;
  60934. }
  60935. }
  60936. declare module BABYLON {
  60937. /**
  60938. * Block used to add support for instances
  60939. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60940. */
  60941. export class InstancesBlock extends NodeMaterialBlock {
  60942. /**
  60943. * Creates a new InstancesBlock
  60944. * @param name defines the block name
  60945. */
  60946. constructor(name: string);
  60947. /**
  60948. * Gets the current class name
  60949. * @returns the class name
  60950. */
  60951. getClassName(): string;
  60952. /**
  60953. * Gets the first world row input component
  60954. */
  60955. get world0(): NodeMaterialConnectionPoint;
  60956. /**
  60957. * Gets the second world row input component
  60958. */
  60959. get world1(): NodeMaterialConnectionPoint;
  60960. /**
  60961. * Gets the third world row input component
  60962. */
  60963. get world2(): NodeMaterialConnectionPoint;
  60964. /**
  60965. * Gets the forth world row input component
  60966. */
  60967. get world3(): NodeMaterialConnectionPoint;
  60968. /**
  60969. * Gets the world input component
  60970. */
  60971. get world(): NodeMaterialConnectionPoint;
  60972. /**
  60973. * Gets the output component
  60974. */
  60975. get output(): NodeMaterialConnectionPoint;
  60976. /**
  60977. * Gets the isntanceID component
  60978. */
  60979. get instanceID(): NodeMaterialConnectionPoint;
  60980. autoConfigure(material: NodeMaterial): void;
  60981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60982. protected _buildBlock(state: NodeMaterialBuildState): this;
  60983. }
  60984. }
  60985. declare module BABYLON {
  60986. /**
  60987. * Block used to add morph targets support to vertex shader
  60988. */
  60989. export class MorphTargetsBlock extends NodeMaterialBlock {
  60990. private _repeatableContentAnchor;
  60991. /**
  60992. * Create a new MorphTargetsBlock
  60993. * @param name defines the block name
  60994. */
  60995. constructor(name: string);
  60996. /**
  60997. * Gets the current class name
  60998. * @returns the class name
  60999. */
  61000. getClassName(): string;
  61001. /**
  61002. * Gets the position input component
  61003. */
  61004. get position(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the normal input component
  61007. */
  61008. get normal(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the tangent input component
  61011. */
  61012. get tangent(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the tangent input component
  61015. */
  61016. get uv(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the position output component
  61019. */
  61020. get positionOutput(): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Gets the normal output component
  61023. */
  61024. get normalOutput(): NodeMaterialConnectionPoint;
  61025. /**
  61026. * Gets the tangent output component
  61027. */
  61028. get tangentOutput(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the tangent output component
  61031. */
  61032. get uvOutput(): NodeMaterialConnectionPoint;
  61033. initialize(state: NodeMaterialBuildState): void;
  61034. autoConfigure(material: NodeMaterial): void;
  61035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61037. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61038. protected _buildBlock(state: NodeMaterialBuildState): this;
  61039. }
  61040. }
  61041. declare module BABYLON {
  61042. /**
  61043. * Block used to get data information from a light
  61044. */
  61045. export class LightInformationBlock extends NodeMaterialBlock {
  61046. private _lightDataUniformName;
  61047. private _lightColorUniformName;
  61048. private _lightTypeDefineName;
  61049. /**
  61050. * Gets or sets the light associated with this block
  61051. */
  61052. light: Nullable<Light>;
  61053. /**
  61054. * Creates a new LightInformationBlock
  61055. * @param name defines the block name
  61056. */
  61057. constructor(name: string);
  61058. /**
  61059. * Gets the current class name
  61060. * @returns the class name
  61061. */
  61062. getClassName(): string;
  61063. /**
  61064. * Gets the world position input component
  61065. */
  61066. get worldPosition(): NodeMaterialConnectionPoint;
  61067. /**
  61068. * Gets the direction output component
  61069. */
  61070. get direction(): NodeMaterialConnectionPoint;
  61071. /**
  61072. * Gets the direction output component
  61073. */
  61074. get color(): NodeMaterialConnectionPoint;
  61075. /**
  61076. * Gets the direction output component
  61077. */
  61078. get intensity(): NodeMaterialConnectionPoint;
  61079. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61080. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61081. protected _buildBlock(state: NodeMaterialBuildState): this;
  61082. serialize(): any;
  61083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61084. }
  61085. }
  61086. declare module BABYLON {
  61087. /**
  61088. * Block used to add image processing support to fragment shader
  61089. */
  61090. export class ImageProcessingBlock extends NodeMaterialBlock {
  61091. /**
  61092. * Create a new ImageProcessingBlock
  61093. * @param name defines the block name
  61094. */
  61095. constructor(name: string);
  61096. /**
  61097. * Gets the current class name
  61098. * @returns the class name
  61099. */
  61100. getClassName(): string;
  61101. /**
  61102. * Gets the color input component
  61103. */
  61104. get color(): NodeMaterialConnectionPoint;
  61105. /**
  61106. * Gets the output component
  61107. */
  61108. get output(): NodeMaterialConnectionPoint;
  61109. /**
  61110. * Initialize the block and prepare the context for build
  61111. * @param state defines the state that will be used for the build
  61112. */
  61113. initialize(state: NodeMaterialBuildState): void;
  61114. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. }
  61119. }
  61120. declare module BABYLON {
  61121. /**
  61122. * Block used to pertub normals based on a normal map
  61123. */
  61124. export class PerturbNormalBlock extends NodeMaterialBlock {
  61125. private _tangentSpaceParameterName;
  61126. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61127. invertX: boolean;
  61128. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61129. invertY: boolean;
  61130. /**
  61131. * Create a new PerturbNormalBlock
  61132. * @param name defines the block name
  61133. */
  61134. constructor(name: string);
  61135. /**
  61136. * Gets the current class name
  61137. * @returns the class name
  61138. */
  61139. getClassName(): string;
  61140. /**
  61141. * Gets the world position input component
  61142. */
  61143. get worldPosition(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Gets the world normal input component
  61146. */
  61147. get worldNormal(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the world tangent input component
  61150. */
  61151. get worldTangent(): NodeMaterialConnectionPoint;
  61152. /**
  61153. * Gets the uv input component
  61154. */
  61155. get uv(): NodeMaterialConnectionPoint;
  61156. /**
  61157. * Gets the normal map color input component
  61158. */
  61159. get normalMapColor(): NodeMaterialConnectionPoint;
  61160. /**
  61161. * Gets the strength input component
  61162. */
  61163. get strength(): NodeMaterialConnectionPoint;
  61164. /**
  61165. * Gets the output component
  61166. */
  61167. get output(): NodeMaterialConnectionPoint;
  61168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61170. autoConfigure(material: NodeMaterial): void;
  61171. protected _buildBlock(state: NodeMaterialBuildState): this;
  61172. protected _dumpPropertiesCode(): string;
  61173. serialize(): any;
  61174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61175. }
  61176. }
  61177. declare module BABYLON {
  61178. /**
  61179. * Block used to discard a pixel if a value is smaller than a cutoff
  61180. */
  61181. export class DiscardBlock extends NodeMaterialBlock {
  61182. /**
  61183. * Create a new DiscardBlock
  61184. * @param name defines the block name
  61185. */
  61186. constructor(name: string);
  61187. /**
  61188. * Gets the current class name
  61189. * @returns the class name
  61190. */
  61191. getClassName(): string;
  61192. /**
  61193. * Gets the color input component
  61194. */
  61195. get value(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Gets the cutoff input component
  61198. */
  61199. get cutoff(): NodeMaterialConnectionPoint;
  61200. protected _buildBlock(state: NodeMaterialBuildState): this;
  61201. }
  61202. }
  61203. declare module BABYLON {
  61204. /**
  61205. * Block used to test if the fragment shader is front facing
  61206. */
  61207. export class FrontFacingBlock extends NodeMaterialBlock {
  61208. /**
  61209. * Creates a new FrontFacingBlock
  61210. * @param name defines the block name
  61211. */
  61212. constructor(name: string);
  61213. /**
  61214. * Gets the current class name
  61215. * @returns the class name
  61216. */
  61217. getClassName(): string;
  61218. /**
  61219. * Gets the output component
  61220. */
  61221. get output(): NodeMaterialConnectionPoint;
  61222. protected _buildBlock(state: NodeMaterialBuildState): this;
  61223. }
  61224. }
  61225. declare module BABYLON {
  61226. /**
  61227. * Block used to get the derivative value on x and y of a given input
  61228. */
  61229. export class DerivativeBlock extends NodeMaterialBlock {
  61230. /**
  61231. * Create a new DerivativeBlock
  61232. * @param name defines the block name
  61233. */
  61234. constructor(name: string);
  61235. /**
  61236. * Gets the current class name
  61237. * @returns the class name
  61238. */
  61239. getClassName(): string;
  61240. /**
  61241. * Gets the input component
  61242. */
  61243. get input(): NodeMaterialConnectionPoint;
  61244. /**
  61245. * Gets the derivative output on x
  61246. */
  61247. get dx(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the derivative output on y
  61250. */
  61251. get dy(): NodeMaterialConnectionPoint;
  61252. protected _buildBlock(state: NodeMaterialBuildState): this;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Block used to make gl_FragCoord available
  61258. */
  61259. export class FragCoordBlock extends NodeMaterialBlock {
  61260. /**
  61261. * Creates a new FragCoordBlock
  61262. * @param name defines the block name
  61263. */
  61264. constructor(name: string);
  61265. /**
  61266. * Gets the current class name
  61267. * @returns the class name
  61268. */
  61269. getClassName(): string;
  61270. /**
  61271. * Gets the xy component
  61272. */
  61273. get xy(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the xyz component
  61276. */
  61277. get xyz(): NodeMaterialConnectionPoint;
  61278. /**
  61279. * Gets the xyzw component
  61280. */
  61281. get xyzw(): NodeMaterialConnectionPoint;
  61282. /**
  61283. * Gets the x component
  61284. */
  61285. get x(): NodeMaterialConnectionPoint;
  61286. /**
  61287. * Gets the y component
  61288. */
  61289. get y(): NodeMaterialConnectionPoint;
  61290. /**
  61291. * Gets the z component
  61292. */
  61293. get z(): NodeMaterialConnectionPoint;
  61294. /**
  61295. * Gets the w component
  61296. */
  61297. get output(): NodeMaterialConnectionPoint;
  61298. protected writeOutputs(state: NodeMaterialBuildState): string;
  61299. protected _buildBlock(state: NodeMaterialBuildState): this;
  61300. }
  61301. }
  61302. declare module BABYLON {
  61303. /**
  61304. * Block used to get the screen sizes
  61305. */
  61306. export class ScreenSizeBlock extends NodeMaterialBlock {
  61307. private _varName;
  61308. private _scene;
  61309. /**
  61310. * Creates a new ScreenSizeBlock
  61311. * @param name defines the block name
  61312. */
  61313. constructor(name: string);
  61314. /**
  61315. * Gets the current class name
  61316. * @returns the class name
  61317. */
  61318. getClassName(): string;
  61319. /**
  61320. * Gets the xy component
  61321. */
  61322. get xy(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the x component
  61325. */
  61326. get x(): NodeMaterialConnectionPoint;
  61327. /**
  61328. * Gets the y component
  61329. */
  61330. get y(): NodeMaterialConnectionPoint;
  61331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61332. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61333. protected _buildBlock(state: NodeMaterialBuildState): this;
  61334. }
  61335. }
  61336. declare module BABYLON {
  61337. /**
  61338. * Block used to add support for scene fog
  61339. */
  61340. export class FogBlock extends NodeMaterialBlock {
  61341. private _fogDistanceName;
  61342. private _fogParameters;
  61343. /**
  61344. * Create a new FogBlock
  61345. * @param name defines the block name
  61346. */
  61347. constructor(name: string);
  61348. /**
  61349. * Gets the current class name
  61350. * @returns the class name
  61351. */
  61352. getClassName(): string;
  61353. /**
  61354. * Gets the world position input component
  61355. */
  61356. get worldPosition(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the view input component
  61359. */
  61360. get view(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the color input component
  61363. */
  61364. get input(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the fog color input component
  61367. */
  61368. get fogColor(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the output component
  61371. */
  61372. get output(): NodeMaterialConnectionPoint;
  61373. autoConfigure(material: NodeMaterial): void;
  61374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61376. protected _buildBlock(state: NodeMaterialBuildState): this;
  61377. }
  61378. }
  61379. declare module BABYLON {
  61380. /**
  61381. * Block used to add light in the fragment shader
  61382. */
  61383. export class LightBlock extends NodeMaterialBlock {
  61384. private _lightId;
  61385. /**
  61386. * Gets or sets the light associated with this block
  61387. */
  61388. light: Nullable<Light>;
  61389. /**
  61390. * Create a new LightBlock
  61391. * @param name defines the block name
  61392. */
  61393. constructor(name: string);
  61394. /**
  61395. * Gets the current class name
  61396. * @returns the class name
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Gets the world position input component
  61401. */
  61402. get worldPosition(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Gets the world normal input component
  61405. */
  61406. get worldNormal(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the camera (or eye) position component
  61409. */
  61410. get cameraPosition(): NodeMaterialConnectionPoint;
  61411. /**
  61412. * Gets the glossiness component
  61413. */
  61414. get glossiness(): NodeMaterialConnectionPoint;
  61415. /**
  61416. * Gets the glossinness power component
  61417. */
  61418. get glossPower(): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Gets the diffuse color component
  61421. */
  61422. get diffuseColor(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the specular color component
  61425. */
  61426. get specularColor(): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Gets the diffuse output component
  61429. */
  61430. get diffuseOutput(): NodeMaterialConnectionPoint;
  61431. /**
  61432. * Gets the specular output component
  61433. */
  61434. get specularOutput(): NodeMaterialConnectionPoint;
  61435. /**
  61436. * Gets the shadow output component
  61437. */
  61438. get shadow(): NodeMaterialConnectionPoint;
  61439. autoConfigure(material: NodeMaterial): void;
  61440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61441. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61443. private _injectVertexCode;
  61444. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61445. serialize(): any;
  61446. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61447. }
  61448. }
  61449. declare module BABYLON {
  61450. /**
  61451. * Block used to read a reflection texture from a sampler
  61452. */
  61453. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61454. /**
  61455. * Create a new ReflectionTextureBlock
  61456. * @param name defines the block name
  61457. */
  61458. constructor(name: string);
  61459. /**
  61460. * Gets the current class name
  61461. * @returns the class name
  61462. */
  61463. getClassName(): string;
  61464. /**
  61465. * Gets the world position input component
  61466. */
  61467. get position(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the world position input component
  61470. */
  61471. get worldPosition(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the world normal input component
  61474. */
  61475. get worldNormal(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the world input component
  61478. */
  61479. get world(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the camera (or eye) position component
  61482. */
  61483. get cameraPosition(): NodeMaterialConnectionPoint;
  61484. /**
  61485. * Gets the view input component
  61486. */
  61487. get view(): NodeMaterialConnectionPoint;
  61488. /**
  61489. * Gets the rgb output component
  61490. */
  61491. get rgb(): NodeMaterialConnectionPoint;
  61492. /**
  61493. * Gets the r output component
  61494. */
  61495. get r(): NodeMaterialConnectionPoint;
  61496. /**
  61497. * Gets the g output component
  61498. */
  61499. get g(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the b output component
  61502. */
  61503. get b(): NodeMaterialConnectionPoint;
  61504. autoConfigure(material: NodeMaterial): void;
  61505. protected _buildBlock(state: NodeMaterialBuildState): this;
  61506. }
  61507. }
  61508. declare module BABYLON {
  61509. /**
  61510. * Block used to add 2 vectors
  61511. */
  61512. export class AddBlock extends NodeMaterialBlock {
  61513. /**
  61514. * Creates a new AddBlock
  61515. * @param name defines the block name
  61516. */
  61517. constructor(name: string);
  61518. /**
  61519. * Gets the current class name
  61520. * @returns the class name
  61521. */
  61522. getClassName(): string;
  61523. /**
  61524. * Gets the left operand input component
  61525. */
  61526. get left(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the right operand input component
  61529. */
  61530. get right(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the output component
  61533. */
  61534. get output(): NodeMaterialConnectionPoint;
  61535. protected _buildBlock(state: NodeMaterialBuildState): this;
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /**
  61540. * Block used to scale a vector by a float
  61541. */
  61542. export class ScaleBlock extends NodeMaterialBlock {
  61543. /**
  61544. * Creates a new ScaleBlock
  61545. * @param name defines the block name
  61546. */
  61547. constructor(name: string);
  61548. /**
  61549. * Gets the current class name
  61550. * @returns the class name
  61551. */
  61552. getClassName(): string;
  61553. /**
  61554. * Gets the input component
  61555. */
  61556. get input(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the factor input component
  61559. */
  61560. get factor(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the output component
  61563. */
  61564. get output(): NodeMaterialConnectionPoint;
  61565. protected _buildBlock(state: NodeMaterialBuildState): this;
  61566. }
  61567. }
  61568. declare module BABYLON {
  61569. /**
  61570. * Block used to clamp a float
  61571. */
  61572. export class ClampBlock extends NodeMaterialBlock {
  61573. /** Gets or sets the minimum range */
  61574. minimum: number;
  61575. /** Gets or sets the maximum range */
  61576. maximum: number;
  61577. /**
  61578. * Creates a new ClampBlock
  61579. * @param name defines the block name
  61580. */
  61581. constructor(name: string);
  61582. /**
  61583. * Gets the current class name
  61584. * @returns the class name
  61585. */
  61586. getClassName(): string;
  61587. /**
  61588. * Gets the value input component
  61589. */
  61590. get value(): NodeMaterialConnectionPoint;
  61591. /**
  61592. * Gets the output component
  61593. */
  61594. get output(): NodeMaterialConnectionPoint;
  61595. protected _buildBlock(state: NodeMaterialBuildState): this;
  61596. protected _dumpPropertiesCode(): string;
  61597. serialize(): any;
  61598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61599. }
  61600. }
  61601. declare module BABYLON {
  61602. /**
  61603. * Block used to apply a cross product between 2 vectors
  61604. */
  61605. export class CrossBlock extends NodeMaterialBlock {
  61606. /**
  61607. * Creates a new CrossBlock
  61608. * @param name defines the block name
  61609. */
  61610. constructor(name: string);
  61611. /**
  61612. * Gets the current class name
  61613. * @returns the class name
  61614. */
  61615. getClassName(): string;
  61616. /**
  61617. * Gets the left operand input component
  61618. */
  61619. get left(): NodeMaterialConnectionPoint;
  61620. /**
  61621. * Gets the right operand input component
  61622. */
  61623. get right(): NodeMaterialConnectionPoint;
  61624. /**
  61625. * Gets the output component
  61626. */
  61627. get output(): NodeMaterialConnectionPoint;
  61628. protected _buildBlock(state: NodeMaterialBuildState): this;
  61629. }
  61630. }
  61631. declare module BABYLON {
  61632. /**
  61633. * Block used to apply a dot product between 2 vectors
  61634. */
  61635. export class DotBlock extends NodeMaterialBlock {
  61636. /**
  61637. * Creates a new DotBlock
  61638. * @param name defines the block name
  61639. */
  61640. constructor(name: string);
  61641. /**
  61642. * Gets the current class name
  61643. * @returns the class name
  61644. */
  61645. getClassName(): string;
  61646. /**
  61647. * Gets the left operand input component
  61648. */
  61649. get left(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the right operand input component
  61652. */
  61653. get right(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the output component
  61656. */
  61657. get output(): NodeMaterialConnectionPoint;
  61658. protected _buildBlock(state: NodeMaterialBuildState): this;
  61659. }
  61660. }
  61661. declare module BABYLON {
  61662. /**
  61663. * Block used to normalize a vector
  61664. */
  61665. export class NormalizeBlock extends NodeMaterialBlock {
  61666. /**
  61667. * Creates a new NormalizeBlock
  61668. * @param name defines the block name
  61669. */
  61670. constructor(name: string);
  61671. /**
  61672. * Gets the current class name
  61673. * @returns the class name
  61674. */
  61675. getClassName(): string;
  61676. /**
  61677. * Gets the input component
  61678. */
  61679. get input(): NodeMaterialConnectionPoint;
  61680. /**
  61681. * Gets the output component
  61682. */
  61683. get output(): NodeMaterialConnectionPoint;
  61684. protected _buildBlock(state: NodeMaterialBuildState): this;
  61685. }
  61686. }
  61687. declare module BABYLON {
  61688. /**
  61689. * Operations supported by the Trigonometry block
  61690. */
  61691. export enum TrigonometryBlockOperations {
  61692. /** Cos */
  61693. Cos = 0,
  61694. /** Sin */
  61695. Sin = 1,
  61696. /** Abs */
  61697. Abs = 2,
  61698. /** Exp */
  61699. Exp = 3,
  61700. /** Exp2 */
  61701. Exp2 = 4,
  61702. /** Round */
  61703. Round = 5,
  61704. /** Floor */
  61705. Floor = 6,
  61706. /** Ceiling */
  61707. Ceiling = 7,
  61708. /** Square root */
  61709. Sqrt = 8,
  61710. /** Log */
  61711. Log = 9,
  61712. /** Tangent */
  61713. Tan = 10,
  61714. /** Arc tangent */
  61715. ArcTan = 11,
  61716. /** Arc cosinus */
  61717. ArcCos = 12,
  61718. /** Arc sinus */
  61719. ArcSin = 13,
  61720. /** Fraction */
  61721. Fract = 14,
  61722. /** Sign */
  61723. Sign = 15,
  61724. /** To radians (from degrees) */
  61725. Radians = 16,
  61726. /** To degrees (from radians) */
  61727. Degrees = 17
  61728. }
  61729. /**
  61730. * Block used to apply trigonometry operation to floats
  61731. */
  61732. export class TrigonometryBlock extends NodeMaterialBlock {
  61733. /**
  61734. * Gets or sets the operation applied by the block
  61735. */
  61736. operation: TrigonometryBlockOperations;
  61737. /**
  61738. * Creates a new TrigonometryBlock
  61739. * @param name defines the block name
  61740. */
  61741. constructor(name: string);
  61742. /**
  61743. * Gets the current class name
  61744. * @returns the class name
  61745. */
  61746. getClassName(): string;
  61747. /**
  61748. * Gets the input component
  61749. */
  61750. get input(): NodeMaterialConnectionPoint;
  61751. /**
  61752. * Gets the output component
  61753. */
  61754. get output(): NodeMaterialConnectionPoint;
  61755. protected _buildBlock(state: NodeMaterialBuildState): this;
  61756. serialize(): any;
  61757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61758. protected _dumpPropertiesCode(): string;
  61759. }
  61760. }
  61761. declare module BABYLON {
  61762. /**
  61763. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61764. */
  61765. export class ColorMergerBlock extends NodeMaterialBlock {
  61766. /**
  61767. * Create a new ColorMergerBlock
  61768. * @param name defines the block name
  61769. */
  61770. constructor(name: string);
  61771. /**
  61772. * Gets the current class name
  61773. * @returns the class name
  61774. */
  61775. getClassName(): string;
  61776. /**
  61777. * Gets the rgb component (input)
  61778. */
  61779. get rgbIn(): NodeMaterialConnectionPoint;
  61780. /**
  61781. * Gets the r component (input)
  61782. */
  61783. get r(): NodeMaterialConnectionPoint;
  61784. /**
  61785. * Gets the g component (input)
  61786. */
  61787. get g(): NodeMaterialConnectionPoint;
  61788. /**
  61789. * Gets the b component (input)
  61790. */
  61791. get b(): NodeMaterialConnectionPoint;
  61792. /**
  61793. * Gets the a component (input)
  61794. */
  61795. get a(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the rgba component (output)
  61798. */
  61799. get rgba(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the rgb component (output)
  61802. */
  61803. get rgbOut(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the rgb component (output)
  61806. * @deprecated Please use rgbOut instead.
  61807. */
  61808. get rgb(): NodeMaterialConnectionPoint;
  61809. protected _buildBlock(state: NodeMaterialBuildState): this;
  61810. }
  61811. }
  61812. declare module BABYLON {
  61813. /**
  61814. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61815. */
  61816. export class VectorSplitterBlock extends NodeMaterialBlock {
  61817. /**
  61818. * Create a new VectorSplitterBlock
  61819. * @param name defines the block name
  61820. */
  61821. constructor(name: string);
  61822. /**
  61823. * Gets the current class name
  61824. * @returns the class name
  61825. */
  61826. getClassName(): string;
  61827. /**
  61828. * Gets the xyzw component (input)
  61829. */
  61830. get xyzw(): NodeMaterialConnectionPoint;
  61831. /**
  61832. * Gets the xyz component (input)
  61833. */
  61834. get xyzIn(): NodeMaterialConnectionPoint;
  61835. /**
  61836. * Gets the xy component (input)
  61837. */
  61838. get xyIn(): NodeMaterialConnectionPoint;
  61839. /**
  61840. * Gets the xyz component (output)
  61841. */
  61842. get xyzOut(): NodeMaterialConnectionPoint;
  61843. /**
  61844. * Gets the xy component (output)
  61845. */
  61846. get xyOut(): NodeMaterialConnectionPoint;
  61847. /**
  61848. * Gets the x component (output)
  61849. */
  61850. get x(): NodeMaterialConnectionPoint;
  61851. /**
  61852. * Gets the y component (output)
  61853. */
  61854. get y(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the z component (output)
  61857. */
  61858. get z(): NodeMaterialConnectionPoint;
  61859. /**
  61860. * Gets the w component (output)
  61861. */
  61862. get w(): NodeMaterialConnectionPoint;
  61863. protected _inputRename(name: string): string;
  61864. protected _outputRename(name: string): string;
  61865. protected _buildBlock(state: NodeMaterialBuildState): this;
  61866. }
  61867. }
  61868. declare module BABYLON {
  61869. /**
  61870. * Block used to lerp between 2 values
  61871. */
  61872. export class LerpBlock extends NodeMaterialBlock {
  61873. /**
  61874. * Creates a new LerpBlock
  61875. * @param name defines the block name
  61876. */
  61877. constructor(name: string);
  61878. /**
  61879. * Gets the current class name
  61880. * @returns the class name
  61881. */
  61882. getClassName(): string;
  61883. /**
  61884. * Gets the left operand input component
  61885. */
  61886. get left(): NodeMaterialConnectionPoint;
  61887. /**
  61888. * Gets the right operand input component
  61889. */
  61890. get right(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the gradient operand input component
  61893. */
  61894. get gradient(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the output component
  61897. */
  61898. get output(): NodeMaterialConnectionPoint;
  61899. protected _buildBlock(state: NodeMaterialBuildState): this;
  61900. }
  61901. }
  61902. declare module BABYLON {
  61903. /**
  61904. * Block used to divide 2 vectors
  61905. */
  61906. export class DivideBlock extends NodeMaterialBlock {
  61907. /**
  61908. * Creates a new DivideBlock
  61909. * @param name defines the block name
  61910. */
  61911. constructor(name: string);
  61912. /**
  61913. * Gets the current class name
  61914. * @returns the class name
  61915. */
  61916. getClassName(): string;
  61917. /**
  61918. * Gets the left operand input component
  61919. */
  61920. get left(): NodeMaterialConnectionPoint;
  61921. /**
  61922. * Gets the right operand input component
  61923. */
  61924. get right(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. protected _buildBlock(state: NodeMaterialBuildState): this;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. /**
  61934. * Block used to subtract 2 vectors
  61935. */
  61936. export class SubtractBlock extends NodeMaterialBlock {
  61937. /**
  61938. * Creates a new SubtractBlock
  61939. * @param name defines the block name
  61940. */
  61941. constructor(name: string);
  61942. /**
  61943. * Gets the current class name
  61944. * @returns the class name
  61945. */
  61946. getClassName(): string;
  61947. /**
  61948. * Gets the left operand input component
  61949. */
  61950. get left(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the right operand input component
  61953. */
  61954. get right(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the output component
  61957. */
  61958. get output(): NodeMaterialConnectionPoint;
  61959. protected _buildBlock(state: NodeMaterialBuildState): this;
  61960. }
  61961. }
  61962. declare module BABYLON {
  61963. /**
  61964. * Block used to step a value
  61965. */
  61966. export class StepBlock extends NodeMaterialBlock {
  61967. /**
  61968. * Creates a new StepBlock
  61969. * @param name defines the block name
  61970. */
  61971. constructor(name: string);
  61972. /**
  61973. * Gets the current class name
  61974. * @returns the class name
  61975. */
  61976. getClassName(): string;
  61977. /**
  61978. * Gets the value operand input component
  61979. */
  61980. get value(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the edge operand input component
  61983. */
  61984. get edge(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the output component
  61987. */
  61988. get output(): NodeMaterialConnectionPoint;
  61989. protected _buildBlock(state: NodeMaterialBuildState): this;
  61990. }
  61991. }
  61992. declare module BABYLON {
  61993. /**
  61994. * Block used to get the opposite (1 - x) of a value
  61995. */
  61996. export class OneMinusBlock extends NodeMaterialBlock {
  61997. /**
  61998. * Creates a new OneMinusBlock
  61999. * @param name defines the block name
  62000. */
  62001. constructor(name: string);
  62002. /**
  62003. * Gets the current class name
  62004. * @returns the class name
  62005. */
  62006. getClassName(): string;
  62007. /**
  62008. * Gets the input component
  62009. */
  62010. get input(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the output component
  62013. */
  62014. get output(): NodeMaterialConnectionPoint;
  62015. protected _buildBlock(state: NodeMaterialBuildState): this;
  62016. }
  62017. }
  62018. declare module BABYLON {
  62019. /**
  62020. * Block used to get the view direction
  62021. */
  62022. export class ViewDirectionBlock extends NodeMaterialBlock {
  62023. /**
  62024. * Creates a new ViewDirectionBlock
  62025. * @param name defines the block name
  62026. */
  62027. constructor(name: string);
  62028. /**
  62029. * Gets the current class name
  62030. * @returns the class name
  62031. */
  62032. getClassName(): string;
  62033. /**
  62034. * Gets the world position component
  62035. */
  62036. get worldPosition(): NodeMaterialConnectionPoint;
  62037. /**
  62038. * Gets the camera position component
  62039. */
  62040. get cameraPosition(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the output component
  62043. */
  62044. get output(): NodeMaterialConnectionPoint;
  62045. autoConfigure(material: NodeMaterial): void;
  62046. protected _buildBlock(state: NodeMaterialBuildState): this;
  62047. }
  62048. }
  62049. declare module BABYLON {
  62050. /**
  62051. * Block used to compute fresnel value
  62052. */
  62053. export class FresnelBlock extends NodeMaterialBlock {
  62054. /**
  62055. * Create a new FresnelBlock
  62056. * @param name defines the block name
  62057. */
  62058. constructor(name: string);
  62059. /**
  62060. * Gets the current class name
  62061. * @returns the class name
  62062. */
  62063. getClassName(): string;
  62064. /**
  62065. * Gets the world normal input component
  62066. */
  62067. get worldNormal(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the view direction input component
  62070. */
  62071. get viewDirection(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the bias input component
  62074. */
  62075. get bias(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the camera (or eye) position component
  62078. */
  62079. get power(): NodeMaterialConnectionPoint;
  62080. /**
  62081. * Gets the fresnel output component
  62082. */
  62083. get fresnel(): NodeMaterialConnectionPoint;
  62084. autoConfigure(material: NodeMaterial): void;
  62085. protected _buildBlock(state: NodeMaterialBuildState): this;
  62086. }
  62087. }
  62088. declare module BABYLON {
  62089. /**
  62090. * Block used to get the max of 2 values
  62091. */
  62092. export class MaxBlock extends NodeMaterialBlock {
  62093. /**
  62094. * Creates a new MaxBlock
  62095. * @param name defines the block name
  62096. */
  62097. constructor(name: string);
  62098. /**
  62099. * Gets the current class name
  62100. * @returns the class name
  62101. */
  62102. getClassName(): string;
  62103. /**
  62104. * Gets the left operand input component
  62105. */
  62106. get left(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the right operand input component
  62109. */
  62110. get right(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the output component
  62113. */
  62114. get output(): NodeMaterialConnectionPoint;
  62115. protected _buildBlock(state: NodeMaterialBuildState): this;
  62116. }
  62117. }
  62118. declare module BABYLON {
  62119. /**
  62120. * Block used to get the min of 2 values
  62121. */
  62122. export class MinBlock extends NodeMaterialBlock {
  62123. /**
  62124. * Creates a new MinBlock
  62125. * @param name defines the block name
  62126. */
  62127. constructor(name: string);
  62128. /**
  62129. * Gets the current class name
  62130. * @returns the class name
  62131. */
  62132. getClassName(): string;
  62133. /**
  62134. * Gets the left operand input component
  62135. */
  62136. get left(): NodeMaterialConnectionPoint;
  62137. /**
  62138. * Gets the right operand input component
  62139. */
  62140. get right(): NodeMaterialConnectionPoint;
  62141. /**
  62142. * Gets the output component
  62143. */
  62144. get output(): NodeMaterialConnectionPoint;
  62145. protected _buildBlock(state: NodeMaterialBuildState): this;
  62146. }
  62147. }
  62148. declare module BABYLON {
  62149. /**
  62150. * Block used to get the distance between 2 values
  62151. */
  62152. export class DistanceBlock extends NodeMaterialBlock {
  62153. /**
  62154. * Creates a new DistanceBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the left operand input component
  62165. */
  62166. get left(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the right operand input component
  62169. */
  62170. get right(): NodeMaterialConnectionPoint;
  62171. /**
  62172. * Gets the output component
  62173. */
  62174. get output(): NodeMaterialConnectionPoint;
  62175. protected _buildBlock(state: NodeMaterialBuildState): this;
  62176. }
  62177. }
  62178. declare module BABYLON {
  62179. /**
  62180. * Block used to get the length of a vector
  62181. */
  62182. export class LengthBlock extends NodeMaterialBlock {
  62183. /**
  62184. * Creates a new LengthBlock
  62185. * @param name defines the block name
  62186. */
  62187. constructor(name: string);
  62188. /**
  62189. * Gets the current class name
  62190. * @returns the class name
  62191. */
  62192. getClassName(): string;
  62193. /**
  62194. * Gets the value input component
  62195. */
  62196. get value(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the output component
  62199. */
  62200. get output(): NodeMaterialConnectionPoint;
  62201. protected _buildBlock(state: NodeMaterialBuildState): this;
  62202. }
  62203. }
  62204. declare module BABYLON {
  62205. /**
  62206. * Block used to get negative version of a value (i.e. x * -1)
  62207. */
  62208. export class NegateBlock extends NodeMaterialBlock {
  62209. /**
  62210. * Creates a new NegateBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the value input component
  62221. */
  62222. get value(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the output component
  62225. */
  62226. get output(): NodeMaterialConnectionPoint;
  62227. protected _buildBlock(state: NodeMaterialBuildState): this;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * Block used to get the value of the first parameter raised to the power of the second
  62233. */
  62234. export class PowBlock extends NodeMaterialBlock {
  62235. /**
  62236. * Creates a new PowBlock
  62237. * @param name defines the block name
  62238. */
  62239. constructor(name: string);
  62240. /**
  62241. * Gets the current class name
  62242. * @returns the class name
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Gets the value operand input component
  62247. */
  62248. get value(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the power operand input component
  62251. */
  62252. get power(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the output component
  62255. */
  62256. get output(): NodeMaterialConnectionPoint;
  62257. protected _buildBlock(state: NodeMaterialBuildState): this;
  62258. }
  62259. }
  62260. declare module BABYLON {
  62261. /**
  62262. * Block used to get a random number
  62263. */
  62264. export class RandomNumberBlock extends NodeMaterialBlock {
  62265. /**
  62266. * Creates a new RandomNumberBlock
  62267. * @param name defines the block name
  62268. */
  62269. constructor(name: string);
  62270. /**
  62271. * Gets the current class name
  62272. * @returns the class name
  62273. */
  62274. getClassName(): string;
  62275. /**
  62276. * Gets the seed input component
  62277. */
  62278. get seed(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the output component
  62281. */
  62282. get output(): NodeMaterialConnectionPoint;
  62283. protected _buildBlock(state: NodeMaterialBuildState): this;
  62284. }
  62285. }
  62286. declare module BABYLON {
  62287. /**
  62288. * Block used to compute arc tangent of 2 values
  62289. */
  62290. export class ArcTan2Block extends NodeMaterialBlock {
  62291. /**
  62292. * Creates a new ArcTan2Block
  62293. * @param name defines the block name
  62294. */
  62295. constructor(name: string);
  62296. /**
  62297. * Gets the current class name
  62298. * @returns the class name
  62299. */
  62300. getClassName(): string;
  62301. /**
  62302. * Gets the x operand input component
  62303. */
  62304. get x(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the y operand input component
  62307. */
  62308. get y(): NodeMaterialConnectionPoint;
  62309. /**
  62310. * Gets the output component
  62311. */
  62312. get output(): NodeMaterialConnectionPoint;
  62313. protected _buildBlock(state: NodeMaterialBuildState): this;
  62314. }
  62315. }
  62316. declare module BABYLON {
  62317. /**
  62318. * Block used to smooth step a value
  62319. */
  62320. export class SmoothStepBlock extends NodeMaterialBlock {
  62321. /**
  62322. * Creates a new SmoothStepBlock
  62323. * @param name defines the block name
  62324. */
  62325. constructor(name: string);
  62326. /**
  62327. * Gets the current class name
  62328. * @returns the class name
  62329. */
  62330. getClassName(): string;
  62331. /**
  62332. * Gets the value operand input component
  62333. */
  62334. get value(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the first edge operand input component
  62337. */
  62338. get edge0(): NodeMaterialConnectionPoint;
  62339. /**
  62340. * Gets the second edge operand input component
  62341. */
  62342. get edge1(): NodeMaterialConnectionPoint;
  62343. /**
  62344. * Gets the output component
  62345. */
  62346. get output(): NodeMaterialConnectionPoint;
  62347. protected _buildBlock(state: NodeMaterialBuildState): this;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Block used to get the reciprocal (1 / x) of a value
  62353. */
  62354. export class ReciprocalBlock extends NodeMaterialBlock {
  62355. /**
  62356. * Creates a new ReciprocalBlock
  62357. * @param name defines the block name
  62358. */
  62359. constructor(name: string);
  62360. /**
  62361. * Gets the current class name
  62362. * @returns the class name
  62363. */
  62364. getClassName(): string;
  62365. /**
  62366. * Gets the input component
  62367. */
  62368. get input(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the output component
  62371. */
  62372. get output(): NodeMaterialConnectionPoint;
  62373. protected _buildBlock(state: NodeMaterialBuildState): this;
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /**
  62378. * Block used to replace a color by another one
  62379. */
  62380. export class ReplaceColorBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Creates a new ReplaceColorBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Gets the current class name
  62388. * @returns the class name
  62389. */
  62390. getClassName(): string;
  62391. /**
  62392. * Gets the value input component
  62393. */
  62394. get value(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the reference input component
  62397. */
  62398. get reference(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the distance input component
  62401. */
  62402. get distance(): NodeMaterialConnectionPoint;
  62403. /**
  62404. * Gets the replacement input component
  62405. */
  62406. get replacement(): NodeMaterialConnectionPoint;
  62407. /**
  62408. * Gets the output component
  62409. */
  62410. get output(): NodeMaterialConnectionPoint;
  62411. protected _buildBlock(state: NodeMaterialBuildState): this;
  62412. }
  62413. }
  62414. declare module BABYLON {
  62415. /**
  62416. * Block used to posterize a value
  62417. * @see https://en.wikipedia.org/wiki/Posterization
  62418. */
  62419. export class PosterizeBlock extends NodeMaterialBlock {
  62420. /**
  62421. * Creates a new PosterizeBlock
  62422. * @param name defines the block name
  62423. */
  62424. constructor(name: string);
  62425. /**
  62426. * Gets the current class name
  62427. * @returns the class name
  62428. */
  62429. getClassName(): string;
  62430. /**
  62431. * Gets the value input component
  62432. */
  62433. get value(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the steps input component
  62436. */
  62437. get steps(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the output component
  62440. */
  62441. get output(): NodeMaterialConnectionPoint;
  62442. protected _buildBlock(state: NodeMaterialBuildState): this;
  62443. }
  62444. }
  62445. declare module BABYLON {
  62446. /**
  62447. * Operations supported by the Wave block
  62448. */
  62449. export enum WaveBlockKind {
  62450. /** SawTooth */
  62451. SawTooth = 0,
  62452. /** Square */
  62453. Square = 1,
  62454. /** Triangle */
  62455. Triangle = 2
  62456. }
  62457. /**
  62458. * Block used to apply wave operation to floats
  62459. */
  62460. export class WaveBlock extends NodeMaterialBlock {
  62461. /**
  62462. * Gets or sets the kibnd of wave to be applied by the block
  62463. */
  62464. kind: WaveBlockKind;
  62465. /**
  62466. * Creates a new WaveBlock
  62467. * @param name defines the block name
  62468. */
  62469. constructor(name: string);
  62470. /**
  62471. * Gets the current class name
  62472. * @returns the class name
  62473. */
  62474. getClassName(): string;
  62475. /**
  62476. * Gets the input component
  62477. */
  62478. get input(): NodeMaterialConnectionPoint;
  62479. /**
  62480. * Gets the output component
  62481. */
  62482. get output(): NodeMaterialConnectionPoint;
  62483. protected _buildBlock(state: NodeMaterialBuildState): this;
  62484. serialize(): any;
  62485. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62486. }
  62487. }
  62488. declare module BABYLON {
  62489. /**
  62490. * Class used to store a color step for the GradientBlock
  62491. */
  62492. export class GradientBlockColorStep {
  62493. /**
  62494. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62495. */
  62496. step: number;
  62497. /**
  62498. * Gets or sets the color associated with this step
  62499. */
  62500. color: Color3;
  62501. /**
  62502. * Creates a new GradientBlockColorStep
  62503. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62504. * @param color defines the color associated with this step
  62505. */
  62506. constructor(
  62507. /**
  62508. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62509. */
  62510. step: number,
  62511. /**
  62512. * Gets or sets the color associated with this step
  62513. */
  62514. color: Color3);
  62515. }
  62516. /**
  62517. * Block used to return a color from a gradient based on an input value between 0 and 1
  62518. */
  62519. export class GradientBlock extends NodeMaterialBlock {
  62520. /**
  62521. * Gets or sets the list of color steps
  62522. */
  62523. colorSteps: GradientBlockColorStep[];
  62524. /**
  62525. * Creates a new GradientBlock
  62526. * @param name defines the block name
  62527. */
  62528. constructor(name: string);
  62529. /**
  62530. * Gets the current class name
  62531. * @returns the class name
  62532. */
  62533. getClassName(): string;
  62534. /**
  62535. * Gets the gradient input component
  62536. */
  62537. get gradient(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the output component
  62540. */
  62541. get output(): NodeMaterialConnectionPoint;
  62542. private _writeColorConstant;
  62543. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62544. serialize(): any;
  62545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62546. protected _dumpPropertiesCode(): string;
  62547. }
  62548. }
  62549. declare module BABYLON {
  62550. /**
  62551. * Block used to normalize lerp between 2 values
  62552. */
  62553. export class NLerpBlock extends NodeMaterialBlock {
  62554. /**
  62555. * Creates a new NLerpBlock
  62556. * @param name defines the block name
  62557. */
  62558. constructor(name: string);
  62559. /**
  62560. * Gets the current class name
  62561. * @returns the class name
  62562. */
  62563. getClassName(): string;
  62564. /**
  62565. * Gets the left operand input component
  62566. */
  62567. get left(): NodeMaterialConnectionPoint;
  62568. /**
  62569. * Gets the right operand input component
  62570. */
  62571. get right(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the gradient operand input component
  62574. */
  62575. get gradient(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the output component
  62578. */
  62579. get output(): NodeMaterialConnectionPoint;
  62580. protected _buildBlock(state: NodeMaterialBuildState): this;
  62581. }
  62582. }
  62583. declare module BABYLON {
  62584. /**
  62585. * block used to Generate a Worley Noise 3D Noise Pattern
  62586. */
  62587. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62588. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62589. manhattanDistance: boolean;
  62590. /**
  62591. * Creates a new WorleyNoise3DBlock
  62592. * @param name defines the block name
  62593. */
  62594. constructor(name: string);
  62595. /**
  62596. * Gets the current class name
  62597. * @returns the class name
  62598. */
  62599. getClassName(): string;
  62600. /**
  62601. * Gets the seed input component
  62602. */
  62603. get seed(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the jitter input component
  62606. */
  62607. get jitter(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the output component
  62610. */
  62611. get output(): NodeMaterialConnectionPoint;
  62612. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62613. /**
  62614. * Exposes the properties to the UI?
  62615. */
  62616. protected _dumpPropertiesCode(): string;
  62617. /**
  62618. * Exposes the properties to the Seralize?
  62619. */
  62620. serialize(): any;
  62621. /**
  62622. * Exposes the properties to the deseralize?
  62623. */
  62624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62625. }
  62626. }
  62627. declare module BABYLON {
  62628. /**
  62629. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62630. */
  62631. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62632. /**
  62633. * Creates a new SimplexPerlin3DBlock
  62634. * @param name defines the block name
  62635. */
  62636. constructor(name: string);
  62637. /**
  62638. * Gets the current class name
  62639. * @returns the class name
  62640. */
  62641. getClassName(): string;
  62642. /**
  62643. * Gets the seed operand input component
  62644. */
  62645. get seed(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the output component
  62648. */
  62649. get output(): NodeMaterialConnectionPoint;
  62650. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62651. }
  62652. }
  62653. declare module BABYLON {
  62654. /**
  62655. * Block used to blend normals
  62656. */
  62657. export class NormalBlendBlock extends NodeMaterialBlock {
  62658. /**
  62659. * Creates a new NormalBlendBlock
  62660. * @param name defines the block name
  62661. */
  62662. constructor(name: string);
  62663. /**
  62664. * Gets the current class name
  62665. * @returns the class name
  62666. */
  62667. getClassName(): string;
  62668. /**
  62669. * Gets the first input component
  62670. */
  62671. get normalMap0(): NodeMaterialConnectionPoint;
  62672. /**
  62673. * Gets the second input component
  62674. */
  62675. get normalMap1(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the output component
  62678. */
  62679. get output(): NodeMaterialConnectionPoint;
  62680. protected _buildBlock(state: NodeMaterialBuildState): this;
  62681. }
  62682. }
  62683. declare module BABYLON {
  62684. /**
  62685. * Block used to rotate a 2d vector by a given angle
  62686. */
  62687. export class Rotate2dBlock extends NodeMaterialBlock {
  62688. /**
  62689. * Creates a new Rotate2dBlock
  62690. * @param name defines the block name
  62691. */
  62692. constructor(name: string);
  62693. /**
  62694. * Gets the current class name
  62695. * @returns the class name
  62696. */
  62697. getClassName(): string;
  62698. /**
  62699. * Gets the input vector
  62700. */
  62701. get input(): NodeMaterialConnectionPoint;
  62702. /**
  62703. * Gets the input angle
  62704. */
  62705. get angle(): NodeMaterialConnectionPoint;
  62706. /**
  62707. * Gets the output component
  62708. */
  62709. get output(): NodeMaterialConnectionPoint;
  62710. autoConfigure(material: NodeMaterial): void;
  62711. protected _buildBlock(state: NodeMaterialBuildState): this;
  62712. }
  62713. }
  62714. declare module BABYLON {
  62715. /**
  62716. * Block used to get the reflected vector from a direction and a normal
  62717. */
  62718. export class ReflectBlock extends NodeMaterialBlock {
  62719. /**
  62720. * Creates a new ReflectBlock
  62721. * @param name defines the block name
  62722. */
  62723. constructor(name: string);
  62724. /**
  62725. * Gets the current class name
  62726. * @returns the class name
  62727. */
  62728. getClassName(): string;
  62729. /**
  62730. * Gets the incident component
  62731. */
  62732. get incident(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the normal component
  62735. */
  62736. get normal(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the output component
  62739. */
  62740. get output(): NodeMaterialConnectionPoint;
  62741. protected _buildBlock(state: NodeMaterialBuildState): this;
  62742. }
  62743. }
  62744. declare module BABYLON {
  62745. /**
  62746. * Block used to get the refracted vector from a direction and a normal
  62747. */
  62748. export class RefractBlock extends NodeMaterialBlock {
  62749. /**
  62750. * Creates a new RefractBlock
  62751. * @param name defines the block name
  62752. */
  62753. constructor(name: string);
  62754. /**
  62755. * Gets the current class name
  62756. * @returns the class name
  62757. */
  62758. getClassName(): string;
  62759. /**
  62760. * Gets the incident component
  62761. */
  62762. get incident(): NodeMaterialConnectionPoint;
  62763. /**
  62764. * Gets the normal component
  62765. */
  62766. get normal(): NodeMaterialConnectionPoint;
  62767. /**
  62768. * Gets the index of refraction component
  62769. */
  62770. get ior(): NodeMaterialConnectionPoint;
  62771. /**
  62772. * Gets the output component
  62773. */
  62774. get output(): NodeMaterialConnectionPoint;
  62775. protected _buildBlock(state: NodeMaterialBuildState): this;
  62776. }
  62777. }
  62778. declare module BABYLON {
  62779. /**
  62780. * Block used to desaturate a color
  62781. */
  62782. export class DesaturateBlock extends NodeMaterialBlock {
  62783. /**
  62784. * Creates a new DesaturateBlock
  62785. * @param name defines the block name
  62786. */
  62787. constructor(name: string);
  62788. /**
  62789. * Gets the current class name
  62790. * @returns the class name
  62791. */
  62792. getClassName(): string;
  62793. /**
  62794. * Gets the color operand input component
  62795. */
  62796. get color(): NodeMaterialConnectionPoint;
  62797. /**
  62798. * Gets the level operand input component
  62799. */
  62800. get level(): NodeMaterialConnectionPoint;
  62801. /**
  62802. * Gets the output component
  62803. */
  62804. get output(): NodeMaterialConnectionPoint;
  62805. protected _buildBlock(state: NodeMaterialBuildState): this;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. /**
  62810. * Block used to implement the ambient occlusion module of the PBR material
  62811. */
  62812. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62813. /**
  62814. * Create a new AmbientOcclusionBlock
  62815. * @param name defines the block name
  62816. */
  62817. constructor(name: string);
  62818. /**
  62819. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62820. */
  62821. useAmbientInGrayScale: boolean;
  62822. /**
  62823. * Initialize the block and prepare the context for build
  62824. * @param state defines the state that will be used for the build
  62825. */
  62826. initialize(state: NodeMaterialBuildState): void;
  62827. /**
  62828. * Gets the current class name
  62829. * @returns the class name
  62830. */
  62831. getClassName(): string;
  62832. /**
  62833. * Gets the texture input component
  62834. */
  62835. get texture(): NodeMaterialConnectionPoint;
  62836. /**
  62837. * Gets the texture intensity component
  62838. */
  62839. get intensity(): NodeMaterialConnectionPoint;
  62840. /**
  62841. * Gets the direct light intensity input component
  62842. */
  62843. get directLightIntensity(): NodeMaterialConnectionPoint;
  62844. /**
  62845. * Gets the ambient occlusion object output component
  62846. */
  62847. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62848. /**
  62849. * Gets the main code of the block (fragment side)
  62850. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62851. * @returns the shader code
  62852. */
  62853. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62855. protected _buildBlock(state: NodeMaterialBuildState): this;
  62856. protected _dumpPropertiesCode(): string;
  62857. serialize(): any;
  62858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62859. }
  62860. }
  62861. declare module BABYLON {
  62862. /**
  62863. * Block used to implement the reflection module of the PBR material
  62864. */
  62865. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62866. /** @hidden */
  62867. _defineLODReflectionAlpha: string;
  62868. /** @hidden */
  62869. _defineLinearSpecularReflection: string;
  62870. private _vEnvironmentIrradianceName;
  62871. /** @hidden */
  62872. _vReflectionMicrosurfaceInfosName: string;
  62873. /** @hidden */
  62874. _vReflectionInfosName: string;
  62875. /** @hidden */
  62876. _vReflectionFilteringInfoName: string;
  62877. private _scene;
  62878. /**
  62879. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62880. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62881. * It's less burden on the user side in the editor part.
  62882. */
  62883. /** @hidden */
  62884. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62885. /** @hidden */
  62886. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62887. /** @hidden */
  62888. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62889. /**
  62890. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62891. * diffuse part of the IBL.
  62892. */
  62893. useSphericalHarmonics: boolean;
  62894. /**
  62895. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62896. */
  62897. forceIrradianceInFragment: boolean;
  62898. /**
  62899. * Create a new ReflectionBlock
  62900. * @param name defines the block name
  62901. */
  62902. constructor(name: string);
  62903. /**
  62904. * Gets the current class name
  62905. * @returns the class name
  62906. */
  62907. getClassName(): string;
  62908. /**
  62909. * Gets the position input component
  62910. */
  62911. get position(): NodeMaterialConnectionPoint;
  62912. /**
  62913. * Gets the world position input component
  62914. */
  62915. get worldPosition(): NodeMaterialConnectionPoint;
  62916. /**
  62917. * Gets the world normal input component
  62918. */
  62919. get worldNormal(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the world input component
  62922. */
  62923. get world(): NodeMaterialConnectionPoint;
  62924. /**
  62925. * Gets the camera (or eye) position component
  62926. */
  62927. get cameraPosition(): NodeMaterialConnectionPoint;
  62928. /**
  62929. * Gets the view input component
  62930. */
  62931. get view(): NodeMaterialConnectionPoint;
  62932. /**
  62933. * Gets the color input component
  62934. */
  62935. get color(): NodeMaterialConnectionPoint;
  62936. /**
  62937. * Gets the reflection object output component
  62938. */
  62939. get reflection(): NodeMaterialConnectionPoint;
  62940. /**
  62941. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62942. */
  62943. get hasTexture(): boolean;
  62944. /**
  62945. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62946. */
  62947. get reflectionColor(): string;
  62948. protected _getTexture(): Nullable<BaseTexture>;
  62949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62951. /**
  62952. * Gets the code to inject in the vertex shader
  62953. * @param state current state of the node material building
  62954. * @returns the shader code
  62955. */
  62956. handleVertexSide(state: NodeMaterialBuildState): string;
  62957. /**
  62958. * Gets the main code of the block (fragment side)
  62959. * @param state current state of the node material building
  62960. * @param normalVarName name of the existing variable corresponding to the normal
  62961. * @returns the shader code
  62962. */
  62963. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. protected _dumpPropertiesCode(): string;
  62966. serialize(): any;
  62967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62968. }
  62969. }
  62970. declare module BABYLON {
  62971. /**
  62972. * Block used to implement the sheen module of the PBR material
  62973. */
  62974. export class SheenBlock extends NodeMaterialBlock {
  62975. /**
  62976. * Create a new SheenBlock
  62977. * @param name defines the block name
  62978. */
  62979. constructor(name: string);
  62980. /**
  62981. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62982. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62983. * making it easier to setup and tweak the effect
  62984. */
  62985. albedoScaling: boolean;
  62986. /**
  62987. * Defines if the sheen is linked to the sheen color.
  62988. */
  62989. linkSheenWithAlbedo: boolean;
  62990. /**
  62991. * Initialize the block and prepare the context for build
  62992. * @param state defines the state that will be used for the build
  62993. */
  62994. initialize(state: NodeMaterialBuildState): void;
  62995. /**
  62996. * Gets the current class name
  62997. * @returns the class name
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Gets the intensity input component
  63002. */
  63003. get intensity(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the color input component
  63006. */
  63007. get color(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the roughness input component
  63010. */
  63011. get roughness(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the sheen object output component
  63014. */
  63015. get sheen(): NodeMaterialConnectionPoint;
  63016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63017. /**
  63018. * Gets the main code of the block (fragment side)
  63019. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63020. * @returns the shader code
  63021. */
  63022. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63023. protected _buildBlock(state: NodeMaterialBuildState): this;
  63024. protected _dumpPropertiesCode(): string;
  63025. serialize(): any;
  63026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63027. }
  63028. }
  63029. declare module BABYLON {
  63030. /**
  63031. * Block used to implement the reflectivity module of the PBR material
  63032. */
  63033. export class ReflectivityBlock extends NodeMaterialBlock {
  63034. private _metallicReflectanceColor;
  63035. private _metallicF0Factor;
  63036. /** @hidden */
  63037. _vMetallicReflectanceFactorsName: string;
  63038. /**
  63039. * The property below is set by the main PBR block prior to calling methods of this class.
  63040. */
  63041. /** @hidden */
  63042. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63043. /**
  63044. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63045. */
  63046. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63047. /**
  63048. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63049. */
  63050. useMetallnessFromMetallicTextureBlue: boolean;
  63051. /**
  63052. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63053. */
  63054. useRoughnessFromMetallicTextureAlpha: boolean;
  63055. /**
  63056. * Specifies if the metallic texture contains the roughness information in its green channel.
  63057. */
  63058. useRoughnessFromMetallicTextureGreen: boolean;
  63059. /**
  63060. * Create a new ReflectivityBlock
  63061. * @param name defines the block name
  63062. */
  63063. constructor(name: string);
  63064. /**
  63065. * Initialize the block and prepare the context for build
  63066. * @param state defines the state that will be used for the build
  63067. */
  63068. initialize(state: NodeMaterialBuildState): void;
  63069. /**
  63070. * Gets the current class name
  63071. * @returns the class name
  63072. */
  63073. getClassName(): string;
  63074. /**
  63075. * Gets the metallic input component
  63076. */
  63077. get metallic(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the roughness input component
  63080. */
  63081. get roughness(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the texture input component
  63084. */
  63085. get texture(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the reflectivity object output component
  63088. */
  63089. get reflectivity(): NodeMaterialConnectionPoint;
  63090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63091. /**
  63092. * Gets the main code of the block (fragment side)
  63093. * @param state current state of the node material building
  63094. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63095. * @returns the shader code
  63096. */
  63097. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63099. protected _buildBlock(state: NodeMaterialBuildState): this;
  63100. protected _dumpPropertiesCode(): string;
  63101. serialize(): any;
  63102. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63103. }
  63104. }
  63105. declare module BABYLON {
  63106. /**
  63107. * Block used to implement the anisotropy module of the PBR material
  63108. */
  63109. export class AnisotropyBlock extends NodeMaterialBlock {
  63110. /**
  63111. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63112. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63113. * It's less burden on the user side in the editor part.
  63114. */
  63115. /** @hidden */
  63116. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63117. /** @hidden */
  63118. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63119. /**
  63120. * Create a new AnisotropyBlock
  63121. * @param name defines the block name
  63122. */
  63123. constructor(name: string);
  63124. /**
  63125. * Initialize the block and prepare the context for build
  63126. * @param state defines the state that will be used for the build
  63127. */
  63128. initialize(state: NodeMaterialBuildState): void;
  63129. /**
  63130. * Gets the current class name
  63131. * @returns the class name
  63132. */
  63133. getClassName(): string;
  63134. /**
  63135. * Gets the intensity input component
  63136. */
  63137. get intensity(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the direction input component
  63140. */
  63141. get direction(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the texture input component
  63144. */
  63145. get texture(): NodeMaterialConnectionPoint;
  63146. /**
  63147. * Gets the uv input component
  63148. */
  63149. get uv(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the worldTangent input component
  63152. */
  63153. get worldTangent(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the anisotropy object output component
  63156. */
  63157. get anisotropy(): NodeMaterialConnectionPoint;
  63158. private _generateTBNSpace;
  63159. /**
  63160. * Gets the main code of the block (fragment side)
  63161. * @param state current state of the node material building
  63162. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63163. * @returns the shader code
  63164. */
  63165. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63167. protected _buildBlock(state: NodeMaterialBuildState): this;
  63168. }
  63169. }
  63170. declare module BABYLON {
  63171. /**
  63172. * Block used to implement the clear coat module of the PBR material
  63173. */
  63174. export class ClearCoatBlock extends NodeMaterialBlock {
  63175. private _scene;
  63176. /**
  63177. * Create a new ClearCoatBlock
  63178. * @param name defines the block name
  63179. */
  63180. constructor(name: string);
  63181. /**
  63182. * Initialize the block and prepare the context for build
  63183. * @param state defines the state that will be used for the build
  63184. */
  63185. initialize(state: NodeMaterialBuildState): void;
  63186. /**
  63187. * Gets the current class name
  63188. * @returns the class name
  63189. */
  63190. getClassName(): string;
  63191. /**
  63192. * Gets the intensity input component
  63193. */
  63194. get intensity(): NodeMaterialConnectionPoint;
  63195. /**
  63196. * Gets the roughness input component
  63197. */
  63198. get roughness(): NodeMaterialConnectionPoint;
  63199. /**
  63200. * Gets the ior input component
  63201. */
  63202. get ior(): NodeMaterialConnectionPoint;
  63203. /**
  63204. * Gets the texture input component
  63205. */
  63206. get texture(): NodeMaterialConnectionPoint;
  63207. /**
  63208. * Gets the bump texture input component
  63209. */
  63210. get bumpTexture(): NodeMaterialConnectionPoint;
  63211. /**
  63212. * Gets the uv input component
  63213. */
  63214. get uv(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the tint color input component
  63217. */
  63218. get tintColor(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the tint "at distance" input component
  63221. */
  63222. get tintAtDistance(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the tint thickness input component
  63225. */
  63226. get tintThickness(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the world tangent input component
  63229. */
  63230. get worldTangent(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the clear coat object output component
  63233. */
  63234. get clearcoat(): NodeMaterialConnectionPoint;
  63235. autoConfigure(material: NodeMaterial): void;
  63236. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63238. private _generateTBNSpace;
  63239. /**
  63240. * Gets the main code of the block (fragment side)
  63241. * @param state current state of the node material building
  63242. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63243. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63244. * @param worldPosVarName name of the variable holding the world position
  63245. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63246. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63247. * @param worldNormalVarName name of the variable holding the world normal
  63248. * @returns the shader code
  63249. */
  63250. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63251. protected _buildBlock(state: NodeMaterialBuildState): this;
  63252. }
  63253. }
  63254. declare module BABYLON {
  63255. /**
  63256. * Block used to implement the sub surface module of the PBR material
  63257. */
  63258. export class SubSurfaceBlock extends NodeMaterialBlock {
  63259. /**
  63260. * Create a new SubSurfaceBlock
  63261. * @param name defines the block name
  63262. */
  63263. constructor(name: string);
  63264. /**
  63265. * Stores the intensity of the different subsurface effects in the thickness texture.
  63266. * * the green channel is the translucency intensity.
  63267. * * the blue channel is the scattering intensity.
  63268. * * the alpha channel is the refraction intensity.
  63269. */
  63270. useMaskFromThicknessTexture: boolean;
  63271. /**
  63272. * Initialize the block and prepare the context for build
  63273. * @param state defines the state that will be used for the build
  63274. */
  63275. initialize(state: NodeMaterialBuildState): void;
  63276. /**
  63277. * Gets the current class name
  63278. * @returns the class name
  63279. */
  63280. getClassName(): string;
  63281. /**
  63282. * Gets the min thickness input component
  63283. */
  63284. get minThickness(): NodeMaterialConnectionPoint;
  63285. /**
  63286. * Gets the max thickness input component
  63287. */
  63288. get maxThickness(): NodeMaterialConnectionPoint;
  63289. /**
  63290. * Gets the thickness texture component
  63291. */
  63292. get thicknessTexture(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the tint color input component
  63295. */
  63296. get tintColor(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the translucency intensity input component
  63299. */
  63300. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the translucency diffusion distance input component
  63303. */
  63304. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63305. /**
  63306. * Gets the refraction object parameters
  63307. */
  63308. get refraction(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the sub surface object output component
  63311. */
  63312. get subsurface(): NodeMaterialConnectionPoint;
  63313. autoConfigure(material: NodeMaterial): void;
  63314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63315. /**
  63316. * Gets the main code of the block (fragment side)
  63317. * @param state current state of the node material building
  63318. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63319. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63320. * @param worldPosVarName name of the variable holding the world position
  63321. * @returns the shader code
  63322. */
  63323. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63324. protected _buildBlock(state: NodeMaterialBuildState): this;
  63325. }
  63326. }
  63327. declare module BABYLON {
  63328. /**
  63329. * Block used to implement the PBR metallic/roughness model
  63330. */
  63331. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63332. /**
  63333. * Gets or sets the light associated with this block
  63334. */
  63335. light: Nullable<Light>;
  63336. private _lightId;
  63337. private _scene;
  63338. private _environmentBRDFTexture;
  63339. private _environmentBrdfSamplerName;
  63340. private _vNormalWName;
  63341. private _invertNormalName;
  63342. /**
  63343. * Create a new ReflectionBlock
  63344. * @param name defines the block name
  63345. */
  63346. constructor(name: string);
  63347. /**
  63348. * Intensity of the direct lights e.g. the four lights available in your scene.
  63349. * This impacts both the direct diffuse and specular highlights.
  63350. */
  63351. directIntensity: number;
  63352. /**
  63353. * Intensity of the environment e.g. how much the environment will light the object
  63354. * either through harmonics for rough material or through the refelction for shiny ones.
  63355. */
  63356. environmentIntensity: number;
  63357. /**
  63358. * This is a special control allowing the reduction of the specular highlights coming from the
  63359. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63360. */
  63361. specularIntensity: number;
  63362. /**
  63363. * Defines the falloff type used in this material.
  63364. * It by default is Physical.
  63365. */
  63366. lightFalloff: number;
  63367. /**
  63368. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63369. */
  63370. useAlphaFromAlbedoTexture: boolean;
  63371. /**
  63372. * Specifies that alpha test should be used
  63373. */
  63374. useAlphaTest: boolean;
  63375. /**
  63376. * Defines the alpha limits in alpha test mode.
  63377. */
  63378. alphaTestCutoff: number;
  63379. /**
  63380. * Specifies that alpha blending should be used
  63381. */
  63382. useAlphaBlending: boolean;
  63383. /**
  63384. * Defines if the alpha value should be determined via the rgb values.
  63385. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63386. */
  63387. opacityRGB: boolean;
  63388. /**
  63389. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63390. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63391. */
  63392. useRadianceOverAlpha: boolean;
  63393. /**
  63394. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63395. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63396. */
  63397. useSpecularOverAlpha: boolean;
  63398. /**
  63399. * Enables specular anti aliasing in the PBR shader.
  63400. * It will both interacts on the Geometry for analytical and IBL lighting.
  63401. * It also prefilter the roughness map based on the bump values.
  63402. */
  63403. enableSpecularAntiAliasing: boolean;
  63404. /**
  63405. * Enables realtime filtering on the texture.
  63406. */
  63407. realTimeFiltering: boolean;
  63408. /**
  63409. * Quality switch for realtime filtering
  63410. */
  63411. realTimeFilteringQuality: number;
  63412. /**
  63413. * Defines if the material uses energy conservation.
  63414. */
  63415. useEnergyConservation: boolean;
  63416. /**
  63417. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63418. * too much the area relying on ambient texture to define their ambient occlusion.
  63419. */
  63420. useRadianceOcclusion: boolean;
  63421. /**
  63422. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63423. * makes the reflect vector face the model (under horizon).
  63424. */
  63425. useHorizonOcclusion: boolean;
  63426. /**
  63427. * If set to true, no lighting calculations will be applied.
  63428. */
  63429. unlit: boolean;
  63430. /**
  63431. * Force normal to face away from face.
  63432. */
  63433. forceNormalForward: boolean;
  63434. /**
  63435. * Defines the material debug mode.
  63436. * It helps seeing only some components of the material while troubleshooting.
  63437. */
  63438. debugMode: number;
  63439. /**
  63440. * Specify from where on screen the debug mode should start.
  63441. * The value goes from -1 (full screen) to 1 (not visible)
  63442. * It helps with side by side comparison against the final render
  63443. * This defaults to 0
  63444. */
  63445. debugLimit: number;
  63446. /**
  63447. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63448. * You can use the factor to better multiply the final value.
  63449. */
  63450. debugFactor: number;
  63451. /**
  63452. * Initialize the block and prepare the context for build
  63453. * @param state defines the state that will be used for the build
  63454. */
  63455. initialize(state: NodeMaterialBuildState): void;
  63456. /**
  63457. * Gets the current class name
  63458. * @returns the class name
  63459. */
  63460. getClassName(): string;
  63461. /**
  63462. * Gets the world position input component
  63463. */
  63464. get worldPosition(): NodeMaterialConnectionPoint;
  63465. /**
  63466. * Gets the world normal input component
  63467. */
  63468. get worldNormal(): NodeMaterialConnectionPoint;
  63469. /**
  63470. * Gets the perturbed normal input component
  63471. */
  63472. get perturbedNormal(): NodeMaterialConnectionPoint;
  63473. /**
  63474. * Gets the camera position input component
  63475. */
  63476. get cameraPosition(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the base color input component
  63479. */
  63480. get baseColor(): NodeMaterialConnectionPoint;
  63481. /**
  63482. * Gets the opacity texture input component
  63483. */
  63484. get opacityTexture(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the ambient color input component
  63487. */
  63488. get ambientColor(): NodeMaterialConnectionPoint;
  63489. /**
  63490. * Gets the reflectivity object parameters
  63491. */
  63492. get reflectivity(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the ambient occlusion object parameters
  63495. */
  63496. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the reflection object parameters
  63499. */
  63500. get reflection(): NodeMaterialConnectionPoint;
  63501. /**
  63502. * Gets the sheen object parameters
  63503. */
  63504. get sheen(): NodeMaterialConnectionPoint;
  63505. /**
  63506. * Gets the clear coat object parameters
  63507. */
  63508. get clearcoat(): NodeMaterialConnectionPoint;
  63509. /**
  63510. * Gets the sub surface object parameters
  63511. */
  63512. get subsurface(): NodeMaterialConnectionPoint;
  63513. /**
  63514. * Gets the anisotropy object parameters
  63515. */
  63516. get anisotropy(): NodeMaterialConnectionPoint;
  63517. /**
  63518. * Gets the ambient output component
  63519. */
  63520. get ambient(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the diffuse output component
  63523. */
  63524. get diffuse(): NodeMaterialConnectionPoint;
  63525. /**
  63526. * Gets the specular output component
  63527. */
  63528. get specular(): NodeMaterialConnectionPoint;
  63529. /**
  63530. * Gets the sheen output component
  63531. */
  63532. get sheenDir(): NodeMaterialConnectionPoint;
  63533. /**
  63534. * Gets the clear coat output component
  63535. */
  63536. get clearcoatDir(): NodeMaterialConnectionPoint;
  63537. /**
  63538. * Gets the indirect diffuse output component
  63539. */
  63540. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63541. /**
  63542. * Gets the indirect specular output component
  63543. */
  63544. get specularIndirect(): NodeMaterialConnectionPoint;
  63545. /**
  63546. * Gets the indirect sheen output component
  63547. */
  63548. get sheenIndirect(): NodeMaterialConnectionPoint;
  63549. /**
  63550. * Gets the indirect clear coat output component
  63551. */
  63552. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the refraction output component
  63555. */
  63556. get refraction(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the global lighting output component
  63559. */
  63560. get lighting(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the shadow output component
  63563. */
  63564. get shadow(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the alpha output component
  63567. */
  63568. get alpha(): NodeMaterialConnectionPoint;
  63569. autoConfigure(material: NodeMaterial): void;
  63570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63571. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63573. private _injectVertexCode;
  63574. /**
  63575. * Gets the code corresponding to the albedo/opacity module
  63576. * @returns the shader code
  63577. */
  63578. getAlbedoOpacityCode(): string;
  63579. protected _buildBlock(state: NodeMaterialBuildState): this;
  63580. protected _dumpPropertiesCode(): string;
  63581. serialize(): any;
  63582. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63583. }
  63584. }
  63585. declare module BABYLON {
  63586. /**
  63587. * Block used to compute value of one parameter modulo another
  63588. */
  63589. export class ModBlock extends NodeMaterialBlock {
  63590. /**
  63591. * Creates a new ModBlock
  63592. * @param name defines the block name
  63593. */
  63594. constructor(name: string);
  63595. /**
  63596. * Gets the current class name
  63597. * @returns the class name
  63598. */
  63599. getClassName(): string;
  63600. /**
  63601. * Gets the left operand input component
  63602. */
  63603. get left(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the right operand input component
  63606. */
  63607. get right(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the output component
  63610. */
  63611. get output(): NodeMaterialConnectionPoint;
  63612. protected _buildBlock(state: NodeMaterialBuildState): this;
  63613. }
  63614. }
  63615. declare module BABYLON {
  63616. /**
  63617. * Helper class to push actions to a pool of workers.
  63618. */
  63619. export class WorkerPool implements IDisposable {
  63620. private _workerInfos;
  63621. private _pendingActions;
  63622. /**
  63623. * Constructor
  63624. * @param workers Array of workers to use for actions
  63625. */
  63626. constructor(workers: Array<Worker>);
  63627. /**
  63628. * Terminates all workers and clears any pending actions.
  63629. */
  63630. dispose(): void;
  63631. /**
  63632. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63633. * pended until a worker has completed its action.
  63634. * @param action The action to perform. Call onComplete when the action is complete.
  63635. */
  63636. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63637. private _execute;
  63638. }
  63639. }
  63640. declare module BABYLON {
  63641. /**
  63642. * Configuration for Draco compression
  63643. */
  63644. export interface IDracoCompressionConfiguration {
  63645. /**
  63646. * Configuration for the decoder.
  63647. */
  63648. decoder: {
  63649. /**
  63650. * The url to the WebAssembly module.
  63651. */
  63652. wasmUrl?: string;
  63653. /**
  63654. * The url to the WebAssembly binary.
  63655. */
  63656. wasmBinaryUrl?: string;
  63657. /**
  63658. * The url to the fallback JavaScript module.
  63659. */
  63660. fallbackUrl?: string;
  63661. };
  63662. }
  63663. /**
  63664. * Draco compression (https://google.github.io/draco/)
  63665. *
  63666. * This class wraps the Draco module.
  63667. *
  63668. * **Encoder**
  63669. *
  63670. * The encoder is not currently implemented.
  63671. *
  63672. * **Decoder**
  63673. *
  63674. * 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.
  63675. *
  63676. * To update the configuration, use the following code:
  63677. * ```javascript
  63678. * DracoCompression.Configuration = {
  63679. * decoder: {
  63680. * wasmUrl: "<url to the WebAssembly library>",
  63681. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63682. * fallbackUrl: "<url to the fallback JavaScript library>",
  63683. * }
  63684. * };
  63685. * ```
  63686. *
  63687. * 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.
  63688. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63689. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63690. *
  63691. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63692. * ```javascript
  63693. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63694. * ```
  63695. *
  63696. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63697. */
  63698. export class DracoCompression implements IDisposable {
  63699. private _workerPoolPromise?;
  63700. private _decoderModulePromise?;
  63701. /**
  63702. * The configuration. Defaults to the following urls:
  63703. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63704. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63705. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63706. */
  63707. static Configuration: IDracoCompressionConfiguration;
  63708. /**
  63709. * Returns true if the decoder configuration is available.
  63710. */
  63711. static get DecoderAvailable(): boolean;
  63712. /**
  63713. * Default number of workers to create when creating the draco compression object.
  63714. */
  63715. static DefaultNumWorkers: number;
  63716. private static GetDefaultNumWorkers;
  63717. private static _Default;
  63718. /**
  63719. * Default instance for the draco compression object.
  63720. */
  63721. static get Default(): DracoCompression;
  63722. /**
  63723. * Constructor
  63724. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63725. */
  63726. constructor(numWorkers?: number);
  63727. /**
  63728. * Stop all async operations and release resources.
  63729. */
  63730. dispose(): void;
  63731. /**
  63732. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63733. * @returns a promise that resolves when ready
  63734. */
  63735. whenReadyAsync(): Promise<void>;
  63736. /**
  63737. * Decode Draco compressed mesh data to vertex data.
  63738. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63739. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63740. * @returns A promise that resolves with the decoded vertex data
  63741. */
  63742. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63743. [kind: string]: number;
  63744. }): Promise<VertexData>;
  63745. }
  63746. }
  63747. declare module BABYLON {
  63748. /**
  63749. * Class for building Constructive Solid Geometry
  63750. */
  63751. export class CSG {
  63752. private polygons;
  63753. /**
  63754. * The world matrix
  63755. */
  63756. matrix: Matrix;
  63757. /**
  63758. * Stores the position
  63759. */
  63760. position: Vector3;
  63761. /**
  63762. * Stores the rotation
  63763. */
  63764. rotation: Vector3;
  63765. /**
  63766. * Stores the rotation quaternion
  63767. */
  63768. rotationQuaternion: Nullable<Quaternion>;
  63769. /**
  63770. * Stores the scaling vector
  63771. */
  63772. scaling: Vector3;
  63773. /**
  63774. * Convert the Mesh to CSG
  63775. * @param mesh The Mesh to convert to CSG
  63776. * @returns A new CSG from the Mesh
  63777. */
  63778. static FromMesh(mesh: Mesh): CSG;
  63779. /**
  63780. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63781. * @param polygons Polygons used to construct a CSG solid
  63782. */
  63783. private static FromPolygons;
  63784. /**
  63785. * Clones, or makes a deep copy, of the CSG
  63786. * @returns A new CSG
  63787. */
  63788. clone(): CSG;
  63789. /**
  63790. * Unions this CSG with another CSG
  63791. * @param csg The CSG to union against this CSG
  63792. * @returns The unioned CSG
  63793. */
  63794. union(csg: CSG): CSG;
  63795. /**
  63796. * Unions this CSG with another CSG in place
  63797. * @param csg The CSG to union against this CSG
  63798. */
  63799. unionInPlace(csg: CSG): void;
  63800. /**
  63801. * Subtracts this CSG with another CSG
  63802. * @param csg The CSG to subtract against this CSG
  63803. * @returns A new CSG
  63804. */
  63805. subtract(csg: CSG): CSG;
  63806. /**
  63807. * Subtracts this CSG with another CSG in place
  63808. * @param csg The CSG to subtact against this CSG
  63809. */
  63810. subtractInPlace(csg: CSG): void;
  63811. /**
  63812. * Intersect this CSG with another CSG
  63813. * @param csg The CSG to intersect against this CSG
  63814. * @returns A new CSG
  63815. */
  63816. intersect(csg: CSG): CSG;
  63817. /**
  63818. * Intersects this CSG with another CSG in place
  63819. * @param csg The CSG to intersect against this CSG
  63820. */
  63821. intersectInPlace(csg: CSG): void;
  63822. /**
  63823. * Return a new CSG solid with solid and empty space switched. This solid is
  63824. * not modified.
  63825. * @returns A new CSG solid with solid and empty space switched
  63826. */
  63827. inverse(): CSG;
  63828. /**
  63829. * Inverses the CSG in place
  63830. */
  63831. inverseInPlace(): void;
  63832. /**
  63833. * This is used to keep meshes transformations so they can be restored
  63834. * when we build back a Babylon Mesh
  63835. * NB : All CSG operations are performed in world coordinates
  63836. * @param csg The CSG to copy the transform attributes from
  63837. * @returns This CSG
  63838. */
  63839. copyTransformAttributes(csg: CSG): CSG;
  63840. /**
  63841. * Build Raw mesh from CSG
  63842. * Coordinates here are in world space
  63843. * @param name The name of the mesh geometry
  63844. * @param scene The Scene
  63845. * @param keepSubMeshes Specifies if the submeshes should be kept
  63846. * @returns A new Mesh
  63847. */
  63848. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63849. /**
  63850. * Build Mesh from CSG taking material and transforms into account
  63851. * @param name The name of the Mesh
  63852. * @param material The material of the Mesh
  63853. * @param scene The Scene
  63854. * @param keepSubMeshes Specifies if submeshes should be kept
  63855. * @returns The new Mesh
  63856. */
  63857. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63858. }
  63859. }
  63860. declare module BABYLON {
  63861. /**
  63862. * Class used to create a trail following a mesh
  63863. */
  63864. export class TrailMesh extends Mesh {
  63865. private _generator;
  63866. private _autoStart;
  63867. private _running;
  63868. private _diameter;
  63869. private _length;
  63870. private _sectionPolygonPointsCount;
  63871. private _sectionVectors;
  63872. private _sectionNormalVectors;
  63873. private _beforeRenderObserver;
  63874. /**
  63875. * @constructor
  63876. * @param name The value used by scene.getMeshByName() to do a lookup.
  63877. * @param generator The mesh or transform node to generate a trail.
  63878. * @param scene The scene to add this mesh to.
  63879. * @param diameter Diameter of trailing mesh. Default is 1.
  63880. * @param length Length of trailing mesh. Default is 60.
  63881. * @param autoStart Automatically start trailing mesh. Default true.
  63882. */
  63883. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63884. /**
  63885. * "TrailMesh"
  63886. * @returns "TrailMesh"
  63887. */
  63888. getClassName(): string;
  63889. private _createMesh;
  63890. /**
  63891. * Start trailing mesh.
  63892. */
  63893. start(): void;
  63894. /**
  63895. * Stop trailing mesh.
  63896. */
  63897. stop(): void;
  63898. /**
  63899. * Update trailing mesh geometry.
  63900. */
  63901. update(): void;
  63902. /**
  63903. * Returns a new TrailMesh object.
  63904. * @param name is a string, the name given to the new mesh
  63905. * @param newGenerator use new generator object for cloned trail mesh
  63906. * @returns a new mesh
  63907. */
  63908. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63909. /**
  63910. * Serializes this trail mesh
  63911. * @param serializationObject object to write serialization to
  63912. */
  63913. serialize(serializationObject: any): void;
  63914. /**
  63915. * Parses a serialized trail mesh
  63916. * @param parsedMesh the serialized mesh
  63917. * @param scene the scene to create the trail mesh in
  63918. * @returns the created trail mesh
  63919. */
  63920. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Class containing static functions to help procedurally build meshes
  63926. */
  63927. export class TiledBoxBuilder {
  63928. /**
  63929. * Creates a box mesh
  63930. * 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)
  63931. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63933. * * 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
  63934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63935. * @param name defines the name of the mesh
  63936. * @param options defines the options used to create the mesh
  63937. * @param scene defines the hosting scene
  63938. * @returns the box mesh
  63939. */
  63940. static CreateTiledBox(name: string, options: {
  63941. pattern?: number;
  63942. width?: number;
  63943. height?: number;
  63944. depth?: number;
  63945. tileSize?: number;
  63946. tileWidth?: number;
  63947. tileHeight?: number;
  63948. alignHorizontal?: number;
  63949. alignVertical?: number;
  63950. faceUV?: Vector4[];
  63951. faceColors?: Color4[];
  63952. sideOrientation?: number;
  63953. updatable?: boolean;
  63954. }, scene?: Nullable<Scene>): Mesh;
  63955. }
  63956. }
  63957. declare module BABYLON {
  63958. /**
  63959. * Class containing static functions to help procedurally build meshes
  63960. */
  63961. export class TorusKnotBuilder {
  63962. /**
  63963. * Creates a torus knot mesh
  63964. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63965. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63966. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63967. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63969. * * 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
  63970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63971. * @param name defines the name of the mesh
  63972. * @param options defines the options used to create the mesh
  63973. * @param scene defines the hosting scene
  63974. * @returns the torus knot mesh
  63975. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63976. */
  63977. static CreateTorusKnot(name: string, options: {
  63978. radius?: number;
  63979. tube?: number;
  63980. radialSegments?: number;
  63981. tubularSegments?: number;
  63982. p?: number;
  63983. q?: number;
  63984. updatable?: boolean;
  63985. sideOrientation?: number;
  63986. frontUVs?: Vector4;
  63987. backUVs?: Vector4;
  63988. }, scene: any): Mesh;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Polygon
  63994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63995. */
  63996. export class Polygon {
  63997. /**
  63998. * Creates a rectangle
  63999. * @param xmin bottom X coord
  64000. * @param ymin bottom Y coord
  64001. * @param xmax top X coord
  64002. * @param ymax top Y coord
  64003. * @returns points that make the resulting rectation
  64004. */
  64005. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64006. /**
  64007. * Creates a circle
  64008. * @param radius radius of circle
  64009. * @param cx scale in x
  64010. * @param cy scale in y
  64011. * @param numberOfSides number of sides that make up the circle
  64012. * @returns points that make the resulting circle
  64013. */
  64014. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64015. /**
  64016. * Creates a polygon from input string
  64017. * @param input Input polygon data
  64018. * @returns the parsed points
  64019. */
  64020. static Parse(input: string): Vector2[];
  64021. /**
  64022. * Starts building a polygon from x and y coordinates
  64023. * @param x x coordinate
  64024. * @param y y coordinate
  64025. * @returns the started path2
  64026. */
  64027. static StartingAt(x: number, y: number): Path2;
  64028. }
  64029. /**
  64030. * Builds a polygon
  64031. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64032. */
  64033. export class PolygonMeshBuilder {
  64034. private _points;
  64035. private _outlinepoints;
  64036. private _holes;
  64037. private _name;
  64038. private _scene;
  64039. private _epoints;
  64040. private _eholes;
  64041. private _addToepoint;
  64042. /**
  64043. * Babylon reference to the earcut plugin.
  64044. */
  64045. bjsEarcut: any;
  64046. /**
  64047. * Creates a PolygonMeshBuilder
  64048. * @param name name of the builder
  64049. * @param contours Path of the polygon
  64050. * @param scene scene to add to when creating the mesh
  64051. * @param earcutInjection can be used to inject your own earcut reference
  64052. */
  64053. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64054. /**
  64055. * Adds a whole within the polygon
  64056. * @param hole Array of points defining the hole
  64057. * @returns this
  64058. */
  64059. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64060. /**
  64061. * Creates the polygon
  64062. * @param updatable If the mesh should be updatable
  64063. * @param depth The depth of the mesh created
  64064. * @returns the created mesh
  64065. */
  64066. build(updatable?: boolean, depth?: number): Mesh;
  64067. /**
  64068. * Creates the polygon
  64069. * @param depth The depth of the mesh created
  64070. * @returns the created VertexData
  64071. */
  64072. buildVertexData(depth?: number): VertexData;
  64073. /**
  64074. * Adds a side to the polygon
  64075. * @param positions points that make the polygon
  64076. * @param normals normals of the polygon
  64077. * @param uvs uvs of the polygon
  64078. * @param indices indices of the polygon
  64079. * @param bounds bounds of the polygon
  64080. * @param points points of the polygon
  64081. * @param depth depth of the polygon
  64082. * @param flip flip of the polygon
  64083. */
  64084. private addSide;
  64085. }
  64086. }
  64087. declare module BABYLON {
  64088. /**
  64089. * Class containing static functions to help procedurally build meshes
  64090. */
  64091. export class PolygonBuilder {
  64092. /**
  64093. * Creates a polygon mesh
  64094. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64095. * * 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
  64096. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64098. * * 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)
  64099. * * Remember you can only change the shape positions, not their number when updating a polygon
  64100. * @param name defines the name of the mesh
  64101. * @param options defines the options used to create the mesh
  64102. * @param scene defines the hosting scene
  64103. * @param earcutInjection can be used to inject your own earcut reference
  64104. * @returns the polygon mesh
  64105. */
  64106. static CreatePolygon(name: string, options: {
  64107. shape: Vector3[];
  64108. holes?: Vector3[][];
  64109. depth?: number;
  64110. faceUV?: Vector4[];
  64111. faceColors?: Color4[];
  64112. updatable?: boolean;
  64113. sideOrientation?: number;
  64114. frontUVs?: Vector4;
  64115. backUVs?: Vector4;
  64116. wrap?: boolean;
  64117. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64118. /**
  64119. * Creates an extruded polygon mesh, with depth in the Y direction.
  64120. * * 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)
  64121. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64122. * @param name defines the name of the mesh
  64123. * @param options defines the options used to create the mesh
  64124. * @param scene defines the hosting scene
  64125. * @param earcutInjection can be used to inject your own earcut reference
  64126. * @returns the polygon mesh
  64127. */
  64128. static ExtrudePolygon(name: string, options: {
  64129. shape: Vector3[];
  64130. holes?: Vector3[][];
  64131. depth?: number;
  64132. faceUV?: Vector4[];
  64133. faceColors?: Color4[];
  64134. updatable?: boolean;
  64135. sideOrientation?: number;
  64136. frontUVs?: Vector4;
  64137. backUVs?: Vector4;
  64138. wrap?: boolean;
  64139. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64140. }
  64141. }
  64142. declare module BABYLON {
  64143. /**
  64144. * Class containing static functions to help procedurally build meshes
  64145. */
  64146. export class LatheBuilder {
  64147. /**
  64148. * Creates lathe mesh.
  64149. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64150. * * 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
  64151. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64152. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64153. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64154. * * 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
  64155. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64156. * * 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
  64157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64158. * * 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
  64159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64161. * @param name defines the name of the mesh
  64162. * @param options defines the options used to create the mesh
  64163. * @param scene defines the hosting scene
  64164. * @returns the lathe mesh
  64165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64166. */
  64167. static CreateLathe(name: string, options: {
  64168. shape: Vector3[];
  64169. radius?: number;
  64170. tessellation?: number;
  64171. clip?: number;
  64172. arc?: number;
  64173. closed?: boolean;
  64174. updatable?: boolean;
  64175. sideOrientation?: number;
  64176. frontUVs?: Vector4;
  64177. backUVs?: Vector4;
  64178. cap?: number;
  64179. invertUV?: boolean;
  64180. }, scene?: Nullable<Scene>): Mesh;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * Class containing static functions to help procedurally build meshes
  64186. */
  64187. export class TiledPlaneBuilder {
  64188. /**
  64189. * Creates a tiled plane mesh
  64190. * * The parameter `pattern` will, depending on value, do nothing or
  64191. * * * flip (reflect about central vertical) alternate tiles across and up
  64192. * * * flip every tile on alternate rows
  64193. * * * rotate (180 degs) alternate tiles across and up
  64194. * * * rotate every tile on alternate rows
  64195. * * * flip and rotate alternate tiles across and up
  64196. * * * flip and rotate every tile on alternate rows
  64197. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64198. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64199. * * 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
  64200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64201. * * 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)
  64202. * * 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)
  64203. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64204. * @param name defines the name of the mesh
  64205. * @param options defines the options used to create the mesh
  64206. * @param scene defines the hosting scene
  64207. * @returns the box mesh
  64208. */
  64209. static CreateTiledPlane(name: string, options: {
  64210. pattern?: number;
  64211. tileSize?: number;
  64212. tileWidth?: number;
  64213. tileHeight?: number;
  64214. size?: number;
  64215. width?: number;
  64216. height?: number;
  64217. alignHorizontal?: number;
  64218. alignVertical?: number;
  64219. sideOrientation?: number;
  64220. frontUVs?: Vector4;
  64221. backUVs?: Vector4;
  64222. updatable?: boolean;
  64223. }, scene?: Nullable<Scene>): Mesh;
  64224. }
  64225. }
  64226. declare module BABYLON {
  64227. /**
  64228. * Class containing static functions to help procedurally build meshes
  64229. */
  64230. export class TubeBuilder {
  64231. /**
  64232. * Creates a tube mesh.
  64233. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64234. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64235. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64236. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64237. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64238. * * 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)
  64239. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64240. * * 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
  64241. * * 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
  64242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64243. * * 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
  64244. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64246. * @param name defines the name of the mesh
  64247. * @param options defines the options used to create the mesh
  64248. * @param scene defines the hosting scene
  64249. * @returns the tube mesh
  64250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64251. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64252. */
  64253. static CreateTube(name: string, options: {
  64254. path: Vector3[];
  64255. radius?: number;
  64256. tessellation?: number;
  64257. radiusFunction?: {
  64258. (i: number, distance: number): number;
  64259. };
  64260. cap?: number;
  64261. arc?: number;
  64262. updatable?: boolean;
  64263. sideOrientation?: number;
  64264. frontUVs?: Vector4;
  64265. backUVs?: Vector4;
  64266. instance?: Mesh;
  64267. invertUV?: boolean;
  64268. }, scene?: Nullable<Scene>): Mesh;
  64269. }
  64270. }
  64271. declare module BABYLON {
  64272. /**
  64273. * Class containing static functions to help procedurally build meshes
  64274. */
  64275. export class IcoSphereBuilder {
  64276. /**
  64277. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64278. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64279. * * 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`)
  64280. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64281. * * 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
  64282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64283. * * 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
  64284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64285. * @param name defines the name of the mesh
  64286. * @param options defines the options used to create the mesh
  64287. * @param scene defines the hosting scene
  64288. * @returns the icosahedron mesh
  64289. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64290. */
  64291. static CreateIcoSphere(name: string, options: {
  64292. radius?: number;
  64293. radiusX?: number;
  64294. radiusY?: number;
  64295. radiusZ?: number;
  64296. flat?: boolean;
  64297. subdivisions?: number;
  64298. sideOrientation?: number;
  64299. frontUVs?: Vector4;
  64300. backUVs?: Vector4;
  64301. updatable?: boolean;
  64302. }, scene?: Nullable<Scene>): Mesh;
  64303. }
  64304. }
  64305. declare module BABYLON {
  64306. /**
  64307. * Class containing static functions to help procedurally build meshes
  64308. */
  64309. export class DecalBuilder {
  64310. /**
  64311. * Creates a decal mesh.
  64312. * 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
  64313. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64314. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64315. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64316. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64317. * @param name defines the name of the mesh
  64318. * @param sourceMesh defines the mesh where the decal must be applied
  64319. * @param options defines the options used to create the mesh
  64320. * @param scene defines the hosting scene
  64321. * @returns the decal mesh
  64322. * @see https://doc.babylonjs.com/how_to/decals
  64323. */
  64324. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64325. position?: Vector3;
  64326. normal?: Vector3;
  64327. size?: Vector3;
  64328. angle?: number;
  64329. }): Mesh;
  64330. }
  64331. }
  64332. declare module BABYLON {
  64333. /**
  64334. * Class containing static functions to help procedurally build meshes
  64335. */
  64336. export class MeshBuilder {
  64337. /**
  64338. * Creates a box mesh
  64339. * * The parameter `size` sets the size (float) of each box side (default 1)
  64340. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64341. * * 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)
  64342. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64346. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64347. * @param name defines the name of the mesh
  64348. * @param options defines the options used to create the mesh
  64349. * @param scene defines the hosting scene
  64350. * @returns the box mesh
  64351. */
  64352. static CreateBox(name: string, options: {
  64353. size?: number;
  64354. width?: number;
  64355. height?: number;
  64356. depth?: number;
  64357. faceUV?: Vector4[];
  64358. faceColors?: Color4[];
  64359. sideOrientation?: number;
  64360. frontUVs?: Vector4;
  64361. backUVs?: Vector4;
  64362. wrap?: boolean;
  64363. topBaseAt?: number;
  64364. bottomBaseAt?: number;
  64365. updatable?: boolean;
  64366. }, scene?: Nullable<Scene>): Mesh;
  64367. /**
  64368. * Creates a tiled box mesh
  64369. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64371. * @param name defines the name of the mesh
  64372. * @param options defines the options used to create the mesh
  64373. * @param scene defines the hosting scene
  64374. * @returns the tiled box mesh
  64375. */
  64376. static CreateTiledBox(name: string, options: {
  64377. pattern?: number;
  64378. size?: number;
  64379. width?: number;
  64380. height?: number;
  64381. depth: number;
  64382. tileSize?: number;
  64383. tileWidth?: number;
  64384. tileHeight?: number;
  64385. faceUV?: Vector4[];
  64386. faceColors?: Color4[];
  64387. alignHorizontal?: number;
  64388. alignVertical?: number;
  64389. sideOrientation?: number;
  64390. updatable?: boolean;
  64391. }, scene?: Nullable<Scene>): Mesh;
  64392. /**
  64393. * Creates a sphere mesh
  64394. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64395. * * 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`)
  64396. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64397. * * 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
  64398. * * 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)
  64399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64400. * * 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
  64401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64402. * @param name defines the name of the mesh
  64403. * @param options defines the options used to create the mesh
  64404. * @param scene defines the hosting scene
  64405. * @returns the sphere mesh
  64406. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64407. */
  64408. static CreateSphere(name: string, options: {
  64409. segments?: number;
  64410. diameter?: number;
  64411. diameterX?: number;
  64412. diameterY?: number;
  64413. diameterZ?: number;
  64414. arc?: number;
  64415. slice?: number;
  64416. sideOrientation?: number;
  64417. frontUVs?: Vector4;
  64418. backUVs?: Vector4;
  64419. updatable?: boolean;
  64420. }, scene?: Nullable<Scene>): Mesh;
  64421. /**
  64422. * Creates a plane polygonal mesh. By default, this is a disc
  64423. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64424. * * 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
  64425. * * 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
  64426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64427. * * 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
  64428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64429. * @param name defines the name of the mesh
  64430. * @param options defines the options used to create the mesh
  64431. * @param scene defines the hosting scene
  64432. * @returns the plane polygonal mesh
  64433. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64434. */
  64435. static CreateDisc(name: string, options: {
  64436. radius?: number;
  64437. tessellation?: number;
  64438. arc?: number;
  64439. updatable?: boolean;
  64440. sideOrientation?: number;
  64441. frontUVs?: Vector4;
  64442. backUVs?: Vector4;
  64443. }, scene?: Nullable<Scene>): Mesh;
  64444. /**
  64445. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64446. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64447. * * 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`)
  64448. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64449. * * 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
  64450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64451. * * 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
  64452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64453. * @param name defines the name of the mesh
  64454. * @param options defines the options used to create the mesh
  64455. * @param scene defines the hosting scene
  64456. * @returns the icosahedron mesh
  64457. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64458. */
  64459. static CreateIcoSphere(name: string, options: {
  64460. radius?: number;
  64461. radiusX?: number;
  64462. radiusY?: number;
  64463. radiusZ?: number;
  64464. flat?: boolean;
  64465. subdivisions?: number;
  64466. sideOrientation?: number;
  64467. frontUVs?: Vector4;
  64468. backUVs?: Vector4;
  64469. updatable?: boolean;
  64470. }, scene?: Nullable<Scene>): Mesh;
  64471. /**
  64472. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64473. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64474. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64475. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64476. * * 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
  64477. * * 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
  64478. * * 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
  64479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64480. * * 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
  64481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64482. * * 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
  64483. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64484. * * 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
  64485. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64487. * @param name defines the name of the mesh
  64488. * @param options defines the options used to create the mesh
  64489. * @param scene defines the hosting scene
  64490. * @returns the ribbon mesh
  64491. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64492. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64493. */
  64494. static CreateRibbon(name: string, options: {
  64495. pathArray: Vector3[][];
  64496. closeArray?: boolean;
  64497. closePath?: boolean;
  64498. offset?: number;
  64499. updatable?: boolean;
  64500. sideOrientation?: number;
  64501. frontUVs?: Vector4;
  64502. backUVs?: Vector4;
  64503. instance?: Mesh;
  64504. invertUV?: boolean;
  64505. uvs?: Vector2[];
  64506. colors?: Color4[];
  64507. }, scene?: Nullable<Scene>): Mesh;
  64508. /**
  64509. * Creates a cylinder or a cone mesh
  64510. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64511. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64512. * * 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.
  64513. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64514. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64515. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64516. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64517. * * 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).
  64518. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64519. * * 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).
  64520. * * 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
  64521. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64522. * * 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
  64523. * * 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.
  64524. * * If `enclose` is false, a ring surface is one element.
  64525. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64526. * * 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
  64527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64528. * * 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
  64529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64530. * @param name defines the name of the mesh
  64531. * @param options defines the options used to create the mesh
  64532. * @param scene defines the hosting scene
  64533. * @returns the cylinder mesh
  64534. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64535. */
  64536. static CreateCylinder(name: string, options: {
  64537. height?: number;
  64538. diameterTop?: number;
  64539. diameterBottom?: number;
  64540. diameter?: number;
  64541. tessellation?: number;
  64542. subdivisions?: number;
  64543. arc?: number;
  64544. faceColors?: Color4[];
  64545. faceUV?: Vector4[];
  64546. updatable?: boolean;
  64547. hasRings?: boolean;
  64548. enclose?: boolean;
  64549. cap?: number;
  64550. sideOrientation?: number;
  64551. frontUVs?: Vector4;
  64552. backUVs?: Vector4;
  64553. }, scene?: Nullable<Scene>): Mesh;
  64554. /**
  64555. * Creates a torus mesh
  64556. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64557. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64558. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64560. * * 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
  64561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64562. * @param name defines the name of the mesh
  64563. * @param options defines the options used to create the mesh
  64564. * @param scene defines the hosting scene
  64565. * @returns the torus mesh
  64566. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64567. */
  64568. static CreateTorus(name: string, options: {
  64569. diameter?: number;
  64570. thickness?: number;
  64571. tessellation?: number;
  64572. updatable?: boolean;
  64573. sideOrientation?: number;
  64574. frontUVs?: Vector4;
  64575. backUVs?: Vector4;
  64576. }, scene?: Nullable<Scene>): Mesh;
  64577. /**
  64578. * Creates a torus knot mesh
  64579. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64580. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64581. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64582. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64584. * * 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
  64585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64586. * @param name defines the name of the mesh
  64587. * @param options defines the options used to create the mesh
  64588. * @param scene defines the hosting scene
  64589. * @returns the torus knot mesh
  64590. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64591. */
  64592. static CreateTorusKnot(name: string, options: {
  64593. radius?: number;
  64594. tube?: number;
  64595. radialSegments?: number;
  64596. tubularSegments?: number;
  64597. p?: number;
  64598. q?: number;
  64599. updatable?: boolean;
  64600. sideOrientation?: number;
  64601. frontUVs?: Vector4;
  64602. backUVs?: Vector4;
  64603. }, scene?: Nullable<Scene>): Mesh;
  64604. /**
  64605. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64606. * * 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
  64607. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64608. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64609. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64610. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64611. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64612. * * 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
  64613. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64616. * @param name defines the name of the new line system
  64617. * @param options defines the options used to create the line system
  64618. * @param scene defines the hosting scene
  64619. * @returns a new line system mesh
  64620. */
  64621. static CreateLineSystem(name: string, options: {
  64622. lines: Vector3[][];
  64623. updatable?: boolean;
  64624. instance?: Nullable<LinesMesh>;
  64625. colors?: Nullable<Color4[][]>;
  64626. useVertexAlpha?: boolean;
  64627. }, scene: Nullable<Scene>): LinesMesh;
  64628. /**
  64629. * Creates a line mesh
  64630. * 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
  64631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64632. * * The parameter `points` is an array successive Vector3
  64633. * * 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
  64634. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64635. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64636. * * When updating an instance, remember that only point positions can change, not the number of points
  64637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64639. * @param name defines the name of the new line system
  64640. * @param options defines the options used to create the line system
  64641. * @param scene defines the hosting scene
  64642. * @returns a new line mesh
  64643. */
  64644. static CreateLines(name: string, options: {
  64645. points: Vector3[];
  64646. updatable?: boolean;
  64647. instance?: Nullable<LinesMesh>;
  64648. colors?: Color4[];
  64649. useVertexAlpha?: boolean;
  64650. }, scene?: Nullable<Scene>): LinesMesh;
  64651. /**
  64652. * Creates a dashed line mesh
  64653. * * 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
  64654. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64655. * * The parameter `points` is an array successive Vector3
  64656. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64657. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64658. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64659. * * 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
  64660. * * When updating an instance, remember that only point positions can change, not the number of points
  64661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64662. * @param name defines the name of the mesh
  64663. * @param options defines the options used to create the mesh
  64664. * @param scene defines the hosting scene
  64665. * @returns the dashed line mesh
  64666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64667. */
  64668. static CreateDashedLines(name: string, options: {
  64669. points: Vector3[];
  64670. dashSize?: number;
  64671. gapSize?: number;
  64672. dashNb?: number;
  64673. updatable?: boolean;
  64674. instance?: LinesMesh;
  64675. }, scene?: Nullable<Scene>): LinesMesh;
  64676. /**
  64677. * 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.
  64678. * * 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.
  64679. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64680. * * 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.
  64681. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64682. * * 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
  64683. * * 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
  64684. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64686. * * 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
  64687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64689. * @param name defines the name of the mesh
  64690. * @param options defines the options used to create the mesh
  64691. * @param scene defines the hosting scene
  64692. * @returns the extruded shape mesh
  64693. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64695. */
  64696. static ExtrudeShape(name: string, options: {
  64697. shape: Vector3[];
  64698. path: Vector3[];
  64699. scale?: number;
  64700. rotation?: number;
  64701. cap?: number;
  64702. updatable?: boolean;
  64703. sideOrientation?: number;
  64704. frontUVs?: Vector4;
  64705. backUVs?: Vector4;
  64706. instance?: Mesh;
  64707. invertUV?: boolean;
  64708. }, scene?: Nullable<Scene>): Mesh;
  64709. /**
  64710. * Creates an custom extruded shape mesh.
  64711. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64712. * * 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.
  64713. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64714. * * 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
  64715. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64716. * * 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
  64717. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64718. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64719. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64720. * * 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
  64721. * * 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
  64722. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64724. * * 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
  64725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64727. * @param name defines the name of the mesh
  64728. * @param options defines the options used to create the mesh
  64729. * @param scene defines the hosting scene
  64730. * @returns the custom extruded shape mesh
  64731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64734. */
  64735. static ExtrudeShapeCustom(name: string, options: {
  64736. shape: Vector3[];
  64737. path: Vector3[];
  64738. scaleFunction?: any;
  64739. rotationFunction?: any;
  64740. ribbonCloseArray?: boolean;
  64741. ribbonClosePath?: boolean;
  64742. cap?: number;
  64743. updatable?: boolean;
  64744. sideOrientation?: number;
  64745. frontUVs?: Vector4;
  64746. backUVs?: Vector4;
  64747. instance?: Mesh;
  64748. invertUV?: boolean;
  64749. }, scene?: Nullable<Scene>): Mesh;
  64750. /**
  64751. * Creates lathe mesh.
  64752. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64753. * * 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
  64754. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64755. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64756. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64757. * * 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
  64758. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64759. * * 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
  64760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64761. * * 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
  64762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64764. * @param name defines the name of the mesh
  64765. * @param options defines the options used to create the mesh
  64766. * @param scene defines the hosting scene
  64767. * @returns the lathe mesh
  64768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64769. */
  64770. static CreateLathe(name: string, options: {
  64771. shape: Vector3[];
  64772. radius?: number;
  64773. tessellation?: number;
  64774. clip?: number;
  64775. arc?: number;
  64776. closed?: boolean;
  64777. updatable?: boolean;
  64778. sideOrientation?: number;
  64779. frontUVs?: Vector4;
  64780. backUVs?: Vector4;
  64781. cap?: number;
  64782. invertUV?: boolean;
  64783. }, scene?: Nullable<Scene>): Mesh;
  64784. /**
  64785. * Creates a tiled plane mesh
  64786. * * You can set a limited pattern arrangement with the tiles
  64787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64788. * * 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
  64789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64790. * @param name defines the name of the mesh
  64791. * @param options defines the options used to create the mesh
  64792. * @param scene defines the hosting scene
  64793. * @returns the plane mesh
  64794. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64795. */
  64796. static CreateTiledPlane(name: string, options: {
  64797. pattern?: number;
  64798. tileSize?: number;
  64799. tileWidth?: number;
  64800. tileHeight?: number;
  64801. size?: number;
  64802. width?: number;
  64803. height?: number;
  64804. alignHorizontal?: number;
  64805. alignVertical?: number;
  64806. sideOrientation?: number;
  64807. frontUVs?: Vector4;
  64808. backUVs?: Vector4;
  64809. updatable?: boolean;
  64810. }, scene?: Nullable<Scene>): Mesh;
  64811. /**
  64812. * Creates a plane mesh
  64813. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64814. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64815. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64817. * * 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
  64818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64819. * @param name defines the name of the mesh
  64820. * @param options defines the options used to create the mesh
  64821. * @param scene defines the hosting scene
  64822. * @returns the plane mesh
  64823. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64824. */
  64825. static CreatePlane(name: string, options: {
  64826. size?: number;
  64827. width?: number;
  64828. height?: number;
  64829. sideOrientation?: number;
  64830. frontUVs?: Vector4;
  64831. backUVs?: Vector4;
  64832. updatable?: boolean;
  64833. sourcePlane?: Plane;
  64834. }, scene?: Nullable<Scene>): Mesh;
  64835. /**
  64836. * Creates a ground mesh
  64837. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64838. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64840. * @param name defines the name of the mesh
  64841. * @param options defines the options used to create the mesh
  64842. * @param scene defines the hosting scene
  64843. * @returns the ground mesh
  64844. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64845. */
  64846. static CreateGround(name: string, options: {
  64847. width?: number;
  64848. height?: number;
  64849. subdivisions?: number;
  64850. subdivisionsX?: number;
  64851. subdivisionsY?: number;
  64852. updatable?: boolean;
  64853. }, scene?: Nullable<Scene>): Mesh;
  64854. /**
  64855. * Creates a tiled ground mesh
  64856. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64857. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64858. * * 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
  64859. * * 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
  64860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64861. * @param name defines the name of the mesh
  64862. * @param options defines the options used to create the mesh
  64863. * @param scene defines the hosting scene
  64864. * @returns the tiled ground mesh
  64865. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64866. */
  64867. static CreateTiledGround(name: string, options: {
  64868. xmin: number;
  64869. zmin: number;
  64870. xmax: number;
  64871. zmax: number;
  64872. subdivisions?: {
  64873. w: number;
  64874. h: number;
  64875. };
  64876. precision?: {
  64877. w: number;
  64878. h: number;
  64879. };
  64880. updatable?: boolean;
  64881. }, scene?: Nullable<Scene>): Mesh;
  64882. /**
  64883. * Creates a ground mesh from a height map
  64884. * * The parameter `url` sets the URL of the height map image resource.
  64885. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64886. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64887. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64888. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64889. * * 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.
  64890. * * 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).
  64891. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64893. * @param name defines the name of the mesh
  64894. * @param url defines the url to the height map
  64895. * @param options defines the options used to create the mesh
  64896. * @param scene defines the hosting scene
  64897. * @returns the ground mesh
  64898. * @see https://doc.babylonjs.com/babylon101/height_map
  64899. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64900. */
  64901. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64902. width?: number;
  64903. height?: number;
  64904. subdivisions?: number;
  64905. minHeight?: number;
  64906. maxHeight?: number;
  64907. colorFilter?: Color3;
  64908. alphaFilter?: number;
  64909. updatable?: boolean;
  64910. onReady?: (mesh: GroundMesh) => void;
  64911. }, scene?: Nullable<Scene>): GroundMesh;
  64912. /**
  64913. * Creates a polygon mesh
  64914. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64915. * * 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
  64916. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64918. * * 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)
  64919. * * Remember you can only change the shape positions, not their number when updating a polygon
  64920. * @param name defines the name of the mesh
  64921. * @param options defines the options used to create the mesh
  64922. * @param scene defines the hosting scene
  64923. * @param earcutInjection can be used to inject your own earcut reference
  64924. * @returns the polygon mesh
  64925. */
  64926. static CreatePolygon(name: string, options: {
  64927. shape: Vector3[];
  64928. holes?: Vector3[][];
  64929. depth?: number;
  64930. faceUV?: Vector4[];
  64931. faceColors?: Color4[];
  64932. updatable?: boolean;
  64933. sideOrientation?: number;
  64934. frontUVs?: Vector4;
  64935. backUVs?: Vector4;
  64936. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64937. /**
  64938. * Creates an extruded polygon mesh, with depth in the Y direction.
  64939. * * 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)
  64940. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64941. * @param name defines the name of the mesh
  64942. * @param options defines the options used to create the mesh
  64943. * @param scene defines the hosting scene
  64944. * @param earcutInjection can be used to inject your own earcut reference
  64945. * @returns the polygon mesh
  64946. */
  64947. static ExtrudePolygon(name: string, options: {
  64948. shape: Vector3[];
  64949. holes?: Vector3[][];
  64950. depth?: number;
  64951. faceUV?: Vector4[];
  64952. faceColors?: Color4[];
  64953. updatable?: boolean;
  64954. sideOrientation?: number;
  64955. frontUVs?: Vector4;
  64956. backUVs?: Vector4;
  64957. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64958. /**
  64959. * Creates a tube mesh.
  64960. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64961. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64962. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64963. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64964. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64965. * * 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)
  64966. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64967. * * 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
  64968. * * 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
  64969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64970. * * 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
  64971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64973. * @param name defines the name of the mesh
  64974. * @param options defines the options used to create the mesh
  64975. * @param scene defines the hosting scene
  64976. * @returns the tube mesh
  64977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64978. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64979. */
  64980. static CreateTube(name: string, options: {
  64981. path: Vector3[];
  64982. radius?: number;
  64983. tessellation?: number;
  64984. radiusFunction?: {
  64985. (i: number, distance: number): number;
  64986. };
  64987. cap?: number;
  64988. arc?: number;
  64989. updatable?: boolean;
  64990. sideOrientation?: number;
  64991. frontUVs?: Vector4;
  64992. backUVs?: Vector4;
  64993. instance?: Mesh;
  64994. invertUV?: boolean;
  64995. }, scene?: Nullable<Scene>): Mesh;
  64996. /**
  64997. * Creates a polyhedron mesh
  64998. * * 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
  64999. * * The parameter `size` (positive float, default 1) sets the polygon size
  65000. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65001. * * 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`
  65002. * * 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
  65003. * * 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)`)
  65004. * * 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
  65005. * * 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
  65006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65007. * * 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
  65008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65009. * @param name defines the name of the mesh
  65010. * @param options defines the options used to create the mesh
  65011. * @param scene defines the hosting scene
  65012. * @returns the polyhedron mesh
  65013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65014. */
  65015. static CreatePolyhedron(name: string, options: {
  65016. type?: number;
  65017. size?: number;
  65018. sizeX?: number;
  65019. sizeY?: number;
  65020. sizeZ?: number;
  65021. custom?: any;
  65022. faceUV?: Vector4[];
  65023. faceColors?: Color4[];
  65024. flat?: boolean;
  65025. updatable?: boolean;
  65026. sideOrientation?: number;
  65027. frontUVs?: Vector4;
  65028. backUVs?: Vector4;
  65029. }, scene?: Nullable<Scene>): Mesh;
  65030. /**
  65031. * Creates a decal mesh.
  65032. * 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
  65033. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65034. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65035. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65036. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65037. * @param name defines the name of the mesh
  65038. * @param sourceMesh defines the mesh where the decal must be applied
  65039. * @param options defines the options used to create the mesh
  65040. * @param scene defines the hosting scene
  65041. * @returns the decal mesh
  65042. * @see https://doc.babylonjs.com/how_to/decals
  65043. */
  65044. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65045. position?: Vector3;
  65046. normal?: Vector3;
  65047. size?: Vector3;
  65048. angle?: number;
  65049. }): Mesh;
  65050. }
  65051. }
  65052. declare module BABYLON {
  65053. /**
  65054. * A simplifier interface for future simplification implementations
  65055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65056. */
  65057. export interface ISimplifier {
  65058. /**
  65059. * Simplification of a given mesh according to the given settings.
  65060. * Since this requires computation, it is assumed that the function runs async.
  65061. * @param settings The settings of the simplification, including quality and distance
  65062. * @param successCallback A callback that will be called after the mesh was simplified.
  65063. * @param errorCallback in case of an error, this callback will be called. optional.
  65064. */
  65065. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65066. }
  65067. /**
  65068. * Expected simplification settings.
  65069. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65071. */
  65072. export interface ISimplificationSettings {
  65073. /**
  65074. * Gets or sets the expected quality
  65075. */
  65076. quality: number;
  65077. /**
  65078. * Gets or sets the distance when this optimized version should be used
  65079. */
  65080. distance: number;
  65081. /**
  65082. * Gets an already optimized mesh
  65083. */
  65084. optimizeMesh?: boolean;
  65085. }
  65086. /**
  65087. * Class used to specify simplification options
  65088. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65089. */
  65090. export class SimplificationSettings implements ISimplificationSettings {
  65091. /** expected quality */
  65092. quality: number;
  65093. /** distance when this optimized version should be used */
  65094. distance: number;
  65095. /** already optimized mesh */
  65096. optimizeMesh?: boolean | undefined;
  65097. /**
  65098. * Creates a SimplificationSettings
  65099. * @param quality expected quality
  65100. * @param distance distance when this optimized version should be used
  65101. * @param optimizeMesh already optimized mesh
  65102. */
  65103. constructor(
  65104. /** expected quality */
  65105. quality: number,
  65106. /** distance when this optimized version should be used */
  65107. distance: number,
  65108. /** already optimized mesh */
  65109. optimizeMesh?: boolean | undefined);
  65110. }
  65111. /**
  65112. * Interface used to define a simplification task
  65113. */
  65114. export interface ISimplificationTask {
  65115. /**
  65116. * Array of settings
  65117. */
  65118. settings: Array<ISimplificationSettings>;
  65119. /**
  65120. * Simplification type
  65121. */
  65122. simplificationType: SimplificationType;
  65123. /**
  65124. * Mesh to simplify
  65125. */
  65126. mesh: Mesh;
  65127. /**
  65128. * Callback called on success
  65129. */
  65130. successCallback?: () => void;
  65131. /**
  65132. * Defines if parallel processing can be used
  65133. */
  65134. parallelProcessing: boolean;
  65135. }
  65136. /**
  65137. * Queue used to order the simplification tasks
  65138. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65139. */
  65140. export class SimplificationQueue {
  65141. private _simplificationArray;
  65142. /**
  65143. * Gets a boolean indicating that the process is still running
  65144. */
  65145. running: boolean;
  65146. /**
  65147. * Creates a new queue
  65148. */
  65149. constructor();
  65150. /**
  65151. * Adds a new simplification task
  65152. * @param task defines a task to add
  65153. */
  65154. addTask(task: ISimplificationTask): void;
  65155. /**
  65156. * Execute next task
  65157. */
  65158. executeNext(): void;
  65159. /**
  65160. * Execute a simplification task
  65161. * @param task defines the task to run
  65162. */
  65163. runSimplification(task: ISimplificationTask): void;
  65164. private getSimplifier;
  65165. }
  65166. /**
  65167. * The implemented types of simplification
  65168. * At the moment only Quadratic Error Decimation is implemented
  65169. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65170. */
  65171. export enum SimplificationType {
  65172. /** Quadratic error decimation */
  65173. QUADRATIC = 0
  65174. }
  65175. /**
  65176. * An implementation of the Quadratic Error simplification algorithm.
  65177. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65178. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65179. * @author RaananW
  65180. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65181. */
  65182. export class QuadraticErrorSimplification implements ISimplifier {
  65183. private _mesh;
  65184. private triangles;
  65185. private vertices;
  65186. private references;
  65187. private _reconstructedMesh;
  65188. /** Gets or sets the number pf sync interations */
  65189. syncIterations: number;
  65190. /** Gets or sets the aggressiveness of the simplifier */
  65191. aggressiveness: number;
  65192. /** Gets or sets the number of allowed iterations for decimation */
  65193. decimationIterations: number;
  65194. /** Gets or sets the espilon to use for bounding box computation */
  65195. boundingBoxEpsilon: number;
  65196. /**
  65197. * Creates a new QuadraticErrorSimplification
  65198. * @param _mesh defines the target mesh
  65199. */
  65200. constructor(_mesh: Mesh);
  65201. /**
  65202. * Simplification of a given mesh according to the given settings.
  65203. * Since this requires computation, it is assumed that the function runs async.
  65204. * @param settings The settings of the simplification, including quality and distance
  65205. * @param successCallback A callback that will be called after the mesh was simplified.
  65206. */
  65207. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65208. private runDecimation;
  65209. private initWithMesh;
  65210. private init;
  65211. private reconstructMesh;
  65212. private initDecimatedMesh;
  65213. private isFlipped;
  65214. private updateTriangles;
  65215. private identifyBorder;
  65216. private updateMesh;
  65217. private vertexError;
  65218. private calculateError;
  65219. }
  65220. }
  65221. declare module BABYLON {
  65222. interface Scene {
  65223. /** @hidden (Backing field) */
  65224. _simplificationQueue: SimplificationQueue;
  65225. /**
  65226. * Gets or sets the simplification queue attached to the scene
  65227. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65228. */
  65229. simplificationQueue: SimplificationQueue;
  65230. }
  65231. interface Mesh {
  65232. /**
  65233. * Simplify the mesh according to the given array of settings.
  65234. * Function will return immediately and will simplify async
  65235. * @param settings a collection of simplification settings
  65236. * @param parallelProcessing should all levels calculate parallel or one after the other
  65237. * @param simplificationType the type of simplification to run
  65238. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65239. * @returns the current mesh
  65240. */
  65241. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65242. }
  65243. /**
  65244. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65245. * created in a scene
  65246. */
  65247. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65248. /**
  65249. * The component name helpfull to identify the component in the list of scene components.
  65250. */
  65251. readonly name: string;
  65252. /**
  65253. * The scene the component belongs to.
  65254. */
  65255. scene: Scene;
  65256. /**
  65257. * Creates a new instance of the component for the given scene
  65258. * @param scene Defines the scene to register the component in
  65259. */
  65260. constructor(scene: Scene);
  65261. /**
  65262. * Registers the component in a given scene
  65263. */
  65264. register(): void;
  65265. /**
  65266. * Rebuilds the elements related to this component in case of
  65267. * context lost for instance.
  65268. */
  65269. rebuild(): void;
  65270. /**
  65271. * Disposes the component and the associated ressources
  65272. */
  65273. dispose(): void;
  65274. private _beforeCameraUpdate;
  65275. }
  65276. }
  65277. declare module BABYLON {
  65278. interface Mesh {
  65279. /**
  65280. * Creates a new thin instance
  65281. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65282. * @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
  65283. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65284. */
  65285. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65286. /**
  65287. * Adds the transformation (matrix) of the current mesh as a thin instance
  65288. * @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
  65289. * @returns the thin instance index number
  65290. */
  65291. thinInstanceAddSelf(refresh: boolean): number;
  65292. /**
  65293. * Registers a custom attribute to be used with thin instances
  65294. * @param kind name of the attribute
  65295. * @param stride size in floats of the attribute
  65296. */
  65297. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65298. /**
  65299. * Sets the matrix of a thin instance
  65300. * @param index index of the thin instance
  65301. * @param matrix matrix to set
  65302. * @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
  65303. */
  65304. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65305. /**
  65306. * Sets the value of a custom attribute for a thin instance
  65307. * @param kind name of the attribute
  65308. * @param index index of the thin instance
  65309. * @param value value to set
  65310. * @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
  65311. */
  65312. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65313. /**
  65314. * 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.
  65315. */
  65316. thinInstanceCount: number;
  65317. /**
  65318. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65319. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65320. * @param buffer buffer to set
  65321. * @param stride size in floats of each value of the buffer
  65322. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65323. */
  65324. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65325. /**
  65326. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65327. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65328. */
  65329. thinInstanceBufferUpdated(kind: string): void;
  65330. /**
  65331. * Refreshes the bounding info, taking into account all the thin instances defined
  65332. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65333. */
  65334. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65335. /** @hidden */
  65336. _thinInstanceInitializeUserStorage(): void;
  65337. /** @hidden */
  65338. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65339. /** @hidden */
  65340. _userThinInstanceBuffersStorage: {
  65341. data: {
  65342. [key: string]: Float32Array;
  65343. };
  65344. sizes: {
  65345. [key: string]: number;
  65346. };
  65347. vertexBuffers: {
  65348. [key: string]: Nullable<VertexBuffer>;
  65349. };
  65350. strides: {
  65351. [key: string]: number;
  65352. };
  65353. };
  65354. }
  65355. }
  65356. declare module BABYLON {
  65357. /**
  65358. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65359. */
  65360. export interface INavigationEnginePlugin {
  65361. /**
  65362. * plugin name
  65363. */
  65364. name: string;
  65365. /**
  65366. * Creates a navigation mesh
  65367. * @param meshes array of all the geometry used to compute the navigatio mesh
  65368. * @param parameters bunch of parameters used to filter geometry
  65369. */
  65370. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65371. /**
  65372. * Create a navigation mesh debug mesh
  65373. * @param scene is where the mesh will be added
  65374. * @returns debug display mesh
  65375. */
  65376. createDebugNavMesh(scene: Scene): Mesh;
  65377. /**
  65378. * Get a navigation mesh constrained position, closest to the parameter position
  65379. * @param position world position
  65380. * @returns the closest point to position constrained by the navigation mesh
  65381. */
  65382. getClosestPoint(position: Vector3): Vector3;
  65383. /**
  65384. * Get a navigation mesh constrained position, closest to the parameter position
  65385. * @param position world position
  65386. * @param result output the closest point to position constrained by the navigation mesh
  65387. */
  65388. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65389. /**
  65390. * Get a navigation mesh constrained position, within a particular radius
  65391. * @param position world position
  65392. * @param maxRadius the maximum distance to the constrained world position
  65393. * @returns the closest point to position constrained by the navigation mesh
  65394. */
  65395. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65396. /**
  65397. * Get a navigation mesh constrained position, within a particular radius
  65398. * @param position world position
  65399. * @param maxRadius the maximum distance to the constrained world position
  65400. * @param result output the closest point to position constrained by the navigation mesh
  65401. */
  65402. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65403. /**
  65404. * Compute the final position from a segment made of destination-position
  65405. * @param position world position
  65406. * @param destination world position
  65407. * @returns the resulting point along the navmesh
  65408. */
  65409. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65410. /**
  65411. * Compute the final position from a segment made of destination-position
  65412. * @param position world position
  65413. * @param destination world position
  65414. * @param result output the resulting point along the navmesh
  65415. */
  65416. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65417. /**
  65418. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65419. * @param start world position
  65420. * @param end world position
  65421. * @returns array containing world position composing the path
  65422. */
  65423. computePath(start: Vector3, end: Vector3): Vector3[];
  65424. /**
  65425. * If this plugin is supported
  65426. * @returns true if plugin is supported
  65427. */
  65428. isSupported(): boolean;
  65429. /**
  65430. * Create a new Crowd so you can add agents
  65431. * @param maxAgents the maximum agent count in the crowd
  65432. * @param maxAgentRadius the maximum radius an agent can have
  65433. * @param scene to attach the crowd to
  65434. * @returns the crowd you can add agents to
  65435. */
  65436. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65437. /**
  65438. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65439. * The queries will try to find a solution within those bounds
  65440. * default is (1,1,1)
  65441. * @param extent x,y,z value that define the extent around the queries point of reference
  65442. */
  65443. setDefaultQueryExtent(extent: Vector3): void;
  65444. /**
  65445. * Get the Bounding box extent specified by setDefaultQueryExtent
  65446. * @returns the box extent values
  65447. */
  65448. getDefaultQueryExtent(): Vector3;
  65449. /**
  65450. * build the navmesh from a previously saved state using getNavmeshData
  65451. * @param data the Uint8Array returned by getNavmeshData
  65452. */
  65453. buildFromNavmeshData(data: Uint8Array): void;
  65454. /**
  65455. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65456. * @returns data the Uint8Array that can be saved and reused
  65457. */
  65458. getNavmeshData(): Uint8Array;
  65459. /**
  65460. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65461. * @param result output the box extent values
  65462. */
  65463. getDefaultQueryExtentToRef(result: Vector3): void;
  65464. /**
  65465. * Release all resources
  65466. */
  65467. dispose(): void;
  65468. }
  65469. /**
  65470. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65471. */
  65472. export interface ICrowd {
  65473. /**
  65474. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65475. * You can attach anything to that node. The node position is updated in the scene update tick.
  65476. * @param pos world position that will be constrained by the navigation mesh
  65477. * @param parameters agent parameters
  65478. * @param transform hooked to the agent that will be update by the scene
  65479. * @returns agent index
  65480. */
  65481. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65482. /**
  65483. * Returns the agent position in world space
  65484. * @param index agent index returned by addAgent
  65485. * @returns world space position
  65486. */
  65487. getAgentPosition(index: number): Vector3;
  65488. /**
  65489. * Gets the agent position result in world space
  65490. * @param index agent index returned by addAgent
  65491. * @param result output world space position
  65492. */
  65493. getAgentPositionToRef(index: number, result: Vector3): void;
  65494. /**
  65495. * Gets the agent velocity in world space
  65496. * @param index agent index returned by addAgent
  65497. * @returns world space velocity
  65498. */
  65499. getAgentVelocity(index: number): Vector3;
  65500. /**
  65501. * Gets the agent velocity result in world space
  65502. * @param index agent index returned by addAgent
  65503. * @param result output world space velocity
  65504. */
  65505. getAgentVelocityToRef(index: number, result: Vector3): void;
  65506. /**
  65507. * remove a particular agent previously created
  65508. * @param index agent index returned by addAgent
  65509. */
  65510. removeAgent(index: number): void;
  65511. /**
  65512. * get the list of all agents attached to this crowd
  65513. * @returns list of agent indices
  65514. */
  65515. getAgents(): number[];
  65516. /**
  65517. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65518. * @param deltaTime in seconds
  65519. */
  65520. update(deltaTime: number): void;
  65521. /**
  65522. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65523. * @param index agent index returned by addAgent
  65524. * @param destination targeted world position
  65525. */
  65526. agentGoto(index: number, destination: Vector3): void;
  65527. /**
  65528. * Teleport the agent to a new position
  65529. * @param index agent index returned by addAgent
  65530. * @param destination targeted world position
  65531. */
  65532. agentTeleport(index: number, destination: Vector3): void;
  65533. /**
  65534. * Update agent parameters
  65535. * @param index agent index returned by addAgent
  65536. * @param parameters agent parameters
  65537. */
  65538. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65539. /**
  65540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65541. * The queries will try to find a solution within those bounds
  65542. * default is (1,1,1)
  65543. * @param extent x,y,z value that define the extent around the queries point of reference
  65544. */
  65545. setDefaultQueryExtent(extent: Vector3): void;
  65546. /**
  65547. * Get the Bounding box extent specified by setDefaultQueryExtent
  65548. * @returns the box extent values
  65549. */
  65550. getDefaultQueryExtent(): Vector3;
  65551. /**
  65552. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65553. * @param result output the box extent values
  65554. */
  65555. getDefaultQueryExtentToRef(result: Vector3): void;
  65556. /**
  65557. * Release all resources
  65558. */
  65559. dispose(): void;
  65560. }
  65561. /**
  65562. * Configures an agent
  65563. */
  65564. export interface IAgentParameters {
  65565. /**
  65566. * Agent radius. [Limit: >= 0]
  65567. */
  65568. radius: number;
  65569. /**
  65570. * Agent height. [Limit: > 0]
  65571. */
  65572. height: number;
  65573. /**
  65574. * Maximum allowed acceleration. [Limit: >= 0]
  65575. */
  65576. maxAcceleration: number;
  65577. /**
  65578. * Maximum allowed speed. [Limit: >= 0]
  65579. */
  65580. maxSpeed: number;
  65581. /**
  65582. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65583. */
  65584. collisionQueryRange: number;
  65585. /**
  65586. * The path visibility optimization range. [Limit: > 0]
  65587. */
  65588. pathOptimizationRange: number;
  65589. /**
  65590. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65591. */
  65592. separationWeight: number;
  65593. }
  65594. /**
  65595. * Configures the navigation mesh creation
  65596. */
  65597. export interface INavMeshParameters {
  65598. /**
  65599. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65600. */
  65601. cs: number;
  65602. /**
  65603. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65604. */
  65605. ch: number;
  65606. /**
  65607. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65608. */
  65609. walkableSlopeAngle: number;
  65610. /**
  65611. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65612. * be considered walkable. [Limit: >= 3] [Units: vx]
  65613. */
  65614. walkableHeight: number;
  65615. /**
  65616. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65617. */
  65618. walkableClimb: number;
  65619. /**
  65620. * The distance to erode/shrink the walkable area of the heightfield away from
  65621. * obstructions. [Limit: >=0] [Units: vx]
  65622. */
  65623. walkableRadius: number;
  65624. /**
  65625. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65626. */
  65627. maxEdgeLen: number;
  65628. /**
  65629. * The maximum distance a simplfied contour's border edges should deviate
  65630. * the original raw contour. [Limit: >=0] [Units: vx]
  65631. */
  65632. maxSimplificationError: number;
  65633. /**
  65634. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65635. */
  65636. minRegionArea: number;
  65637. /**
  65638. * Any regions with a span count smaller than this value will, if possible,
  65639. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65640. */
  65641. mergeRegionArea: number;
  65642. /**
  65643. * The maximum number of vertices allowed for polygons generated during the
  65644. * contour to polygon conversion process. [Limit: >= 3]
  65645. */
  65646. maxVertsPerPoly: number;
  65647. /**
  65648. * Sets the sampling distance to use when generating the detail mesh.
  65649. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65650. */
  65651. detailSampleDist: number;
  65652. /**
  65653. * The maximum distance the detail mesh surface should deviate from heightfield
  65654. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65655. */
  65656. detailSampleMaxError: number;
  65657. }
  65658. }
  65659. declare module BABYLON {
  65660. /**
  65661. * RecastJS navigation plugin
  65662. */
  65663. export class RecastJSPlugin implements INavigationEnginePlugin {
  65664. /**
  65665. * Reference to the Recast library
  65666. */
  65667. bjsRECAST: any;
  65668. /**
  65669. * plugin name
  65670. */
  65671. name: string;
  65672. /**
  65673. * the first navmesh created. We might extend this to support multiple navmeshes
  65674. */
  65675. navMesh: any;
  65676. /**
  65677. * Initializes the recastJS plugin
  65678. * @param recastInjection can be used to inject your own recast reference
  65679. */
  65680. constructor(recastInjection?: any);
  65681. /**
  65682. * Creates a navigation mesh
  65683. * @param meshes array of all the geometry used to compute the navigatio mesh
  65684. * @param parameters bunch of parameters used to filter geometry
  65685. */
  65686. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65687. /**
  65688. * Create a navigation mesh debug mesh
  65689. * @param scene is where the mesh will be added
  65690. * @returns debug display mesh
  65691. */
  65692. createDebugNavMesh(scene: Scene): Mesh;
  65693. /**
  65694. * Get a navigation mesh constrained position, closest to the parameter position
  65695. * @param position world position
  65696. * @returns the closest point to position constrained by the navigation mesh
  65697. */
  65698. getClosestPoint(position: Vector3): Vector3;
  65699. /**
  65700. * Get a navigation mesh constrained position, closest to the parameter position
  65701. * @param position world position
  65702. * @param result output the closest point to position constrained by the navigation mesh
  65703. */
  65704. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65705. /**
  65706. * Get a navigation mesh constrained position, within a particular radius
  65707. * @param position world position
  65708. * @param maxRadius the maximum distance to the constrained world position
  65709. * @returns the closest point to position constrained by the navigation mesh
  65710. */
  65711. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65712. /**
  65713. * Get a navigation mesh constrained position, within a particular radius
  65714. * @param position world position
  65715. * @param maxRadius the maximum distance to the constrained world position
  65716. * @param result output the closest point to position constrained by the navigation mesh
  65717. */
  65718. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65719. /**
  65720. * Compute the final position from a segment made of destination-position
  65721. * @param position world position
  65722. * @param destination world position
  65723. * @returns the resulting point along the navmesh
  65724. */
  65725. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65726. /**
  65727. * Compute the final position from a segment made of destination-position
  65728. * @param position world position
  65729. * @param destination world position
  65730. * @param result output the resulting point along the navmesh
  65731. */
  65732. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65733. /**
  65734. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65735. * @param start world position
  65736. * @param end world position
  65737. * @returns array containing world position composing the path
  65738. */
  65739. computePath(start: Vector3, end: Vector3): Vector3[];
  65740. /**
  65741. * Create a new Crowd so you can add agents
  65742. * @param maxAgents the maximum agent count in the crowd
  65743. * @param maxAgentRadius the maximum radius an agent can have
  65744. * @param scene to attach the crowd to
  65745. * @returns the crowd you can add agents to
  65746. */
  65747. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65748. /**
  65749. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65750. * The queries will try to find a solution within those bounds
  65751. * default is (1,1,1)
  65752. * @param extent x,y,z value that define the extent around the queries point of reference
  65753. */
  65754. setDefaultQueryExtent(extent: Vector3): void;
  65755. /**
  65756. * Get the Bounding box extent specified by setDefaultQueryExtent
  65757. * @returns the box extent values
  65758. */
  65759. getDefaultQueryExtent(): Vector3;
  65760. /**
  65761. * build the navmesh from a previously saved state using getNavmeshData
  65762. * @param data the Uint8Array returned by getNavmeshData
  65763. */
  65764. buildFromNavmeshData(data: Uint8Array): void;
  65765. /**
  65766. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65767. * @returns data the Uint8Array that can be saved and reused
  65768. */
  65769. getNavmeshData(): Uint8Array;
  65770. /**
  65771. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65772. * @param result output the box extent values
  65773. */
  65774. getDefaultQueryExtentToRef(result: Vector3): void;
  65775. /**
  65776. * Disposes
  65777. */
  65778. dispose(): void;
  65779. /**
  65780. * If this plugin is supported
  65781. * @returns true if plugin is supported
  65782. */
  65783. isSupported(): boolean;
  65784. }
  65785. /**
  65786. * Recast detour crowd implementation
  65787. */
  65788. export class RecastJSCrowd implements ICrowd {
  65789. /**
  65790. * Recast/detour plugin
  65791. */
  65792. bjsRECASTPlugin: RecastJSPlugin;
  65793. /**
  65794. * Link to the detour crowd
  65795. */
  65796. recastCrowd: any;
  65797. /**
  65798. * One transform per agent
  65799. */
  65800. transforms: TransformNode[];
  65801. /**
  65802. * All agents created
  65803. */
  65804. agents: number[];
  65805. /**
  65806. * Link to the scene is kept to unregister the crowd from the scene
  65807. */
  65808. private _scene;
  65809. /**
  65810. * Observer for crowd updates
  65811. */
  65812. private _onBeforeAnimationsObserver;
  65813. /**
  65814. * Constructor
  65815. * @param plugin recastJS plugin
  65816. * @param maxAgents the maximum agent count in the crowd
  65817. * @param maxAgentRadius the maximum radius an agent can have
  65818. * @param scene to attach the crowd to
  65819. * @returns the crowd you can add agents to
  65820. */
  65821. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65822. /**
  65823. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65824. * You can attach anything to that node. The node position is updated in the scene update tick.
  65825. * @param pos world position that will be constrained by the navigation mesh
  65826. * @param parameters agent parameters
  65827. * @param transform hooked to the agent that will be update by the scene
  65828. * @returns agent index
  65829. */
  65830. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65831. /**
  65832. * Returns the agent position in world space
  65833. * @param index agent index returned by addAgent
  65834. * @returns world space position
  65835. */
  65836. getAgentPosition(index: number): Vector3;
  65837. /**
  65838. * Returns the agent position result in world space
  65839. * @param index agent index returned by addAgent
  65840. * @param result output world space position
  65841. */
  65842. getAgentPositionToRef(index: number, result: Vector3): void;
  65843. /**
  65844. * Returns the agent velocity in world space
  65845. * @param index agent index returned by addAgent
  65846. * @returns world space velocity
  65847. */
  65848. getAgentVelocity(index: number): Vector3;
  65849. /**
  65850. * Returns the agent velocity result in world space
  65851. * @param index agent index returned by addAgent
  65852. * @param result output world space velocity
  65853. */
  65854. getAgentVelocityToRef(index: number, result: Vector3): void;
  65855. /**
  65856. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65857. * @param index agent index returned by addAgent
  65858. * @param destination targeted world position
  65859. */
  65860. agentGoto(index: number, destination: Vector3): void;
  65861. /**
  65862. * Teleport the agent to a new position
  65863. * @param index agent index returned by addAgent
  65864. * @param destination targeted world position
  65865. */
  65866. agentTeleport(index: number, destination: Vector3): void;
  65867. /**
  65868. * Update agent parameters
  65869. * @param index agent index returned by addAgent
  65870. * @param parameters agent parameters
  65871. */
  65872. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65873. /**
  65874. * remove a particular agent previously created
  65875. * @param index agent index returned by addAgent
  65876. */
  65877. removeAgent(index: number): void;
  65878. /**
  65879. * get the list of all agents attached to this crowd
  65880. * @returns list of agent indices
  65881. */
  65882. getAgents(): number[];
  65883. /**
  65884. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65885. * @param deltaTime in seconds
  65886. */
  65887. update(deltaTime: number): void;
  65888. /**
  65889. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65890. * The queries will try to find a solution within those bounds
  65891. * default is (1,1,1)
  65892. * @param extent x,y,z value that define the extent around the queries point of reference
  65893. */
  65894. setDefaultQueryExtent(extent: Vector3): void;
  65895. /**
  65896. * Get the Bounding box extent specified by setDefaultQueryExtent
  65897. * @returns the box extent values
  65898. */
  65899. getDefaultQueryExtent(): Vector3;
  65900. /**
  65901. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65902. * @param result output the box extent values
  65903. */
  65904. getDefaultQueryExtentToRef(result: Vector3): void;
  65905. /**
  65906. * Release all resources
  65907. */
  65908. dispose(): void;
  65909. }
  65910. }
  65911. declare module BABYLON {
  65912. /**
  65913. * Class used to enable access to IndexedDB
  65914. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65915. */
  65916. export class Database implements IOfflineProvider {
  65917. private _callbackManifestChecked;
  65918. private _currentSceneUrl;
  65919. private _db;
  65920. private _enableSceneOffline;
  65921. private _enableTexturesOffline;
  65922. private _manifestVersionFound;
  65923. private _mustUpdateRessources;
  65924. private _hasReachedQuota;
  65925. private _isSupported;
  65926. private _idbFactory;
  65927. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65928. private static IsUASupportingBlobStorage;
  65929. /**
  65930. * Gets a boolean indicating if Database storate is enabled (off by default)
  65931. */
  65932. static IDBStorageEnabled: boolean;
  65933. /**
  65934. * Gets a boolean indicating if scene must be saved in the database
  65935. */
  65936. get enableSceneOffline(): boolean;
  65937. /**
  65938. * Gets a boolean indicating if textures must be saved in the database
  65939. */
  65940. get enableTexturesOffline(): boolean;
  65941. /**
  65942. * Creates a new Database
  65943. * @param urlToScene defines the url to load the scene
  65944. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65945. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65946. */
  65947. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65948. private static _ParseURL;
  65949. private static _ReturnFullUrlLocation;
  65950. private _checkManifestFile;
  65951. /**
  65952. * Open the database and make it available
  65953. * @param successCallback defines the callback to call on success
  65954. * @param errorCallback defines the callback to call on error
  65955. */
  65956. open(successCallback: () => void, errorCallback: () => void): void;
  65957. /**
  65958. * Loads an image from the database
  65959. * @param url defines the url to load from
  65960. * @param image defines the target DOM image
  65961. */
  65962. loadImage(url: string, image: HTMLImageElement): void;
  65963. private _loadImageFromDBAsync;
  65964. private _saveImageIntoDBAsync;
  65965. private _checkVersionFromDB;
  65966. private _loadVersionFromDBAsync;
  65967. private _saveVersionIntoDBAsync;
  65968. /**
  65969. * Loads a file from database
  65970. * @param url defines the URL to load from
  65971. * @param sceneLoaded defines a callback to call on success
  65972. * @param progressCallBack defines a callback to call when progress changed
  65973. * @param errorCallback defines a callback to call on error
  65974. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65975. */
  65976. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65977. private _loadFileAsync;
  65978. private _saveFileAsync;
  65979. /**
  65980. * Validates if xhr data is correct
  65981. * @param xhr defines the request to validate
  65982. * @param dataType defines the expected data type
  65983. * @returns true if data is correct
  65984. */
  65985. private static _ValidateXHRData;
  65986. }
  65987. }
  65988. declare module BABYLON {
  65989. /** @hidden */
  65990. export var gpuUpdateParticlesPixelShader: {
  65991. name: string;
  65992. shader: string;
  65993. };
  65994. }
  65995. declare module BABYLON {
  65996. /** @hidden */
  65997. export var gpuUpdateParticlesVertexShader: {
  65998. name: string;
  65999. shader: string;
  66000. };
  66001. }
  66002. declare module BABYLON {
  66003. /** @hidden */
  66004. export var clipPlaneFragmentDeclaration2: {
  66005. name: string;
  66006. shader: string;
  66007. };
  66008. }
  66009. declare module BABYLON {
  66010. /** @hidden */
  66011. export var gpuRenderParticlesPixelShader: {
  66012. name: string;
  66013. shader: string;
  66014. };
  66015. }
  66016. declare module BABYLON {
  66017. /** @hidden */
  66018. export var clipPlaneVertexDeclaration2: {
  66019. name: string;
  66020. shader: string;
  66021. };
  66022. }
  66023. declare module BABYLON {
  66024. /** @hidden */
  66025. export var gpuRenderParticlesVertexShader: {
  66026. name: string;
  66027. shader: string;
  66028. };
  66029. }
  66030. declare module BABYLON {
  66031. /**
  66032. * This represents a GPU particle system in Babylon
  66033. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66034. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66035. */
  66036. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66037. /**
  66038. * The layer mask we are rendering the particles through.
  66039. */
  66040. layerMask: number;
  66041. private _capacity;
  66042. private _activeCount;
  66043. private _currentActiveCount;
  66044. private _accumulatedCount;
  66045. private _renderEffect;
  66046. private _updateEffect;
  66047. private _buffer0;
  66048. private _buffer1;
  66049. private _spriteBuffer;
  66050. private _updateVAO;
  66051. private _renderVAO;
  66052. private _targetIndex;
  66053. private _sourceBuffer;
  66054. private _targetBuffer;
  66055. private _engine;
  66056. private _currentRenderId;
  66057. private _started;
  66058. private _stopped;
  66059. private _timeDelta;
  66060. private _randomTexture;
  66061. private _randomTexture2;
  66062. private _attributesStrideSize;
  66063. private _updateEffectOptions;
  66064. private _randomTextureSize;
  66065. private _actualFrame;
  66066. private _customEffect;
  66067. private readonly _rawTextureWidth;
  66068. /**
  66069. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66070. */
  66071. static get IsSupported(): boolean;
  66072. /**
  66073. * An event triggered when the system is disposed.
  66074. */
  66075. onDisposeObservable: Observable<IParticleSystem>;
  66076. /**
  66077. * Gets the maximum number of particles active at the same time.
  66078. * @returns The max number of active particles.
  66079. */
  66080. getCapacity(): number;
  66081. /**
  66082. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66083. * to override the particles.
  66084. */
  66085. forceDepthWrite: boolean;
  66086. /**
  66087. * Gets or set the number of active particles
  66088. */
  66089. get activeParticleCount(): number;
  66090. set activeParticleCount(value: number);
  66091. private _preWarmDone;
  66092. /**
  66093. * Specifies if the particles are updated in emitter local space or world space.
  66094. */
  66095. isLocal: boolean;
  66096. /**
  66097. * Is this system ready to be used/rendered
  66098. * @return true if the system is ready
  66099. */
  66100. isReady(): boolean;
  66101. /**
  66102. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66103. * @returns True if it has been started, otherwise false.
  66104. */
  66105. isStarted(): boolean;
  66106. /**
  66107. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66108. * @returns True if it has been stopped, otherwise false.
  66109. */
  66110. isStopped(): boolean;
  66111. /**
  66112. * Gets a boolean indicating that the system is stopping
  66113. * @returns true if the system is currently stopping
  66114. */
  66115. isStopping(): boolean;
  66116. /**
  66117. * Gets the number of particles active at the same time.
  66118. * @returns The number of active particles.
  66119. */
  66120. getActiveCount(): number;
  66121. /**
  66122. * Starts the particle system and begins to emit
  66123. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66124. */
  66125. start(delay?: number): void;
  66126. /**
  66127. * Stops the particle system.
  66128. */
  66129. stop(): void;
  66130. /**
  66131. * Remove all active particles
  66132. */
  66133. reset(): void;
  66134. /**
  66135. * Returns the string "GPUParticleSystem"
  66136. * @returns a string containing the class name
  66137. */
  66138. getClassName(): string;
  66139. /**
  66140. * Gets the custom effect used to render the particles
  66141. * @param blendMode Blend mode for which the effect should be retrieved
  66142. * @returns The effect
  66143. */
  66144. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66145. /**
  66146. * Sets the custom effect used to render the particles
  66147. * @param effect The effect to set
  66148. * @param blendMode Blend mode for which the effect should be set
  66149. */
  66150. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66151. /** @hidden */
  66152. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66153. /**
  66154. * Observable that will be called just before the particles are drawn
  66155. */
  66156. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66157. /**
  66158. * Gets the name of the particle vertex shader
  66159. */
  66160. get vertexShaderName(): string;
  66161. private _colorGradientsTexture;
  66162. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66163. /**
  66164. * Adds a new color gradient
  66165. * @param gradient defines the gradient to use (between 0 and 1)
  66166. * @param color1 defines the color to affect to the specified gradient
  66167. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66168. * @returns the current particle system
  66169. */
  66170. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66171. private _refreshColorGradient;
  66172. /** Force the system to rebuild all gradients that need to be resync */
  66173. forceRefreshGradients(): void;
  66174. /**
  66175. * Remove a specific color gradient
  66176. * @param gradient defines the gradient to remove
  66177. * @returns the current particle system
  66178. */
  66179. removeColorGradient(gradient: number): GPUParticleSystem;
  66180. private _angularSpeedGradientsTexture;
  66181. private _sizeGradientsTexture;
  66182. private _velocityGradientsTexture;
  66183. private _limitVelocityGradientsTexture;
  66184. private _dragGradientsTexture;
  66185. private _addFactorGradient;
  66186. /**
  66187. * Adds a new size gradient
  66188. * @param gradient defines the gradient to use (between 0 and 1)
  66189. * @param factor defines the size factor to affect to the specified gradient
  66190. * @returns the current particle system
  66191. */
  66192. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66193. /**
  66194. * Remove a specific size gradient
  66195. * @param gradient defines the gradient to remove
  66196. * @returns the current particle system
  66197. */
  66198. removeSizeGradient(gradient: number): GPUParticleSystem;
  66199. private _refreshFactorGradient;
  66200. /**
  66201. * Adds a new angular speed gradient
  66202. * @param gradient defines the gradient to use (between 0 and 1)
  66203. * @param factor defines the angular speed to affect to the specified gradient
  66204. * @returns the current particle system
  66205. */
  66206. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66207. /**
  66208. * Remove a specific angular speed gradient
  66209. * @param gradient defines the gradient to remove
  66210. * @returns the current particle system
  66211. */
  66212. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66213. /**
  66214. * Adds a new velocity gradient
  66215. * @param gradient defines the gradient to use (between 0 and 1)
  66216. * @param factor defines the velocity to affect to the specified gradient
  66217. * @returns the current particle system
  66218. */
  66219. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66220. /**
  66221. * Remove a specific velocity gradient
  66222. * @param gradient defines the gradient to remove
  66223. * @returns the current particle system
  66224. */
  66225. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66226. /**
  66227. * Adds a new limit velocity gradient
  66228. * @param gradient defines the gradient to use (between 0 and 1)
  66229. * @param factor defines the limit velocity value to affect to the specified gradient
  66230. * @returns the current particle system
  66231. */
  66232. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66233. /**
  66234. * Remove a specific limit velocity gradient
  66235. * @param gradient defines the gradient to remove
  66236. * @returns the current particle system
  66237. */
  66238. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66239. /**
  66240. * Adds a new drag gradient
  66241. * @param gradient defines the gradient to use (between 0 and 1)
  66242. * @param factor defines the drag value to affect to the specified gradient
  66243. * @returns the current particle system
  66244. */
  66245. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66246. /**
  66247. * Remove a specific drag gradient
  66248. * @param gradient defines the gradient to remove
  66249. * @returns the current particle system
  66250. */
  66251. removeDragGradient(gradient: number): GPUParticleSystem;
  66252. /**
  66253. * Not supported by GPUParticleSystem
  66254. * @param gradient defines the gradient to use (between 0 and 1)
  66255. * @param factor defines the emit rate value to affect to the specified gradient
  66256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66257. * @returns the current particle system
  66258. */
  66259. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66260. /**
  66261. * Not supported by GPUParticleSystem
  66262. * @param gradient defines the gradient to remove
  66263. * @returns the current particle system
  66264. */
  66265. removeEmitRateGradient(gradient: number): IParticleSystem;
  66266. /**
  66267. * Not supported by GPUParticleSystem
  66268. * @param gradient defines the gradient to use (between 0 and 1)
  66269. * @param factor defines the start size value to affect to the specified gradient
  66270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66271. * @returns the current particle system
  66272. */
  66273. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66274. /**
  66275. * Not supported by GPUParticleSystem
  66276. * @param gradient defines the gradient to remove
  66277. * @returns the current particle system
  66278. */
  66279. removeStartSizeGradient(gradient: number): IParticleSystem;
  66280. /**
  66281. * Not supported by GPUParticleSystem
  66282. * @param gradient defines the gradient to use (between 0 and 1)
  66283. * @param min defines the color remap minimal range
  66284. * @param max defines the color remap maximal range
  66285. * @returns the current particle system
  66286. */
  66287. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66288. /**
  66289. * Not supported by GPUParticleSystem
  66290. * @param gradient defines the gradient to remove
  66291. * @returns the current particle system
  66292. */
  66293. removeColorRemapGradient(): IParticleSystem;
  66294. /**
  66295. * Not supported by GPUParticleSystem
  66296. * @param gradient defines the gradient to use (between 0 and 1)
  66297. * @param min defines the alpha remap minimal range
  66298. * @param max defines the alpha remap maximal range
  66299. * @returns the current particle system
  66300. */
  66301. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66302. /**
  66303. * Not supported by GPUParticleSystem
  66304. * @param gradient defines the gradient to remove
  66305. * @returns the current particle system
  66306. */
  66307. removeAlphaRemapGradient(): IParticleSystem;
  66308. /**
  66309. * Not supported by GPUParticleSystem
  66310. * @param gradient defines the gradient to use (between 0 and 1)
  66311. * @param color defines the color to affect to the specified gradient
  66312. * @returns the current particle system
  66313. */
  66314. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66315. /**
  66316. * Not supported by GPUParticleSystem
  66317. * @param gradient defines the gradient to remove
  66318. * @returns the current particle system
  66319. */
  66320. removeRampGradient(): IParticleSystem;
  66321. /**
  66322. * Not supported by GPUParticleSystem
  66323. * @returns the list of ramp gradients
  66324. */
  66325. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66326. /**
  66327. * Not supported by GPUParticleSystem
  66328. * Gets or sets a boolean indicating that ramp gradients must be used
  66329. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66330. */
  66331. get useRampGradients(): boolean;
  66332. set useRampGradients(value: boolean);
  66333. /**
  66334. * Not supported by GPUParticleSystem
  66335. * @param gradient defines the gradient to use (between 0 and 1)
  66336. * @param factor defines the life time factor to affect to the specified gradient
  66337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66338. * @returns the current particle system
  66339. */
  66340. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66341. /**
  66342. * Not supported by GPUParticleSystem
  66343. * @param gradient defines the gradient to remove
  66344. * @returns the current particle system
  66345. */
  66346. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66347. /**
  66348. * Instantiates a GPU particle system.
  66349. * 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.
  66350. * @param name The name of the particle system
  66351. * @param options The options used to create the system
  66352. * @param scene The scene the particle system belongs to
  66353. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66354. * @param customEffect a custom effect used to change the way particles are rendered by default
  66355. */
  66356. constructor(name: string, options: Partial<{
  66357. capacity: number;
  66358. randomTextureSize: number;
  66359. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66360. protected _reset(): void;
  66361. private _createUpdateVAO;
  66362. private _createRenderVAO;
  66363. private _initialize;
  66364. /** @hidden */
  66365. _recreateUpdateEffect(): void;
  66366. private _getEffect;
  66367. /**
  66368. * Fill the defines array according to the current settings of the particle system
  66369. * @param defines Array to be updated
  66370. * @param blendMode blend mode to take into account when updating the array
  66371. */
  66372. fillDefines(defines: Array<string>, blendMode?: number): void;
  66373. /**
  66374. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66375. * @param uniforms Uniforms array to fill
  66376. * @param attributes Attributes array to fill
  66377. * @param samplers Samplers array to fill
  66378. */
  66379. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66380. /** @hidden */
  66381. _recreateRenderEffect(): Effect;
  66382. /**
  66383. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66384. * @param preWarm defines if we are in the pre-warmimg phase
  66385. */
  66386. animate(preWarm?: boolean): void;
  66387. private _createFactorGradientTexture;
  66388. private _createSizeGradientTexture;
  66389. private _createAngularSpeedGradientTexture;
  66390. private _createVelocityGradientTexture;
  66391. private _createLimitVelocityGradientTexture;
  66392. private _createDragGradientTexture;
  66393. private _createColorGradientTexture;
  66394. /**
  66395. * Renders the particle system in its current state
  66396. * @param preWarm defines if the system should only update the particles but not render them
  66397. * @returns the current number of particles
  66398. */
  66399. render(preWarm?: boolean): number;
  66400. /**
  66401. * Rebuilds the particle system
  66402. */
  66403. rebuild(): void;
  66404. private _releaseBuffers;
  66405. private _releaseVAOs;
  66406. /**
  66407. * Disposes the particle system and free the associated resources
  66408. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66409. */
  66410. dispose(disposeTexture?: boolean): void;
  66411. /**
  66412. * Clones the particle system.
  66413. * @param name The name of the cloned object
  66414. * @param newEmitter The new emitter to use
  66415. * @returns the cloned particle system
  66416. */
  66417. clone(name: string, newEmitter: any): GPUParticleSystem;
  66418. /**
  66419. * Serializes the particle system to a JSON object
  66420. * @param serializeTexture defines if the texture must be serialized as well
  66421. * @returns the JSON object
  66422. */
  66423. serialize(serializeTexture?: boolean): any;
  66424. /**
  66425. * Parses a JSON object to create a GPU particle system.
  66426. * @param parsedParticleSystem The JSON object to parse
  66427. * @param scene The scene to create the particle system in
  66428. * @param rootUrl The root url to use to load external dependencies like texture
  66429. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66430. * @returns the parsed GPU particle system
  66431. */
  66432. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66433. }
  66434. }
  66435. declare module BABYLON {
  66436. /**
  66437. * Represents a set of particle systems working together to create a specific effect
  66438. */
  66439. export class ParticleSystemSet implements IDisposable {
  66440. /**
  66441. * Gets or sets base Assets URL
  66442. */
  66443. static BaseAssetsUrl: string;
  66444. private _emitterCreationOptions;
  66445. private _emitterNode;
  66446. /**
  66447. * Gets the particle system list
  66448. */
  66449. systems: IParticleSystem[];
  66450. /**
  66451. * Gets the emitter node used with this set
  66452. */
  66453. get emitterNode(): Nullable<TransformNode>;
  66454. /**
  66455. * Creates a new emitter mesh as a sphere
  66456. * @param options defines the options used to create the sphere
  66457. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66458. * @param scene defines the hosting scene
  66459. */
  66460. setEmitterAsSphere(options: {
  66461. diameter: number;
  66462. segments: number;
  66463. color: Color3;
  66464. }, renderingGroupId: number, scene: Scene): void;
  66465. /**
  66466. * Starts all particle systems of the set
  66467. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66468. */
  66469. start(emitter?: AbstractMesh): void;
  66470. /**
  66471. * Release all associated resources
  66472. */
  66473. dispose(): void;
  66474. /**
  66475. * Serialize the set into a JSON compatible object
  66476. * @param serializeTexture defines if the texture must be serialized as well
  66477. * @returns a JSON compatible representation of the set
  66478. */
  66479. serialize(serializeTexture?: boolean): any;
  66480. /**
  66481. * Parse a new ParticleSystemSet from a serialized source
  66482. * @param data defines a JSON compatible representation of the set
  66483. * @param scene defines the hosting scene
  66484. * @param gpu defines if we want GPU particles or CPU particles
  66485. * @returns a new ParticleSystemSet
  66486. */
  66487. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66488. }
  66489. }
  66490. declare module BABYLON {
  66491. /**
  66492. * This class is made for on one-liner static method to help creating particle system set.
  66493. */
  66494. export class ParticleHelper {
  66495. /**
  66496. * Gets or sets base Assets URL
  66497. */
  66498. static BaseAssetsUrl: string;
  66499. /** Define the Url to load snippets */
  66500. static SnippetUrl: string;
  66501. /**
  66502. * Create a default particle system that you can tweak
  66503. * @param emitter defines the emitter to use
  66504. * @param capacity defines the system capacity (default is 500 particles)
  66505. * @param scene defines the hosting scene
  66506. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66507. * @returns the new Particle system
  66508. */
  66509. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66510. /**
  66511. * This is the main static method (one-liner) of this helper to create different particle systems
  66512. * @param type This string represents the type to the particle system to create
  66513. * @param scene The scene where the particle system should live
  66514. * @param gpu If the system will use gpu
  66515. * @returns the ParticleSystemSet created
  66516. */
  66517. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66518. /**
  66519. * Static function used to export a particle system to a ParticleSystemSet variable.
  66520. * Please note that the emitter shape is not exported
  66521. * @param systems defines the particle systems to export
  66522. * @returns the created particle system set
  66523. */
  66524. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66525. /**
  66526. * Creates a particle system from a snippet saved in a remote file
  66527. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66528. * @param url defines the url to load from
  66529. * @param scene defines the hosting scene
  66530. * @param gpu If the system will use gpu
  66531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66532. * @returns a promise that will resolve to the new particle system
  66533. */
  66534. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66535. /**
  66536. * Creates a particle system from a snippet saved by the particle system editor
  66537. * @param snippetId defines the snippet to load
  66538. * @param scene defines the hosting scene
  66539. * @param gpu If the system will use gpu
  66540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66541. * @returns a promise that will resolve to the new particle system
  66542. */
  66543. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66544. }
  66545. }
  66546. declare module BABYLON {
  66547. interface Engine {
  66548. /**
  66549. * Create an effect to use with particle systems.
  66550. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66551. * the particle system for which you want to create a custom effect in the last parameter
  66552. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66553. * @param uniformsNames defines a list of attribute names
  66554. * @param samplers defines an array of string used to represent textures
  66555. * @param defines defines the string containing the defines to use to compile the shaders
  66556. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66557. * @param onCompiled defines a function to call when the effect creation is successful
  66558. * @param onError defines a function to call when the effect creation has failed
  66559. * @param particleSystem the particle system you want to create the effect for
  66560. * @returns the new Effect
  66561. */
  66562. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66563. }
  66564. interface Mesh {
  66565. /**
  66566. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66567. * @returns an array of IParticleSystem
  66568. */
  66569. getEmittedParticleSystems(): IParticleSystem[];
  66570. /**
  66571. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66572. * @returns an array of IParticleSystem
  66573. */
  66574. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66575. }
  66576. }
  66577. declare module BABYLON {
  66578. /** Defines the 4 color options */
  66579. export enum PointColor {
  66580. /** color value */
  66581. Color = 2,
  66582. /** uv value */
  66583. UV = 1,
  66584. /** random value */
  66585. Random = 0,
  66586. /** stated value */
  66587. Stated = 3
  66588. }
  66589. /**
  66590. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66591. * 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.
  66592. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66593. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66594. *
  66595. * Full documentation here : TO BE ENTERED
  66596. */
  66597. export class PointsCloudSystem implements IDisposable {
  66598. /**
  66599. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66600. * Example : var p = SPS.particles[i];
  66601. */
  66602. particles: CloudPoint[];
  66603. /**
  66604. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66605. */
  66606. nbParticles: number;
  66607. /**
  66608. * This a counter for your own usage. It's not set by any SPS functions.
  66609. */
  66610. counter: number;
  66611. /**
  66612. * The PCS name. This name is also given to the underlying mesh.
  66613. */
  66614. name: string;
  66615. /**
  66616. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66617. */
  66618. mesh: Mesh;
  66619. /**
  66620. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66621. * Please read :
  66622. */
  66623. vars: any;
  66624. /**
  66625. * @hidden
  66626. */
  66627. _size: number;
  66628. private _scene;
  66629. private _promises;
  66630. private _positions;
  66631. private _indices;
  66632. private _normals;
  66633. private _colors;
  66634. private _uvs;
  66635. private _indices32;
  66636. private _positions32;
  66637. private _colors32;
  66638. private _uvs32;
  66639. private _updatable;
  66640. private _isVisibilityBoxLocked;
  66641. private _alwaysVisible;
  66642. private _groups;
  66643. private _groupCounter;
  66644. private _computeParticleColor;
  66645. private _computeParticleTexture;
  66646. private _computeParticleRotation;
  66647. private _computeBoundingBox;
  66648. private _isReady;
  66649. /**
  66650. * Creates a PCS (Points Cloud System) object
  66651. * @param name (String) is the PCS name, this will be the underlying mesh name
  66652. * @param pointSize (number) is the size for each point
  66653. * @param scene (Scene) is the scene in which the PCS is added
  66654. * @param options defines the options of the PCS e.g.
  66655. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66656. */
  66657. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66658. updatable?: boolean;
  66659. });
  66660. /**
  66661. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66662. * If no points were added to the PCS, the returned mesh is just a single point.
  66663. * @returns a promise for the created mesh
  66664. */
  66665. buildMeshAsync(): Promise<Mesh>;
  66666. /**
  66667. * @hidden
  66668. */
  66669. private _buildMesh;
  66670. private _addParticle;
  66671. private _randomUnitVector;
  66672. private _getColorIndicesForCoord;
  66673. private _setPointsColorOrUV;
  66674. private _colorFromTexture;
  66675. private _calculateDensity;
  66676. /**
  66677. * Adds points to the PCS in random positions within a unit sphere
  66678. * @param nb (positive integer) the number of particles to be created from this model
  66679. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66680. * @returns the number of groups in the system
  66681. */
  66682. addPoints(nb: number, pointFunction?: any): number;
  66683. /**
  66684. * Adds points to the PCS from the surface of the model shape
  66685. * @param mesh is any Mesh object that will be used as a surface model for the points
  66686. * @param nb (positive integer) the number of particles to be created from this model
  66687. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66688. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66689. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66690. * @returns the number of groups in the system
  66691. */
  66692. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66693. /**
  66694. * Adds points to the PCS inside the model shape
  66695. * @param mesh is any Mesh object that will be used as a surface model for the points
  66696. * @param nb (positive integer) the number of particles to be created from this model
  66697. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66698. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66699. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66700. * @returns the number of groups in the system
  66701. */
  66702. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66703. /**
  66704. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66705. * This method calls `updateParticle()` for each particle of the SPS.
  66706. * For an animated SPS, it is usually called within the render loop.
  66707. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66708. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66709. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66710. * @returns the PCS.
  66711. */
  66712. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66713. /**
  66714. * Disposes the PCS.
  66715. */
  66716. dispose(): void;
  66717. /**
  66718. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66719. * doc :
  66720. * @returns the PCS.
  66721. */
  66722. refreshVisibleSize(): PointsCloudSystem;
  66723. /**
  66724. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66725. * @param size the size (float) of the visibility box
  66726. * note : this doesn't lock the PCS mesh bounding box.
  66727. * doc :
  66728. */
  66729. setVisibilityBox(size: number): void;
  66730. /**
  66731. * Gets whether the PCS is always visible or not
  66732. * doc :
  66733. */
  66734. get isAlwaysVisible(): boolean;
  66735. /**
  66736. * Sets the PCS as always visible or not
  66737. * doc :
  66738. */
  66739. set isAlwaysVisible(val: boolean);
  66740. /**
  66741. * Tells to `setParticles()` to compute the particle rotations or not
  66742. * Default value : false. The PCS is faster when it's set to false
  66743. * Note : particle rotations are only applied to parent particles
  66744. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66745. */
  66746. set computeParticleRotation(val: boolean);
  66747. /**
  66748. * Tells to `setParticles()` to compute the particle colors or not.
  66749. * Default value : true. The PCS is faster when it's set to false.
  66750. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66751. */
  66752. set computeParticleColor(val: boolean);
  66753. set computeParticleTexture(val: boolean);
  66754. /**
  66755. * Gets if `setParticles()` computes the particle colors or not.
  66756. * Default value : false. The PCS is faster when it's set to false.
  66757. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66758. */
  66759. get computeParticleColor(): boolean;
  66760. /**
  66761. * Gets if `setParticles()` computes the particle textures or not.
  66762. * Default value : false. The PCS is faster when it's set to false.
  66763. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66764. */
  66765. get computeParticleTexture(): boolean;
  66766. /**
  66767. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66768. */
  66769. set computeBoundingBox(val: boolean);
  66770. /**
  66771. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66772. */
  66773. get computeBoundingBox(): boolean;
  66774. /**
  66775. * This function does nothing. It may be overwritten to set all the particle first values.
  66776. * The PCS doesn't call this function, you may have to call it by your own.
  66777. * doc :
  66778. */
  66779. initParticles(): void;
  66780. /**
  66781. * This function does nothing. It may be overwritten to recycle a particle
  66782. * The PCS doesn't call this function, you can to call it
  66783. * doc :
  66784. * @param particle The particle to recycle
  66785. * @returns the recycled particle
  66786. */
  66787. recycleParticle(particle: CloudPoint): CloudPoint;
  66788. /**
  66789. * Updates a particle : this function should be overwritten by the user.
  66790. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66791. * doc :
  66792. * @example : just set a particle position or velocity and recycle conditions
  66793. * @param particle The particle to update
  66794. * @returns the updated particle
  66795. */
  66796. updateParticle(particle: CloudPoint): CloudPoint;
  66797. /**
  66798. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66799. * This does nothing and may be overwritten by the user.
  66800. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66801. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66802. * @param update the boolean update value actually passed to setParticles()
  66803. */
  66804. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66805. /**
  66806. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66807. * This will be passed three parameters.
  66808. * This does nothing and may be overwritten by the user.
  66809. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66810. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66811. * @param update the boolean update value actually passed to setParticles()
  66812. */
  66813. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66814. }
  66815. }
  66816. declare module BABYLON {
  66817. /**
  66818. * Represents one particle of a points cloud system.
  66819. */
  66820. export class CloudPoint {
  66821. /**
  66822. * particle global index
  66823. */
  66824. idx: number;
  66825. /**
  66826. * The color of the particle
  66827. */
  66828. color: Nullable<Color4>;
  66829. /**
  66830. * The world space position of the particle.
  66831. */
  66832. position: Vector3;
  66833. /**
  66834. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66835. */
  66836. rotation: Vector3;
  66837. /**
  66838. * The world space rotation quaternion of the particle.
  66839. */
  66840. rotationQuaternion: Nullable<Quaternion>;
  66841. /**
  66842. * The uv of the particle.
  66843. */
  66844. uv: Nullable<Vector2>;
  66845. /**
  66846. * The current speed of the particle.
  66847. */
  66848. velocity: Vector3;
  66849. /**
  66850. * The pivot point in the particle local space.
  66851. */
  66852. pivot: Vector3;
  66853. /**
  66854. * Must the particle be translated from its pivot point in its local space ?
  66855. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66856. * Default : false
  66857. */
  66858. translateFromPivot: boolean;
  66859. /**
  66860. * Index of this particle in the global "positions" array (Internal use)
  66861. * @hidden
  66862. */
  66863. _pos: number;
  66864. /**
  66865. * @hidden Index of this particle in the global "indices" array (Internal use)
  66866. */
  66867. _ind: number;
  66868. /**
  66869. * Group this particle belongs to
  66870. */
  66871. _group: PointsGroup;
  66872. /**
  66873. * Group id of this particle
  66874. */
  66875. groupId: number;
  66876. /**
  66877. * Index of the particle in its group id (Internal use)
  66878. */
  66879. idxInGroup: number;
  66880. /**
  66881. * @hidden Particle BoundingInfo object (Internal use)
  66882. */
  66883. _boundingInfo: BoundingInfo;
  66884. /**
  66885. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66886. */
  66887. _pcs: PointsCloudSystem;
  66888. /**
  66889. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66890. */
  66891. _stillInvisible: boolean;
  66892. /**
  66893. * @hidden Last computed particle rotation matrix
  66894. */
  66895. _rotationMatrix: number[];
  66896. /**
  66897. * Parent particle Id, if any.
  66898. * Default null.
  66899. */
  66900. parentId: Nullable<number>;
  66901. /**
  66902. * @hidden Internal global position in the PCS.
  66903. */
  66904. _globalPosition: Vector3;
  66905. /**
  66906. * Creates a Point Cloud object.
  66907. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66908. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66909. * @param group (PointsGroup) is the group the particle belongs to
  66910. * @param groupId (integer) is the group identifier in the PCS.
  66911. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66912. * @param pcs defines the PCS it is associated to
  66913. */
  66914. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66915. /**
  66916. * get point size
  66917. */
  66918. get size(): Vector3;
  66919. /**
  66920. * Set point size
  66921. */
  66922. set size(scale: Vector3);
  66923. /**
  66924. * Legacy support, changed quaternion to rotationQuaternion
  66925. */
  66926. get quaternion(): Nullable<Quaternion>;
  66927. /**
  66928. * Legacy support, changed quaternion to rotationQuaternion
  66929. */
  66930. set quaternion(q: Nullable<Quaternion>);
  66931. /**
  66932. * Returns a boolean. True if the particle intersects a mesh, else false
  66933. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66934. * @param target is the object (point or mesh) what the intersection is computed against
  66935. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66936. * @returns true if it intersects
  66937. */
  66938. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66939. /**
  66940. * get the rotation matrix of the particle
  66941. * @hidden
  66942. */
  66943. getRotationMatrix(m: Matrix): void;
  66944. }
  66945. /**
  66946. * Represents a group of points in a points cloud system
  66947. * * PCS internal tool, don't use it manually.
  66948. */
  66949. export class PointsGroup {
  66950. /**
  66951. * The group id
  66952. * @hidden
  66953. */
  66954. groupID: number;
  66955. /**
  66956. * image data for group (internal use)
  66957. * @hidden
  66958. */
  66959. _groupImageData: Nullable<ArrayBufferView>;
  66960. /**
  66961. * Image Width (internal use)
  66962. * @hidden
  66963. */
  66964. _groupImgWidth: number;
  66965. /**
  66966. * Image Height (internal use)
  66967. * @hidden
  66968. */
  66969. _groupImgHeight: number;
  66970. /**
  66971. * Custom position function (internal use)
  66972. * @hidden
  66973. */
  66974. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66975. /**
  66976. * density per facet for surface points
  66977. * @hidden
  66978. */
  66979. _groupDensity: number[];
  66980. /**
  66981. * Only when points are colored by texture carries pointer to texture list array
  66982. * @hidden
  66983. */
  66984. _textureNb: number;
  66985. /**
  66986. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66987. * PCS internal tool, don't use it manually.
  66988. * @hidden
  66989. */
  66990. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66991. }
  66992. }
  66993. declare module BABYLON {
  66994. interface Scene {
  66995. /** @hidden (Backing field) */
  66996. _physicsEngine: Nullable<IPhysicsEngine>;
  66997. /** @hidden */
  66998. _physicsTimeAccumulator: number;
  66999. /**
  67000. * Gets the current physics engine
  67001. * @returns a IPhysicsEngine or null if none attached
  67002. */
  67003. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67004. /**
  67005. * Enables physics to the current scene
  67006. * @param gravity defines the scene's gravity for the physics engine
  67007. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67008. * @return a boolean indicating if the physics engine was initialized
  67009. */
  67010. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67011. /**
  67012. * Disables and disposes the physics engine associated with the scene
  67013. */
  67014. disablePhysicsEngine(): void;
  67015. /**
  67016. * Gets a boolean indicating if there is an active physics engine
  67017. * @returns a boolean indicating if there is an active physics engine
  67018. */
  67019. isPhysicsEnabled(): boolean;
  67020. /**
  67021. * Deletes a physics compound impostor
  67022. * @param compound defines the compound to delete
  67023. */
  67024. deleteCompoundImpostor(compound: any): void;
  67025. /**
  67026. * An event triggered when physic simulation is about to be run
  67027. */
  67028. onBeforePhysicsObservable: Observable<Scene>;
  67029. /**
  67030. * An event triggered when physic simulation has been done
  67031. */
  67032. onAfterPhysicsObservable: Observable<Scene>;
  67033. }
  67034. interface AbstractMesh {
  67035. /** @hidden */
  67036. _physicsImpostor: Nullable<PhysicsImpostor>;
  67037. /**
  67038. * Gets or sets impostor used for physic simulation
  67039. * @see http://doc.babylonjs.com/features/physics_engine
  67040. */
  67041. physicsImpostor: Nullable<PhysicsImpostor>;
  67042. /**
  67043. * Gets the current physics impostor
  67044. * @see http://doc.babylonjs.com/features/physics_engine
  67045. * @returns a physics impostor or null
  67046. */
  67047. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67048. /** Apply a physic impulse to the mesh
  67049. * @param force defines the force to apply
  67050. * @param contactPoint defines where to apply the force
  67051. * @returns the current mesh
  67052. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67053. */
  67054. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67055. /**
  67056. * Creates a physic joint between two meshes
  67057. * @param otherMesh defines the other mesh to use
  67058. * @param pivot1 defines the pivot to use on this mesh
  67059. * @param pivot2 defines the pivot to use on the other mesh
  67060. * @param options defines additional options (can be plugin dependent)
  67061. * @returns the current mesh
  67062. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67063. */
  67064. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67065. /** @hidden */
  67066. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67067. }
  67068. /**
  67069. * Defines the physics engine scene component responsible to manage a physics engine
  67070. */
  67071. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67072. /**
  67073. * The component name helpful to identify the component in the list of scene components.
  67074. */
  67075. readonly name: string;
  67076. /**
  67077. * The scene the component belongs to.
  67078. */
  67079. scene: Scene;
  67080. /**
  67081. * Creates a new instance of the component for the given scene
  67082. * @param scene Defines the scene to register the component in
  67083. */
  67084. constructor(scene: Scene);
  67085. /**
  67086. * Registers the component in a given scene
  67087. */
  67088. register(): void;
  67089. /**
  67090. * Rebuilds the elements related to this component in case of
  67091. * context lost for instance.
  67092. */
  67093. rebuild(): void;
  67094. /**
  67095. * Disposes the component and the associated ressources
  67096. */
  67097. dispose(): void;
  67098. }
  67099. }
  67100. declare module BABYLON {
  67101. /**
  67102. * A helper for physics simulations
  67103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67104. */
  67105. export class PhysicsHelper {
  67106. private _scene;
  67107. private _physicsEngine;
  67108. /**
  67109. * Initializes the Physics helper
  67110. * @param scene Babylon.js scene
  67111. */
  67112. constructor(scene: Scene);
  67113. /**
  67114. * Applies a radial explosion impulse
  67115. * @param origin the origin of the explosion
  67116. * @param radiusOrEventOptions the radius or the options of radial explosion
  67117. * @param strength the explosion strength
  67118. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67119. * @returns A physics radial explosion event, or null
  67120. */
  67121. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67122. /**
  67123. * Applies a radial explosion force
  67124. * @param origin the origin of the explosion
  67125. * @param radiusOrEventOptions the radius or the options of radial explosion
  67126. * @param strength the explosion strength
  67127. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67128. * @returns A physics radial explosion event, or null
  67129. */
  67130. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67131. /**
  67132. * Creates a gravitational field
  67133. * @param origin the origin of the explosion
  67134. * @param radiusOrEventOptions the radius or the options of radial explosion
  67135. * @param strength the explosion strength
  67136. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67137. * @returns A physics gravitational field event, or null
  67138. */
  67139. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67140. /**
  67141. * Creates a physics updraft event
  67142. * @param origin the origin of the updraft
  67143. * @param radiusOrEventOptions the radius or the options of the updraft
  67144. * @param strength the strength of the updraft
  67145. * @param height the height of the updraft
  67146. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67147. * @returns A physics updraft event, or null
  67148. */
  67149. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67150. /**
  67151. * Creates a physics vortex event
  67152. * @param origin the of the vortex
  67153. * @param radiusOrEventOptions the radius or the options of the vortex
  67154. * @param strength the strength of the vortex
  67155. * @param height the height of the vortex
  67156. * @returns a Physics vortex event, or null
  67157. * A physics vortex event or null
  67158. */
  67159. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67160. }
  67161. /**
  67162. * Represents a physics radial explosion event
  67163. */
  67164. class PhysicsRadialExplosionEvent {
  67165. private _scene;
  67166. private _options;
  67167. private _sphere;
  67168. private _dataFetched;
  67169. /**
  67170. * Initializes a radial explosioin event
  67171. * @param _scene BabylonJS scene
  67172. * @param _options The options for the vortex event
  67173. */
  67174. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67175. /**
  67176. * Returns the data related to the radial explosion event (sphere).
  67177. * @returns The radial explosion event data
  67178. */
  67179. getData(): PhysicsRadialExplosionEventData;
  67180. /**
  67181. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67182. * @param impostor A physics imposter
  67183. * @param origin the origin of the explosion
  67184. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67185. */
  67186. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67187. /**
  67188. * Triggers affecterd impostors callbacks
  67189. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67190. */
  67191. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67192. /**
  67193. * Disposes the sphere.
  67194. * @param force Specifies if the sphere should be disposed by force
  67195. */
  67196. dispose(force?: boolean): void;
  67197. /*** Helpers ***/
  67198. private _prepareSphere;
  67199. private _intersectsWithSphere;
  67200. }
  67201. /**
  67202. * Represents a gravitational field event
  67203. */
  67204. class PhysicsGravitationalFieldEvent {
  67205. private _physicsHelper;
  67206. private _scene;
  67207. private _origin;
  67208. private _options;
  67209. private _tickCallback;
  67210. private _sphere;
  67211. private _dataFetched;
  67212. /**
  67213. * Initializes the physics gravitational field event
  67214. * @param _physicsHelper A physics helper
  67215. * @param _scene BabylonJS scene
  67216. * @param _origin The origin position of the gravitational field event
  67217. * @param _options The options for the vortex event
  67218. */
  67219. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67220. /**
  67221. * Returns the data related to the gravitational field event (sphere).
  67222. * @returns A gravitational field event
  67223. */
  67224. getData(): PhysicsGravitationalFieldEventData;
  67225. /**
  67226. * Enables the gravitational field.
  67227. */
  67228. enable(): void;
  67229. /**
  67230. * Disables the gravitational field.
  67231. */
  67232. disable(): void;
  67233. /**
  67234. * Disposes the sphere.
  67235. * @param force The force to dispose from the gravitational field event
  67236. */
  67237. dispose(force?: boolean): void;
  67238. private _tick;
  67239. }
  67240. /**
  67241. * Represents a physics updraft event
  67242. */
  67243. class PhysicsUpdraftEvent {
  67244. private _scene;
  67245. private _origin;
  67246. private _options;
  67247. private _physicsEngine;
  67248. private _originTop;
  67249. private _originDirection;
  67250. private _tickCallback;
  67251. private _cylinder;
  67252. private _cylinderPosition;
  67253. private _dataFetched;
  67254. /**
  67255. * Initializes the physics updraft event
  67256. * @param _scene BabylonJS scene
  67257. * @param _origin The origin position of the updraft
  67258. * @param _options The options for the updraft event
  67259. */
  67260. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67261. /**
  67262. * Returns the data related to the updraft event (cylinder).
  67263. * @returns A physics updraft event
  67264. */
  67265. getData(): PhysicsUpdraftEventData;
  67266. /**
  67267. * Enables the updraft.
  67268. */
  67269. enable(): void;
  67270. /**
  67271. * Disables the updraft.
  67272. */
  67273. disable(): void;
  67274. /**
  67275. * Disposes the cylinder.
  67276. * @param force Specifies if the updraft should be disposed by force
  67277. */
  67278. dispose(force?: boolean): void;
  67279. private getImpostorHitData;
  67280. private _tick;
  67281. /*** Helpers ***/
  67282. private _prepareCylinder;
  67283. private _intersectsWithCylinder;
  67284. }
  67285. /**
  67286. * Represents a physics vortex event
  67287. */
  67288. class PhysicsVortexEvent {
  67289. private _scene;
  67290. private _origin;
  67291. private _options;
  67292. private _physicsEngine;
  67293. private _originTop;
  67294. private _tickCallback;
  67295. private _cylinder;
  67296. private _cylinderPosition;
  67297. private _dataFetched;
  67298. /**
  67299. * Initializes the physics vortex event
  67300. * @param _scene The BabylonJS scene
  67301. * @param _origin The origin position of the vortex
  67302. * @param _options The options for the vortex event
  67303. */
  67304. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67305. /**
  67306. * Returns the data related to the vortex event (cylinder).
  67307. * @returns The physics vortex event data
  67308. */
  67309. getData(): PhysicsVortexEventData;
  67310. /**
  67311. * Enables the vortex.
  67312. */
  67313. enable(): void;
  67314. /**
  67315. * Disables the cortex.
  67316. */
  67317. disable(): void;
  67318. /**
  67319. * Disposes the sphere.
  67320. * @param force
  67321. */
  67322. dispose(force?: boolean): void;
  67323. private getImpostorHitData;
  67324. private _tick;
  67325. /*** Helpers ***/
  67326. private _prepareCylinder;
  67327. private _intersectsWithCylinder;
  67328. }
  67329. /**
  67330. * Options fot the radial explosion event
  67331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67332. */
  67333. export class PhysicsRadialExplosionEventOptions {
  67334. /**
  67335. * The radius of the sphere for the radial explosion.
  67336. */
  67337. radius: number;
  67338. /**
  67339. * The strenth of the explosion.
  67340. */
  67341. strength: number;
  67342. /**
  67343. * The strenght of the force in correspondence to the distance of the affected object
  67344. */
  67345. falloff: PhysicsRadialImpulseFalloff;
  67346. /**
  67347. * Sphere options for the radial explosion.
  67348. */
  67349. sphere: {
  67350. segments: number;
  67351. diameter: number;
  67352. };
  67353. /**
  67354. * Sphere options for the radial explosion.
  67355. */
  67356. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67357. }
  67358. /**
  67359. * Options fot the updraft event
  67360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67361. */
  67362. export class PhysicsUpdraftEventOptions {
  67363. /**
  67364. * The radius of the cylinder for the vortex
  67365. */
  67366. radius: number;
  67367. /**
  67368. * The strenth of the updraft.
  67369. */
  67370. strength: number;
  67371. /**
  67372. * The height of the cylinder for the updraft.
  67373. */
  67374. height: number;
  67375. /**
  67376. * The mode for the the updraft.
  67377. */
  67378. updraftMode: PhysicsUpdraftMode;
  67379. }
  67380. /**
  67381. * Options fot the vortex event
  67382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67383. */
  67384. export class PhysicsVortexEventOptions {
  67385. /**
  67386. * The radius of the cylinder for the vortex
  67387. */
  67388. radius: number;
  67389. /**
  67390. * The strenth of the vortex.
  67391. */
  67392. strength: number;
  67393. /**
  67394. * The height of the cylinder for the vortex.
  67395. */
  67396. height: number;
  67397. /**
  67398. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67399. */
  67400. centripetalForceThreshold: number;
  67401. /**
  67402. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67403. */
  67404. centripetalForceMultiplier: number;
  67405. /**
  67406. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67407. */
  67408. centrifugalForceMultiplier: number;
  67409. /**
  67410. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67411. */
  67412. updraftForceMultiplier: number;
  67413. }
  67414. /**
  67415. * The strenght of the force in correspondence to the distance of the affected object
  67416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67417. */
  67418. export enum PhysicsRadialImpulseFalloff {
  67419. /** Defines that impulse is constant in strength across it's whole radius */
  67420. Constant = 0,
  67421. /** Defines that impulse gets weaker if it's further from the origin */
  67422. Linear = 1
  67423. }
  67424. /**
  67425. * The strength of the force in correspondence to the distance of the affected object
  67426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67427. */
  67428. export enum PhysicsUpdraftMode {
  67429. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67430. Center = 0,
  67431. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67432. Perpendicular = 1
  67433. }
  67434. /**
  67435. * Interface for a physics hit data
  67436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67437. */
  67438. export interface PhysicsHitData {
  67439. /**
  67440. * The force applied at the contact point
  67441. */
  67442. force: Vector3;
  67443. /**
  67444. * The contact point
  67445. */
  67446. contactPoint: Vector3;
  67447. /**
  67448. * The distance from the origin to the contact point
  67449. */
  67450. distanceFromOrigin: number;
  67451. }
  67452. /**
  67453. * Interface for radial explosion event data
  67454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67455. */
  67456. export interface PhysicsRadialExplosionEventData {
  67457. /**
  67458. * A sphere used for the radial explosion event
  67459. */
  67460. sphere: Mesh;
  67461. }
  67462. /**
  67463. * Interface for gravitational field event data
  67464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67465. */
  67466. export interface PhysicsGravitationalFieldEventData {
  67467. /**
  67468. * A sphere mesh used for the gravitational field event
  67469. */
  67470. sphere: Mesh;
  67471. }
  67472. /**
  67473. * Interface for updraft event data
  67474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67475. */
  67476. export interface PhysicsUpdraftEventData {
  67477. /**
  67478. * A cylinder used for the updraft event
  67479. */
  67480. cylinder: Mesh;
  67481. }
  67482. /**
  67483. * Interface for vortex event data
  67484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67485. */
  67486. export interface PhysicsVortexEventData {
  67487. /**
  67488. * A cylinder used for the vortex event
  67489. */
  67490. cylinder: Mesh;
  67491. }
  67492. /**
  67493. * Interface for an affected physics impostor
  67494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67495. */
  67496. export interface PhysicsAffectedImpostorWithData {
  67497. /**
  67498. * The impostor affected by the effect
  67499. */
  67500. impostor: PhysicsImpostor;
  67501. /**
  67502. * The data about the hit/horce from the explosion
  67503. */
  67504. hitData: PhysicsHitData;
  67505. }
  67506. }
  67507. declare module BABYLON {
  67508. /** @hidden */
  67509. export var blackAndWhitePixelShader: {
  67510. name: string;
  67511. shader: string;
  67512. };
  67513. }
  67514. declare module BABYLON {
  67515. /**
  67516. * Post process used to render in black and white
  67517. */
  67518. export class BlackAndWhitePostProcess extends PostProcess {
  67519. /**
  67520. * Linear about to convert he result to black and white (default: 1)
  67521. */
  67522. degree: number;
  67523. /**
  67524. * Creates a black and white post process
  67525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67526. * @param name The name of the effect.
  67527. * @param options The required width/height ratio to downsize to before computing the render pass.
  67528. * @param camera The camera to apply the render pass to.
  67529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67530. * @param engine The engine which the post process will be applied. (default: current engine)
  67531. * @param reusable If the post process can be reused on the same frame. (default: false)
  67532. */
  67533. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67534. }
  67535. }
  67536. declare module BABYLON {
  67537. /**
  67538. * This represents a set of one or more post processes in Babylon.
  67539. * A post process can be used to apply a shader to a texture after it is rendered.
  67540. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67541. */
  67542. export class PostProcessRenderEffect {
  67543. private _postProcesses;
  67544. private _getPostProcesses;
  67545. private _singleInstance;
  67546. private _cameras;
  67547. private _indicesForCamera;
  67548. /**
  67549. * Name of the effect
  67550. * @hidden
  67551. */
  67552. _name: string;
  67553. /**
  67554. * Instantiates a post process render effect.
  67555. * A post process can be used to apply a shader to a texture after it is rendered.
  67556. * @param engine The engine the effect is tied to
  67557. * @param name The name of the effect
  67558. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67559. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67560. */
  67561. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67562. /**
  67563. * Checks if all the post processes in the effect are supported.
  67564. */
  67565. get isSupported(): boolean;
  67566. /**
  67567. * Updates the current state of the effect
  67568. * @hidden
  67569. */
  67570. _update(): void;
  67571. /**
  67572. * Attaches the effect on cameras
  67573. * @param cameras The camera to attach to.
  67574. * @hidden
  67575. */
  67576. _attachCameras(cameras: Camera): void;
  67577. /**
  67578. * Attaches the effect on cameras
  67579. * @param cameras The camera to attach to.
  67580. * @hidden
  67581. */
  67582. _attachCameras(cameras: Camera[]): void;
  67583. /**
  67584. * Detaches the effect on cameras
  67585. * @param cameras The camera to detatch from.
  67586. * @hidden
  67587. */
  67588. _detachCameras(cameras: Camera): void;
  67589. /**
  67590. * Detatches the effect on cameras
  67591. * @param cameras The camera to detatch from.
  67592. * @hidden
  67593. */
  67594. _detachCameras(cameras: Camera[]): void;
  67595. /**
  67596. * Enables the effect on given cameras
  67597. * @param cameras The camera to enable.
  67598. * @hidden
  67599. */
  67600. _enable(cameras: Camera): void;
  67601. /**
  67602. * Enables the effect on given cameras
  67603. * @param cameras The camera to enable.
  67604. * @hidden
  67605. */
  67606. _enable(cameras: Nullable<Camera[]>): void;
  67607. /**
  67608. * Disables the effect on the given cameras
  67609. * @param cameras The camera to disable.
  67610. * @hidden
  67611. */
  67612. _disable(cameras: Camera): void;
  67613. /**
  67614. * Disables the effect on the given cameras
  67615. * @param cameras The camera to disable.
  67616. * @hidden
  67617. */
  67618. _disable(cameras: Nullable<Camera[]>): void;
  67619. /**
  67620. * Gets a list of the post processes contained in the effect.
  67621. * @param camera The camera to get the post processes on.
  67622. * @returns The list of the post processes in the effect.
  67623. */
  67624. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67625. }
  67626. }
  67627. declare module BABYLON {
  67628. /** @hidden */
  67629. export var extractHighlightsPixelShader: {
  67630. name: string;
  67631. shader: string;
  67632. };
  67633. }
  67634. declare module BABYLON {
  67635. /**
  67636. * 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.
  67637. */
  67638. export class ExtractHighlightsPostProcess extends PostProcess {
  67639. /**
  67640. * The luminance threshold, pixels below this value will be set to black.
  67641. */
  67642. threshold: number;
  67643. /** @hidden */
  67644. _exposure: number;
  67645. /**
  67646. * Post process which has the input texture to be used when performing highlight extraction
  67647. * @hidden
  67648. */
  67649. _inputPostProcess: Nullable<PostProcess>;
  67650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67651. }
  67652. }
  67653. declare module BABYLON {
  67654. /** @hidden */
  67655. export var bloomMergePixelShader: {
  67656. name: string;
  67657. shader: string;
  67658. };
  67659. }
  67660. declare module BABYLON {
  67661. /**
  67662. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67663. */
  67664. export class BloomMergePostProcess extends PostProcess {
  67665. /** Weight of the bloom to be added to the original input. */
  67666. weight: number;
  67667. /**
  67668. * Creates a new instance of @see BloomMergePostProcess
  67669. * @param name The name of the effect.
  67670. * @param originalFromInput Post process which's input will be used for the merge.
  67671. * @param blurred Blurred highlights post process which's output will be used.
  67672. * @param weight Weight of the bloom to be added to the original input.
  67673. * @param options The required width/height ratio to downsize to before computing the render pass.
  67674. * @param camera The camera to apply the render pass to.
  67675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67676. * @param engine The engine which the post process will be applied. (default: current engine)
  67677. * @param reusable If the post process can be reused on the same frame. (default: false)
  67678. * @param textureType Type of textures used when performing the post process. (default: 0)
  67679. * @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)
  67680. */
  67681. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67682. /** Weight of the bloom to be added to the original input. */
  67683. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67684. }
  67685. }
  67686. declare module BABYLON {
  67687. /**
  67688. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67689. */
  67690. export class BloomEffect extends PostProcessRenderEffect {
  67691. private bloomScale;
  67692. /**
  67693. * @hidden Internal
  67694. */
  67695. _effects: Array<PostProcess>;
  67696. /**
  67697. * @hidden Internal
  67698. */
  67699. _downscale: ExtractHighlightsPostProcess;
  67700. private _blurX;
  67701. private _blurY;
  67702. private _merge;
  67703. /**
  67704. * The luminance threshold to find bright areas of the image to bloom.
  67705. */
  67706. get threshold(): number;
  67707. set threshold(value: number);
  67708. /**
  67709. * The strength of the bloom.
  67710. */
  67711. get weight(): number;
  67712. set weight(value: number);
  67713. /**
  67714. * Specifies the size of the bloom blur kernel, relative to the final output size
  67715. */
  67716. get kernel(): number;
  67717. set kernel(value: number);
  67718. /**
  67719. * Creates a new instance of @see BloomEffect
  67720. * @param scene The scene the effect belongs to.
  67721. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67722. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67723. * @param bloomWeight The the strength of bloom.
  67724. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67725. * @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)
  67726. */
  67727. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67728. /**
  67729. * Disposes each of the internal effects for a given camera.
  67730. * @param camera The camera to dispose the effect on.
  67731. */
  67732. disposeEffects(camera: Camera): void;
  67733. /**
  67734. * @hidden Internal
  67735. */
  67736. _updateEffects(): void;
  67737. /**
  67738. * Internal
  67739. * @returns if all the contained post processes are ready.
  67740. * @hidden
  67741. */
  67742. _isReady(): boolean;
  67743. }
  67744. }
  67745. declare module BABYLON {
  67746. /** @hidden */
  67747. export var chromaticAberrationPixelShader: {
  67748. name: string;
  67749. shader: string;
  67750. };
  67751. }
  67752. declare module BABYLON {
  67753. /**
  67754. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67755. */
  67756. export class ChromaticAberrationPostProcess extends PostProcess {
  67757. /**
  67758. * The amount of seperation of rgb channels (default: 30)
  67759. */
  67760. aberrationAmount: number;
  67761. /**
  67762. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67763. */
  67764. radialIntensity: number;
  67765. /**
  67766. * 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))
  67767. */
  67768. direction: Vector2;
  67769. /**
  67770. * 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))
  67771. */
  67772. centerPosition: Vector2;
  67773. /**
  67774. * Creates a new instance ChromaticAberrationPostProcess
  67775. * @param name The name of the effect.
  67776. * @param screenWidth The width of the screen to apply the effect on.
  67777. * @param screenHeight The height of the screen to apply the effect on.
  67778. * @param options The required width/height ratio to downsize to before computing the render pass.
  67779. * @param camera The camera to apply the render pass to.
  67780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67781. * @param engine The engine which the post process will be applied. (default: current engine)
  67782. * @param reusable If the post process can be reused on the same frame. (default: false)
  67783. * @param textureType Type of textures used when performing the post process. (default: 0)
  67784. * @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)
  67785. */
  67786. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67787. }
  67788. }
  67789. declare module BABYLON {
  67790. /** @hidden */
  67791. export var circleOfConfusionPixelShader: {
  67792. name: string;
  67793. shader: string;
  67794. };
  67795. }
  67796. declare module BABYLON {
  67797. /**
  67798. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67799. */
  67800. export class CircleOfConfusionPostProcess extends PostProcess {
  67801. /**
  67802. * 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.
  67803. */
  67804. lensSize: number;
  67805. /**
  67806. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67807. */
  67808. fStop: number;
  67809. /**
  67810. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67811. */
  67812. focusDistance: number;
  67813. /**
  67814. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67815. */
  67816. focalLength: number;
  67817. private _depthTexture;
  67818. /**
  67819. * Creates a new instance CircleOfConfusionPostProcess
  67820. * @param name The name of the effect.
  67821. * @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.
  67822. * @param options The required width/height ratio to downsize to before computing the render pass.
  67823. * @param camera The camera to apply the render pass to.
  67824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67825. * @param engine The engine which the post process will be applied. (default: current engine)
  67826. * @param reusable If the post process can be reused on the same frame. (default: false)
  67827. * @param textureType Type of textures used when performing the post process. (default: 0)
  67828. * @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)
  67829. */
  67830. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67831. /**
  67832. * 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.
  67833. */
  67834. set depthTexture(value: RenderTargetTexture);
  67835. }
  67836. }
  67837. declare module BABYLON {
  67838. /** @hidden */
  67839. export var colorCorrectionPixelShader: {
  67840. name: string;
  67841. shader: string;
  67842. };
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. *
  67847. * This post-process allows the modification of rendered colors by using
  67848. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67849. *
  67850. * The object needs to be provided an url to a texture containing the color
  67851. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67852. * Use an image editing software to tweak the LUT to match your needs.
  67853. *
  67854. * For an example of a color LUT, see here:
  67855. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67856. * For explanations on color grading, see here:
  67857. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67858. *
  67859. */
  67860. export class ColorCorrectionPostProcess extends PostProcess {
  67861. private _colorTableTexture;
  67862. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67863. }
  67864. }
  67865. declare module BABYLON {
  67866. /** @hidden */
  67867. export var convolutionPixelShader: {
  67868. name: string;
  67869. shader: string;
  67870. };
  67871. }
  67872. declare module BABYLON {
  67873. /**
  67874. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67875. * input texture to perform effects such as edge detection or sharpening
  67876. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67877. */
  67878. export class ConvolutionPostProcess extends PostProcess {
  67879. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67880. kernel: number[];
  67881. /**
  67882. * Creates a new instance ConvolutionPostProcess
  67883. * @param name The name of the effect.
  67884. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67885. * @param options The required width/height ratio to downsize to before computing the render pass.
  67886. * @param camera The camera to apply the render pass to.
  67887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67888. * @param engine The engine which the post process will be applied. (default: current engine)
  67889. * @param reusable If the post process can be reused on the same frame. (default: false)
  67890. * @param textureType Type of textures used when performing the post process. (default: 0)
  67891. */
  67892. constructor(name: string,
  67893. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67894. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67895. /**
  67896. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67897. */
  67898. static EdgeDetect0Kernel: number[];
  67899. /**
  67900. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67901. */
  67902. static EdgeDetect1Kernel: number[];
  67903. /**
  67904. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67905. */
  67906. static EdgeDetect2Kernel: number[];
  67907. /**
  67908. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67909. */
  67910. static SharpenKernel: number[];
  67911. /**
  67912. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67913. */
  67914. static EmbossKernel: number[];
  67915. /**
  67916. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67917. */
  67918. static GaussianKernel: number[];
  67919. }
  67920. }
  67921. declare module BABYLON {
  67922. /**
  67923. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67924. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67925. * based on samples that have a large difference in distance than the center pixel.
  67926. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67927. */
  67928. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67929. direction: Vector2;
  67930. /**
  67931. * Creates a new instance CircleOfConfusionPostProcess
  67932. * @param name The name of the effect.
  67933. * @param scene The scene the effect belongs to.
  67934. * @param direction The direction the blur should be applied.
  67935. * @param kernel The size of the kernel used to blur.
  67936. * @param options The required width/height ratio to downsize to before computing the render pass.
  67937. * @param camera The camera to apply the render pass to.
  67938. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67939. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67941. * @param engine The engine which the post process will be applied. (default: current engine)
  67942. * @param reusable If the post process can be reused on the same frame. (default: false)
  67943. * @param textureType Type of textures used when performing the post process. (default: 0)
  67944. * @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)
  67945. */
  67946. 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);
  67947. }
  67948. }
  67949. declare module BABYLON {
  67950. /** @hidden */
  67951. export var depthOfFieldMergePixelShader: {
  67952. name: string;
  67953. shader: string;
  67954. };
  67955. }
  67956. declare module BABYLON {
  67957. /**
  67958. * Options to be set when merging outputs from the default pipeline.
  67959. */
  67960. export class DepthOfFieldMergePostProcessOptions {
  67961. /**
  67962. * The original image to merge on top of
  67963. */
  67964. originalFromInput: PostProcess;
  67965. /**
  67966. * Parameters to perform the merge of the depth of field effect
  67967. */
  67968. depthOfField?: {
  67969. circleOfConfusion: PostProcess;
  67970. blurSteps: Array<PostProcess>;
  67971. };
  67972. /**
  67973. * Parameters to perform the merge of bloom effect
  67974. */
  67975. bloom?: {
  67976. blurred: PostProcess;
  67977. weight: number;
  67978. };
  67979. }
  67980. /**
  67981. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67982. */
  67983. export class DepthOfFieldMergePostProcess extends PostProcess {
  67984. private blurSteps;
  67985. /**
  67986. * Creates a new instance of DepthOfFieldMergePostProcess
  67987. * @param name The name of the effect.
  67988. * @param originalFromInput Post process which's input will be used for the merge.
  67989. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67990. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67991. * @param options The required width/height ratio to downsize to before computing the render pass.
  67992. * @param camera The camera to apply the render pass to.
  67993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67994. * @param engine The engine which the post process will be applied. (default: current engine)
  67995. * @param reusable If the post process can be reused on the same frame. (default: false)
  67996. * @param textureType Type of textures used when performing the post process. (default: 0)
  67997. * @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)
  67998. */
  67999. 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);
  68000. /**
  68001. * Updates the effect with the current post process compile time values and recompiles the shader.
  68002. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68003. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68004. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68005. * @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
  68006. * @param onCompiled Called when the shader has been compiled.
  68007. * @param onError Called if there is an error when compiling a shader.
  68008. */
  68009. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /**
  68014. * Specifies the level of max blur that should be applied when using the depth of field effect
  68015. */
  68016. export enum DepthOfFieldEffectBlurLevel {
  68017. /**
  68018. * Subtle blur
  68019. */
  68020. Low = 0,
  68021. /**
  68022. * Medium blur
  68023. */
  68024. Medium = 1,
  68025. /**
  68026. * Large blur
  68027. */
  68028. High = 2
  68029. }
  68030. /**
  68031. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68032. */
  68033. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68034. private _circleOfConfusion;
  68035. /**
  68036. * @hidden Internal, blurs from high to low
  68037. */
  68038. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68039. private _depthOfFieldBlurY;
  68040. private _dofMerge;
  68041. /**
  68042. * @hidden Internal post processes in depth of field effect
  68043. */
  68044. _effects: Array<PostProcess>;
  68045. /**
  68046. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68047. */
  68048. set focalLength(value: number);
  68049. get focalLength(): number;
  68050. /**
  68051. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68052. */
  68053. set fStop(value: number);
  68054. get fStop(): number;
  68055. /**
  68056. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68057. */
  68058. set focusDistance(value: number);
  68059. get focusDistance(): number;
  68060. /**
  68061. * 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.
  68062. */
  68063. set lensSize(value: number);
  68064. get lensSize(): number;
  68065. /**
  68066. * Creates a new instance DepthOfFieldEffect
  68067. * @param scene The scene the effect belongs to.
  68068. * @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.
  68069. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68070. * @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)
  68071. */
  68072. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68073. /**
  68074. * Get the current class name of the current effet
  68075. * @returns "DepthOfFieldEffect"
  68076. */
  68077. getClassName(): string;
  68078. /**
  68079. * 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.
  68080. */
  68081. set depthTexture(value: RenderTargetTexture);
  68082. /**
  68083. * Disposes each of the internal effects for a given camera.
  68084. * @param camera The camera to dispose the effect on.
  68085. */
  68086. disposeEffects(camera: Camera): void;
  68087. /**
  68088. * @hidden Internal
  68089. */
  68090. _updateEffects(): void;
  68091. /**
  68092. * Internal
  68093. * @returns if all the contained post processes are ready.
  68094. * @hidden
  68095. */
  68096. _isReady(): boolean;
  68097. }
  68098. }
  68099. declare module BABYLON {
  68100. /** @hidden */
  68101. export var displayPassPixelShader: {
  68102. name: string;
  68103. shader: string;
  68104. };
  68105. }
  68106. declare module BABYLON {
  68107. /**
  68108. * DisplayPassPostProcess which produces an output the same as it's input
  68109. */
  68110. export class DisplayPassPostProcess extends PostProcess {
  68111. /**
  68112. * Creates the DisplayPassPostProcess
  68113. * @param name The name of the effect.
  68114. * @param options The required width/height ratio to downsize to before computing the render pass.
  68115. * @param camera The camera to apply the render pass to.
  68116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68117. * @param engine The engine which the post process will be applied. (default: current engine)
  68118. * @param reusable If the post process can be reused on the same frame. (default: false)
  68119. */
  68120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68121. }
  68122. }
  68123. declare module BABYLON {
  68124. /** @hidden */
  68125. export var filterPixelShader: {
  68126. name: string;
  68127. shader: string;
  68128. };
  68129. }
  68130. declare module BABYLON {
  68131. /**
  68132. * Applies a kernel filter to the image
  68133. */
  68134. export class FilterPostProcess extends PostProcess {
  68135. /** The matrix to be applied to the image */
  68136. kernelMatrix: Matrix;
  68137. /**
  68138. *
  68139. * @param name The name of the effect.
  68140. * @param kernelMatrix The matrix to be applied to the image
  68141. * @param options The required width/height ratio to downsize to before computing the render pass.
  68142. * @param camera The camera to apply the render pass to.
  68143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68144. * @param engine The engine which the post process will be applied. (default: current engine)
  68145. * @param reusable If the post process can be reused on the same frame. (default: false)
  68146. */
  68147. constructor(name: string,
  68148. /** The matrix to be applied to the image */
  68149. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68150. }
  68151. }
  68152. declare module BABYLON {
  68153. /** @hidden */
  68154. export var fxaaPixelShader: {
  68155. name: string;
  68156. shader: string;
  68157. };
  68158. }
  68159. declare module BABYLON {
  68160. /** @hidden */
  68161. export var fxaaVertexShader: {
  68162. name: string;
  68163. shader: string;
  68164. };
  68165. }
  68166. declare module BABYLON {
  68167. /**
  68168. * Fxaa post process
  68169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68170. */
  68171. export class FxaaPostProcess extends PostProcess {
  68172. /** @hidden */
  68173. texelWidth: number;
  68174. /** @hidden */
  68175. texelHeight: number;
  68176. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68177. private _getDefines;
  68178. }
  68179. }
  68180. declare module BABYLON {
  68181. /** @hidden */
  68182. export var grainPixelShader: {
  68183. name: string;
  68184. shader: string;
  68185. };
  68186. }
  68187. declare module BABYLON {
  68188. /**
  68189. * The GrainPostProcess adds noise to the image at mid luminance levels
  68190. */
  68191. export class GrainPostProcess extends PostProcess {
  68192. /**
  68193. * The intensity of the grain added (default: 30)
  68194. */
  68195. intensity: number;
  68196. /**
  68197. * If the grain should be randomized on every frame
  68198. */
  68199. animated: boolean;
  68200. /**
  68201. * Creates a new instance of @see GrainPostProcess
  68202. * @param name The name of the effect.
  68203. * @param options The required width/height ratio to downsize to before computing the render pass.
  68204. * @param camera The camera to apply the render pass to.
  68205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68206. * @param engine The engine which the post process will be applied. (default: current engine)
  68207. * @param reusable If the post process can be reused on the same frame. (default: false)
  68208. * @param textureType Type of textures used when performing the post process. (default: 0)
  68209. * @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)
  68210. */
  68211. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68212. }
  68213. }
  68214. declare module BABYLON {
  68215. /** @hidden */
  68216. export var highlightsPixelShader: {
  68217. name: string;
  68218. shader: string;
  68219. };
  68220. }
  68221. declare module BABYLON {
  68222. /**
  68223. * Extracts highlights from the image
  68224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68225. */
  68226. export class HighlightsPostProcess extends PostProcess {
  68227. /**
  68228. * Extracts highlights from the image
  68229. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68230. * @param name The name of the effect.
  68231. * @param options The required width/height ratio to downsize to before computing the render pass.
  68232. * @param camera The camera to apply the render pass to.
  68233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68234. * @param engine The engine which the post process will be applied. (default: current engine)
  68235. * @param reusable If the post process can be reused on the same frame. (default: false)
  68236. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68237. */
  68238. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68239. }
  68240. }
  68241. declare module BABYLON {
  68242. /** @hidden */
  68243. export var mrtFragmentDeclaration: {
  68244. name: string;
  68245. shader: string;
  68246. };
  68247. }
  68248. declare module BABYLON {
  68249. /** @hidden */
  68250. export var geometryPixelShader: {
  68251. name: string;
  68252. shader: string;
  68253. };
  68254. }
  68255. declare module BABYLON {
  68256. /** @hidden */
  68257. export var geometryVertexShader: {
  68258. name: string;
  68259. shader: string;
  68260. };
  68261. }
  68262. declare module BABYLON {
  68263. /** @hidden */
  68264. interface ISavedTransformationMatrix {
  68265. world: Matrix;
  68266. viewProjection: Matrix;
  68267. }
  68268. /**
  68269. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68270. */
  68271. export class GeometryBufferRenderer {
  68272. /**
  68273. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68274. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68275. */
  68276. static readonly POSITION_TEXTURE_TYPE: number;
  68277. /**
  68278. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68279. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68280. */
  68281. static readonly VELOCITY_TEXTURE_TYPE: number;
  68282. /**
  68283. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68284. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68285. */
  68286. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68287. /**
  68288. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68289. * in order to compute objects velocities when enableVelocity is set to "true"
  68290. * @hidden
  68291. */
  68292. _previousTransformationMatrices: {
  68293. [index: number]: ISavedTransformationMatrix;
  68294. };
  68295. /**
  68296. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68297. * in order to compute objects velocities when enableVelocity is set to "true"
  68298. * @hidden
  68299. */
  68300. _previousBonesTransformationMatrices: {
  68301. [index: number]: Float32Array;
  68302. };
  68303. /**
  68304. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68305. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68306. */
  68307. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68308. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68309. renderTransparentMeshes: boolean;
  68310. private _scene;
  68311. private _multiRenderTarget;
  68312. private _ratio;
  68313. private _enablePosition;
  68314. private _enableVelocity;
  68315. private _enableReflectivity;
  68316. private _positionIndex;
  68317. private _velocityIndex;
  68318. private _reflectivityIndex;
  68319. protected _effect: Effect;
  68320. protected _cachedDefines: string;
  68321. /**
  68322. * Set the render list (meshes to be rendered) used in the G buffer.
  68323. */
  68324. set renderList(meshes: Mesh[]);
  68325. /**
  68326. * Gets wether or not G buffer are supported by the running hardware.
  68327. * This requires draw buffer supports
  68328. */
  68329. get isSupported(): boolean;
  68330. /**
  68331. * Returns the index of the given texture type in the G-Buffer textures array
  68332. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68333. * @returns the index of the given texture type in the G-Buffer textures array
  68334. */
  68335. getTextureIndex(textureType: number): number;
  68336. /**
  68337. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68338. */
  68339. get enablePosition(): boolean;
  68340. /**
  68341. * Sets whether or not objects positions are enabled for the G buffer.
  68342. */
  68343. set enablePosition(enable: boolean);
  68344. /**
  68345. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68346. */
  68347. get enableVelocity(): boolean;
  68348. /**
  68349. * Sets wether or not objects velocities are enabled for the G buffer.
  68350. */
  68351. set enableVelocity(enable: boolean);
  68352. /**
  68353. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68354. */
  68355. get enableReflectivity(): boolean;
  68356. /**
  68357. * Sets wether or not objects roughness are enabled for the G buffer.
  68358. */
  68359. set enableReflectivity(enable: boolean);
  68360. /**
  68361. * Gets the scene associated with the buffer.
  68362. */
  68363. get scene(): Scene;
  68364. /**
  68365. * Gets the ratio used by the buffer during its creation.
  68366. * How big is the buffer related to the main canvas.
  68367. */
  68368. get ratio(): number;
  68369. /** @hidden */
  68370. static _SceneComponentInitialization: (scene: Scene) => void;
  68371. /**
  68372. * Creates a new G Buffer for the scene
  68373. * @param scene The scene the buffer belongs to
  68374. * @param ratio How big is the buffer related to the main canvas.
  68375. */
  68376. constructor(scene: Scene, ratio?: number);
  68377. /**
  68378. * Checks wether everything is ready to render a submesh to the G buffer.
  68379. * @param subMesh the submesh to check readiness for
  68380. * @param useInstances is the mesh drawn using instance or not
  68381. * @returns true if ready otherwise false
  68382. */
  68383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68384. /**
  68385. * Gets the current underlying G Buffer.
  68386. * @returns the buffer
  68387. */
  68388. getGBuffer(): MultiRenderTarget;
  68389. /**
  68390. * Gets the number of samples used to render the buffer (anti aliasing).
  68391. */
  68392. get samples(): number;
  68393. /**
  68394. * Sets the number of samples used to render the buffer (anti aliasing).
  68395. */
  68396. set samples(value: number);
  68397. /**
  68398. * Disposes the renderer and frees up associated resources.
  68399. */
  68400. dispose(): void;
  68401. protected _createRenderTargets(): void;
  68402. private _copyBonesTransformationMatrices;
  68403. }
  68404. }
  68405. declare module BABYLON {
  68406. interface Scene {
  68407. /** @hidden (Backing field) */
  68408. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68409. /**
  68410. * Gets or Sets the current geometry buffer associated to the scene.
  68411. */
  68412. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68413. /**
  68414. * Enables a GeometryBufferRender and associates it with the scene
  68415. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68416. * @returns the GeometryBufferRenderer
  68417. */
  68418. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68419. /**
  68420. * Disables the GeometryBufferRender associated with the scene
  68421. */
  68422. disableGeometryBufferRenderer(): void;
  68423. }
  68424. /**
  68425. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68426. * in several rendering techniques.
  68427. */
  68428. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68429. /**
  68430. * The component name helpful to identify the component in the list of scene components.
  68431. */
  68432. readonly name: string;
  68433. /**
  68434. * The scene the component belongs to.
  68435. */
  68436. scene: Scene;
  68437. /**
  68438. * Creates a new instance of the component for the given scene
  68439. * @param scene Defines the scene to register the component in
  68440. */
  68441. constructor(scene: Scene);
  68442. /**
  68443. * Registers the component in a given scene
  68444. */
  68445. register(): void;
  68446. /**
  68447. * Rebuilds the elements related to this component in case of
  68448. * context lost for instance.
  68449. */
  68450. rebuild(): void;
  68451. /**
  68452. * Disposes the component and the associated ressources
  68453. */
  68454. dispose(): void;
  68455. private _gatherRenderTargets;
  68456. }
  68457. }
  68458. declare module BABYLON {
  68459. /** @hidden */
  68460. export var motionBlurPixelShader: {
  68461. name: string;
  68462. shader: string;
  68463. };
  68464. }
  68465. declare module BABYLON {
  68466. /**
  68467. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68468. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68469. * As an example, all you have to do is to create the post-process:
  68470. * var mb = new BABYLON.MotionBlurPostProcess(
  68471. * 'mb', // The name of the effect.
  68472. * scene, // The scene containing the objects to blur according to their velocity.
  68473. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68474. * camera // The camera to apply the render pass to.
  68475. * );
  68476. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68477. */
  68478. export class MotionBlurPostProcess extends PostProcess {
  68479. /**
  68480. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68481. */
  68482. motionStrength: number;
  68483. /**
  68484. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68485. */
  68486. get motionBlurSamples(): number;
  68487. /**
  68488. * Sets the number of iterations to be used for motion blur quality
  68489. */
  68490. set motionBlurSamples(samples: number);
  68491. private _motionBlurSamples;
  68492. private _geometryBufferRenderer;
  68493. /**
  68494. * Creates a new instance MotionBlurPostProcess
  68495. * @param name The name of the effect.
  68496. * @param scene The scene containing the objects to blur according to their velocity.
  68497. * @param options The required width/height ratio to downsize to before computing the render pass.
  68498. * @param camera The camera to apply the render pass to.
  68499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68500. * @param engine The engine which the post process will be applied. (default: current engine)
  68501. * @param reusable If the post process can be reused on the same frame. (default: false)
  68502. * @param textureType Type of textures used when performing the post process. (default: 0)
  68503. * @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)
  68504. */
  68505. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68506. /**
  68507. * Excludes the given skinned mesh from computing bones velocities.
  68508. * 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.
  68509. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68510. */
  68511. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68512. /**
  68513. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68514. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68515. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68516. */
  68517. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68518. /**
  68519. * Disposes the post process.
  68520. * @param camera The camera to dispose the post process on.
  68521. */
  68522. dispose(camera?: Camera): void;
  68523. }
  68524. }
  68525. declare module BABYLON {
  68526. /** @hidden */
  68527. export var refractionPixelShader: {
  68528. name: string;
  68529. shader: string;
  68530. };
  68531. }
  68532. declare module BABYLON {
  68533. /**
  68534. * Post process which applies a refractin texture
  68535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68536. */
  68537. export class RefractionPostProcess extends PostProcess {
  68538. /** the base color of the refraction (used to taint the rendering) */
  68539. color: Color3;
  68540. /** simulated refraction depth */
  68541. depth: number;
  68542. /** the coefficient of the base color (0 to remove base color tainting) */
  68543. colorLevel: number;
  68544. private _refTexture;
  68545. private _ownRefractionTexture;
  68546. /**
  68547. * Gets or sets the refraction texture
  68548. * Please note that you are responsible for disposing the texture if you set it manually
  68549. */
  68550. get refractionTexture(): Texture;
  68551. set refractionTexture(value: Texture);
  68552. /**
  68553. * Initializes the RefractionPostProcess
  68554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68555. * @param name The name of the effect.
  68556. * @param refractionTextureUrl Url of the refraction texture to use
  68557. * @param color the base color of the refraction (used to taint the rendering)
  68558. * @param depth simulated refraction depth
  68559. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68560. * @param camera The camera to apply the render pass to.
  68561. * @param options The required width/height ratio to downsize to before computing the render pass.
  68562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68563. * @param engine The engine which the post process will be applied. (default: current engine)
  68564. * @param reusable If the post process can be reused on the same frame. (default: false)
  68565. */
  68566. constructor(name: string, refractionTextureUrl: string,
  68567. /** the base color of the refraction (used to taint the rendering) */
  68568. color: Color3,
  68569. /** simulated refraction depth */
  68570. depth: number,
  68571. /** the coefficient of the base color (0 to remove base color tainting) */
  68572. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68573. /**
  68574. * Disposes of the post process
  68575. * @param camera Camera to dispose post process on
  68576. */
  68577. dispose(camera: Camera): void;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /** @hidden */
  68582. export var sharpenPixelShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68590. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68591. */
  68592. export class SharpenPostProcess extends PostProcess {
  68593. /**
  68594. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68595. */
  68596. colorAmount: number;
  68597. /**
  68598. * How much sharpness should be applied (default: 0.3)
  68599. */
  68600. edgeAmount: number;
  68601. /**
  68602. * Creates a new instance ConvolutionPostProcess
  68603. * @param name The name of the effect.
  68604. * @param options The required width/height ratio to downsize to before computing the render pass.
  68605. * @param camera The camera to apply the render pass to.
  68606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68607. * @param engine The engine which the post process will be applied. (default: current engine)
  68608. * @param reusable If the post process can be reused on the same frame. (default: false)
  68609. * @param textureType Type of textures used when performing the post process. (default: 0)
  68610. * @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)
  68611. */
  68612. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68613. }
  68614. }
  68615. declare module BABYLON {
  68616. /**
  68617. * PostProcessRenderPipeline
  68618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68619. */
  68620. export class PostProcessRenderPipeline {
  68621. private engine;
  68622. private _renderEffects;
  68623. private _renderEffectsForIsolatedPass;
  68624. /**
  68625. * List of inspectable custom properties (used by the Inspector)
  68626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68627. */
  68628. inspectableCustomProperties: IInspectable[];
  68629. /**
  68630. * @hidden
  68631. */
  68632. protected _cameras: Camera[];
  68633. /** @hidden */
  68634. _name: string;
  68635. /**
  68636. * Gets pipeline name
  68637. */
  68638. get name(): string;
  68639. /** Gets the list of attached cameras */
  68640. get cameras(): Camera[];
  68641. /**
  68642. * Initializes a PostProcessRenderPipeline
  68643. * @param engine engine to add the pipeline to
  68644. * @param name name of the pipeline
  68645. */
  68646. constructor(engine: Engine, name: string);
  68647. /**
  68648. * Gets the class name
  68649. * @returns "PostProcessRenderPipeline"
  68650. */
  68651. getClassName(): string;
  68652. /**
  68653. * If all the render effects in the pipeline are supported
  68654. */
  68655. get isSupported(): boolean;
  68656. /**
  68657. * Adds an effect to the pipeline
  68658. * @param renderEffect the effect to add
  68659. */
  68660. addEffect(renderEffect: PostProcessRenderEffect): void;
  68661. /** @hidden */
  68662. _rebuild(): void;
  68663. /** @hidden */
  68664. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68665. /** @hidden */
  68666. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68667. /** @hidden */
  68668. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68669. /** @hidden */
  68670. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68671. /** @hidden */
  68672. _attachCameras(cameras: Camera, unique: boolean): void;
  68673. /** @hidden */
  68674. _attachCameras(cameras: Camera[], unique: boolean): void;
  68675. /** @hidden */
  68676. _detachCameras(cameras: Camera): void;
  68677. /** @hidden */
  68678. _detachCameras(cameras: Nullable<Camera[]>): void;
  68679. /** @hidden */
  68680. _update(): void;
  68681. /** @hidden */
  68682. _reset(): void;
  68683. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68684. /**
  68685. * Disposes of the pipeline
  68686. */
  68687. dispose(): void;
  68688. }
  68689. }
  68690. declare module BABYLON {
  68691. /**
  68692. * PostProcessRenderPipelineManager class
  68693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68694. */
  68695. export class PostProcessRenderPipelineManager {
  68696. private _renderPipelines;
  68697. /**
  68698. * Initializes a PostProcessRenderPipelineManager
  68699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68700. */
  68701. constructor();
  68702. /**
  68703. * Gets the list of supported render pipelines
  68704. */
  68705. get supportedPipelines(): PostProcessRenderPipeline[];
  68706. /**
  68707. * Adds a pipeline to the manager
  68708. * @param renderPipeline The pipeline to add
  68709. */
  68710. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68711. /**
  68712. * Attaches a camera to the pipeline
  68713. * @param renderPipelineName The name of the pipeline to attach to
  68714. * @param cameras the camera to attach
  68715. * @param unique if the camera can be attached multiple times to the pipeline
  68716. */
  68717. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68718. /**
  68719. * Detaches a camera from the pipeline
  68720. * @param renderPipelineName The name of the pipeline to detach from
  68721. * @param cameras the camera to detach
  68722. */
  68723. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68724. /**
  68725. * Enables an effect by name on a pipeline
  68726. * @param renderPipelineName the name of the pipeline to enable the effect in
  68727. * @param renderEffectName the name of the effect to enable
  68728. * @param cameras the cameras that the effect should be enabled on
  68729. */
  68730. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68731. /**
  68732. * Disables an effect by name on a pipeline
  68733. * @param renderPipelineName the name of the pipeline to disable the effect in
  68734. * @param renderEffectName the name of the effect to disable
  68735. * @param cameras the cameras that the effect should be disabled on
  68736. */
  68737. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68738. /**
  68739. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68740. */
  68741. update(): void;
  68742. /** @hidden */
  68743. _rebuild(): void;
  68744. /**
  68745. * Disposes of the manager and pipelines
  68746. */
  68747. dispose(): void;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. interface Scene {
  68752. /** @hidden (Backing field) */
  68753. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68754. /**
  68755. * Gets the postprocess render pipeline manager
  68756. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68757. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68758. */
  68759. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68760. }
  68761. /**
  68762. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68763. */
  68764. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68765. /**
  68766. * The component name helpfull to identify the component in the list of scene components.
  68767. */
  68768. readonly name: string;
  68769. /**
  68770. * The scene the component belongs to.
  68771. */
  68772. scene: Scene;
  68773. /**
  68774. * Creates a new instance of the component for the given scene
  68775. * @param scene Defines the scene to register the component in
  68776. */
  68777. constructor(scene: Scene);
  68778. /**
  68779. * Registers the component in a given scene
  68780. */
  68781. register(): void;
  68782. /**
  68783. * Rebuilds the elements related to this component in case of
  68784. * context lost for instance.
  68785. */
  68786. rebuild(): void;
  68787. /**
  68788. * Disposes the component and the associated ressources
  68789. */
  68790. dispose(): void;
  68791. private _gatherRenderTargets;
  68792. }
  68793. }
  68794. declare module BABYLON {
  68795. /**
  68796. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68797. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68798. */
  68799. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68800. private _scene;
  68801. private _camerasToBeAttached;
  68802. /**
  68803. * ID of the sharpen post process,
  68804. */
  68805. private readonly SharpenPostProcessId;
  68806. /**
  68807. * @ignore
  68808. * ID of the image processing post process;
  68809. */
  68810. readonly ImageProcessingPostProcessId: string;
  68811. /**
  68812. * @ignore
  68813. * ID of the Fast Approximate Anti-Aliasing post process;
  68814. */
  68815. readonly FxaaPostProcessId: string;
  68816. /**
  68817. * ID of the chromatic aberration post process,
  68818. */
  68819. private readonly ChromaticAberrationPostProcessId;
  68820. /**
  68821. * ID of the grain post process
  68822. */
  68823. private readonly GrainPostProcessId;
  68824. /**
  68825. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68826. */
  68827. sharpen: SharpenPostProcess;
  68828. private _sharpenEffect;
  68829. private bloom;
  68830. /**
  68831. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68832. */
  68833. depthOfField: DepthOfFieldEffect;
  68834. /**
  68835. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68836. */
  68837. fxaa: FxaaPostProcess;
  68838. /**
  68839. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68840. */
  68841. imageProcessing: ImageProcessingPostProcess;
  68842. /**
  68843. * Chromatic aberration post process which will shift rgb colors in the image
  68844. */
  68845. chromaticAberration: ChromaticAberrationPostProcess;
  68846. private _chromaticAberrationEffect;
  68847. /**
  68848. * Grain post process which add noise to the image
  68849. */
  68850. grain: GrainPostProcess;
  68851. private _grainEffect;
  68852. /**
  68853. * Glow post process which adds a glow to emissive areas of the image
  68854. */
  68855. private _glowLayer;
  68856. /**
  68857. * Animations which can be used to tweak settings over a period of time
  68858. */
  68859. animations: Animation[];
  68860. private _imageProcessingConfigurationObserver;
  68861. private _sharpenEnabled;
  68862. private _bloomEnabled;
  68863. private _depthOfFieldEnabled;
  68864. private _depthOfFieldBlurLevel;
  68865. private _fxaaEnabled;
  68866. private _imageProcessingEnabled;
  68867. private _defaultPipelineTextureType;
  68868. private _bloomScale;
  68869. private _chromaticAberrationEnabled;
  68870. private _grainEnabled;
  68871. private _buildAllowed;
  68872. /**
  68873. * Gets active scene
  68874. */
  68875. get scene(): Scene;
  68876. /**
  68877. * Enable or disable the sharpen process from the pipeline
  68878. */
  68879. set sharpenEnabled(enabled: boolean);
  68880. get sharpenEnabled(): boolean;
  68881. private _resizeObserver;
  68882. private _hardwareScaleLevel;
  68883. private _bloomKernel;
  68884. /**
  68885. * Specifies the size of the bloom blur kernel, relative to the final output size
  68886. */
  68887. get bloomKernel(): number;
  68888. set bloomKernel(value: number);
  68889. /**
  68890. * Specifies the weight of the bloom in the final rendering
  68891. */
  68892. private _bloomWeight;
  68893. /**
  68894. * Specifies the luma threshold for the area that will be blurred by the bloom
  68895. */
  68896. private _bloomThreshold;
  68897. private _hdr;
  68898. /**
  68899. * The strength of the bloom.
  68900. */
  68901. set bloomWeight(value: number);
  68902. get bloomWeight(): number;
  68903. /**
  68904. * The strength of the bloom.
  68905. */
  68906. set bloomThreshold(value: number);
  68907. get bloomThreshold(): number;
  68908. /**
  68909. * The scale of the bloom, lower value will provide better performance.
  68910. */
  68911. set bloomScale(value: number);
  68912. get bloomScale(): number;
  68913. /**
  68914. * Enable or disable the bloom from the pipeline
  68915. */
  68916. set bloomEnabled(enabled: boolean);
  68917. get bloomEnabled(): boolean;
  68918. private _rebuildBloom;
  68919. /**
  68920. * If the depth of field is enabled.
  68921. */
  68922. get depthOfFieldEnabled(): boolean;
  68923. set depthOfFieldEnabled(enabled: boolean);
  68924. /**
  68925. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68926. */
  68927. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68928. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68929. /**
  68930. * If the anti aliasing is enabled.
  68931. */
  68932. set fxaaEnabled(enabled: boolean);
  68933. get fxaaEnabled(): boolean;
  68934. private _samples;
  68935. /**
  68936. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68937. */
  68938. set samples(sampleCount: number);
  68939. get samples(): number;
  68940. /**
  68941. * If image processing is enabled.
  68942. */
  68943. set imageProcessingEnabled(enabled: boolean);
  68944. get imageProcessingEnabled(): boolean;
  68945. /**
  68946. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68947. */
  68948. set glowLayerEnabled(enabled: boolean);
  68949. get glowLayerEnabled(): boolean;
  68950. /**
  68951. * Gets the glow layer (or null if not defined)
  68952. */
  68953. get glowLayer(): Nullable<GlowLayer>;
  68954. /**
  68955. * Enable or disable the chromaticAberration process from the pipeline
  68956. */
  68957. set chromaticAberrationEnabled(enabled: boolean);
  68958. get chromaticAberrationEnabled(): boolean;
  68959. /**
  68960. * Enable or disable the grain process from the pipeline
  68961. */
  68962. set grainEnabled(enabled: boolean);
  68963. get grainEnabled(): boolean;
  68964. /**
  68965. * @constructor
  68966. * @param name - The rendering pipeline name (default: "")
  68967. * @param hdr - If high dynamic range textures should be used (default: true)
  68968. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68969. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68970. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68971. */
  68972. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68973. /**
  68974. * Get the class name
  68975. * @returns "DefaultRenderingPipeline"
  68976. */
  68977. getClassName(): string;
  68978. /**
  68979. * Force the compilation of the entire pipeline.
  68980. */
  68981. prepare(): void;
  68982. private _hasCleared;
  68983. private _prevPostProcess;
  68984. private _prevPrevPostProcess;
  68985. private _setAutoClearAndTextureSharing;
  68986. private _depthOfFieldSceneObserver;
  68987. private _buildPipeline;
  68988. private _disposePostProcesses;
  68989. /**
  68990. * Adds a camera to the pipeline
  68991. * @param camera the camera to be added
  68992. */
  68993. addCamera(camera: Camera): void;
  68994. /**
  68995. * Removes a camera from the pipeline
  68996. * @param camera the camera to remove
  68997. */
  68998. removeCamera(camera: Camera): void;
  68999. /**
  69000. * Dispose of the pipeline and stop all post processes
  69001. */
  69002. dispose(): void;
  69003. /**
  69004. * Serialize the rendering pipeline (Used when exporting)
  69005. * @returns the serialized object
  69006. */
  69007. serialize(): any;
  69008. /**
  69009. * Parse the serialized pipeline
  69010. * @param source Source pipeline.
  69011. * @param scene The scene to load the pipeline to.
  69012. * @param rootUrl The URL of the serialized pipeline.
  69013. * @returns An instantiated pipeline from the serialized object.
  69014. */
  69015. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69016. }
  69017. }
  69018. declare module BABYLON {
  69019. /** @hidden */
  69020. export var lensHighlightsPixelShader: {
  69021. name: string;
  69022. shader: string;
  69023. };
  69024. }
  69025. declare module BABYLON {
  69026. /** @hidden */
  69027. export var depthOfFieldPixelShader: {
  69028. name: string;
  69029. shader: string;
  69030. };
  69031. }
  69032. declare module BABYLON {
  69033. /**
  69034. * BABYLON.JS Chromatic Aberration GLSL Shader
  69035. * Author: Olivier Guyot
  69036. * Separates very slightly R, G and B colors on the edges of the screen
  69037. * Inspired by Francois Tarlier & Martins Upitis
  69038. */
  69039. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69040. /**
  69041. * @ignore
  69042. * The chromatic aberration PostProcess id in the pipeline
  69043. */
  69044. LensChromaticAberrationEffect: string;
  69045. /**
  69046. * @ignore
  69047. * The highlights enhancing PostProcess id in the pipeline
  69048. */
  69049. HighlightsEnhancingEffect: string;
  69050. /**
  69051. * @ignore
  69052. * The depth-of-field PostProcess id in the pipeline
  69053. */
  69054. LensDepthOfFieldEffect: string;
  69055. private _scene;
  69056. private _depthTexture;
  69057. private _grainTexture;
  69058. private _chromaticAberrationPostProcess;
  69059. private _highlightsPostProcess;
  69060. private _depthOfFieldPostProcess;
  69061. private _edgeBlur;
  69062. private _grainAmount;
  69063. private _chromaticAberration;
  69064. private _distortion;
  69065. private _highlightsGain;
  69066. private _highlightsThreshold;
  69067. private _dofDistance;
  69068. private _dofAperture;
  69069. private _dofDarken;
  69070. private _dofPentagon;
  69071. private _blurNoise;
  69072. /**
  69073. * @constructor
  69074. *
  69075. * Effect parameters are as follow:
  69076. * {
  69077. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69078. * edge_blur: number; // from 0 to x (1 for realism)
  69079. * distortion: number; // from 0 to x (1 for realism)
  69080. * grain_amount: number; // from 0 to 1
  69081. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69082. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69083. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69084. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69085. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69086. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69087. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69088. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69089. * }
  69090. * Note: if an effect parameter is unset, effect is disabled
  69091. *
  69092. * @param name The rendering pipeline name
  69093. * @param parameters - An object containing all parameters (see above)
  69094. * @param scene The scene linked to this pipeline
  69095. * @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)
  69096. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69097. */
  69098. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69099. /**
  69100. * Get the class name
  69101. * @returns "LensRenderingPipeline"
  69102. */
  69103. getClassName(): string;
  69104. /**
  69105. * Gets associated scene
  69106. */
  69107. get scene(): Scene;
  69108. /**
  69109. * Gets or sets the edge blur
  69110. */
  69111. get edgeBlur(): number;
  69112. set edgeBlur(value: number);
  69113. /**
  69114. * Gets or sets the grain amount
  69115. */
  69116. get grainAmount(): number;
  69117. set grainAmount(value: number);
  69118. /**
  69119. * Gets or sets the chromatic aberration amount
  69120. */
  69121. get chromaticAberration(): number;
  69122. set chromaticAberration(value: number);
  69123. /**
  69124. * Gets or sets the depth of field aperture
  69125. */
  69126. get dofAperture(): number;
  69127. set dofAperture(value: number);
  69128. /**
  69129. * Gets or sets the edge distortion
  69130. */
  69131. get edgeDistortion(): number;
  69132. set edgeDistortion(value: number);
  69133. /**
  69134. * Gets or sets the depth of field distortion
  69135. */
  69136. get dofDistortion(): number;
  69137. set dofDistortion(value: number);
  69138. /**
  69139. * Gets or sets the darken out of focus amount
  69140. */
  69141. get darkenOutOfFocus(): number;
  69142. set darkenOutOfFocus(value: number);
  69143. /**
  69144. * Gets or sets a boolean indicating if blur noise is enabled
  69145. */
  69146. get blurNoise(): boolean;
  69147. set blurNoise(value: boolean);
  69148. /**
  69149. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69150. */
  69151. get pentagonBokeh(): boolean;
  69152. set pentagonBokeh(value: boolean);
  69153. /**
  69154. * Gets or sets the highlight grain amount
  69155. */
  69156. get highlightsGain(): number;
  69157. set highlightsGain(value: number);
  69158. /**
  69159. * Gets or sets the highlight threshold
  69160. */
  69161. get highlightsThreshold(): number;
  69162. set highlightsThreshold(value: number);
  69163. /**
  69164. * Sets the amount of blur at the edges
  69165. * @param amount blur amount
  69166. */
  69167. setEdgeBlur(amount: number): void;
  69168. /**
  69169. * Sets edge blur to 0
  69170. */
  69171. disableEdgeBlur(): void;
  69172. /**
  69173. * Sets the amout of grain
  69174. * @param amount Amount of grain
  69175. */
  69176. setGrainAmount(amount: number): void;
  69177. /**
  69178. * Set grain amount to 0
  69179. */
  69180. disableGrain(): void;
  69181. /**
  69182. * Sets the chromatic aberration amount
  69183. * @param amount amount of chromatic aberration
  69184. */
  69185. setChromaticAberration(amount: number): void;
  69186. /**
  69187. * Sets chromatic aberration amount to 0
  69188. */
  69189. disableChromaticAberration(): void;
  69190. /**
  69191. * Sets the EdgeDistortion amount
  69192. * @param amount amount of EdgeDistortion
  69193. */
  69194. setEdgeDistortion(amount: number): void;
  69195. /**
  69196. * Sets edge distortion to 0
  69197. */
  69198. disableEdgeDistortion(): void;
  69199. /**
  69200. * Sets the FocusDistance amount
  69201. * @param amount amount of FocusDistance
  69202. */
  69203. setFocusDistance(amount: number): void;
  69204. /**
  69205. * Disables depth of field
  69206. */
  69207. disableDepthOfField(): void;
  69208. /**
  69209. * Sets the Aperture amount
  69210. * @param amount amount of Aperture
  69211. */
  69212. setAperture(amount: number): void;
  69213. /**
  69214. * Sets the DarkenOutOfFocus amount
  69215. * @param amount amount of DarkenOutOfFocus
  69216. */
  69217. setDarkenOutOfFocus(amount: number): void;
  69218. private _pentagonBokehIsEnabled;
  69219. /**
  69220. * Creates a pentagon bokeh effect
  69221. */
  69222. enablePentagonBokeh(): void;
  69223. /**
  69224. * Disables the pentagon bokeh effect
  69225. */
  69226. disablePentagonBokeh(): void;
  69227. /**
  69228. * Enables noise blur
  69229. */
  69230. enableNoiseBlur(): void;
  69231. /**
  69232. * Disables noise blur
  69233. */
  69234. disableNoiseBlur(): void;
  69235. /**
  69236. * Sets the HighlightsGain amount
  69237. * @param amount amount of HighlightsGain
  69238. */
  69239. setHighlightsGain(amount: number): void;
  69240. /**
  69241. * Sets the HighlightsThreshold amount
  69242. * @param amount amount of HighlightsThreshold
  69243. */
  69244. setHighlightsThreshold(amount: number): void;
  69245. /**
  69246. * Disables highlights
  69247. */
  69248. disableHighlights(): void;
  69249. /**
  69250. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69251. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69252. */
  69253. dispose(disableDepthRender?: boolean): void;
  69254. private _createChromaticAberrationPostProcess;
  69255. private _createHighlightsPostProcess;
  69256. private _createDepthOfFieldPostProcess;
  69257. private _createGrainTexture;
  69258. }
  69259. }
  69260. declare module BABYLON {
  69261. /** @hidden */
  69262. export var ssao2PixelShader: {
  69263. name: string;
  69264. shader: string;
  69265. };
  69266. }
  69267. declare module BABYLON {
  69268. /** @hidden */
  69269. export var ssaoCombinePixelShader: {
  69270. name: string;
  69271. shader: string;
  69272. };
  69273. }
  69274. declare module BABYLON {
  69275. /**
  69276. * Render pipeline to produce ssao effect
  69277. */
  69278. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69279. /**
  69280. * @ignore
  69281. * The PassPostProcess id in the pipeline that contains the original scene color
  69282. */
  69283. SSAOOriginalSceneColorEffect: string;
  69284. /**
  69285. * @ignore
  69286. * The SSAO PostProcess id in the pipeline
  69287. */
  69288. SSAORenderEffect: string;
  69289. /**
  69290. * @ignore
  69291. * The horizontal blur PostProcess id in the pipeline
  69292. */
  69293. SSAOBlurHRenderEffect: string;
  69294. /**
  69295. * @ignore
  69296. * The vertical blur PostProcess id in the pipeline
  69297. */
  69298. SSAOBlurVRenderEffect: string;
  69299. /**
  69300. * @ignore
  69301. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69302. */
  69303. SSAOCombineRenderEffect: string;
  69304. /**
  69305. * The output strength of the SSAO post-process. Default value is 1.0.
  69306. */
  69307. totalStrength: number;
  69308. /**
  69309. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69310. */
  69311. maxZ: number;
  69312. /**
  69313. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69314. */
  69315. minZAspect: number;
  69316. private _samples;
  69317. /**
  69318. * Number of samples used for the SSAO calculations. Default value is 8
  69319. */
  69320. set samples(n: number);
  69321. get samples(): number;
  69322. private _textureSamples;
  69323. /**
  69324. * Number of samples to use for antialiasing
  69325. */
  69326. set textureSamples(n: number);
  69327. get textureSamples(): number;
  69328. /**
  69329. * Ratio object used for SSAO ratio and blur ratio
  69330. */
  69331. private _ratio;
  69332. /**
  69333. * Dynamically generated sphere sampler.
  69334. */
  69335. private _sampleSphere;
  69336. /**
  69337. * Blur filter offsets
  69338. */
  69339. private _samplerOffsets;
  69340. private _expensiveBlur;
  69341. /**
  69342. * If bilateral blur should be used
  69343. */
  69344. set expensiveBlur(b: boolean);
  69345. get expensiveBlur(): boolean;
  69346. /**
  69347. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69348. */
  69349. radius: number;
  69350. /**
  69351. * The base color of the SSAO post-process
  69352. * The final result is "base + ssao" between [0, 1]
  69353. */
  69354. base: number;
  69355. /**
  69356. * Support test.
  69357. */
  69358. static get IsSupported(): boolean;
  69359. private _scene;
  69360. private _depthTexture;
  69361. private _normalTexture;
  69362. private _randomTexture;
  69363. private _originalColorPostProcess;
  69364. private _ssaoPostProcess;
  69365. private _blurHPostProcess;
  69366. private _blurVPostProcess;
  69367. private _ssaoCombinePostProcess;
  69368. /**
  69369. * Gets active scene
  69370. */
  69371. get scene(): Scene;
  69372. /**
  69373. * @constructor
  69374. * @param name The rendering pipeline name
  69375. * @param scene The scene linked to this pipeline
  69376. * @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 }
  69377. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69378. */
  69379. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69380. /**
  69381. * Get the class name
  69382. * @returns "SSAO2RenderingPipeline"
  69383. */
  69384. getClassName(): string;
  69385. /**
  69386. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69387. */
  69388. dispose(disableGeometryBufferRenderer?: boolean): void;
  69389. private _createBlurPostProcess;
  69390. /** @hidden */
  69391. _rebuild(): void;
  69392. private _bits;
  69393. private _radicalInverse_VdC;
  69394. private _hammersley;
  69395. private _hemisphereSample_uniform;
  69396. private _generateHemisphere;
  69397. private _createSSAOPostProcess;
  69398. private _createSSAOCombinePostProcess;
  69399. private _createRandomTexture;
  69400. /**
  69401. * Serialize the rendering pipeline (Used when exporting)
  69402. * @returns the serialized object
  69403. */
  69404. serialize(): any;
  69405. /**
  69406. * Parse the serialized pipeline
  69407. * @param source Source pipeline.
  69408. * @param scene The scene to load the pipeline to.
  69409. * @param rootUrl The URL of the serialized pipeline.
  69410. * @returns An instantiated pipeline from the serialized object.
  69411. */
  69412. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /** @hidden */
  69417. export var ssaoPixelShader: {
  69418. name: string;
  69419. shader: string;
  69420. };
  69421. }
  69422. declare module BABYLON {
  69423. /**
  69424. * Render pipeline to produce ssao effect
  69425. */
  69426. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69427. /**
  69428. * @ignore
  69429. * The PassPostProcess id in the pipeline that contains the original scene color
  69430. */
  69431. SSAOOriginalSceneColorEffect: string;
  69432. /**
  69433. * @ignore
  69434. * The SSAO PostProcess id in the pipeline
  69435. */
  69436. SSAORenderEffect: string;
  69437. /**
  69438. * @ignore
  69439. * The horizontal blur PostProcess id in the pipeline
  69440. */
  69441. SSAOBlurHRenderEffect: string;
  69442. /**
  69443. * @ignore
  69444. * The vertical blur PostProcess id in the pipeline
  69445. */
  69446. SSAOBlurVRenderEffect: string;
  69447. /**
  69448. * @ignore
  69449. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69450. */
  69451. SSAOCombineRenderEffect: string;
  69452. /**
  69453. * The output strength of the SSAO post-process. Default value is 1.0.
  69454. */
  69455. totalStrength: number;
  69456. /**
  69457. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69458. */
  69459. radius: number;
  69460. /**
  69461. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69462. * Must not be equal to fallOff and superior to fallOff.
  69463. * Default value is 0.0075
  69464. */
  69465. area: number;
  69466. /**
  69467. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69468. * Must not be equal to area and inferior to area.
  69469. * Default value is 0.000001
  69470. */
  69471. fallOff: number;
  69472. /**
  69473. * The base color of the SSAO post-process
  69474. * The final result is "base + ssao" between [0, 1]
  69475. */
  69476. base: number;
  69477. private _scene;
  69478. private _depthTexture;
  69479. private _randomTexture;
  69480. private _originalColorPostProcess;
  69481. private _ssaoPostProcess;
  69482. private _blurHPostProcess;
  69483. private _blurVPostProcess;
  69484. private _ssaoCombinePostProcess;
  69485. private _firstUpdate;
  69486. /**
  69487. * Gets active scene
  69488. */
  69489. get scene(): Scene;
  69490. /**
  69491. * @constructor
  69492. * @param name - The rendering pipeline name
  69493. * @param scene - The scene linked to this pipeline
  69494. * @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 }
  69495. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69496. */
  69497. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69498. /**
  69499. * Get the class name
  69500. * @returns "SSAORenderingPipeline"
  69501. */
  69502. getClassName(): string;
  69503. /**
  69504. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69505. */
  69506. dispose(disableDepthRender?: boolean): void;
  69507. private _createBlurPostProcess;
  69508. /** @hidden */
  69509. _rebuild(): void;
  69510. private _createSSAOPostProcess;
  69511. private _createSSAOCombinePostProcess;
  69512. private _createRandomTexture;
  69513. }
  69514. }
  69515. declare module BABYLON {
  69516. /** @hidden */
  69517. export var screenSpaceReflectionPixelShader: {
  69518. name: string;
  69519. shader: string;
  69520. };
  69521. }
  69522. declare module BABYLON {
  69523. /**
  69524. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69525. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69526. */
  69527. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69528. /**
  69529. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69530. */
  69531. threshold: number;
  69532. /**
  69533. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69534. */
  69535. strength: number;
  69536. /**
  69537. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69538. */
  69539. reflectionSpecularFalloffExponent: number;
  69540. /**
  69541. * 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]
  69542. */
  69543. step: number;
  69544. /**
  69545. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69546. */
  69547. roughnessFactor: number;
  69548. private _geometryBufferRenderer;
  69549. private _enableSmoothReflections;
  69550. private _reflectionSamples;
  69551. private _smoothSteps;
  69552. /**
  69553. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69554. * @param name The name of the effect.
  69555. * @param scene The scene containing the objects to calculate reflections.
  69556. * @param options The required width/height ratio to downsize to before computing the render pass.
  69557. * @param camera The camera to apply the render pass to.
  69558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69559. * @param engine The engine which the post process will be applied. (default: current engine)
  69560. * @param reusable If the post process can be reused on the same frame. (default: false)
  69561. * @param textureType Type of textures used when performing the post process. (default: 0)
  69562. * @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)
  69563. */
  69564. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69565. /**
  69566. * Gets wether or not smoothing reflections is enabled.
  69567. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69568. */
  69569. get enableSmoothReflections(): boolean;
  69570. /**
  69571. * Sets wether or not smoothing reflections is enabled.
  69572. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69573. */
  69574. set enableSmoothReflections(enabled: boolean);
  69575. /**
  69576. * Gets the number of samples taken while computing reflections. More samples count is high,
  69577. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69578. */
  69579. get reflectionSamples(): number;
  69580. /**
  69581. * Sets the number of samples taken while computing reflections. More samples count is high,
  69582. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69583. */
  69584. set reflectionSamples(samples: number);
  69585. /**
  69586. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69587. * more the post-process will require GPU power and can generate a drop in FPS.
  69588. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69589. */
  69590. get smoothSteps(): number;
  69591. set smoothSteps(steps: number);
  69592. private _updateEffectDefines;
  69593. }
  69594. }
  69595. declare module BABYLON {
  69596. /** @hidden */
  69597. export var standardPixelShader: {
  69598. name: string;
  69599. shader: string;
  69600. };
  69601. }
  69602. declare module BABYLON {
  69603. /**
  69604. * Standard rendering pipeline
  69605. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69606. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69607. */
  69608. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69609. /**
  69610. * Public members
  69611. */
  69612. /**
  69613. * Post-process which contains the original scene color before the pipeline applies all the effects
  69614. */
  69615. originalPostProcess: Nullable<PostProcess>;
  69616. /**
  69617. * Post-process used to down scale an image x4
  69618. */
  69619. downSampleX4PostProcess: Nullable<PostProcess>;
  69620. /**
  69621. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69622. */
  69623. brightPassPostProcess: Nullable<PostProcess>;
  69624. /**
  69625. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69626. */
  69627. blurHPostProcesses: PostProcess[];
  69628. /**
  69629. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69630. */
  69631. blurVPostProcesses: PostProcess[];
  69632. /**
  69633. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69634. */
  69635. textureAdderPostProcess: Nullable<PostProcess>;
  69636. /**
  69637. * Post-process used to create volumetric lighting effect
  69638. */
  69639. volumetricLightPostProcess: Nullable<PostProcess>;
  69640. /**
  69641. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69642. */
  69643. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69644. /**
  69645. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69646. */
  69647. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69648. /**
  69649. * Post-process used to merge the volumetric light effect and the real scene color
  69650. */
  69651. volumetricLightMergePostProces: Nullable<PostProcess>;
  69652. /**
  69653. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69654. */
  69655. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69656. /**
  69657. * Base post-process used to calculate the average luminance of the final image for HDR
  69658. */
  69659. luminancePostProcess: Nullable<PostProcess>;
  69660. /**
  69661. * Post-processes used to create down sample post-processes in order to get
  69662. * the average luminance of the final image for HDR
  69663. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69664. */
  69665. luminanceDownSamplePostProcesses: PostProcess[];
  69666. /**
  69667. * Post-process used to create a HDR effect (light adaptation)
  69668. */
  69669. hdrPostProcess: Nullable<PostProcess>;
  69670. /**
  69671. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69672. */
  69673. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69674. /**
  69675. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69676. */
  69677. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69678. /**
  69679. * Post-process used to merge the final HDR post-process and the real scene color
  69680. */
  69681. hdrFinalPostProcess: Nullable<PostProcess>;
  69682. /**
  69683. * Post-process used to create a lens flare effect
  69684. */
  69685. lensFlarePostProcess: Nullable<PostProcess>;
  69686. /**
  69687. * Post-process that merges the result of the lens flare post-process and the real scene color
  69688. */
  69689. lensFlareComposePostProcess: Nullable<PostProcess>;
  69690. /**
  69691. * Post-process used to create a motion blur effect
  69692. */
  69693. motionBlurPostProcess: Nullable<PostProcess>;
  69694. /**
  69695. * Post-process used to create a depth of field effect
  69696. */
  69697. depthOfFieldPostProcess: Nullable<PostProcess>;
  69698. /**
  69699. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69700. */
  69701. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69702. /**
  69703. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69704. */
  69705. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69706. /**
  69707. * Represents the brightness threshold in order to configure the illuminated surfaces
  69708. */
  69709. brightThreshold: number;
  69710. /**
  69711. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69712. */
  69713. blurWidth: number;
  69714. /**
  69715. * Sets if the blur for highlighted surfaces must be only horizontal
  69716. */
  69717. horizontalBlur: boolean;
  69718. /**
  69719. * Gets the overall exposure used by the pipeline
  69720. */
  69721. get exposure(): number;
  69722. /**
  69723. * Sets the overall exposure used by the pipeline
  69724. */
  69725. set exposure(value: number);
  69726. /**
  69727. * Texture used typically to simulate "dirty" on camera lens
  69728. */
  69729. lensTexture: Nullable<Texture>;
  69730. /**
  69731. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69732. */
  69733. volumetricLightCoefficient: number;
  69734. /**
  69735. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69736. */
  69737. volumetricLightPower: number;
  69738. /**
  69739. * Used the set the blur intensity to smooth the volumetric lights
  69740. */
  69741. volumetricLightBlurScale: number;
  69742. /**
  69743. * Light (spot or directional) used to generate the volumetric lights rays
  69744. * The source light must have a shadow generate so the pipeline can get its
  69745. * depth map
  69746. */
  69747. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69748. /**
  69749. * For eye adaptation, represents the minimum luminance the eye can see
  69750. */
  69751. hdrMinimumLuminance: number;
  69752. /**
  69753. * For eye adaptation, represents the decrease luminance speed
  69754. */
  69755. hdrDecreaseRate: number;
  69756. /**
  69757. * For eye adaptation, represents the increase luminance speed
  69758. */
  69759. hdrIncreaseRate: number;
  69760. /**
  69761. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69762. */
  69763. get hdrAutoExposure(): boolean;
  69764. /**
  69765. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69766. */
  69767. set hdrAutoExposure(value: boolean);
  69768. /**
  69769. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69770. */
  69771. lensColorTexture: Nullable<Texture>;
  69772. /**
  69773. * The overall strengh for the lens flare effect
  69774. */
  69775. lensFlareStrength: number;
  69776. /**
  69777. * Dispersion coefficient for lens flare ghosts
  69778. */
  69779. lensFlareGhostDispersal: number;
  69780. /**
  69781. * Main lens flare halo width
  69782. */
  69783. lensFlareHaloWidth: number;
  69784. /**
  69785. * Based on the lens distortion effect, defines how much the lens flare result
  69786. * is distorted
  69787. */
  69788. lensFlareDistortionStrength: number;
  69789. /**
  69790. * Configures the blur intensity used for for lens flare (halo)
  69791. */
  69792. lensFlareBlurWidth: number;
  69793. /**
  69794. * Lens star texture must be used to simulate rays on the flares and is available
  69795. * in the documentation
  69796. */
  69797. lensStarTexture: Nullable<Texture>;
  69798. /**
  69799. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69800. * flare effect by taking account of the dirt texture
  69801. */
  69802. lensFlareDirtTexture: Nullable<Texture>;
  69803. /**
  69804. * Represents the focal length for the depth of field effect
  69805. */
  69806. depthOfFieldDistance: number;
  69807. /**
  69808. * Represents the blur intensity for the blurred part of the depth of field effect
  69809. */
  69810. depthOfFieldBlurWidth: number;
  69811. /**
  69812. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69813. */
  69814. get motionStrength(): number;
  69815. /**
  69816. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69817. */
  69818. set motionStrength(strength: number);
  69819. /**
  69820. * Gets wether or not the motion blur post-process is object based or screen based.
  69821. */
  69822. get objectBasedMotionBlur(): boolean;
  69823. /**
  69824. * Sets wether or not the motion blur post-process should be object based or screen based
  69825. */
  69826. set objectBasedMotionBlur(value: boolean);
  69827. /**
  69828. * List of animations for the pipeline (IAnimatable implementation)
  69829. */
  69830. animations: Animation[];
  69831. /**
  69832. * Private members
  69833. */
  69834. private _scene;
  69835. private _currentDepthOfFieldSource;
  69836. private _basePostProcess;
  69837. private _fixedExposure;
  69838. private _currentExposure;
  69839. private _hdrAutoExposure;
  69840. private _hdrCurrentLuminance;
  69841. private _motionStrength;
  69842. private _isObjectBasedMotionBlur;
  69843. private _floatTextureType;
  69844. private _camerasToBeAttached;
  69845. private _ratio;
  69846. private _bloomEnabled;
  69847. private _depthOfFieldEnabled;
  69848. private _vlsEnabled;
  69849. private _lensFlareEnabled;
  69850. private _hdrEnabled;
  69851. private _motionBlurEnabled;
  69852. private _fxaaEnabled;
  69853. private _screenSpaceReflectionsEnabled;
  69854. private _motionBlurSamples;
  69855. private _volumetricLightStepsCount;
  69856. private _samples;
  69857. /**
  69858. * @ignore
  69859. * Specifies if the bloom pipeline is enabled
  69860. */
  69861. get BloomEnabled(): boolean;
  69862. set BloomEnabled(enabled: boolean);
  69863. /**
  69864. * @ignore
  69865. * Specifies if the depth of field pipeline is enabed
  69866. */
  69867. get DepthOfFieldEnabled(): boolean;
  69868. set DepthOfFieldEnabled(enabled: boolean);
  69869. /**
  69870. * @ignore
  69871. * Specifies if the lens flare pipeline is enabed
  69872. */
  69873. get LensFlareEnabled(): boolean;
  69874. set LensFlareEnabled(enabled: boolean);
  69875. /**
  69876. * @ignore
  69877. * Specifies if the HDR pipeline is enabled
  69878. */
  69879. get HDREnabled(): boolean;
  69880. set HDREnabled(enabled: boolean);
  69881. /**
  69882. * @ignore
  69883. * Specifies if the volumetric lights scattering effect is enabled
  69884. */
  69885. get VLSEnabled(): boolean;
  69886. set VLSEnabled(enabled: boolean);
  69887. /**
  69888. * @ignore
  69889. * Specifies if the motion blur effect is enabled
  69890. */
  69891. get MotionBlurEnabled(): boolean;
  69892. set MotionBlurEnabled(enabled: boolean);
  69893. /**
  69894. * Specifies if anti-aliasing is enabled
  69895. */
  69896. get fxaaEnabled(): boolean;
  69897. set fxaaEnabled(enabled: boolean);
  69898. /**
  69899. * Specifies if screen space reflections are enabled.
  69900. */
  69901. get screenSpaceReflectionsEnabled(): boolean;
  69902. set screenSpaceReflectionsEnabled(enabled: boolean);
  69903. /**
  69904. * Specifies the number of steps used to calculate the volumetric lights
  69905. * Typically in interval [50, 200]
  69906. */
  69907. get volumetricLightStepsCount(): number;
  69908. set volumetricLightStepsCount(count: number);
  69909. /**
  69910. * Specifies the number of samples used for the motion blur effect
  69911. * Typically in interval [16, 64]
  69912. */
  69913. get motionBlurSamples(): number;
  69914. set motionBlurSamples(samples: number);
  69915. /**
  69916. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69917. */
  69918. get samples(): number;
  69919. set samples(sampleCount: number);
  69920. /**
  69921. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69922. * @constructor
  69923. * @param name The rendering pipeline name
  69924. * @param scene The scene linked to this pipeline
  69925. * @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)
  69926. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69927. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69928. */
  69929. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69930. private _buildPipeline;
  69931. private _createDownSampleX4PostProcess;
  69932. private _createBrightPassPostProcess;
  69933. private _createBlurPostProcesses;
  69934. private _createTextureAdderPostProcess;
  69935. private _createVolumetricLightPostProcess;
  69936. private _createLuminancePostProcesses;
  69937. private _createHdrPostProcess;
  69938. private _createLensFlarePostProcess;
  69939. private _createDepthOfFieldPostProcess;
  69940. private _createMotionBlurPostProcess;
  69941. private _getDepthTexture;
  69942. private _disposePostProcesses;
  69943. /**
  69944. * Dispose of the pipeline and stop all post processes
  69945. */
  69946. dispose(): void;
  69947. /**
  69948. * Serialize the rendering pipeline (Used when exporting)
  69949. * @returns the serialized object
  69950. */
  69951. serialize(): any;
  69952. /**
  69953. * Parse the serialized pipeline
  69954. * @param source Source pipeline.
  69955. * @param scene The scene to load the pipeline to.
  69956. * @param rootUrl The URL of the serialized pipeline.
  69957. * @returns An instantiated pipeline from the serialized object.
  69958. */
  69959. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69960. /**
  69961. * Luminance steps
  69962. */
  69963. static LuminanceSteps: number;
  69964. }
  69965. }
  69966. declare module BABYLON {
  69967. /** @hidden */
  69968. export var stereoscopicInterlacePixelShader: {
  69969. name: string;
  69970. shader: string;
  69971. };
  69972. }
  69973. declare module BABYLON {
  69974. /**
  69975. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69976. */
  69977. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69978. private _stepSize;
  69979. private _passedProcess;
  69980. /**
  69981. * Initializes a StereoscopicInterlacePostProcessI
  69982. * @param name The name of the effect.
  69983. * @param rigCameras The rig cameras to be appled to the post process
  69984. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69985. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69987. * @param engine The engine which the post process will be applied. (default: current engine)
  69988. * @param reusable If the post process can be reused on the same frame. (default: false)
  69989. */
  69990. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69991. }
  69992. /**
  69993. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69994. */
  69995. export class StereoscopicInterlacePostProcess extends PostProcess {
  69996. private _stepSize;
  69997. private _passedProcess;
  69998. /**
  69999. * Initializes a StereoscopicInterlacePostProcess
  70000. * @param name The name of the effect.
  70001. * @param rigCameras The rig cameras to be appled to the post process
  70002. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70003. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70004. * @param engine The engine which the post process will be applied. (default: current engine)
  70005. * @param reusable If the post process can be reused on the same frame. (default: false)
  70006. */
  70007. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70008. }
  70009. }
  70010. declare module BABYLON {
  70011. /** @hidden */
  70012. export var tonemapPixelShader: {
  70013. name: string;
  70014. shader: string;
  70015. };
  70016. }
  70017. declare module BABYLON {
  70018. /** Defines operator used for tonemapping */
  70019. export enum TonemappingOperator {
  70020. /** Hable */
  70021. Hable = 0,
  70022. /** Reinhard */
  70023. Reinhard = 1,
  70024. /** HejiDawson */
  70025. HejiDawson = 2,
  70026. /** Photographic */
  70027. Photographic = 3
  70028. }
  70029. /**
  70030. * Defines a post process to apply tone mapping
  70031. */
  70032. export class TonemapPostProcess extends PostProcess {
  70033. private _operator;
  70034. /** Defines the required exposure adjustement */
  70035. exposureAdjustment: number;
  70036. /**
  70037. * Creates a new TonemapPostProcess
  70038. * @param name defines the name of the postprocess
  70039. * @param _operator defines the operator to use
  70040. * @param exposureAdjustment defines the required exposure adjustement
  70041. * @param camera defines the camera to use (can be null)
  70042. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70043. * @param engine defines the hosting engine (can be ignore if camera is set)
  70044. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70045. */
  70046. constructor(name: string, _operator: TonemappingOperator,
  70047. /** Defines the required exposure adjustement */
  70048. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70049. }
  70050. }
  70051. declare module BABYLON {
  70052. /** @hidden */
  70053. export var volumetricLightScatteringPixelShader: {
  70054. name: string;
  70055. shader: string;
  70056. };
  70057. }
  70058. declare module BABYLON {
  70059. /** @hidden */
  70060. export var volumetricLightScatteringPassVertexShader: {
  70061. name: string;
  70062. shader: string;
  70063. };
  70064. }
  70065. declare module BABYLON {
  70066. /** @hidden */
  70067. export var volumetricLightScatteringPassPixelShader: {
  70068. name: string;
  70069. shader: string;
  70070. };
  70071. }
  70072. declare module BABYLON {
  70073. /**
  70074. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70075. */
  70076. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70077. private _volumetricLightScatteringPass;
  70078. private _volumetricLightScatteringRTT;
  70079. private _viewPort;
  70080. private _screenCoordinates;
  70081. private _cachedDefines;
  70082. /**
  70083. * If not undefined, the mesh position is computed from the attached node position
  70084. */
  70085. attachedNode: {
  70086. position: Vector3;
  70087. };
  70088. /**
  70089. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70090. */
  70091. customMeshPosition: Vector3;
  70092. /**
  70093. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70094. */
  70095. useCustomMeshPosition: boolean;
  70096. /**
  70097. * If the post-process should inverse the light scattering direction
  70098. */
  70099. invert: boolean;
  70100. /**
  70101. * The internal mesh used by the post-process
  70102. */
  70103. mesh: Mesh;
  70104. /**
  70105. * @hidden
  70106. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70107. */
  70108. get useDiffuseColor(): boolean;
  70109. set useDiffuseColor(useDiffuseColor: boolean);
  70110. /**
  70111. * Array containing the excluded meshes not rendered in the internal pass
  70112. */
  70113. excludedMeshes: AbstractMesh[];
  70114. /**
  70115. * Controls the overall intensity of the post-process
  70116. */
  70117. exposure: number;
  70118. /**
  70119. * Dissipates each sample's contribution in range [0, 1]
  70120. */
  70121. decay: number;
  70122. /**
  70123. * Controls the overall intensity of each sample
  70124. */
  70125. weight: number;
  70126. /**
  70127. * Controls the density of each sample
  70128. */
  70129. density: number;
  70130. /**
  70131. * @constructor
  70132. * @param name The post-process name
  70133. * @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)
  70134. * @param camera The camera that the post-process will be attached to
  70135. * @param mesh The mesh used to create the light scattering
  70136. * @param samples The post-process quality, default 100
  70137. * @param samplingModeThe post-process filtering mode
  70138. * @param engine The babylon engine
  70139. * @param reusable If the post-process is reusable
  70140. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70141. */
  70142. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70143. /**
  70144. * Returns the string "VolumetricLightScatteringPostProcess"
  70145. * @returns "VolumetricLightScatteringPostProcess"
  70146. */
  70147. getClassName(): string;
  70148. private _isReady;
  70149. /**
  70150. * Sets the new light position for light scattering effect
  70151. * @param position The new custom light position
  70152. */
  70153. setCustomMeshPosition(position: Vector3): void;
  70154. /**
  70155. * Returns the light position for light scattering effect
  70156. * @return Vector3 The custom light position
  70157. */
  70158. getCustomMeshPosition(): Vector3;
  70159. /**
  70160. * Disposes the internal assets and detaches the post-process from the camera
  70161. */
  70162. dispose(camera: Camera): void;
  70163. /**
  70164. * Returns the render target texture used by the post-process
  70165. * @return the render target texture used by the post-process
  70166. */
  70167. getPass(): RenderTargetTexture;
  70168. private _meshExcluded;
  70169. private _createPass;
  70170. private _updateMeshScreenCoordinates;
  70171. /**
  70172. * Creates a default mesh for the Volumeric Light Scattering post-process
  70173. * @param name The mesh name
  70174. * @param scene The scene where to create the mesh
  70175. * @return the default mesh
  70176. */
  70177. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70178. }
  70179. }
  70180. declare module BABYLON {
  70181. interface Scene {
  70182. /** @hidden (Backing field) */
  70183. _boundingBoxRenderer: BoundingBoxRenderer;
  70184. /** @hidden (Backing field) */
  70185. _forceShowBoundingBoxes: boolean;
  70186. /**
  70187. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70188. */
  70189. forceShowBoundingBoxes: boolean;
  70190. /**
  70191. * Gets the bounding box renderer associated with the scene
  70192. * @returns a BoundingBoxRenderer
  70193. */
  70194. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70195. }
  70196. interface AbstractMesh {
  70197. /** @hidden (Backing field) */
  70198. _showBoundingBox: boolean;
  70199. /**
  70200. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70201. */
  70202. showBoundingBox: boolean;
  70203. }
  70204. /**
  70205. * Component responsible of rendering the bounding box of the meshes in a scene.
  70206. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70207. */
  70208. export class BoundingBoxRenderer implements ISceneComponent {
  70209. /**
  70210. * The component name helpfull to identify the component in the list of scene components.
  70211. */
  70212. readonly name: string;
  70213. /**
  70214. * The scene the component belongs to.
  70215. */
  70216. scene: Scene;
  70217. /**
  70218. * Color of the bounding box lines placed in front of an object
  70219. */
  70220. frontColor: Color3;
  70221. /**
  70222. * Color of the bounding box lines placed behind an object
  70223. */
  70224. backColor: Color3;
  70225. /**
  70226. * Defines if the renderer should show the back lines or not
  70227. */
  70228. showBackLines: boolean;
  70229. /**
  70230. * Observable raised before rendering a bounding box
  70231. */
  70232. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70233. /**
  70234. * Observable raised after rendering a bounding box
  70235. */
  70236. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70237. /**
  70238. * @hidden
  70239. */
  70240. renderList: SmartArray<BoundingBox>;
  70241. private _colorShader;
  70242. private _vertexBuffers;
  70243. private _indexBuffer;
  70244. private _fillIndexBuffer;
  70245. private _fillIndexData;
  70246. /**
  70247. * Instantiates a new bounding box renderer in a scene.
  70248. * @param scene the scene the renderer renders in
  70249. */
  70250. constructor(scene: Scene);
  70251. /**
  70252. * Registers the component in a given scene
  70253. */
  70254. register(): void;
  70255. private _evaluateSubMesh;
  70256. private _activeMesh;
  70257. private _prepareRessources;
  70258. private _createIndexBuffer;
  70259. /**
  70260. * Rebuilds the elements related to this component in case of
  70261. * context lost for instance.
  70262. */
  70263. rebuild(): void;
  70264. /**
  70265. * @hidden
  70266. */
  70267. reset(): void;
  70268. /**
  70269. * Render the bounding boxes of a specific rendering group
  70270. * @param renderingGroupId defines the rendering group to render
  70271. */
  70272. render(renderingGroupId: number): void;
  70273. /**
  70274. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70275. * @param mesh Define the mesh to render the occlusion bounding box for
  70276. */
  70277. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70278. /**
  70279. * Dispose and release the resources attached to this renderer.
  70280. */
  70281. dispose(): void;
  70282. }
  70283. }
  70284. declare module BABYLON {
  70285. interface Scene {
  70286. /** @hidden (Backing field) */
  70287. _depthRenderer: {
  70288. [id: string]: DepthRenderer;
  70289. };
  70290. /**
  70291. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70292. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70293. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70294. * @returns the created depth renderer
  70295. */
  70296. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70297. /**
  70298. * Disables a depth renderer for a given camera
  70299. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70300. */
  70301. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70302. }
  70303. /**
  70304. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70305. * in several rendering techniques.
  70306. */
  70307. export class DepthRendererSceneComponent implements ISceneComponent {
  70308. /**
  70309. * The component name helpfull to identify the component in the list of scene components.
  70310. */
  70311. readonly name: string;
  70312. /**
  70313. * The scene the component belongs to.
  70314. */
  70315. scene: Scene;
  70316. /**
  70317. * Creates a new instance of the component for the given scene
  70318. * @param scene Defines the scene to register the component in
  70319. */
  70320. constructor(scene: Scene);
  70321. /**
  70322. * Registers the component in a given scene
  70323. */
  70324. register(): void;
  70325. /**
  70326. * Rebuilds the elements related to this component in case of
  70327. * context lost for instance.
  70328. */
  70329. rebuild(): void;
  70330. /**
  70331. * Disposes the component and the associated ressources
  70332. */
  70333. dispose(): void;
  70334. private _gatherRenderTargets;
  70335. private _gatherActiveCameraRenderTargets;
  70336. }
  70337. }
  70338. declare module BABYLON {
  70339. /** @hidden */
  70340. export var outlinePixelShader: {
  70341. name: string;
  70342. shader: string;
  70343. };
  70344. }
  70345. declare module BABYLON {
  70346. /** @hidden */
  70347. export var outlineVertexShader: {
  70348. name: string;
  70349. shader: string;
  70350. };
  70351. }
  70352. declare module BABYLON {
  70353. interface Scene {
  70354. /** @hidden */
  70355. _outlineRenderer: OutlineRenderer;
  70356. /**
  70357. * Gets the outline renderer associated with the scene
  70358. * @returns a OutlineRenderer
  70359. */
  70360. getOutlineRenderer(): OutlineRenderer;
  70361. }
  70362. interface AbstractMesh {
  70363. /** @hidden (Backing field) */
  70364. _renderOutline: boolean;
  70365. /**
  70366. * Gets or sets a boolean indicating if the outline must be rendered as well
  70367. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70368. */
  70369. renderOutline: boolean;
  70370. /** @hidden (Backing field) */
  70371. _renderOverlay: boolean;
  70372. /**
  70373. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70374. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70375. */
  70376. renderOverlay: boolean;
  70377. }
  70378. /**
  70379. * This class is responsible to draw bothe outline/overlay of meshes.
  70380. * It should not be used directly but through the available method on mesh.
  70381. */
  70382. export class OutlineRenderer implements ISceneComponent {
  70383. /**
  70384. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70385. */
  70386. private static _StencilReference;
  70387. /**
  70388. * The name of the component. Each component must have a unique name.
  70389. */
  70390. name: string;
  70391. /**
  70392. * The scene the component belongs to.
  70393. */
  70394. scene: Scene;
  70395. /**
  70396. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70397. */
  70398. zOffset: number;
  70399. private _engine;
  70400. private _effect;
  70401. private _cachedDefines;
  70402. private _savedDepthWrite;
  70403. /**
  70404. * Instantiates a new outline renderer. (There could be only one per scene).
  70405. * @param scene Defines the scene it belongs to
  70406. */
  70407. constructor(scene: Scene);
  70408. /**
  70409. * Register the component to one instance of a scene.
  70410. */
  70411. register(): void;
  70412. /**
  70413. * Rebuilds the elements related to this component in case of
  70414. * context lost for instance.
  70415. */
  70416. rebuild(): void;
  70417. /**
  70418. * Disposes the component and the associated ressources.
  70419. */
  70420. dispose(): void;
  70421. /**
  70422. * Renders the outline in the canvas.
  70423. * @param subMesh Defines the sumesh to render
  70424. * @param batch Defines the batch of meshes in case of instances
  70425. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70426. */
  70427. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70428. /**
  70429. * Returns whether or not the outline renderer is ready for a given submesh.
  70430. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70431. * @param subMesh Defines the submesh to check readyness for
  70432. * @param useInstances Defines wheter wee are trying to render instances or not
  70433. * @returns true if ready otherwise false
  70434. */
  70435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70436. private _beforeRenderingMesh;
  70437. private _afterRenderingMesh;
  70438. }
  70439. }
  70440. declare module BABYLON {
  70441. /**
  70442. * Defines the basic options interface of a Sprite Frame Source Size.
  70443. */
  70444. export interface ISpriteJSONSpriteSourceSize {
  70445. /**
  70446. * number of the original width of the Frame
  70447. */
  70448. w: number;
  70449. /**
  70450. * number of the original height of the Frame
  70451. */
  70452. h: number;
  70453. }
  70454. /**
  70455. * Defines the basic options interface of a Sprite Frame Data.
  70456. */
  70457. export interface ISpriteJSONSpriteFrameData {
  70458. /**
  70459. * number of the x offset of the Frame
  70460. */
  70461. x: number;
  70462. /**
  70463. * number of the y offset of the Frame
  70464. */
  70465. y: number;
  70466. /**
  70467. * number of the width of the Frame
  70468. */
  70469. w: number;
  70470. /**
  70471. * number of the height of the Frame
  70472. */
  70473. h: number;
  70474. }
  70475. /**
  70476. * Defines the basic options interface of a JSON Sprite.
  70477. */
  70478. export interface ISpriteJSONSprite {
  70479. /**
  70480. * string name of the Frame
  70481. */
  70482. filename: string;
  70483. /**
  70484. * ISpriteJSONSpriteFrame basic object of the frame data
  70485. */
  70486. frame: ISpriteJSONSpriteFrameData;
  70487. /**
  70488. * boolean to flag is the frame was rotated.
  70489. */
  70490. rotated: boolean;
  70491. /**
  70492. * boolean to flag is the frame was trimmed.
  70493. */
  70494. trimmed: boolean;
  70495. /**
  70496. * ISpriteJSONSpriteFrame basic object of the source data
  70497. */
  70498. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70499. /**
  70500. * ISpriteJSONSpriteFrame basic object of the source data
  70501. */
  70502. sourceSize: ISpriteJSONSpriteSourceSize;
  70503. }
  70504. /**
  70505. * Defines the basic options interface of a JSON atlas.
  70506. */
  70507. export interface ISpriteJSONAtlas {
  70508. /**
  70509. * Array of objects that contain the frame data.
  70510. */
  70511. frames: Array<ISpriteJSONSprite>;
  70512. /**
  70513. * object basic object containing the sprite meta data.
  70514. */
  70515. meta?: object;
  70516. }
  70517. }
  70518. declare module BABYLON {
  70519. /** @hidden */
  70520. export var spriteMapPixelShader: {
  70521. name: string;
  70522. shader: string;
  70523. };
  70524. }
  70525. declare module BABYLON {
  70526. /** @hidden */
  70527. export var spriteMapVertexShader: {
  70528. name: string;
  70529. shader: string;
  70530. };
  70531. }
  70532. declare module BABYLON {
  70533. /**
  70534. * Defines the basic options interface of a SpriteMap
  70535. */
  70536. export interface ISpriteMapOptions {
  70537. /**
  70538. * Vector2 of the number of cells in the grid.
  70539. */
  70540. stageSize?: Vector2;
  70541. /**
  70542. * Vector2 of the size of the output plane in World Units.
  70543. */
  70544. outputSize?: Vector2;
  70545. /**
  70546. * Vector3 of the position of the output plane in World Units.
  70547. */
  70548. outputPosition?: Vector3;
  70549. /**
  70550. * Vector3 of the rotation of the output plane.
  70551. */
  70552. outputRotation?: Vector3;
  70553. /**
  70554. * number of layers that the system will reserve in resources.
  70555. */
  70556. layerCount?: number;
  70557. /**
  70558. * number of max animation frames a single cell will reserve in resources.
  70559. */
  70560. maxAnimationFrames?: number;
  70561. /**
  70562. * number cell index of the base tile when the system compiles.
  70563. */
  70564. baseTile?: number;
  70565. /**
  70566. * boolean flip the sprite after its been repositioned by the framing data.
  70567. */
  70568. flipU?: boolean;
  70569. /**
  70570. * Vector3 scalar of the global RGB values of the SpriteMap.
  70571. */
  70572. colorMultiply?: Vector3;
  70573. }
  70574. /**
  70575. * Defines the IDisposable interface in order to be cleanable from resources.
  70576. */
  70577. export interface ISpriteMap extends IDisposable {
  70578. /**
  70579. * String name of the SpriteMap.
  70580. */
  70581. name: string;
  70582. /**
  70583. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70584. */
  70585. atlasJSON: ISpriteJSONAtlas;
  70586. /**
  70587. * Texture of the SpriteMap.
  70588. */
  70589. spriteSheet: Texture;
  70590. /**
  70591. * The parameters to initialize the SpriteMap with.
  70592. */
  70593. options: ISpriteMapOptions;
  70594. }
  70595. /**
  70596. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70597. */
  70598. export class SpriteMap implements ISpriteMap {
  70599. /** The Name of the spriteMap */
  70600. name: string;
  70601. /** The JSON file with the frame and meta data */
  70602. atlasJSON: ISpriteJSONAtlas;
  70603. /** The systems Sprite Sheet Texture */
  70604. spriteSheet: Texture;
  70605. /** Arguments passed with the Constructor */
  70606. options: ISpriteMapOptions;
  70607. /** Public Sprite Storage array, parsed from atlasJSON */
  70608. sprites: Array<ISpriteJSONSprite>;
  70609. /** Returns the Number of Sprites in the System */
  70610. get spriteCount(): number;
  70611. /** Returns the Position of Output Plane*/
  70612. get position(): Vector3;
  70613. /** Returns the Position of Output Plane*/
  70614. set position(v: Vector3);
  70615. /** Returns the Rotation of Output Plane*/
  70616. get rotation(): Vector3;
  70617. /** Returns the Rotation of Output Plane*/
  70618. set rotation(v: Vector3);
  70619. /** Sets the AnimationMap*/
  70620. get animationMap(): RawTexture;
  70621. /** Sets the AnimationMap*/
  70622. set animationMap(v: RawTexture);
  70623. /** Scene that the SpriteMap was created in */
  70624. private _scene;
  70625. /** Texture Buffer of Float32 that holds tile frame data*/
  70626. private _frameMap;
  70627. /** Texture Buffers of Float32 that holds tileMap data*/
  70628. private _tileMaps;
  70629. /** Texture Buffer of Float32 that holds Animation Data*/
  70630. private _animationMap;
  70631. /** Custom ShaderMaterial Central to the System*/
  70632. private _material;
  70633. /** Custom ShaderMaterial Central to the System*/
  70634. private _output;
  70635. /** Systems Time Ticker*/
  70636. private _time;
  70637. /**
  70638. * Creates a new SpriteMap
  70639. * @param name defines the SpriteMaps Name
  70640. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70641. * @param spriteSheet is the Texture that the Sprites are on.
  70642. * @param options a basic deployment configuration
  70643. * @param scene The Scene that the map is deployed on
  70644. */
  70645. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70646. /**
  70647. * Returns tileID location
  70648. * @returns Vector2 the cell position ID
  70649. */
  70650. getTileID(): Vector2;
  70651. /**
  70652. * Gets the UV location of the mouse over the SpriteMap.
  70653. * @returns Vector2 the UV position of the mouse interaction
  70654. */
  70655. getMousePosition(): Vector2;
  70656. /**
  70657. * Creates the "frame" texture Buffer
  70658. * -------------------------------------
  70659. * Structure of frames
  70660. * "filename": "Falling-Water-2.png",
  70661. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70662. * "rotated": true,
  70663. * "trimmed": true,
  70664. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70665. * "sourceSize": {"w":32,"h":32}
  70666. * @returns RawTexture of the frameMap
  70667. */
  70668. private _createFrameBuffer;
  70669. /**
  70670. * Creates the tileMap texture Buffer
  70671. * @param buffer normally and array of numbers, or a false to generate from scratch
  70672. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70673. * @returns RawTexture of the tileMap
  70674. */
  70675. private _createTileBuffer;
  70676. /**
  70677. * Modifies the data of the tileMaps
  70678. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70679. * @param pos is the iVector2 Coordinates of the Tile
  70680. * @param tile The SpriteIndex of the new Tile
  70681. */
  70682. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70683. /**
  70684. * Creates the animationMap texture Buffer
  70685. * @param buffer normally and array of numbers, or a false to generate from scratch
  70686. * @returns RawTexture of the animationMap
  70687. */
  70688. private _createTileAnimationBuffer;
  70689. /**
  70690. * Modifies the data of the animationMap
  70691. * @param cellID is the Index of the Sprite
  70692. * @param _frame is the target Animation frame
  70693. * @param toCell is the Target Index of the next frame of the animation
  70694. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70695. * @param speed is a global scalar of the time variable on the map.
  70696. */
  70697. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70698. /**
  70699. * Exports the .tilemaps file
  70700. */
  70701. saveTileMaps(): void;
  70702. /**
  70703. * Imports the .tilemaps file
  70704. * @param url of the .tilemaps file
  70705. */
  70706. loadTileMaps(url: string): void;
  70707. /**
  70708. * Release associated resources
  70709. */
  70710. dispose(): void;
  70711. }
  70712. }
  70713. declare module BABYLON {
  70714. /**
  70715. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70716. * @see http://doc.babylonjs.com/babylon101/sprites
  70717. */
  70718. export class SpritePackedManager extends SpriteManager {
  70719. /** defines the packed manager's name */
  70720. name: string;
  70721. /**
  70722. * Creates a new sprite manager from a packed sprite sheet
  70723. * @param name defines the manager's name
  70724. * @param imgUrl defines the sprite sheet url
  70725. * @param capacity defines the maximum allowed number of sprites
  70726. * @param scene defines the hosting scene
  70727. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70728. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70729. * @param samplingMode defines the smapling mode to use with spritesheet
  70730. * @param fromPacked set to true; do not alter
  70731. */
  70732. constructor(
  70733. /** defines the packed manager's name */
  70734. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70735. }
  70736. }
  70737. declare module BABYLON {
  70738. /**
  70739. * Defines the list of states available for a task inside a AssetsManager
  70740. */
  70741. export enum AssetTaskState {
  70742. /**
  70743. * Initialization
  70744. */
  70745. INIT = 0,
  70746. /**
  70747. * Running
  70748. */
  70749. RUNNING = 1,
  70750. /**
  70751. * Done
  70752. */
  70753. DONE = 2,
  70754. /**
  70755. * Error
  70756. */
  70757. ERROR = 3
  70758. }
  70759. /**
  70760. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70761. */
  70762. export abstract class AbstractAssetTask {
  70763. /**
  70764. * Task name
  70765. */ name: string;
  70766. /**
  70767. * Callback called when the task is successful
  70768. */
  70769. onSuccess: (task: any) => void;
  70770. /**
  70771. * Callback called when the task is not successful
  70772. */
  70773. onError: (task: any, message?: string, exception?: any) => void;
  70774. /**
  70775. * Creates a new AssetsManager
  70776. * @param name defines the name of the task
  70777. */
  70778. constructor(
  70779. /**
  70780. * Task name
  70781. */ name: string);
  70782. private _isCompleted;
  70783. private _taskState;
  70784. private _errorObject;
  70785. /**
  70786. * Get if the task is completed
  70787. */
  70788. get isCompleted(): boolean;
  70789. /**
  70790. * Gets the current state of the task
  70791. */
  70792. get taskState(): AssetTaskState;
  70793. /**
  70794. * Gets the current error object (if task is in error)
  70795. */
  70796. get errorObject(): {
  70797. message?: string;
  70798. exception?: any;
  70799. };
  70800. /**
  70801. * Internal only
  70802. * @hidden
  70803. */
  70804. _setErrorObject(message?: string, exception?: any): void;
  70805. /**
  70806. * Execute the current task
  70807. * @param scene defines the scene where you want your assets to be loaded
  70808. * @param onSuccess is a callback called when the task is successfully executed
  70809. * @param onError is a callback called if an error occurs
  70810. */
  70811. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70812. /**
  70813. * Execute the current task
  70814. * @param scene defines the scene where you want your assets to be loaded
  70815. * @param onSuccess is a callback called when the task is successfully executed
  70816. * @param onError is a callback called if an error occurs
  70817. */
  70818. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70819. /**
  70820. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70821. * This can be used with failed tasks that have the reason for failure fixed.
  70822. */
  70823. reset(): void;
  70824. private onErrorCallback;
  70825. private onDoneCallback;
  70826. }
  70827. /**
  70828. * Define the interface used by progress events raised during assets loading
  70829. */
  70830. export interface IAssetsProgressEvent {
  70831. /**
  70832. * Defines the number of remaining tasks to process
  70833. */
  70834. remainingCount: number;
  70835. /**
  70836. * Defines the total number of tasks
  70837. */
  70838. totalCount: number;
  70839. /**
  70840. * Defines the task that was just processed
  70841. */
  70842. task: AbstractAssetTask;
  70843. }
  70844. /**
  70845. * Class used to share progress information about assets loading
  70846. */
  70847. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70848. /**
  70849. * Defines the number of remaining tasks to process
  70850. */
  70851. remainingCount: number;
  70852. /**
  70853. * Defines the total number of tasks
  70854. */
  70855. totalCount: number;
  70856. /**
  70857. * Defines the task that was just processed
  70858. */
  70859. task: AbstractAssetTask;
  70860. /**
  70861. * Creates a AssetsProgressEvent
  70862. * @param remainingCount defines the number of remaining tasks to process
  70863. * @param totalCount defines the total number of tasks
  70864. * @param task defines the task that was just processed
  70865. */
  70866. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70867. }
  70868. /**
  70869. * Define a task used by AssetsManager to load meshes
  70870. */
  70871. export class MeshAssetTask extends AbstractAssetTask {
  70872. /**
  70873. * Defines the name of the task
  70874. */
  70875. name: string;
  70876. /**
  70877. * Defines the list of mesh's names you want to load
  70878. */
  70879. meshesNames: any;
  70880. /**
  70881. * Defines the root url to use as a base to load your meshes and associated resources
  70882. */
  70883. rootUrl: string;
  70884. /**
  70885. * Defines the filename or File of the scene to load from
  70886. */
  70887. sceneFilename: string | File;
  70888. /**
  70889. * Gets the list of loaded meshes
  70890. */
  70891. loadedMeshes: Array<AbstractMesh>;
  70892. /**
  70893. * Gets the list of loaded particle systems
  70894. */
  70895. loadedParticleSystems: Array<IParticleSystem>;
  70896. /**
  70897. * Gets the list of loaded skeletons
  70898. */
  70899. loadedSkeletons: Array<Skeleton>;
  70900. /**
  70901. * Gets the list of loaded animation groups
  70902. */
  70903. loadedAnimationGroups: Array<AnimationGroup>;
  70904. /**
  70905. * Callback called when the task is successful
  70906. */
  70907. onSuccess: (task: MeshAssetTask) => void;
  70908. /**
  70909. * Callback called when the task is successful
  70910. */
  70911. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70912. /**
  70913. * Creates a new MeshAssetTask
  70914. * @param name defines the name of the task
  70915. * @param meshesNames defines the list of mesh's names you want to load
  70916. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70917. * @param sceneFilename defines the filename or File of the scene to load from
  70918. */
  70919. constructor(
  70920. /**
  70921. * Defines the name of the task
  70922. */
  70923. name: string,
  70924. /**
  70925. * Defines the list of mesh's names you want to load
  70926. */
  70927. meshesNames: any,
  70928. /**
  70929. * Defines the root url to use as a base to load your meshes and associated resources
  70930. */
  70931. rootUrl: string,
  70932. /**
  70933. * Defines the filename or File of the scene to load from
  70934. */
  70935. sceneFilename: string | File);
  70936. /**
  70937. * Execute the current task
  70938. * @param scene defines the scene where you want your assets to be loaded
  70939. * @param onSuccess is a callback called when the task is successfully executed
  70940. * @param onError is a callback called if an error occurs
  70941. */
  70942. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70943. }
  70944. /**
  70945. * Define a task used by AssetsManager to load text content
  70946. */
  70947. export class TextFileAssetTask extends AbstractAssetTask {
  70948. /**
  70949. * Defines the name of the task
  70950. */
  70951. name: string;
  70952. /**
  70953. * Defines the location of the file to load
  70954. */
  70955. url: string;
  70956. /**
  70957. * Gets the loaded text string
  70958. */
  70959. text: string;
  70960. /**
  70961. * Callback called when the task is successful
  70962. */
  70963. onSuccess: (task: TextFileAssetTask) => void;
  70964. /**
  70965. * Callback called when the task is successful
  70966. */
  70967. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70968. /**
  70969. * Creates a new TextFileAssetTask object
  70970. * @param name defines the name of the task
  70971. * @param url defines the location of the file to load
  70972. */
  70973. constructor(
  70974. /**
  70975. * Defines the name of the task
  70976. */
  70977. name: string,
  70978. /**
  70979. * Defines the location of the file to load
  70980. */
  70981. url: string);
  70982. /**
  70983. * Execute the current task
  70984. * @param scene defines the scene where you want your assets to be loaded
  70985. * @param onSuccess is a callback called when the task is successfully executed
  70986. * @param onError is a callback called if an error occurs
  70987. */
  70988. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70989. }
  70990. /**
  70991. * Define a task used by AssetsManager to load binary data
  70992. */
  70993. export class BinaryFileAssetTask extends AbstractAssetTask {
  70994. /**
  70995. * Defines the name of the task
  70996. */
  70997. name: string;
  70998. /**
  70999. * Defines the location of the file to load
  71000. */
  71001. url: string;
  71002. /**
  71003. * Gets the lodaded data (as an array buffer)
  71004. */
  71005. data: ArrayBuffer;
  71006. /**
  71007. * Callback called when the task is successful
  71008. */
  71009. onSuccess: (task: BinaryFileAssetTask) => void;
  71010. /**
  71011. * Callback called when the task is successful
  71012. */
  71013. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71014. /**
  71015. * Creates a new BinaryFileAssetTask object
  71016. * @param name defines the name of the new task
  71017. * @param url defines the location of the file to load
  71018. */
  71019. constructor(
  71020. /**
  71021. * Defines the name of the task
  71022. */
  71023. name: string,
  71024. /**
  71025. * Defines the location of the file to load
  71026. */
  71027. url: string);
  71028. /**
  71029. * Execute the current task
  71030. * @param scene defines the scene where you want your assets to be loaded
  71031. * @param onSuccess is a callback called when the task is successfully executed
  71032. * @param onError is a callback called if an error occurs
  71033. */
  71034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71035. }
  71036. /**
  71037. * Define a task used by AssetsManager to load images
  71038. */
  71039. export class ImageAssetTask extends AbstractAssetTask {
  71040. /**
  71041. * Defines the name of the task
  71042. */
  71043. name: string;
  71044. /**
  71045. * Defines the location of the image to load
  71046. */
  71047. url: string;
  71048. /**
  71049. * Gets the loaded images
  71050. */
  71051. image: HTMLImageElement;
  71052. /**
  71053. * Callback called when the task is successful
  71054. */
  71055. onSuccess: (task: ImageAssetTask) => void;
  71056. /**
  71057. * Callback called when the task is successful
  71058. */
  71059. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71060. /**
  71061. * Creates a new ImageAssetTask
  71062. * @param name defines the name of the task
  71063. * @param url defines the location of the image to load
  71064. */
  71065. constructor(
  71066. /**
  71067. * Defines the name of the task
  71068. */
  71069. name: string,
  71070. /**
  71071. * Defines the location of the image to load
  71072. */
  71073. url: string);
  71074. /**
  71075. * Execute the current task
  71076. * @param scene defines the scene where you want your assets to be loaded
  71077. * @param onSuccess is a callback called when the task is successfully executed
  71078. * @param onError is a callback called if an error occurs
  71079. */
  71080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71081. }
  71082. /**
  71083. * Defines the interface used by texture loading tasks
  71084. */
  71085. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71086. /**
  71087. * Gets the loaded texture
  71088. */
  71089. texture: TEX;
  71090. }
  71091. /**
  71092. * Define a task used by AssetsManager to load 2D textures
  71093. */
  71094. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71095. /**
  71096. * Defines the name of the task
  71097. */
  71098. name: string;
  71099. /**
  71100. * Defines the location of the file to load
  71101. */
  71102. url: string;
  71103. /**
  71104. * Defines if mipmap should not be generated (default is false)
  71105. */
  71106. noMipmap?: boolean | undefined;
  71107. /**
  71108. * Defines if texture must be inverted on Y axis (default is true)
  71109. */
  71110. invertY: boolean;
  71111. /**
  71112. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71113. */
  71114. samplingMode: number;
  71115. /**
  71116. * Gets the loaded texture
  71117. */
  71118. texture: Texture;
  71119. /**
  71120. * Callback called when the task is successful
  71121. */
  71122. onSuccess: (task: TextureAssetTask) => void;
  71123. /**
  71124. * Callback called when the task is successful
  71125. */
  71126. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71127. /**
  71128. * Creates a new TextureAssetTask object
  71129. * @param name defines the name of the task
  71130. * @param url defines the location of the file to load
  71131. * @param noMipmap defines if mipmap should not be generated (default is false)
  71132. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71133. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71134. */
  71135. constructor(
  71136. /**
  71137. * Defines the name of the task
  71138. */
  71139. name: string,
  71140. /**
  71141. * Defines the location of the file to load
  71142. */
  71143. url: string,
  71144. /**
  71145. * Defines if mipmap should not be generated (default is false)
  71146. */
  71147. noMipmap?: boolean | undefined,
  71148. /**
  71149. * Defines if texture must be inverted on Y axis (default is true)
  71150. */
  71151. invertY?: boolean,
  71152. /**
  71153. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71154. */
  71155. samplingMode?: number);
  71156. /**
  71157. * Execute the current task
  71158. * @param scene defines the scene where you want your assets to be loaded
  71159. * @param onSuccess is a callback called when the task is successfully executed
  71160. * @param onError is a callback called if an error occurs
  71161. */
  71162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71163. }
  71164. /**
  71165. * Define a task used by AssetsManager to load cube textures
  71166. */
  71167. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71168. /**
  71169. * Defines the name of the task
  71170. */
  71171. name: string;
  71172. /**
  71173. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71174. */
  71175. url: string;
  71176. /**
  71177. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71178. */
  71179. extensions?: string[] | undefined;
  71180. /**
  71181. * Defines if mipmaps should not be generated (default is false)
  71182. */
  71183. noMipmap?: boolean | undefined;
  71184. /**
  71185. * Defines the explicit list of files (undefined by default)
  71186. */
  71187. files?: string[] | undefined;
  71188. /**
  71189. * Gets the loaded texture
  71190. */
  71191. texture: CubeTexture;
  71192. /**
  71193. * Callback called when the task is successful
  71194. */
  71195. onSuccess: (task: CubeTextureAssetTask) => void;
  71196. /**
  71197. * Callback called when the task is successful
  71198. */
  71199. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71200. /**
  71201. * Creates a new CubeTextureAssetTask
  71202. * @param name defines the name of the task
  71203. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71204. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71205. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71206. * @param files defines the explicit list of files (undefined by default)
  71207. */
  71208. constructor(
  71209. /**
  71210. * Defines the name of the task
  71211. */
  71212. name: string,
  71213. /**
  71214. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71215. */
  71216. url: string,
  71217. /**
  71218. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71219. */
  71220. extensions?: string[] | undefined,
  71221. /**
  71222. * Defines if mipmaps should not be generated (default is false)
  71223. */
  71224. noMipmap?: boolean | undefined,
  71225. /**
  71226. * Defines the explicit list of files (undefined by default)
  71227. */
  71228. files?: string[] | undefined);
  71229. /**
  71230. * Execute the current task
  71231. * @param scene defines the scene where you want your assets to be loaded
  71232. * @param onSuccess is a callback called when the task is successfully executed
  71233. * @param onError is a callback called if an error occurs
  71234. */
  71235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71236. }
  71237. /**
  71238. * Define a task used by AssetsManager to load HDR cube textures
  71239. */
  71240. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71241. /**
  71242. * Defines the name of the task
  71243. */
  71244. name: string;
  71245. /**
  71246. * Defines the location of the file to load
  71247. */
  71248. url: string;
  71249. /**
  71250. * Defines the desired size (the more it increases the longer the generation will be)
  71251. */
  71252. size: number;
  71253. /**
  71254. * Defines if mipmaps should not be generated (default is false)
  71255. */
  71256. noMipmap: boolean;
  71257. /**
  71258. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71259. */
  71260. generateHarmonics: boolean;
  71261. /**
  71262. * 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)
  71263. */
  71264. gammaSpace: boolean;
  71265. /**
  71266. * Internal Use Only
  71267. */
  71268. reserved: boolean;
  71269. /**
  71270. * Gets the loaded texture
  71271. */
  71272. texture: HDRCubeTexture;
  71273. /**
  71274. * Callback called when the task is successful
  71275. */
  71276. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71277. /**
  71278. * Callback called when the task is successful
  71279. */
  71280. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71281. /**
  71282. * Creates a new HDRCubeTextureAssetTask object
  71283. * @param name defines the name of the task
  71284. * @param url defines the location of the file to load
  71285. * @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.
  71286. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71287. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71288. * @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)
  71289. * @param reserved Internal use only
  71290. */
  71291. constructor(
  71292. /**
  71293. * Defines the name of the task
  71294. */
  71295. name: string,
  71296. /**
  71297. * Defines the location of the file to load
  71298. */
  71299. url: string,
  71300. /**
  71301. * Defines the desired size (the more it increases the longer the generation will be)
  71302. */
  71303. size: number,
  71304. /**
  71305. * Defines if mipmaps should not be generated (default is false)
  71306. */
  71307. noMipmap?: boolean,
  71308. /**
  71309. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71310. */
  71311. generateHarmonics?: boolean,
  71312. /**
  71313. * 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)
  71314. */
  71315. gammaSpace?: boolean,
  71316. /**
  71317. * Internal Use Only
  71318. */
  71319. reserved?: boolean);
  71320. /**
  71321. * Execute the current task
  71322. * @param scene defines the scene where you want your assets to be loaded
  71323. * @param onSuccess is a callback called when the task is successfully executed
  71324. * @param onError is a callback called if an error occurs
  71325. */
  71326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71327. }
  71328. /**
  71329. * Define a task used by AssetsManager to load Equirectangular cube textures
  71330. */
  71331. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71332. /**
  71333. * Defines the name of the task
  71334. */
  71335. name: string;
  71336. /**
  71337. * Defines the location of the file to load
  71338. */
  71339. url: string;
  71340. /**
  71341. * Defines the desired size (the more it increases the longer the generation will be)
  71342. */
  71343. size: number;
  71344. /**
  71345. * Defines if mipmaps should not be generated (default is false)
  71346. */
  71347. noMipmap: boolean;
  71348. /**
  71349. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71350. * but the standard material would require them in Gamma space) (default is true)
  71351. */
  71352. gammaSpace: boolean;
  71353. /**
  71354. * Gets the loaded texture
  71355. */
  71356. texture: EquiRectangularCubeTexture;
  71357. /**
  71358. * Callback called when the task is successful
  71359. */
  71360. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71361. /**
  71362. * Callback called when the task is successful
  71363. */
  71364. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71365. /**
  71366. * Creates a new EquiRectangularCubeTextureAssetTask object
  71367. * @param name defines the name of the task
  71368. * @param url defines the location of the file to load
  71369. * @param size defines the desired size (the more it increases the longer the generation will be)
  71370. * If the size is omitted this implies you are using a preprocessed cubemap.
  71371. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71372. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71373. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71374. * (default is true)
  71375. */
  71376. constructor(
  71377. /**
  71378. * Defines the name of the task
  71379. */
  71380. name: string,
  71381. /**
  71382. * Defines the location of the file to load
  71383. */
  71384. url: string,
  71385. /**
  71386. * Defines the desired size (the more it increases the longer the generation will be)
  71387. */
  71388. size: number,
  71389. /**
  71390. * Defines if mipmaps should not be generated (default is false)
  71391. */
  71392. noMipmap?: boolean,
  71393. /**
  71394. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71395. * but the standard material would require them in Gamma space) (default is true)
  71396. */
  71397. gammaSpace?: boolean);
  71398. /**
  71399. * Execute the current task
  71400. * @param scene defines the scene where you want your assets to be loaded
  71401. * @param onSuccess is a callback called when the task is successfully executed
  71402. * @param onError is a callback called if an error occurs
  71403. */
  71404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71405. }
  71406. /**
  71407. * This class can be used to easily import assets into a scene
  71408. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71409. */
  71410. export class AssetsManager {
  71411. private _scene;
  71412. private _isLoading;
  71413. protected _tasks: AbstractAssetTask[];
  71414. protected _waitingTasksCount: number;
  71415. protected _totalTasksCount: number;
  71416. /**
  71417. * Callback called when all tasks are processed
  71418. */
  71419. onFinish: (tasks: AbstractAssetTask[]) => void;
  71420. /**
  71421. * Callback called when a task is successful
  71422. */
  71423. onTaskSuccess: (task: AbstractAssetTask) => void;
  71424. /**
  71425. * Callback called when a task had an error
  71426. */
  71427. onTaskError: (task: AbstractAssetTask) => void;
  71428. /**
  71429. * Callback called when a task is done (whatever the result is)
  71430. */
  71431. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71432. /**
  71433. * Observable called when all tasks are processed
  71434. */
  71435. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71436. /**
  71437. * Observable called when a task had an error
  71438. */
  71439. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71440. /**
  71441. * Observable called when all tasks were executed
  71442. */
  71443. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71444. /**
  71445. * Observable called when a task is done (whatever the result is)
  71446. */
  71447. onProgressObservable: Observable<IAssetsProgressEvent>;
  71448. /**
  71449. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71450. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71451. */
  71452. useDefaultLoadingScreen: boolean;
  71453. /**
  71454. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71455. * when all assets have been downloaded.
  71456. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71457. */
  71458. autoHideLoadingUI: boolean;
  71459. /**
  71460. * Creates a new AssetsManager
  71461. * @param scene defines the scene to work on
  71462. */
  71463. constructor(scene: Scene);
  71464. /**
  71465. * Add a MeshAssetTask to the list of active tasks
  71466. * @param taskName defines the name of the new task
  71467. * @param meshesNames defines the name of meshes to load
  71468. * @param rootUrl defines the root url to use to locate files
  71469. * @param sceneFilename defines the filename of the scene file
  71470. * @returns a new MeshAssetTask object
  71471. */
  71472. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71473. /**
  71474. * Add a TextFileAssetTask to the list of active tasks
  71475. * @param taskName defines the name of the new task
  71476. * @param url defines the url of the file to load
  71477. * @returns a new TextFileAssetTask object
  71478. */
  71479. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71480. /**
  71481. * Add a BinaryFileAssetTask to the list of active tasks
  71482. * @param taskName defines the name of the new task
  71483. * @param url defines the url of the file to load
  71484. * @returns a new BinaryFileAssetTask object
  71485. */
  71486. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71487. /**
  71488. * Add a ImageAssetTask to the list of active tasks
  71489. * @param taskName defines the name of the new task
  71490. * @param url defines the url of the file to load
  71491. * @returns a new ImageAssetTask object
  71492. */
  71493. addImageTask(taskName: string, url: string): ImageAssetTask;
  71494. /**
  71495. * Add a TextureAssetTask to the list of active tasks
  71496. * @param taskName defines the name of the new task
  71497. * @param url defines the url of the file to load
  71498. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71499. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71500. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71501. * @returns a new TextureAssetTask object
  71502. */
  71503. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71504. /**
  71505. * Add a CubeTextureAssetTask to the list of active tasks
  71506. * @param taskName defines the name of the new task
  71507. * @param url defines the url of the file to load
  71508. * @param extensions defines the extension to use to load the cube map (can be null)
  71509. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71510. * @param files defines the list of files to load (can be null)
  71511. * @returns a new CubeTextureAssetTask object
  71512. */
  71513. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71514. /**
  71515. *
  71516. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71517. * @param taskName defines the name of the new task
  71518. * @param url defines the url of the file to load
  71519. * @param size defines the size you want for the cubemap (can be null)
  71520. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71521. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71522. * @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)
  71523. * @param reserved Internal use only
  71524. * @returns a new HDRCubeTextureAssetTask object
  71525. */
  71526. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71527. /**
  71528. *
  71529. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71530. * @param taskName defines the name of the new task
  71531. * @param url defines the url of the file to load
  71532. * @param size defines the size you want for the cubemap (can be null)
  71533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71534. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71535. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71536. * @returns a new EquiRectangularCubeTextureAssetTask object
  71537. */
  71538. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71539. /**
  71540. * Remove a task from the assets manager.
  71541. * @param task the task to remove
  71542. */
  71543. removeTask(task: AbstractAssetTask): void;
  71544. private _decreaseWaitingTasksCount;
  71545. private _runTask;
  71546. /**
  71547. * Reset the AssetsManager and remove all tasks
  71548. * @return the current instance of the AssetsManager
  71549. */
  71550. reset(): AssetsManager;
  71551. /**
  71552. * Start the loading process
  71553. * @return the current instance of the AssetsManager
  71554. */
  71555. load(): AssetsManager;
  71556. /**
  71557. * Start the loading process as an async operation
  71558. * @return a promise returning the list of failed tasks
  71559. */
  71560. loadAsync(): Promise<void>;
  71561. }
  71562. }
  71563. declare module BABYLON {
  71564. /**
  71565. * Wrapper class for promise with external resolve and reject.
  71566. */
  71567. export class Deferred<T> {
  71568. /**
  71569. * The promise associated with this deferred object.
  71570. */
  71571. readonly promise: Promise<T>;
  71572. private _resolve;
  71573. private _reject;
  71574. /**
  71575. * The resolve method of the promise associated with this deferred object.
  71576. */
  71577. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71578. /**
  71579. * The reject method of the promise associated with this deferred object.
  71580. */
  71581. get reject(): (reason?: any) => void;
  71582. /**
  71583. * Constructor for this deferred object.
  71584. */
  71585. constructor();
  71586. }
  71587. }
  71588. declare module BABYLON {
  71589. /**
  71590. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71591. */
  71592. export class MeshExploder {
  71593. private _centerMesh;
  71594. private _meshes;
  71595. private _meshesOrigins;
  71596. private _toCenterVectors;
  71597. private _scaledDirection;
  71598. private _newPosition;
  71599. private _centerPosition;
  71600. /**
  71601. * Explodes meshes from a center mesh.
  71602. * @param meshes The meshes to explode.
  71603. * @param centerMesh The mesh to be center of explosion.
  71604. */
  71605. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71606. private _setCenterMesh;
  71607. /**
  71608. * Get class name
  71609. * @returns "MeshExploder"
  71610. */
  71611. getClassName(): string;
  71612. /**
  71613. * "Exploded meshes"
  71614. * @returns Array of meshes with the centerMesh at index 0.
  71615. */
  71616. getMeshes(): Array<Mesh>;
  71617. /**
  71618. * Explodes meshes giving a specific direction
  71619. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71620. */
  71621. explode(direction?: number): void;
  71622. }
  71623. }
  71624. declare module BABYLON {
  71625. /**
  71626. * Class used to help managing file picking and drag'n'drop
  71627. */
  71628. export class FilesInput {
  71629. /**
  71630. * List of files ready to be loaded
  71631. */
  71632. static get FilesToLoad(): {
  71633. [key: string]: File;
  71634. };
  71635. /**
  71636. * Callback called when a file is processed
  71637. */
  71638. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71639. private _engine;
  71640. private _currentScene;
  71641. private _sceneLoadedCallback;
  71642. private _progressCallback;
  71643. private _additionalRenderLoopLogicCallback;
  71644. private _textureLoadingCallback;
  71645. private _startingProcessingFilesCallback;
  71646. private _onReloadCallback;
  71647. private _errorCallback;
  71648. private _elementToMonitor;
  71649. private _sceneFileToLoad;
  71650. private _filesToLoad;
  71651. /**
  71652. * Creates a new FilesInput
  71653. * @param engine defines the rendering engine
  71654. * @param scene defines the hosting scene
  71655. * @param sceneLoadedCallback callback called when scene is loaded
  71656. * @param progressCallback callback called to track progress
  71657. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71658. * @param textureLoadingCallback callback called when a texture is loading
  71659. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71660. * @param onReloadCallback callback called when a reload is requested
  71661. * @param errorCallback callback call if an error occurs
  71662. */
  71663. 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);
  71664. private _dragEnterHandler;
  71665. private _dragOverHandler;
  71666. private _dropHandler;
  71667. /**
  71668. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71669. * @param elementToMonitor defines the DOM element to track
  71670. */
  71671. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71672. /**
  71673. * Release all associated resources
  71674. */
  71675. dispose(): void;
  71676. private renderFunction;
  71677. private drag;
  71678. private drop;
  71679. private _traverseFolder;
  71680. private _processFiles;
  71681. /**
  71682. * Load files from a drop event
  71683. * @param event defines the drop event to use as source
  71684. */
  71685. loadFiles(event: any): void;
  71686. private _processReload;
  71687. /**
  71688. * Reload the current scene from the loaded files
  71689. */
  71690. reload(): void;
  71691. }
  71692. }
  71693. declare module BABYLON {
  71694. /**
  71695. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71697. */
  71698. export class SceneOptimization {
  71699. /**
  71700. * Defines the priority of this optimization (0 by default which means first in the list)
  71701. */
  71702. priority: number;
  71703. /**
  71704. * Gets a string describing the action executed by the current optimization
  71705. * @returns description string
  71706. */
  71707. getDescription(): string;
  71708. /**
  71709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71710. * @param scene defines the current scene where to apply this optimization
  71711. * @param optimizer defines the current optimizer
  71712. * @returns true if everything that can be done was applied
  71713. */
  71714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71715. /**
  71716. * Creates the SceneOptimization object
  71717. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71718. * @param desc defines the description associated with the optimization
  71719. */
  71720. constructor(
  71721. /**
  71722. * Defines the priority of this optimization (0 by default which means first in the list)
  71723. */
  71724. priority?: number);
  71725. }
  71726. /**
  71727. * Defines an optimization used to reduce the size of render target textures
  71728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71729. */
  71730. export class TextureOptimization extends SceneOptimization {
  71731. /**
  71732. * Defines the priority of this optimization (0 by default which means first in the list)
  71733. */
  71734. priority: number;
  71735. /**
  71736. * 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
  71737. */
  71738. maximumSize: number;
  71739. /**
  71740. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71741. */
  71742. step: number;
  71743. /**
  71744. * Gets a string describing the action executed by the current optimization
  71745. * @returns description string
  71746. */
  71747. getDescription(): string;
  71748. /**
  71749. * Creates the TextureOptimization object
  71750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71751. * @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
  71752. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71753. */
  71754. constructor(
  71755. /**
  71756. * Defines the priority of this optimization (0 by default which means first in the list)
  71757. */
  71758. priority?: number,
  71759. /**
  71760. * 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
  71761. */
  71762. maximumSize?: number,
  71763. /**
  71764. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71765. */
  71766. step?: number);
  71767. /**
  71768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71769. * @param scene defines the current scene where to apply this optimization
  71770. * @param optimizer defines the current optimizer
  71771. * @returns true if everything that can be done was applied
  71772. */
  71773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71774. }
  71775. /**
  71776. * Defines an optimization used to increase or decrease the rendering resolution
  71777. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71778. */
  71779. export class HardwareScalingOptimization extends SceneOptimization {
  71780. /**
  71781. * Defines the priority of this optimization (0 by default which means first in the list)
  71782. */
  71783. priority: number;
  71784. /**
  71785. * Defines the maximum scale to use (2 by default)
  71786. */
  71787. maximumScale: number;
  71788. /**
  71789. * Defines the step to use between two passes (0.5 by default)
  71790. */
  71791. step: number;
  71792. private _currentScale;
  71793. private _directionOffset;
  71794. /**
  71795. * Gets a string describing the action executed by the current optimization
  71796. * @return description string
  71797. */
  71798. getDescription(): string;
  71799. /**
  71800. * Creates the HardwareScalingOptimization object
  71801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71802. * @param maximumScale defines the maximum scale to use (2 by default)
  71803. * @param step defines the step to use between two passes (0.5 by default)
  71804. */
  71805. constructor(
  71806. /**
  71807. * Defines the priority of this optimization (0 by default which means first in the list)
  71808. */
  71809. priority?: number,
  71810. /**
  71811. * Defines the maximum scale to use (2 by default)
  71812. */
  71813. maximumScale?: number,
  71814. /**
  71815. * Defines the step to use between two passes (0.5 by default)
  71816. */
  71817. step?: number);
  71818. /**
  71819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71820. * @param scene defines the current scene where to apply this optimization
  71821. * @param optimizer defines the current optimizer
  71822. * @returns true if everything that can be done was applied
  71823. */
  71824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71825. }
  71826. /**
  71827. * Defines an optimization used to remove shadows
  71828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71829. */
  71830. export class ShadowsOptimization extends SceneOptimization {
  71831. /**
  71832. * Gets a string describing the action executed by the current optimization
  71833. * @return description string
  71834. */
  71835. getDescription(): string;
  71836. /**
  71837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71838. * @param scene defines the current scene where to apply this optimization
  71839. * @param optimizer defines the current optimizer
  71840. * @returns true if everything that can be done was applied
  71841. */
  71842. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71843. }
  71844. /**
  71845. * Defines an optimization used to turn post-processes off
  71846. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71847. */
  71848. export class PostProcessesOptimization extends SceneOptimization {
  71849. /**
  71850. * Gets a string describing the action executed by the current optimization
  71851. * @return description string
  71852. */
  71853. getDescription(): string;
  71854. /**
  71855. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71856. * @param scene defines the current scene where to apply this optimization
  71857. * @param optimizer defines the current optimizer
  71858. * @returns true if everything that can be done was applied
  71859. */
  71860. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71861. }
  71862. /**
  71863. * Defines an optimization used to turn lens flares off
  71864. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71865. */
  71866. export class LensFlaresOptimization extends SceneOptimization {
  71867. /**
  71868. * Gets a string describing the action executed by the current optimization
  71869. * @return description string
  71870. */
  71871. getDescription(): string;
  71872. /**
  71873. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71874. * @param scene defines the current scene where to apply this optimization
  71875. * @param optimizer defines the current optimizer
  71876. * @returns true if everything that can be done was applied
  71877. */
  71878. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71879. }
  71880. /**
  71881. * Defines an optimization based on user defined callback.
  71882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71883. */
  71884. export class CustomOptimization extends SceneOptimization {
  71885. /**
  71886. * Callback called to apply the custom optimization.
  71887. */
  71888. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71889. /**
  71890. * Callback called to get custom description
  71891. */
  71892. onGetDescription: () => string;
  71893. /**
  71894. * Gets a string describing the action executed by the current optimization
  71895. * @returns description string
  71896. */
  71897. getDescription(): string;
  71898. /**
  71899. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71900. * @param scene defines the current scene where to apply this optimization
  71901. * @param optimizer defines the current optimizer
  71902. * @returns true if everything that can be done was applied
  71903. */
  71904. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71905. }
  71906. /**
  71907. * Defines an optimization used to turn particles off
  71908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71909. */
  71910. export class ParticlesOptimization extends SceneOptimization {
  71911. /**
  71912. * Gets a string describing the action executed by the current optimization
  71913. * @return description string
  71914. */
  71915. getDescription(): string;
  71916. /**
  71917. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71918. * @param scene defines the current scene where to apply this optimization
  71919. * @param optimizer defines the current optimizer
  71920. * @returns true if everything that can be done was applied
  71921. */
  71922. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71923. }
  71924. /**
  71925. * Defines an optimization used to turn render targets off
  71926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71927. */
  71928. export class RenderTargetsOptimization extends SceneOptimization {
  71929. /**
  71930. * Gets a string describing the action executed by the current optimization
  71931. * @return description string
  71932. */
  71933. getDescription(): string;
  71934. /**
  71935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71936. * @param scene defines the current scene where to apply this optimization
  71937. * @param optimizer defines the current optimizer
  71938. * @returns true if everything that can be done was applied
  71939. */
  71940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71941. }
  71942. /**
  71943. * Defines an optimization used to merge meshes with compatible materials
  71944. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71945. */
  71946. export class MergeMeshesOptimization extends SceneOptimization {
  71947. private static _UpdateSelectionTree;
  71948. /**
  71949. * Gets or sets a boolean which defines if optimization octree has to be updated
  71950. */
  71951. static get UpdateSelectionTree(): boolean;
  71952. /**
  71953. * Gets or sets a boolean which defines if optimization octree has to be updated
  71954. */
  71955. static set UpdateSelectionTree(value: boolean);
  71956. /**
  71957. * Gets a string describing the action executed by the current optimization
  71958. * @return description string
  71959. */
  71960. getDescription(): string;
  71961. private _canBeMerged;
  71962. /**
  71963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71964. * @param scene defines the current scene where to apply this optimization
  71965. * @param optimizer defines the current optimizer
  71966. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71967. * @returns true if everything that can be done was applied
  71968. */
  71969. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71970. }
  71971. /**
  71972. * Defines a list of options used by SceneOptimizer
  71973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71974. */
  71975. export class SceneOptimizerOptions {
  71976. /**
  71977. * Defines the target frame rate to reach (60 by default)
  71978. */
  71979. targetFrameRate: number;
  71980. /**
  71981. * Defines the interval between two checkes (2000ms by default)
  71982. */
  71983. trackerDuration: number;
  71984. /**
  71985. * Gets the list of optimizations to apply
  71986. */
  71987. optimizations: SceneOptimization[];
  71988. /**
  71989. * Creates a new list of options used by SceneOptimizer
  71990. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71991. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71992. */
  71993. constructor(
  71994. /**
  71995. * Defines the target frame rate to reach (60 by default)
  71996. */
  71997. targetFrameRate?: number,
  71998. /**
  71999. * Defines the interval between two checkes (2000ms by default)
  72000. */
  72001. trackerDuration?: number);
  72002. /**
  72003. * Add a new optimization
  72004. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72005. * @returns the current SceneOptimizerOptions
  72006. */
  72007. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72008. /**
  72009. * Add a new custom optimization
  72010. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72011. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72013. * @returns the current SceneOptimizerOptions
  72014. */
  72015. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72016. /**
  72017. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72018. * @param targetFrameRate defines the target frame rate (60 by default)
  72019. * @returns a SceneOptimizerOptions object
  72020. */
  72021. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72022. /**
  72023. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72024. * @param targetFrameRate defines the target frame rate (60 by default)
  72025. * @returns a SceneOptimizerOptions object
  72026. */
  72027. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72028. /**
  72029. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72030. * @param targetFrameRate defines the target frame rate (60 by default)
  72031. * @returns a SceneOptimizerOptions object
  72032. */
  72033. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72034. }
  72035. /**
  72036. * Class used to run optimizations in order to reach a target frame rate
  72037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72038. */
  72039. export class SceneOptimizer implements IDisposable {
  72040. private _isRunning;
  72041. private _options;
  72042. private _scene;
  72043. private _currentPriorityLevel;
  72044. private _targetFrameRate;
  72045. private _trackerDuration;
  72046. private _currentFrameRate;
  72047. private _sceneDisposeObserver;
  72048. private _improvementMode;
  72049. /**
  72050. * Defines an observable called when the optimizer reaches the target frame rate
  72051. */
  72052. onSuccessObservable: Observable<SceneOptimizer>;
  72053. /**
  72054. * Defines an observable called when the optimizer enables an optimization
  72055. */
  72056. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72057. /**
  72058. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72059. */
  72060. onFailureObservable: Observable<SceneOptimizer>;
  72061. /**
  72062. * Gets a boolean indicating if the optimizer is in improvement mode
  72063. */
  72064. get isInImprovementMode(): boolean;
  72065. /**
  72066. * Gets the current priority level (0 at start)
  72067. */
  72068. get currentPriorityLevel(): number;
  72069. /**
  72070. * Gets the current frame rate checked by the SceneOptimizer
  72071. */
  72072. get currentFrameRate(): number;
  72073. /**
  72074. * Gets or sets the current target frame rate (60 by default)
  72075. */
  72076. get targetFrameRate(): number;
  72077. /**
  72078. * Gets or sets the current target frame rate (60 by default)
  72079. */
  72080. set targetFrameRate(value: number);
  72081. /**
  72082. * Gets or sets the current interval between two checks (every 2000ms by default)
  72083. */
  72084. get trackerDuration(): number;
  72085. /**
  72086. * Gets or sets the current interval between two checks (every 2000ms by default)
  72087. */
  72088. set trackerDuration(value: number);
  72089. /**
  72090. * Gets the list of active optimizations
  72091. */
  72092. get optimizations(): SceneOptimization[];
  72093. /**
  72094. * Creates a new SceneOptimizer
  72095. * @param scene defines the scene to work on
  72096. * @param options defines the options to use with the SceneOptimizer
  72097. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72098. * @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)
  72099. */
  72100. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72101. /**
  72102. * Stops the current optimizer
  72103. */
  72104. stop(): void;
  72105. /**
  72106. * Reset the optimizer to initial step (current priority level = 0)
  72107. */
  72108. reset(): void;
  72109. /**
  72110. * Start the optimizer. By default it will try to reach a specific framerate
  72111. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72112. */
  72113. start(): void;
  72114. private _checkCurrentState;
  72115. /**
  72116. * Release all resources
  72117. */
  72118. dispose(): void;
  72119. /**
  72120. * Helper function to create a SceneOptimizer with one single line of code
  72121. * @param scene defines the scene to work on
  72122. * @param options defines the options to use with the SceneOptimizer
  72123. * @param onSuccess defines a callback to call on success
  72124. * @param onFailure defines a callback to call on failure
  72125. * @returns the new SceneOptimizer object
  72126. */
  72127. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72128. }
  72129. }
  72130. declare module BABYLON {
  72131. /**
  72132. * Class used to serialize a scene into a string
  72133. */
  72134. export class SceneSerializer {
  72135. /**
  72136. * Clear cache used by a previous serialization
  72137. */
  72138. static ClearCache(): void;
  72139. /**
  72140. * Serialize a scene into a JSON compatible object
  72141. * @param scene defines the scene to serialize
  72142. * @returns a JSON compatible object
  72143. */
  72144. static Serialize(scene: Scene): any;
  72145. /**
  72146. * Serialize a mesh into a JSON compatible object
  72147. * @param toSerialize defines the mesh to serialize
  72148. * @param withParents defines if parents must be serialized as well
  72149. * @param withChildren defines if children must be serialized as well
  72150. * @returns a JSON compatible object
  72151. */
  72152. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72153. }
  72154. }
  72155. declare module BABYLON {
  72156. /**
  72157. * Class used to host texture specific utilities
  72158. */
  72159. export class TextureTools {
  72160. /**
  72161. * Uses the GPU to create a copy texture rescaled at a given size
  72162. * @param texture Texture to copy from
  72163. * @param width defines the desired width
  72164. * @param height defines the desired height
  72165. * @param useBilinearMode defines if bilinear mode has to be used
  72166. * @return the generated texture
  72167. */
  72168. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72169. }
  72170. }
  72171. declare module BABYLON {
  72172. /**
  72173. * This represents the different options available for the video capture.
  72174. */
  72175. export interface VideoRecorderOptions {
  72176. /** Defines the mime type of the video. */
  72177. mimeType: string;
  72178. /** Defines the FPS the video should be recorded at. */
  72179. fps: number;
  72180. /** Defines the chunk size for the recording data. */
  72181. recordChunckSize: number;
  72182. /** The audio tracks to attach to the recording. */
  72183. audioTracks?: MediaStreamTrack[];
  72184. }
  72185. /**
  72186. * This can help with recording videos from BabylonJS.
  72187. * This is based on the available WebRTC functionalities of the browser.
  72188. *
  72189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72190. */
  72191. export class VideoRecorder {
  72192. private static readonly _defaultOptions;
  72193. /**
  72194. * Returns whether or not the VideoRecorder is available in your browser.
  72195. * @param engine Defines the Babylon Engine.
  72196. * @returns true if supported otherwise false.
  72197. */
  72198. static IsSupported(engine: Engine): boolean;
  72199. private readonly _options;
  72200. private _canvas;
  72201. private _mediaRecorder;
  72202. private _recordedChunks;
  72203. private _fileName;
  72204. private _resolve;
  72205. private _reject;
  72206. /**
  72207. * True when a recording is already in progress.
  72208. */
  72209. get isRecording(): boolean;
  72210. /**
  72211. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72212. * @param engine Defines the BabylonJS Engine you wish to record.
  72213. * @param options Defines options that can be used to customize the capture.
  72214. */
  72215. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72216. /**
  72217. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72218. */
  72219. stopRecording(): void;
  72220. /**
  72221. * Starts recording the canvas for a max duration specified in parameters.
  72222. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72223. * If null no automatic download will start and you can rely on the promise to get the data back.
  72224. * @param maxDuration Defines the maximum recording time in seconds.
  72225. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72226. * @return A promise callback at the end of the recording with the video data in Blob.
  72227. */
  72228. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72229. /**
  72230. * Releases internal resources used during the recording.
  72231. */
  72232. dispose(): void;
  72233. private _handleDataAvailable;
  72234. private _handleError;
  72235. private _handleStop;
  72236. }
  72237. }
  72238. declare module BABYLON {
  72239. /**
  72240. * Class containing a set of static utilities functions for screenshots
  72241. */
  72242. export class ScreenshotTools {
  72243. /**
  72244. * Captures a screenshot of the current rendering
  72245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72246. * @param engine defines the rendering engine
  72247. * @param camera defines the source camera
  72248. * @param size This parameter can be set to a single number or to an object with the
  72249. * following (optional) properties: precision, width, height. If a single number is passed,
  72250. * it will be used for both width and height. If an object is passed, the screenshot size
  72251. * will be derived from the parameters. The precision property is a multiplier allowing
  72252. * rendering at a higher or lower resolution
  72253. * @param successCallback defines the callback receives a single parameter which contains the
  72254. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72255. * src parameter of an <img> to display it
  72256. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72257. * Check your browser for supported MIME types
  72258. */
  72259. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72260. /**
  72261. * Captures a screenshot of the current rendering
  72262. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72263. * @param engine defines the rendering engine
  72264. * @param camera defines the source camera
  72265. * @param size This parameter can be set to a single number or to an object with the
  72266. * following (optional) properties: precision, width, height. If a single number is passed,
  72267. * it will be used for both width and height. If an object is passed, the screenshot size
  72268. * will be derived from the parameters. The precision property is a multiplier allowing
  72269. * rendering at a higher or lower resolution
  72270. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72271. * Check your browser for supported MIME types
  72272. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72273. * to the src parameter of an <img> to display it
  72274. */
  72275. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72276. /**
  72277. * Generates an image screenshot from the specified camera.
  72278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72279. * @param engine The engine to use for rendering
  72280. * @param camera The camera to use for rendering
  72281. * @param size This parameter can be set to a single number or to an object with the
  72282. * following (optional) properties: precision, width, height. If a single number is passed,
  72283. * it will be used for both width and height. If an object is passed, the screenshot size
  72284. * will be derived from the parameters. The precision property is a multiplier allowing
  72285. * rendering at a higher or lower resolution
  72286. * @param successCallback The callback receives a single parameter which contains the
  72287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72288. * src parameter of an <img> to display it
  72289. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72290. * Check your browser for supported MIME types
  72291. * @param samples Texture samples (default: 1)
  72292. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72293. * @param fileName A name for for the downloaded file.
  72294. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72295. */
  72296. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72297. /**
  72298. * Generates an image screenshot from the specified camera.
  72299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72300. * @param engine The engine to use for rendering
  72301. * @param camera The camera to use for rendering
  72302. * @param size This parameter can be set to a single number or to an object with the
  72303. * following (optional) properties: precision, width, height. If a single number is passed,
  72304. * it will be used for both width and height. If an object is passed, the screenshot size
  72305. * will be derived from the parameters. The precision property is a multiplier allowing
  72306. * rendering at a higher or lower resolution
  72307. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72308. * Check your browser for supported MIME types
  72309. * @param samples Texture samples (default: 1)
  72310. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72311. * @param fileName A name for for the downloaded file.
  72312. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72313. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72314. * to the src parameter of an <img> to display it
  72315. */
  72316. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72317. /**
  72318. * Gets height and width for screenshot size
  72319. * @private
  72320. */
  72321. private static _getScreenshotSize;
  72322. }
  72323. }
  72324. declare module BABYLON {
  72325. /**
  72326. * Interface for a data buffer
  72327. */
  72328. export interface IDataBuffer {
  72329. /**
  72330. * Reads bytes from the data buffer.
  72331. * @param byteOffset The byte offset to read
  72332. * @param byteLength The byte length to read
  72333. * @returns A promise that resolves when the bytes are read
  72334. */
  72335. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72336. /**
  72337. * The byte length of the buffer.
  72338. */
  72339. readonly byteLength: number;
  72340. }
  72341. /**
  72342. * Utility class for reading from a data buffer
  72343. */
  72344. export class DataReader {
  72345. /**
  72346. * The data buffer associated with this data reader.
  72347. */
  72348. readonly buffer: IDataBuffer;
  72349. /**
  72350. * The current byte offset from the beginning of the data buffer.
  72351. */
  72352. byteOffset: number;
  72353. private _dataView;
  72354. private _dataByteOffset;
  72355. /**
  72356. * Constructor
  72357. * @param buffer The buffer to read
  72358. */
  72359. constructor(buffer: IDataBuffer);
  72360. /**
  72361. * Loads the given byte length.
  72362. * @param byteLength The byte length to load
  72363. * @returns A promise that resolves when the load is complete
  72364. */
  72365. loadAsync(byteLength: number): Promise<void>;
  72366. /**
  72367. * Read a unsigned 32-bit integer from the currently loaded data range.
  72368. * @returns The 32-bit integer read
  72369. */
  72370. readUint32(): number;
  72371. /**
  72372. * Read a byte array from the currently loaded data range.
  72373. * @param byteLength The byte length to read
  72374. * @returns The byte array read
  72375. */
  72376. readUint8Array(byteLength: number): Uint8Array;
  72377. /**
  72378. * Read a string from the currently loaded data range.
  72379. * @param byteLength The byte length to read
  72380. * @returns The string read
  72381. */
  72382. readString(byteLength: number): string;
  72383. /**
  72384. * Skips the given byte length the currently loaded data range.
  72385. * @param byteLength The byte length to skip
  72386. */
  72387. skipBytes(byteLength: number): void;
  72388. }
  72389. }
  72390. declare module BABYLON {
  72391. /**
  72392. * Class for storing data to local storage if available or in-memory storage otherwise
  72393. */
  72394. export class DataStorage {
  72395. private static _Storage;
  72396. private static _GetStorage;
  72397. /**
  72398. * Reads a string from the data storage
  72399. * @param key The key to read
  72400. * @param defaultValue The value if the key doesn't exist
  72401. * @returns The string value
  72402. */
  72403. static ReadString(key: string, defaultValue: string): string;
  72404. /**
  72405. * Writes a string to the data storage
  72406. * @param key The key to write
  72407. * @param value The value to write
  72408. */
  72409. static WriteString(key: string, value: string): void;
  72410. /**
  72411. * Reads a boolean from the data storage
  72412. * @param key The key to read
  72413. * @param defaultValue The value if the key doesn't exist
  72414. * @returns The boolean value
  72415. */
  72416. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72417. /**
  72418. * Writes a boolean to the data storage
  72419. * @param key The key to write
  72420. * @param value The value to write
  72421. */
  72422. static WriteBoolean(key: string, value: boolean): void;
  72423. /**
  72424. * Reads a number from the data storage
  72425. * @param key The key to read
  72426. * @param defaultValue The value if the key doesn't exist
  72427. * @returns The number value
  72428. */
  72429. static ReadNumber(key: string, defaultValue: number): number;
  72430. /**
  72431. * Writes a number to the data storage
  72432. * @param key The key to write
  72433. * @param value The value to write
  72434. */
  72435. static WriteNumber(key: string, value: number): void;
  72436. }
  72437. }
  72438. declare module BABYLON {
  72439. /**
  72440. * An interface for all Hit test features
  72441. */
  72442. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72443. /**
  72444. * Triggered when new babylon (transformed) hit test results are available
  72445. */
  72446. onHitTestResultObservable: Observable<T[]>;
  72447. }
  72448. /**
  72449. * Options used for hit testing
  72450. */
  72451. export interface IWebXRLegacyHitTestOptions {
  72452. /**
  72453. * Only test when user interacted with the scene. Default - hit test every frame
  72454. */
  72455. testOnPointerDownOnly?: boolean;
  72456. /**
  72457. * The node to use to transform the local results to world coordinates
  72458. */
  72459. worldParentNode?: TransformNode;
  72460. }
  72461. /**
  72462. * Interface defining the babylon result of raycasting/hit-test
  72463. */
  72464. export interface IWebXRLegacyHitResult {
  72465. /**
  72466. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72467. */
  72468. transformationMatrix: Matrix;
  72469. /**
  72470. * The native hit test result
  72471. */
  72472. xrHitResult: XRHitResult | XRHitTestResult;
  72473. }
  72474. /**
  72475. * The currently-working hit-test module.
  72476. * Hit test (or Ray-casting) is used to interact with the real world.
  72477. * For further information read here - https://github.com/immersive-web/hit-test
  72478. */
  72479. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72480. /**
  72481. * options to use when constructing this feature
  72482. */
  72483. readonly options: IWebXRLegacyHitTestOptions;
  72484. private _direction;
  72485. private _mat;
  72486. private _onSelectEnabled;
  72487. private _origin;
  72488. /**
  72489. * The module's name
  72490. */
  72491. static readonly Name: string;
  72492. /**
  72493. * The (Babylon) version of this module.
  72494. * This is an integer representing the implementation version.
  72495. * This number does not correspond to the WebXR specs version
  72496. */
  72497. static readonly Version: number;
  72498. /**
  72499. * Populated with the last native XR Hit Results
  72500. */
  72501. lastNativeXRHitResults: XRHitResult[];
  72502. /**
  72503. * Triggered when new babylon (transformed) hit test results are available
  72504. */
  72505. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72506. /**
  72507. * Creates a new instance of the (legacy version) hit test feature
  72508. * @param _xrSessionManager an instance of WebXRSessionManager
  72509. * @param options options to use when constructing this feature
  72510. */
  72511. constructor(_xrSessionManager: WebXRSessionManager,
  72512. /**
  72513. * options to use when constructing this feature
  72514. */
  72515. options?: IWebXRLegacyHitTestOptions);
  72516. /**
  72517. * execute a hit test with an XR Ray
  72518. *
  72519. * @param xrSession a native xrSession that will execute this hit test
  72520. * @param xrRay the ray (position and direction) to use for ray-casting
  72521. * @param referenceSpace native XR reference space to use for the hit-test
  72522. * @param filter filter function that will filter the results
  72523. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72524. */
  72525. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72526. /**
  72527. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72528. * @param event the (select) event to use to select with
  72529. * @param referenceSpace the reference space to use for this hit test
  72530. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72531. */
  72532. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72533. /**
  72534. * attach this feature
  72535. * Will usually be called by the features manager
  72536. *
  72537. * @returns true if successful.
  72538. */
  72539. attach(): boolean;
  72540. /**
  72541. * detach this feature.
  72542. * Will usually be called by the features manager
  72543. *
  72544. * @returns true if successful.
  72545. */
  72546. detach(): boolean;
  72547. /**
  72548. * Dispose this feature and all of the resources attached
  72549. */
  72550. dispose(): void;
  72551. protected _onXRFrame(frame: XRFrame): void;
  72552. private _onHitTestResults;
  72553. private _onSelect;
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /**
  72558. * Options used for hit testing (version 2)
  72559. */
  72560. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72561. /**
  72562. * Do not create a permanent hit test. Will usually be used when only
  72563. * transient inputs are needed.
  72564. */
  72565. disablePermanentHitTest?: boolean;
  72566. /**
  72567. * Enable transient (for example touch-based) hit test inspections
  72568. */
  72569. enableTransientHitTest?: boolean;
  72570. /**
  72571. * Offset ray for the permanent hit test
  72572. */
  72573. offsetRay?: Vector3;
  72574. /**
  72575. * Offset ray for the transient hit test
  72576. */
  72577. transientOffsetRay?: Vector3;
  72578. /**
  72579. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72580. */
  72581. useReferenceSpace?: boolean;
  72582. }
  72583. /**
  72584. * Interface defining the babylon result of hit-test
  72585. */
  72586. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72587. /**
  72588. * The input source that generated this hit test (if transient)
  72589. */
  72590. inputSource?: XRInputSource;
  72591. /**
  72592. * Is this a transient hit test
  72593. */
  72594. isTransient?: boolean;
  72595. /**
  72596. * Position of the hit test result
  72597. */
  72598. position: Vector3;
  72599. /**
  72600. * Rotation of the hit test result
  72601. */
  72602. rotationQuaternion: Quaternion;
  72603. /**
  72604. * The native hit test result
  72605. */
  72606. xrHitResult: XRHitTestResult;
  72607. }
  72608. /**
  72609. * The currently-working hit-test module.
  72610. * Hit test (or Ray-casting) is used to interact with the real world.
  72611. * For further information read here - https://github.com/immersive-web/hit-test
  72612. *
  72613. * Tested on chrome (mobile) 80.
  72614. */
  72615. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72616. /**
  72617. * options to use when constructing this feature
  72618. */
  72619. readonly options: IWebXRHitTestOptions;
  72620. private _tmpMat;
  72621. private _tmpPos;
  72622. private _tmpQuat;
  72623. private _transientXrHitTestSource;
  72624. private _xrHitTestSource;
  72625. private initHitTestSource;
  72626. /**
  72627. * The module's name
  72628. */
  72629. static readonly Name: string;
  72630. /**
  72631. * The (Babylon) version of this module.
  72632. * This is an integer representing the implementation version.
  72633. * This number does not correspond to the WebXR specs version
  72634. */
  72635. static readonly Version: number;
  72636. /**
  72637. * When set to true, each hit test will have its own position/rotation objects
  72638. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72639. * the developers will clone them or copy them as they see fit.
  72640. */
  72641. autoCloneTransformation: boolean;
  72642. /**
  72643. * Triggered when new babylon (transformed) hit test results are available
  72644. */
  72645. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72646. /**
  72647. * Use this to temporarily pause hit test checks.
  72648. */
  72649. paused: boolean;
  72650. /**
  72651. * Creates a new instance of the hit test feature
  72652. * @param _xrSessionManager an instance of WebXRSessionManager
  72653. * @param options options to use when constructing this feature
  72654. */
  72655. constructor(_xrSessionManager: WebXRSessionManager,
  72656. /**
  72657. * options to use when constructing this feature
  72658. */
  72659. options?: IWebXRHitTestOptions);
  72660. /**
  72661. * attach this feature
  72662. * Will usually be called by the features manager
  72663. *
  72664. * @returns true if successful.
  72665. */
  72666. attach(): boolean;
  72667. /**
  72668. * detach this feature.
  72669. * Will usually be called by the features manager
  72670. *
  72671. * @returns true if successful.
  72672. */
  72673. detach(): boolean;
  72674. /**
  72675. * Dispose this feature and all of the resources attached
  72676. */
  72677. dispose(): void;
  72678. protected _onXRFrame(frame: XRFrame): void;
  72679. private _processWebXRHitTestResult;
  72680. }
  72681. }
  72682. declare module BABYLON {
  72683. /**
  72684. * Configuration options of the anchor system
  72685. */
  72686. export interface IWebXRAnchorSystemOptions {
  72687. /**
  72688. * a node that will be used to convert local to world coordinates
  72689. */
  72690. worldParentNode?: TransformNode;
  72691. /**
  72692. * If set to true a reference of the created anchors will be kept until the next session starts
  72693. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72694. */
  72695. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72696. }
  72697. /**
  72698. * A babylon container for an XR Anchor
  72699. */
  72700. export interface IWebXRAnchor {
  72701. /**
  72702. * A babylon-assigned ID for this anchor
  72703. */
  72704. id: number;
  72705. /**
  72706. * Transformation matrix to apply to an object attached to this anchor
  72707. */
  72708. transformationMatrix: Matrix;
  72709. /**
  72710. * The native anchor object
  72711. */
  72712. xrAnchor: XRAnchor;
  72713. /**
  72714. * if defined, this object will be constantly updated by the anchor's position and rotation
  72715. */
  72716. attachedNode?: TransformNode;
  72717. }
  72718. /**
  72719. * An implementation of the anchor system for WebXR.
  72720. * For further information see https://github.com/immersive-web/anchors/
  72721. */
  72722. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72723. private _options;
  72724. private _lastFrameDetected;
  72725. private _trackedAnchors;
  72726. private _referenceSpaceForFrameAnchors;
  72727. private _futureAnchors;
  72728. /**
  72729. * The module's name
  72730. */
  72731. static readonly Name: string;
  72732. /**
  72733. * The (Babylon) version of this module.
  72734. * This is an integer representing the implementation version.
  72735. * This number does not correspond to the WebXR specs version
  72736. */
  72737. static readonly Version: number;
  72738. /**
  72739. * Observers registered here will be executed when a new anchor was added to the session
  72740. */
  72741. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72742. /**
  72743. * Observers registered here will be executed when an anchor was removed from the session
  72744. */
  72745. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72746. /**
  72747. * Observers registered here will be executed when an existing anchor updates
  72748. * This can execute N times every frame
  72749. */
  72750. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72751. /**
  72752. * Set the reference space to use for anchor creation, when not using a hit test.
  72753. * Will default to the session's reference space if not defined
  72754. */
  72755. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72756. /**
  72757. * constructs a new anchor system
  72758. * @param _xrSessionManager an instance of WebXRSessionManager
  72759. * @param _options configuration object for this feature
  72760. */
  72761. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72762. private _tmpVector;
  72763. private _tmpQuaternion;
  72764. private _populateTmpTransformation;
  72765. /**
  72766. * Create a new anchor point using a hit test result at a specific point in the scene
  72767. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72768. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72769. *
  72770. * @param hitTestResult The hit test result to use for this anchor creation
  72771. * @param position an optional position offset for this anchor
  72772. * @param rotationQuaternion an optional rotation offset for this anchor
  72773. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72774. */
  72775. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72776. /**
  72777. * Add a new anchor at a specific position and rotation
  72778. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72779. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72780. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72781. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72782. *
  72783. * @param position the position in which to add an anchor
  72784. * @param rotationQuaternion an optional rotation for the anchor transformation
  72785. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72786. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72787. */
  72788. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72789. /**
  72790. * detach this feature.
  72791. * Will usually be called by the features manager
  72792. *
  72793. * @returns true if successful.
  72794. */
  72795. detach(): boolean;
  72796. /**
  72797. * Dispose this feature and all of the resources attached
  72798. */
  72799. dispose(): void;
  72800. protected _onXRFrame(frame: XRFrame): void;
  72801. /**
  72802. * avoiding using Array.find for global support.
  72803. * @param xrAnchor the plane to find in the array
  72804. */
  72805. private _findIndexInAnchorArray;
  72806. private _updateAnchorWithXRFrame;
  72807. private _createAnchorAtTransformation;
  72808. }
  72809. }
  72810. declare module BABYLON {
  72811. /**
  72812. * Options used in the plane detector module
  72813. */
  72814. export interface IWebXRPlaneDetectorOptions {
  72815. /**
  72816. * The node to use to transform the local results to world coordinates
  72817. */
  72818. worldParentNode?: TransformNode;
  72819. /**
  72820. * If set to true a reference of the created planes will be kept until the next session starts
  72821. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72822. */
  72823. doNotRemovePlanesOnSessionEnded?: boolean;
  72824. }
  72825. /**
  72826. * A babylon interface for a WebXR plane.
  72827. * A Plane is actually a polygon, built from N points in space
  72828. *
  72829. * Supported in chrome 79, not supported in canary 81 ATM
  72830. */
  72831. export interface IWebXRPlane {
  72832. /**
  72833. * a babylon-assigned ID for this polygon
  72834. */
  72835. id: number;
  72836. /**
  72837. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72838. */
  72839. polygonDefinition: Array<Vector3>;
  72840. /**
  72841. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72842. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72843. */
  72844. transformationMatrix: Matrix;
  72845. /**
  72846. * the native xr-plane object
  72847. */
  72848. xrPlane: XRPlane;
  72849. }
  72850. /**
  72851. * The plane detector is used to detect planes in the real world when in AR
  72852. * For more information see https://github.com/immersive-web/real-world-geometry/
  72853. */
  72854. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72855. private _options;
  72856. private _detectedPlanes;
  72857. private _enabled;
  72858. private _lastFrameDetected;
  72859. /**
  72860. * The module's name
  72861. */
  72862. static readonly Name: string;
  72863. /**
  72864. * The (Babylon) version of this module.
  72865. * This is an integer representing the implementation version.
  72866. * This number does not correspond to the WebXR specs version
  72867. */
  72868. static readonly Version: number;
  72869. /**
  72870. * Observers registered here will be executed when a new plane was added to the session
  72871. */
  72872. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72873. /**
  72874. * Observers registered here will be executed when a plane is no longer detected in the session
  72875. */
  72876. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72877. /**
  72878. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72879. * This can execute N times every frame
  72880. */
  72881. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72882. /**
  72883. * construct a new Plane Detector
  72884. * @param _xrSessionManager an instance of xr Session manager
  72885. * @param _options configuration to use when constructing this feature
  72886. */
  72887. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72888. /**
  72889. * detach this feature.
  72890. * Will usually be called by the features manager
  72891. *
  72892. * @returns true if successful.
  72893. */
  72894. detach(): boolean;
  72895. /**
  72896. * Dispose this feature and all of the resources attached
  72897. */
  72898. dispose(): void;
  72899. protected _onXRFrame(frame: XRFrame): void;
  72900. private _init;
  72901. private _updatePlaneWithXRPlane;
  72902. /**
  72903. * avoiding using Array.find for global support.
  72904. * @param xrPlane the plane to find in the array
  72905. */
  72906. private findIndexInPlaneArray;
  72907. }
  72908. }
  72909. declare module BABYLON {
  72910. /**
  72911. * Options interface for the background remover plugin
  72912. */
  72913. export interface IWebXRBackgroundRemoverOptions {
  72914. /**
  72915. * Further background meshes to disable when entering AR
  72916. */
  72917. backgroundMeshes?: AbstractMesh[];
  72918. /**
  72919. * flags to configure the removal of the environment helper.
  72920. * If not set, the entire background will be removed. If set, flags should be set as well.
  72921. */
  72922. environmentHelperRemovalFlags?: {
  72923. /**
  72924. * Should the skybox be removed (default false)
  72925. */
  72926. skyBox?: boolean;
  72927. /**
  72928. * Should the ground be removed (default false)
  72929. */
  72930. ground?: boolean;
  72931. };
  72932. /**
  72933. * don't disable the environment helper
  72934. */
  72935. ignoreEnvironmentHelper?: boolean;
  72936. }
  72937. /**
  72938. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72939. */
  72940. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72941. /**
  72942. * read-only options to be used in this module
  72943. */
  72944. readonly options: IWebXRBackgroundRemoverOptions;
  72945. /**
  72946. * The module's name
  72947. */
  72948. static readonly Name: string;
  72949. /**
  72950. * The (Babylon) version of this module.
  72951. * This is an integer representing the implementation version.
  72952. * This number does not correspond to the WebXR specs version
  72953. */
  72954. static readonly Version: number;
  72955. /**
  72956. * registered observers will be triggered when the background state changes
  72957. */
  72958. onBackgroundStateChangedObservable: Observable<boolean>;
  72959. /**
  72960. * constructs a new background remover module
  72961. * @param _xrSessionManager the session manager for this module
  72962. * @param options read-only options to be used in this module
  72963. */
  72964. constructor(_xrSessionManager: WebXRSessionManager,
  72965. /**
  72966. * read-only options to be used in this module
  72967. */
  72968. options?: IWebXRBackgroundRemoverOptions);
  72969. /**
  72970. * attach this feature
  72971. * Will usually be called by the features manager
  72972. *
  72973. * @returns true if successful.
  72974. */
  72975. attach(): boolean;
  72976. /**
  72977. * detach this feature.
  72978. * Will usually be called by the features manager
  72979. *
  72980. * @returns true if successful.
  72981. */
  72982. detach(): boolean;
  72983. /**
  72984. * Dispose this feature and all of the resources attached
  72985. */
  72986. dispose(): void;
  72987. protected _onXRFrame(_xrFrame: XRFrame): void;
  72988. private _setBackgroundState;
  72989. }
  72990. }
  72991. declare module BABYLON {
  72992. /**
  72993. * Options for the controller physics feature
  72994. */
  72995. export class IWebXRControllerPhysicsOptions {
  72996. /**
  72997. * Should the headset get its own impostor
  72998. */
  72999. enableHeadsetImpostor?: boolean;
  73000. /**
  73001. * Optional parameters for the headset impostor
  73002. */
  73003. headsetImpostorParams?: {
  73004. /**
  73005. * The type of impostor to create. Default is sphere
  73006. */
  73007. impostorType: number;
  73008. /**
  73009. * the size of the impostor. Defaults to 10cm
  73010. */
  73011. impostorSize?: number | {
  73012. width: number;
  73013. height: number;
  73014. depth: number;
  73015. };
  73016. /**
  73017. * Friction definitions
  73018. */
  73019. friction?: number;
  73020. /**
  73021. * Restitution
  73022. */
  73023. restitution?: number;
  73024. };
  73025. /**
  73026. * The physics properties of the future impostors
  73027. */
  73028. physicsProperties?: {
  73029. /**
  73030. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73031. * Note that this requires a physics engine that supports mesh impostors!
  73032. */
  73033. useControllerMesh?: boolean;
  73034. /**
  73035. * The type of impostor to create. Default is sphere
  73036. */
  73037. impostorType?: number;
  73038. /**
  73039. * the size of the impostor. Defaults to 10cm
  73040. */
  73041. impostorSize?: number | {
  73042. width: number;
  73043. height: number;
  73044. depth: number;
  73045. };
  73046. /**
  73047. * Friction definitions
  73048. */
  73049. friction?: number;
  73050. /**
  73051. * Restitution
  73052. */
  73053. restitution?: number;
  73054. };
  73055. /**
  73056. * the xr input to use with this pointer selection
  73057. */
  73058. xrInput: WebXRInput;
  73059. }
  73060. /**
  73061. * Add physics impostor to your webxr controllers,
  73062. * including naive calculation of their linear and angular velocity
  73063. */
  73064. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73065. private readonly _options;
  73066. private _attachController;
  73067. private _controllers;
  73068. private _debugMode;
  73069. private _delta;
  73070. private _headsetImpostor?;
  73071. private _headsetMesh?;
  73072. private _lastTimestamp;
  73073. private _tmpQuaternion;
  73074. private _tmpVector;
  73075. /**
  73076. * The module's name
  73077. */
  73078. static readonly Name: string;
  73079. /**
  73080. * The (Babylon) version of this module.
  73081. * This is an integer representing the implementation version.
  73082. * This number does not correspond to the webxr specs version
  73083. */
  73084. static readonly Version: number;
  73085. /**
  73086. * Construct a new Controller Physics Feature
  73087. * @param _xrSessionManager the corresponding xr session manager
  73088. * @param _options options to create this feature with
  73089. */
  73090. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73091. /**
  73092. * @hidden
  73093. * enable debugging - will show console outputs and the impostor mesh
  73094. */
  73095. _enablePhysicsDebug(): void;
  73096. /**
  73097. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73098. * @param xrController the controller to add
  73099. */
  73100. addController(xrController: WebXRInputSource): void;
  73101. /**
  73102. * attach this feature
  73103. * Will usually be called by the features manager
  73104. *
  73105. * @returns true if successful.
  73106. */
  73107. attach(): boolean;
  73108. /**
  73109. * detach this feature.
  73110. * Will usually be called by the features manager
  73111. *
  73112. * @returns true if successful.
  73113. */
  73114. detach(): boolean;
  73115. /**
  73116. * Get the headset impostor, if enabled
  73117. * @returns the impostor
  73118. */
  73119. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73120. /**
  73121. * Get the physics impostor of a specific controller.
  73122. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73123. * @param controller the controller or the controller id of which to get the impostor
  73124. * @returns the impostor or null
  73125. */
  73126. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73127. /**
  73128. * Update the physics properties provided in the constructor
  73129. * @param newProperties the new properties object
  73130. */
  73131. setPhysicsProperties(newProperties: {
  73132. impostorType?: number;
  73133. impostorSize?: number | {
  73134. width: number;
  73135. height: number;
  73136. depth: number;
  73137. };
  73138. friction?: number;
  73139. restitution?: number;
  73140. }): void;
  73141. protected _onXRFrame(_xrFrame: any): void;
  73142. private _detachController;
  73143. }
  73144. }
  73145. declare module BABYLON {
  73146. /**
  73147. * The motion controller class for all microsoft mixed reality controllers
  73148. */
  73149. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73150. protected readonly _mapping: {
  73151. defaultButton: {
  73152. valueNodeName: string;
  73153. unpressedNodeName: string;
  73154. pressedNodeName: string;
  73155. };
  73156. defaultAxis: {
  73157. valueNodeName: string;
  73158. minNodeName: string;
  73159. maxNodeName: string;
  73160. };
  73161. buttons: {
  73162. "xr-standard-trigger": {
  73163. rootNodeName: string;
  73164. componentProperty: string;
  73165. states: string[];
  73166. };
  73167. "xr-standard-squeeze": {
  73168. rootNodeName: string;
  73169. componentProperty: string;
  73170. states: string[];
  73171. };
  73172. "xr-standard-touchpad": {
  73173. rootNodeName: string;
  73174. labelAnchorNodeName: string;
  73175. touchPointNodeName: string;
  73176. };
  73177. "xr-standard-thumbstick": {
  73178. rootNodeName: string;
  73179. componentProperty: string;
  73180. states: string[];
  73181. };
  73182. };
  73183. axes: {
  73184. "xr-standard-touchpad": {
  73185. "x-axis": {
  73186. rootNodeName: string;
  73187. };
  73188. "y-axis": {
  73189. rootNodeName: string;
  73190. };
  73191. };
  73192. "xr-standard-thumbstick": {
  73193. "x-axis": {
  73194. rootNodeName: string;
  73195. };
  73196. "y-axis": {
  73197. rootNodeName: string;
  73198. };
  73199. };
  73200. };
  73201. };
  73202. /**
  73203. * The base url used to load the left and right controller models
  73204. */
  73205. static MODEL_BASE_URL: string;
  73206. /**
  73207. * The name of the left controller model file
  73208. */
  73209. static MODEL_LEFT_FILENAME: string;
  73210. /**
  73211. * The name of the right controller model file
  73212. */
  73213. static MODEL_RIGHT_FILENAME: string;
  73214. profileId: string;
  73215. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73216. protected _getFilenameAndPath(): {
  73217. filename: string;
  73218. path: string;
  73219. };
  73220. protected _getModelLoadingConstraints(): boolean;
  73221. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73222. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73223. protected _updateModel(): void;
  73224. }
  73225. }
  73226. declare module BABYLON {
  73227. /**
  73228. * The motion controller class for oculus touch (quest, rift).
  73229. * This class supports legacy mapping as well the standard xr mapping
  73230. */
  73231. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73232. private _forceLegacyControllers;
  73233. private _modelRootNode;
  73234. /**
  73235. * The base url used to load the left and right controller models
  73236. */
  73237. static MODEL_BASE_URL: string;
  73238. /**
  73239. * The name of the left controller model file
  73240. */
  73241. static MODEL_LEFT_FILENAME: string;
  73242. /**
  73243. * The name of the right controller model file
  73244. */
  73245. static MODEL_RIGHT_FILENAME: string;
  73246. /**
  73247. * Base Url for the Quest controller model.
  73248. */
  73249. static QUEST_MODEL_BASE_URL: string;
  73250. profileId: string;
  73251. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73252. protected _getFilenameAndPath(): {
  73253. filename: string;
  73254. path: string;
  73255. };
  73256. protected _getModelLoadingConstraints(): boolean;
  73257. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73259. protected _updateModel(): void;
  73260. /**
  73261. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73262. * between the touch and touch 2.
  73263. */
  73264. private _isQuest;
  73265. }
  73266. }
  73267. declare module BABYLON {
  73268. /**
  73269. * The motion controller class for the standard HTC-Vive controllers
  73270. */
  73271. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73272. private _modelRootNode;
  73273. /**
  73274. * The base url used to load the left and right controller models
  73275. */
  73276. static MODEL_BASE_URL: string;
  73277. /**
  73278. * File name for the controller model.
  73279. */
  73280. static MODEL_FILENAME: string;
  73281. profileId: string;
  73282. /**
  73283. * Create a new Vive motion controller object
  73284. * @param scene the scene to use to create this controller
  73285. * @param gamepadObject the corresponding gamepad object
  73286. * @param handedness the handedness of the controller
  73287. */
  73288. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73289. protected _getFilenameAndPath(): {
  73290. filename: string;
  73291. path: string;
  73292. };
  73293. protected _getModelLoadingConstraints(): boolean;
  73294. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73295. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73296. protected _updateModel(): void;
  73297. }
  73298. }
  73299. declare module BABYLON {
  73300. /**
  73301. * A cursor which tracks a point on a path
  73302. */
  73303. export class PathCursor {
  73304. private path;
  73305. /**
  73306. * Stores path cursor callbacks for when an onchange event is triggered
  73307. */
  73308. private _onchange;
  73309. /**
  73310. * The value of the path cursor
  73311. */
  73312. value: number;
  73313. /**
  73314. * The animation array of the path cursor
  73315. */
  73316. animations: Animation[];
  73317. /**
  73318. * Initializes the path cursor
  73319. * @param path The path to track
  73320. */
  73321. constructor(path: Path2);
  73322. /**
  73323. * Gets the cursor point on the path
  73324. * @returns A point on the path cursor at the cursor location
  73325. */
  73326. getPoint(): Vector3;
  73327. /**
  73328. * Moves the cursor ahead by the step amount
  73329. * @param step The amount to move the cursor forward
  73330. * @returns This path cursor
  73331. */
  73332. moveAhead(step?: number): PathCursor;
  73333. /**
  73334. * Moves the cursor behind by the step amount
  73335. * @param step The amount to move the cursor back
  73336. * @returns This path cursor
  73337. */
  73338. moveBack(step?: number): PathCursor;
  73339. /**
  73340. * Moves the cursor by the step amount
  73341. * If the step amount is greater than one, an exception is thrown
  73342. * @param step The amount to move the cursor
  73343. * @returns This path cursor
  73344. */
  73345. move(step: number): PathCursor;
  73346. /**
  73347. * Ensures that the value is limited between zero and one
  73348. * @returns This path cursor
  73349. */
  73350. private ensureLimits;
  73351. /**
  73352. * Runs onchange callbacks on change (used by the animation engine)
  73353. * @returns This path cursor
  73354. */
  73355. private raiseOnChange;
  73356. /**
  73357. * Executes a function on change
  73358. * @param f A path cursor onchange callback
  73359. * @returns This path cursor
  73360. */
  73361. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73362. }
  73363. }
  73364. declare module BABYLON {
  73365. /** @hidden */
  73366. export var blurPixelShader: {
  73367. name: string;
  73368. shader: string;
  73369. };
  73370. }
  73371. declare module BABYLON {
  73372. /** @hidden */
  73373. export var pointCloudVertexDeclaration: {
  73374. name: string;
  73375. shader: string;
  73376. };
  73377. }
  73378. // Mixins
  73379. interface Window {
  73380. mozIndexedDB: IDBFactory;
  73381. webkitIndexedDB: IDBFactory;
  73382. msIndexedDB: IDBFactory;
  73383. webkitURL: typeof URL;
  73384. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73385. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73386. WebGLRenderingContext: WebGLRenderingContext;
  73387. MSGesture: MSGesture;
  73388. CANNON: any;
  73389. AudioContext: AudioContext;
  73390. webkitAudioContext: AudioContext;
  73391. PointerEvent: any;
  73392. Math: Math;
  73393. Uint8Array: Uint8ArrayConstructor;
  73394. Float32Array: Float32ArrayConstructor;
  73395. mozURL: typeof URL;
  73396. msURL: typeof URL;
  73397. VRFrameData: any; // WebVR, from specs 1.1
  73398. DracoDecoderModule: any;
  73399. setImmediate(handler: (...args: any[]) => void): number;
  73400. }
  73401. interface HTMLCanvasElement {
  73402. requestPointerLock(): void;
  73403. msRequestPointerLock?(): void;
  73404. mozRequestPointerLock?(): void;
  73405. webkitRequestPointerLock?(): void;
  73406. /** Track wether a record is in progress */
  73407. isRecording: boolean;
  73408. /** Capture Stream method defined by some browsers */
  73409. captureStream(fps?: number): MediaStream;
  73410. }
  73411. interface CanvasRenderingContext2D {
  73412. msImageSmoothingEnabled: boolean;
  73413. }
  73414. interface MouseEvent {
  73415. mozMovementX: number;
  73416. mozMovementY: number;
  73417. webkitMovementX: number;
  73418. webkitMovementY: number;
  73419. msMovementX: number;
  73420. msMovementY: number;
  73421. }
  73422. interface Navigator {
  73423. mozGetVRDevices: (any: any) => any;
  73424. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73425. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73426. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73427. webkitGetGamepads(): Gamepad[];
  73428. msGetGamepads(): Gamepad[];
  73429. webkitGamepads(): Gamepad[];
  73430. }
  73431. interface HTMLVideoElement {
  73432. mozSrcObject: any;
  73433. }
  73434. interface Math {
  73435. fround(x: number): number;
  73436. imul(a: number, b: number): number;
  73437. }
  73438. interface WebGLRenderingContext {
  73439. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73440. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73441. vertexAttribDivisor(index: number, divisor: number): void;
  73442. createVertexArray(): any;
  73443. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73444. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73445. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73446. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73447. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73448. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73449. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73450. // Queries
  73451. createQuery(): WebGLQuery;
  73452. deleteQuery(query: WebGLQuery): void;
  73453. beginQuery(target: number, query: WebGLQuery): void;
  73454. endQuery(target: number): void;
  73455. getQueryParameter(query: WebGLQuery, pname: number): any;
  73456. getQuery(target: number, pname: number): any;
  73457. MAX_SAMPLES: number;
  73458. RGBA8: number;
  73459. READ_FRAMEBUFFER: number;
  73460. DRAW_FRAMEBUFFER: number;
  73461. UNIFORM_BUFFER: number;
  73462. HALF_FLOAT_OES: number;
  73463. RGBA16F: number;
  73464. RGBA32F: number;
  73465. R32F: number;
  73466. RG32F: number;
  73467. RGB32F: number;
  73468. R16F: number;
  73469. RG16F: number;
  73470. RGB16F: number;
  73471. RED: number;
  73472. RG: number;
  73473. R8: number;
  73474. RG8: number;
  73475. UNSIGNED_INT_24_8: number;
  73476. DEPTH24_STENCIL8: number;
  73477. MIN: number;
  73478. MAX: number;
  73479. /* Multiple Render Targets */
  73480. drawBuffers(buffers: number[]): void;
  73481. readBuffer(src: number): void;
  73482. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73483. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73484. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73485. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73486. // Occlusion Query
  73487. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73488. ANY_SAMPLES_PASSED: number;
  73489. QUERY_RESULT_AVAILABLE: number;
  73490. QUERY_RESULT: number;
  73491. }
  73492. interface WebGLProgram {
  73493. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73494. }
  73495. interface EXT_disjoint_timer_query {
  73496. QUERY_COUNTER_BITS_EXT: number;
  73497. TIME_ELAPSED_EXT: number;
  73498. TIMESTAMP_EXT: number;
  73499. GPU_DISJOINT_EXT: number;
  73500. QUERY_RESULT_EXT: number;
  73501. QUERY_RESULT_AVAILABLE_EXT: number;
  73502. queryCounterEXT(query: WebGLQuery, target: number): void;
  73503. createQueryEXT(): WebGLQuery;
  73504. beginQueryEXT(target: number, query: WebGLQuery): void;
  73505. endQueryEXT(target: number): void;
  73506. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73507. deleteQueryEXT(query: WebGLQuery): void;
  73508. }
  73509. interface WebGLUniformLocation {
  73510. _currentState: any;
  73511. }
  73512. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73513. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73514. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73515. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73516. interface WebGLRenderingContext {
  73517. readonly RASTERIZER_DISCARD: number;
  73518. readonly DEPTH_COMPONENT24: number;
  73519. readonly TEXTURE_3D: number;
  73520. readonly TEXTURE_2D_ARRAY: number;
  73521. readonly TEXTURE_COMPARE_FUNC: number;
  73522. readonly TEXTURE_COMPARE_MODE: number;
  73523. readonly COMPARE_REF_TO_TEXTURE: number;
  73524. readonly TEXTURE_WRAP_R: number;
  73525. readonly HALF_FLOAT: number;
  73526. readonly RGB8: number;
  73527. readonly RED_INTEGER: number;
  73528. readonly RG_INTEGER: number;
  73529. readonly RGB_INTEGER: number;
  73530. readonly RGBA_INTEGER: number;
  73531. readonly R8_SNORM: number;
  73532. readonly RG8_SNORM: number;
  73533. readonly RGB8_SNORM: number;
  73534. readonly RGBA8_SNORM: number;
  73535. readonly R8I: number;
  73536. readonly RG8I: number;
  73537. readonly RGB8I: number;
  73538. readonly RGBA8I: number;
  73539. readonly R8UI: number;
  73540. readonly RG8UI: number;
  73541. readonly RGB8UI: number;
  73542. readonly RGBA8UI: number;
  73543. readonly R16I: number;
  73544. readonly RG16I: number;
  73545. readonly RGB16I: number;
  73546. readonly RGBA16I: number;
  73547. readonly R16UI: number;
  73548. readonly RG16UI: number;
  73549. readonly RGB16UI: number;
  73550. readonly RGBA16UI: number;
  73551. readonly R32I: number;
  73552. readonly RG32I: number;
  73553. readonly RGB32I: number;
  73554. readonly RGBA32I: number;
  73555. readonly R32UI: number;
  73556. readonly RG32UI: number;
  73557. readonly RGB32UI: number;
  73558. readonly RGBA32UI: number;
  73559. readonly RGB10_A2UI: number;
  73560. readonly R11F_G11F_B10F: number;
  73561. readonly RGB9_E5: number;
  73562. readonly RGB10_A2: number;
  73563. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73564. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73565. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73566. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73567. readonly DEPTH_COMPONENT32F: number;
  73568. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73569. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73570. 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;
  73571. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73572. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73573. readonly TRANSFORM_FEEDBACK: number;
  73574. readonly INTERLEAVED_ATTRIBS: number;
  73575. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73576. createTransformFeedback(): WebGLTransformFeedback;
  73577. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73578. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73579. beginTransformFeedback(primitiveMode: number): void;
  73580. endTransformFeedback(): void;
  73581. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73582. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73583. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73584. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73585. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73586. }
  73587. interface ImageBitmap {
  73588. readonly width: number;
  73589. readonly height: number;
  73590. close(): void;
  73591. }
  73592. interface WebGLQuery extends WebGLObject {
  73593. }
  73594. declare var WebGLQuery: {
  73595. prototype: WebGLQuery;
  73596. new(): WebGLQuery;
  73597. };
  73598. interface WebGLSampler extends WebGLObject {
  73599. }
  73600. declare var WebGLSampler: {
  73601. prototype: WebGLSampler;
  73602. new(): WebGLSampler;
  73603. };
  73604. interface WebGLSync extends WebGLObject {
  73605. }
  73606. declare var WebGLSync: {
  73607. prototype: WebGLSync;
  73608. new(): WebGLSync;
  73609. };
  73610. interface WebGLTransformFeedback extends WebGLObject {
  73611. }
  73612. declare var WebGLTransformFeedback: {
  73613. prototype: WebGLTransformFeedback;
  73614. new(): WebGLTransformFeedback;
  73615. };
  73616. interface WebGLVertexArrayObject extends WebGLObject {
  73617. }
  73618. declare var WebGLVertexArrayObject: {
  73619. prototype: WebGLVertexArrayObject;
  73620. new(): WebGLVertexArrayObject;
  73621. };
  73622. // Type definitions for WebVR API
  73623. // Project: https://w3c.github.io/webvr/
  73624. // Definitions by: six a <https://github.com/lostfictions>
  73625. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73626. interface VRDisplay extends EventTarget {
  73627. /**
  73628. * Dictionary of capabilities describing the VRDisplay.
  73629. */
  73630. readonly capabilities: VRDisplayCapabilities;
  73631. /**
  73632. * z-depth defining the far plane of the eye view frustum
  73633. * enables mapping of values in the render target depth
  73634. * attachment to scene coordinates. Initially set to 10000.0.
  73635. */
  73636. depthFar: number;
  73637. /**
  73638. * z-depth defining the near plane of the eye view frustum
  73639. * enables mapping of values in the render target depth
  73640. * attachment to scene coordinates. Initially set to 0.01.
  73641. */
  73642. depthNear: number;
  73643. /**
  73644. * An identifier for this distinct VRDisplay. Used as an
  73645. * association point in the Gamepad API.
  73646. */
  73647. readonly displayId: number;
  73648. /**
  73649. * A display name, a user-readable name identifying it.
  73650. */
  73651. readonly displayName: string;
  73652. readonly isConnected: boolean;
  73653. readonly isPresenting: boolean;
  73654. /**
  73655. * If this VRDisplay supports room-scale experiences, the optional
  73656. * stage attribute contains details on the room-scale parameters.
  73657. */
  73658. readonly stageParameters: VRStageParameters | null;
  73659. /**
  73660. * Passing the value returned by `requestAnimationFrame` to
  73661. * `cancelAnimationFrame` will unregister the callback.
  73662. * @param handle Define the hanle of the request to cancel
  73663. */
  73664. cancelAnimationFrame(handle: number): void;
  73665. /**
  73666. * Stops presenting to the VRDisplay.
  73667. * @returns a promise to know when it stopped
  73668. */
  73669. exitPresent(): Promise<void>;
  73670. /**
  73671. * Return the current VREyeParameters for the given eye.
  73672. * @param whichEye Define the eye we want the parameter for
  73673. * @returns the eye parameters
  73674. */
  73675. getEyeParameters(whichEye: string): VREyeParameters;
  73676. /**
  73677. * Populates the passed VRFrameData with the information required to render
  73678. * the current frame.
  73679. * @param frameData Define the data structure to populate
  73680. * @returns true if ok otherwise false
  73681. */
  73682. getFrameData(frameData: VRFrameData): boolean;
  73683. /**
  73684. * Get the layers currently being presented.
  73685. * @returns the list of VR layers
  73686. */
  73687. getLayers(): VRLayer[];
  73688. /**
  73689. * Return a VRPose containing the future predicted pose of the VRDisplay
  73690. * when the current frame will be presented. The value returned will not
  73691. * change until JavaScript has returned control to the browser.
  73692. *
  73693. * The VRPose will contain the position, orientation, velocity,
  73694. * and acceleration of each of these properties.
  73695. * @returns the pose object
  73696. */
  73697. getPose(): VRPose;
  73698. /**
  73699. * Return the current instantaneous pose of the VRDisplay, with no
  73700. * prediction applied.
  73701. * @returns the current instantaneous pose
  73702. */
  73703. getImmediatePose(): VRPose;
  73704. /**
  73705. * The callback passed to `requestAnimationFrame` will be called
  73706. * any time a new frame should be rendered. When the VRDisplay is
  73707. * presenting the callback will be called at the native refresh
  73708. * rate of the HMD. When not presenting this function acts
  73709. * identically to how window.requestAnimationFrame acts. Content should
  73710. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73711. * asynchronously from other displays and at differing refresh rates.
  73712. * @param callback Define the eaction to run next frame
  73713. * @returns the request handle it
  73714. */
  73715. requestAnimationFrame(callback: FrameRequestCallback): number;
  73716. /**
  73717. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73718. * Repeat calls while already presenting will update the VRLayers being displayed.
  73719. * @param layers Define the list of layer to present
  73720. * @returns a promise to know when the request has been fulfilled
  73721. */
  73722. requestPresent(layers: VRLayer[]): Promise<void>;
  73723. /**
  73724. * Reset the pose for this display, treating its current position and
  73725. * orientation as the "origin/zero" values. VRPose.position,
  73726. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73727. * updated when calling resetPose(). This should be called in only
  73728. * sitting-space experiences.
  73729. */
  73730. resetPose(): void;
  73731. /**
  73732. * The VRLayer provided to the VRDisplay will be captured and presented
  73733. * in the HMD. Calling this function has the same effect on the source
  73734. * canvas as any other operation that uses its source image, and canvases
  73735. * created without preserveDrawingBuffer set to true will be cleared.
  73736. * @param pose Define the pose to submit
  73737. */
  73738. submitFrame(pose?: VRPose): void;
  73739. }
  73740. declare var VRDisplay: {
  73741. prototype: VRDisplay;
  73742. new(): VRDisplay;
  73743. };
  73744. interface VRLayer {
  73745. leftBounds?: number[] | Float32Array | null;
  73746. rightBounds?: number[] | Float32Array | null;
  73747. source?: HTMLCanvasElement | null;
  73748. }
  73749. interface VRDisplayCapabilities {
  73750. readonly canPresent: boolean;
  73751. readonly hasExternalDisplay: boolean;
  73752. readonly hasOrientation: boolean;
  73753. readonly hasPosition: boolean;
  73754. readonly maxLayers: number;
  73755. }
  73756. interface VREyeParameters {
  73757. /** @deprecated */
  73758. readonly fieldOfView: VRFieldOfView;
  73759. readonly offset: Float32Array;
  73760. readonly renderHeight: number;
  73761. readonly renderWidth: number;
  73762. }
  73763. interface VRFieldOfView {
  73764. readonly downDegrees: number;
  73765. readonly leftDegrees: number;
  73766. readonly rightDegrees: number;
  73767. readonly upDegrees: number;
  73768. }
  73769. interface VRFrameData {
  73770. readonly leftProjectionMatrix: Float32Array;
  73771. readonly leftViewMatrix: Float32Array;
  73772. readonly pose: VRPose;
  73773. readonly rightProjectionMatrix: Float32Array;
  73774. readonly rightViewMatrix: Float32Array;
  73775. readonly timestamp: number;
  73776. }
  73777. interface VRPose {
  73778. readonly angularAcceleration: Float32Array | null;
  73779. readonly angularVelocity: Float32Array | null;
  73780. readonly linearAcceleration: Float32Array | null;
  73781. readonly linearVelocity: Float32Array | null;
  73782. readonly orientation: Float32Array | null;
  73783. readonly position: Float32Array | null;
  73784. readonly timestamp: number;
  73785. }
  73786. interface VRStageParameters {
  73787. sittingToStandingTransform?: Float32Array;
  73788. sizeX?: number;
  73789. sizeY?: number;
  73790. }
  73791. interface Navigator {
  73792. getVRDisplays(): Promise<VRDisplay[]>;
  73793. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73794. }
  73795. interface Window {
  73796. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73797. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73798. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73799. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73800. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73801. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73802. }
  73803. interface Gamepad {
  73804. readonly displayId: number;
  73805. }
  73806. type XRSessionMode =
  73807. | "inline"
  73808. | "immersive-vr"
  73809. | "immersive-ar";
  73810. type XRReferenceSpaceType =
  73811. | "viewer"
  73812. | "local"
  73813. | "local-floor"
  73814. | "bounded-floor"
  73815. | "unbounded";
  73816. type XREnvironmentBlendMode =
  73817. | "opaque"
  73818. | "additive"
  73819. | "alpha-blend";
  73820. type XRVisibilityState =
  73821. | "visible"
  73822. | "visible-blurred"
  73823. | "hidden";
  73824. type XRHandedness =
  73825. | "none"
  73826. | "left"
  73827. | "right";
  73828. type XRTargetRayMode =
  73829. | "gaze"
  73830. | "tracked-pointer"
  73831. | "screen";
  73832. type XREye =
  73833. | "none"
  73834. | "left"
  73835. | "right";
  73836. type XREventType =
  73837. | "devicechange"
  73838. | "visibilitychange"
  73839. | "end"
  73840. | "inputsourceschange"
  73841. | "select"
  73842. | "selectstart"
  73843. | "selectend"
  73844. | "squeeze"
  73845. | "squeezestart"
  73846. | "squeezeend"
  73847. | "reset";
  73848. interface XRSpace extends EventTarget {
  73849. }
  73850. interface XRRenderState {
  73851. depthNear?: number;
  73852. depthFar?: number;
  73853. inlineVerticalFieldOfView?: number;
  73854. baseLayer?: XRWebGLLayer;
  73855. }
  73856. interface XRInputSource {
  73857. handedness: XRHandedness;
  73858. targetRayMode: XRTargetRayMode;
  73859. targetRaySpace: XRSpace;
  73860. gripSpace: XRSpace | undefined;
  73861. gamepad: Gamepad | undefined;
  73862. profiles: Array<string>;
  73863. }
  73864. interface XRSessionInit {
  73865. optionalFeatures?: string[];
  73866. requiredFeatures?: string[];
  73867. }
  73868. interface XRSession {
  73869. addEventListener: Function;
  73870. removeEventListener: Function;
  73871. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73872. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73873. requestAnimationFrame: Function;
  73874. end(): Promise<void>;
  73875. renderState: XRRenderState;
  73876. inputSources: Array<XRInputSource>;
  73877. // hit test
  73878. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73879. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73880. // legacy AR hit test
  73881. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73882. // legacy plane detection
  73883. updateWorldTrackingState(options: {
  73884. planeDetectionState?: { enabled: boolean; }
  73885. }): void;
  73886. }
  73887. interface XRReferenceSpace extends XRSpace {
  73888. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73889. onreset: any;
  73890. }
  73891. type XRPlaneSet = Set<XRPlane>;
  73892. type XRAnchorSet = Set<XRAnchor>;
  73893. interface XRFrame {
  73894. session: XRSession;
  73895. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73896. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73897. // AR
  73898. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73899. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73900. // Anchors
  73901. trackedAnchors?: XRAnchorSet;
  73902. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73903. // Planes
  73904. worldInformation: {
  73905. detectedPlanes?: XRPlaneSet;
  73906. };
  73907. }
  73908. interface XRViewerPose extends XRPose {
  73909. views: Array<XRView>;
  73910. }
  73911. interface XRPose {
  73912. transform: XRRigidTransform;
  73913. emulatedPosition: boolean;
  73914. }
  73915. interface XRWebGLLayerOptions {
  73916. antialias?: boolean;
  73917. depth?: boolean;
  73918. stencil?: boolean;
  73919. alpha?: boolean;
  73920. multiview?: boolean;
  73921. framebufferScaleFactor?: number;
  73922. }
  73923. declare var XRWebGLLayer: {
  73924. prototype: XRWebGLLayer;
  73925. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73926. };
  73927. interface XRWebGLLayer {
  73928. framebuffer: WebGLFramebuffer;
  73929. framebufferWidth: number;
  73930. framebufferHeight: number;
  73931. getViewport: Function;
  73932. }
  73933. declare class XRRigidTransform {
  73934. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73935. position: DOMPointReadOnly;
  73936. orientation: DOMPointReadOnly;
  73937. matrix: Float32Array;
  73938. inverse: XRRigidTransform;
  73939. }
  73940. interface XRView {
  73941. eye: XREye;
  73942. projectionMatrix: Float32Array;
  73943. transform: XRRigidTransform;
  73944. }
  73945. interface XRInputSourceChangeEvent {
  73946. session: XRSession;
  73947. removed: Array<XRInputSource>;
  73948. added: Array<XRInputSource>;
  73949. }
  73950. interface XRInputSourceEvent extends Event {
  73951. readonly frame: XRFrame;
  73952. readonly inputSource: XRInputSource;
  73953. }
  73954. // Experimental(er) features
  73955. declare class XRRay {
  73956. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73957. origin: DOMPointReadOnly;
  73958. direction: DOMPointReadOnly;
  73959. matrix: Float32Array;
  73960. }
  73961. declare enum XRHitTestTrackableType {
  73962. "point",
  73963. "plane"
  73964. }
  73965. interface XRHitResult {
  73966. hitMatrix: Float32Array;
  73967. }
  73968. interface XRTransientInputHitTestResult {
  73969. readonly inputSource: XRInputSource;
  73970. readonly results: Array<XRHitTestResult>;
  73971. }
  73972. interface XRHitTestResult {
  73973. getPose(baseSpace: XRSpace): XRPose | undefined;
  73974. // When anchor system is enabled
  73975. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73976. }
  73977. interface XRHitTestSource {
  73978. cancel(): void;
  73979. }
  73980. interface XRTransientInputHitTestSource {
  73981. cancel(): void;
  73982. }
  73983. interface XRHitTestOptionsInit {
  73984. space: XRSpace;
  73985. entityTypes?: Array<XRHitTestTrackableType>;
  73986. offsetRay?: XRRay;
  73987. }
  73988. interface XRTransientInputHitTestOptionsInit {
  73989. profile: string;
  73990. entityTypes?: Array<XRHitTestTrackableType>;
  73991. offsetRay?: XRRay;
  73992. }
  73993. interface XRAnchor {
  73994. anchorSpace: XRSpace;
  73995. delete(): void;
  73996. }
  73997. interface XRPlane {
  73998. orientation: "Horizontal" | "Vertical";
  73999. planeSpace: XRSpace;
  74000. polygon: Array<DOMPointReadOnly>;
  74001. lastChangedTime: number;
  74002. }
  74003. /**
  74004. * @ignore
  74005. */
  74006. declare module BABYLON.GLTF2.Exporter {
  74007. }
  74008. /**
  74009. * @ignore
  74010. */
  74011. declare module BABYLON.GLTF1 {
  74012. }
  74013. declare module BABYLON.GUI {
  74014. /**
  74015. * Class used to specific a value and its associated unit
  74016. */
  74017. export class ValueAndUnit {
  74018. /** defines the unit to store */
  74019. unit: number;
  74020. /** defines a boolean indicating if the value can be negative */
  74021. negativeValueAllowed: boolean;
  74022. private _value;
  74023. private _originalUnit;
  74024. /**
  74025. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74026. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74027. */
  74028. ignoreAdaptiveScaling: boolean;
  74029. /**
  74030. * Creates a new ValueAndUnit
  74031. * @param value defines the value to store
  74032. * @param unit defines the unit to store
  74033. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74034. */
  74035. constructor(value: number,
  74036. /** defines the unit to store */
  74037. unit?: number,
  74038. /** defines a boolean indicating if the value can be negative */
  74039. negativeValueAllowed?: boolean);
  74040. /** Gets a boolean indicating if the value is a percentage */
  74041. get isPercentage(): boolean;
  74042. /** Gets a boolean indicating if the value is store as pixel */
  74043. get isPixel(): boolean;
  74044. /** Gets direct internal value */
  74045. get internalValue(): number;
  74046. /**
  74047. * Gets value as pixel
  74048. * @param host defines the root host
  74049. * @param refValue defines the reference value for percentages
  74050. * @returns the value as pixel
  74051. */
  74052. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74053. /**
  74054. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74055. * @param value defines the value to store
  74056. * @param unit defines the unit to store
  74057. * @returns the current ValueAndUnit
  74058. */
  74059. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74060. /**
  74061. * Gets the value accordingly to its unit
  74062. * @param host defines the root host
  74063. * @returns the value
  74064. */
  74065. getValue(host: AdvancedDynamicTexture): number;
  74066. /**
  74067. * Gets a string representation of the value
  74068. * @param host defines the root host
  74069. * @param decimals defines an optional number of decimals to display
  74070. * @returns a string
  74071. */
  74072. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74073. /**
  74074. * Store a value parsed from a string
  74075. * @param source defines the source string
  74076. * @returns true if the value was successfully parsed
  74077. */
  74078. fromString(source: string | number): boolean;
  74079. private static _Regex;
  74080. private static _UNITMODE_PERCENTAGE;
  74081. private static _UNITMODE_PIXEL;
  74082. /** UNITMODE_PERCENTAGE */
  74083. static get UNITMODE_PERCENTAGE(): number;
  74084. /** UNITMODE_PIXEL */
  74085. static get UNITMODE_PIXEL(): number;
  74086. }
  74087. }
  74088. declare module BABYLON.GUI {
  74089. /**
  74090. * Define a style used by control to automatically setup properties based on a template.
  74091. * Only support font related properties so far
  74092. */
  74093. export class Style implements BABYLON.IDisposable {
  74094. private _fontFamily;
  74095. private _fontStyle;
  74096. private _fontWeight;
  74097. /** @hidden */
  74098. _host: AdvancedDynamicTexture;
  74099. /** @hidden */
  74100. _fontSize: ValueAndUnit;
  74101. /**
  74102. * BABYLON.Observable raised when the style values are changed
  74103. */
  74104. onChangedObservable: BABYLON.Observable<Style>;
  74105. /**
  74106. * Creates a new style object
  74107. * @param host defines the AdvancedDynamicTexture which hosts this style
  74108. */
  74109. constructor(host: AdvancedDynamicTexture);
  74110. /**
  74111. * Gets or sets the font size
  74112. */
  74113. get fontSize(): string | number;
  74114. set fontSize(value: string | number);
  74115. /**
  74116. * Gets or sets the font family
  74117. */
  74118. get fontFamily(): string;
  74119. set fontFamily(value: string);
  74120. /**
  74121. * Gets or sets the font style
  74122. */
  74123. get fontStyle(): string;
  74124. set fontStyle(value: string);
  74125. /** Gets or sets font weight */
  74126. get fontWeight(): string;
  74127. set fontWeight(value: string);
  74128. /** Dispose all associated resources */
  74129. dispose(): void;
  74130. }
  74131. }
  74132. declare module BABYLON.GUI {
  74133. /**
  74134. * Class used to transport BABYLON.Vector2 information for pointer events
  74135. */
  74136. export class Vector2WithInfo extends BABYLON.Vector2 {
  74137. /** defines the current mouse button index */
  74138. buttonIndex: number;
  74139. /**
  74140. * Creates a new Vector2WithInfo
  74141. * @param source defines the vector2 data to transport
  74142. * @param buttonIndex defines the current mouse button index
  74143. */
  74144. constructor(source: BABYLON.Vector2,
  74145. /** defines the current mouse button index */
  74146. buttonIndex?: number);
  74147. }
  74148. /** Class used to provide 2D matrix features */
  74149. export class Matrix2D {
  74150. /** Gets the internal array of 6 floats used to store matrix data */
  74151. m: Float32Array;
  74152. /**
  74153. * Creates a new matrix
  74154. * @param m00 defines value for (0, 0)
  74155. * @param m01 defines value for (0, 1)
  74156. * @param m10 defines value for (1, 0)
  74157. * @param m11 defines value for (1, 1)
  74158. * @param m20 defines value for (2, 0)
  74159. * @param m21 defines value for (2, 1)
  74160. */
  74161. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74162. /**
  74163. * Fills the matrix from direct values
  74164. * @param m00 defines value for (0, 0)
  74165. * @param m01 defines value for (0, 1)
  74166. * @param m10 defines value for (1, 0)
  74167. * @param m11 defines value for (1, 1)
  74168. * @param m20 defines value for (2, 0)
  74169. * @param m21 defines value for (2, 1)
  74170. * @returns the current modified matrix
  74171. */
  74172. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74173. /**
  74174. * Gets matrix determinant
  74175. * @returns the determinant
  74176. */
  74177. determinant(): number;
  74178. /**
  74179. * Inverses the matrix and stores it in a target matrix
  74180. * @param result defines the target matrix
  74181. * @returns the current matrix
  74182. */
  74183. invertToRef(result: Matrix2D): Matrix2D;
  74184. /**
  74185. * Multiplies the current matrix with another one
  74186. * @param other defines the second operand
  74187. * @param result defines the target matrix
  74188. * @returns the current matrix
  74189. */
  74190. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74191. /**
  74192. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74193. * @param x defines the x coordinate to transform
  74194. * @param y defines the x coordinate to transform
  74195. * @param result defines the target vector2
  74196. * @returns the current matrix
  74197. */
  74198. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74199. /**
  74200. * Creates an identity matrix
  74201. * @returns a new matrix
  74202. */
  74203. static Identity(): Matrix2D;
  74204. /**
  74205. * Creates a translation matrix and stores it in a target matrix
  74206. * @param x defines the x coordinate of the translation
  74207. * @param y defines the y coordinate of the translation
  74208. * @param result defines the target matrix
  74209. */
  74210. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74211. /**
  74212. * Creates a scaling matrix and stores it in a target matrix
  74213. * @param x defines the x coordinate of the scaling
  74214. * @param y defines the y coordinate of the scaling
  74215. * @param result defines the target matrix
  74216. */
  74217. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74218. /**
  74219. * Creates a rotation matrix and stores it in a target matrix
  74220. * @param angle defines the rotation angle
  74221. * @param result defines the target matrix
  74222. */
  74223. static RotationToRef(angle: number, result: Matrix2D): void;
  74224. private static _TempPreTranslationMatrix;
  74225. private static _TempPostTranslationMatrix;
  74226. private static _TempRotationMatrix;
  74227. private static _TempScalingMatrix;
  74228. private static _TempCompose0;
  74229. private static _TempCompose1;
  74230. private static _TempCompose2;
  74231. /**
  74232. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74233. * @param tx defines the x coordinate of the translation
  74234. * @param ty defines the y coordinate of the translation
  74235. * @param angle defines the rotation angle
  74236. * @param scaleX defines the x coordinate of the scaling
  74237. * @param scaleY defines the y coordinate of the scaling
  74238. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74239. * @param result defines the target matrix
  74240. */
  74241. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74242. }
  74243. }
  74244. declare module BABYLON.GUI {
  74245. /**
  74246. * Class used to store 2D control sizes
  74247. */
  74248. export class Measure {
  74249. /** defines left coordinate */
  74250. left: number;
  74251. /** defines top coordinate */
  74252. top: number;
  74253. /** defines width dimension */
  74254. width: number;
  74255. /** defines height dimension */
  74256. height: number;
  74257. /**
  74258. * Creates a new measure
  74259. * @param left defines left coordinate
  74260. * @param top defines top coordinate
  74261. * @param width defines width dimension
  74262. * @param height defines height dimension
  74263. */
  74264. constructor(
  74265. /** defines left coordinate */
  74266. left: number,
  74267. /** defines top coordinate */
  74268. top: number,
  74269. /** defines width dimension */
  74270. width: number,
  74271. /** defines height dimension */
  74272. height: number);
  74273. /**
  74274. * Copy from another measure
  74275. * @param other defines the other measure to copy from
  74276. */
  74277. copyFrom(other: Measure): void;
  74278. /**
  74279. * Copy from a group of 4 floats
  74280. * @param left defines left coordinate
  74281. * @param top defines top coordinate
  74282. * @param width defines width dimension
  74283. * @param height defines height dimension
  74284. */
  74285. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74286. /**
  74287. * Computes the axis aligned bounding box measure for two given measures
  74288. * @param a Input measure
  74289. * @param b Input measure
  74290. * @param result the resulting bounding measure
  74291. */
  74292. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74293. /**
  74294. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74295. * @param transform the matrix to transform the measure before computing the AABB
  74296. * @param result the resulting AABB
  74297. */
  74298. transformToRef(transform: Matrix2D, result: Measure): void;
  74299. /**
  74300. * Check equality between this measure and another one
  74301. * @param other defines the other measures
  74302. * @returns true if both measures are equals
  74303. */
  74304. isEqualsTo(other: Measure): boolean;
  74305. /**
  74306. * Creates an empty measure
  74307. * @returns a new measure
  74308. */
  74309. static Empty(): Measure;
  74310. }
  74311. }
  74312. declare module BABYLON.GUI {
  74313. /**
  74314. * Interface used to define a control that can receive focus
  74315. */
  74316. export interface IFocusableControl {
  74317. /**
  74318. * Function called when the control receives the focus
  74319. */
  74320. onFocus(): void;
  74321. /**
  74322. * Function called when the control loses the focus
  74323. */
  74324. onBlur(): void;
  74325. /**
  74326. * Function called to let the control handle keyboard events
  74327. * @param evt defines the current keyboard event
  74328. */
  74329. processKeyboard(evt: KeyboardEvent): void;
  74330. /**
  74331. * Function called to get the list of controls that should not steal the focus from this control
  74332. * @returns an array of controls
  74333. */
  74334. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74335. }
  74336. /**
  74337. * Class used to create texture to support 2D GUI elements
  74338. * @see http://doc.babylonjs.com/how_to/gui
  74339. */
  74340. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74341. private _isDirty;
  74342. private _renderObserver;
  74343. private _resizeObserver;
  74344. private _preKeyboardObserver;
  74345. private _pointerMoveObserver;
  74346. private _pointerObserver;
  74347. private _canvasPointerOutObserver;
  74348. private _background;
  74349. /** @hidden */
  74350. _rootContainer: Container;
  74351. /** @hidden */
  74352. _lastPickedControl: Control;
  74353. /** @hidden */
  74354. _lastControlOver: {
  74355. [pointerId: number]: Control;
  74356. };
  74357. /** @hidden */
  74358. _lastControlDown: {
  74359. [pointerId: number]: Control;
  74360. };
  74361. /** @hidden */
  74362. _capturingControl: {
  74363. [pointerId: number]: Control;
  74364. };
  74365. /** @hidden */
  74366. _shouldBlockPointer: boolean;
  74367. /** @hidden */
  74368. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74369. /** @hidden */
  74370. _linkedControls: Control[];
  74371. private _isFullscreen;
  74372. private _fullscreenViewport;
  74373. private _idealWidth;
  74374. private _idealHeight;
  74375. private _useSmallestIdeal;
  74376. private _renderAtIdealSize;
  74377. private _focusedControl;
  74378. private _blockNextFocusCheck;
  74379. private _renderScale;
  74380. private _rootElement;
  74381. private _cursorChanged;
  74382. private _defaultMousePointerId;
  74383. /** @hidden */
  74384. _numLayoutCalls: number;
  74385. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74386. get numLayoutCalls(): number;
  74387. /** @hidden */
  74388. _numRenderCalls: number;
  74389. /** Gets the number of render calls made the last time the ADT has been rendered */
  74390. get numRenderCalls(): number;
  74391. /**
  74392. * Define type to string to ensure compatibility across browsers
  74393. * Safari doesn't support DataTransfer constructor
  74394. */
  74395. private _clipboardData;
  74396. /**
  74397. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74398. */
  74399. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74400. /**
  74401. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74402. */
  74403. onControlPickedObservable: BABYLON.Observable<Control>;
  74404. /**
  74405. * BABYLON.Observable event triggered before layout is evaluated
  74406. */
  74407. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74408. /**
  74409. * BABYLON.Observable event triggered after the layout was evaluated
  74410. */
  74411. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74412. /**
  74413. * BABYLON.Observable event triggered before the texture is rendered
  74414. */
  74415. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74416. /**
  74417. * BABYLON.Observable event triggered after the texture was rendered
  74418. */
  74419. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74420. /**
  74421. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74422. */
  74423. premulAlpha: boolean;
  74424. /**
  74425. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74426. * Useful when you want more antialiasing
  74427. */
  74428. get renderScale(): number;
  74429. set renderScale(value: number);
  74430. /** Gets or sets the background color */
  74431. get background(): string;
  74432. set background(value: string);
  74433. /**
  74434. * Gets or sets the ideal width used to design controls.
  74435. * The GUI will then rescale everything accordingly
  74436. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74437. */
  74438. get idealWidth(): number;
  74439. set idealWidth(value: number);
  74440. /**
  74441. * Gets or sets the ideal height used to design controls.
  74442. * The GUI will then rescale everything accordingly
  74443. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74444. */
  74445. get idealHeight(): number;
  74446. set idealHeight(value: number);
  74447. /**
  74448. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74449. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74450. */
  74451. get useSmallestIdeal(): boolean;
  74452. set useSmallestIdeal(value: boolean);
  74453. /**
  74454. * Gets or sets a boolean indicating if adaptive scaling must be used
  74455. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74456. */
  74457. get renderAtIdealSize(): boolean;
  74458. set renderAtIdealSize(value: boolean);
  74459. /**
  74460. * Gets the ratio used when in "ideal mode"
  74461. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74462. * */
  74463. get idealRatio(): number;
  74464. /**
  74465. * Gets the underlying layer used to render the texture when in fullscreen mode
  74466. */
  74467. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74468. /**
  74469. * Gets the root container control
  74470. */
  74471. get rootContainer(): Container;
  74472. /**
  74473. * Returns an array containing the root container.
  74474. * This is mostly used to let the Inspector introspects the ADT
  74475. * @returns an array containing the rootContainer
  74476. */
  74477. getChildren(): Array<Container>;
  74478. /**
  74479. * Will return all controls that are inside this texture
  74480. * @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
  74481. * @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
  74482. * @return all child controls
  74483. */
  74484. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74485. /**
  74486. * Gets or sets the current focused control
  74487. */
  74488. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74489. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74490. /**
  74491. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74492. */
  74493. get isForeground(): boolean;
  74494. set isForeground(value: boolean);
  74495. /**
  74496. * Gets or set information about clipboardData
  74497. */
  74498. get clipboardData(): string;
  74499. set clipboardData(value: string);
  74500. /**
  74501. * Creates a new AdvancedDynamicTexture
  74502. * @param name defines the name of the texture
  74503. * @param width defines the width of the texture
  74504. * @param height defines the height of the texture
  74505. * @param scene defines the hosting scene
  74506. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74507. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74508. */
  74509. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74510. /**
  74511. * Get the current class name of the texture useful for serialization or dynamic coding.
  74512. * @returns "AdvancedDynamicTexture"
  74513. */
  74514. getClassName(): string;
  74515. /**
  74516. * Function used to execute a function on all controls
  74517. * @param func defines the function to execute
  74518. * @param container defines the container where controls belong. If null the root container will be used
  74519. */
  74520. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74521. private _useInvalidateRectOptimization;
  74522. /**
  74523. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74524. */
  74525. get useInvalidateRectOptimization(): boolean;
  74526. set useInvalidateRectOptimization(value: boolean);
  74527. private _invalidatedRectangle;
  74528. /**
  74529. * Invalidates a rectangle area on the gui texture
  74530. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74531. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74532. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74533. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74534. */
  74535. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74536. /**
  74537. * Marks the texture as dirty forcing a complete update
  74538. */
  74539. markAsDirty(): void;
  74540. /**
  74541. * Helper function used to create a new style
  74542. * @returns a new style
  74543. * @see http://doc.babylonjs.com/how_to/gui#styles
  74544. */
  74545. createStyle(): Style;
  74546. /**
  74547. * Adds a new control to the root container
  74548. * @param control defines the control to add
  74549. * @returns the current texture
  74550. */
  74551. addControl(control: Control): AdvancedDynamicTexture;
  74552. /**
  74553. * Removes a control from the root container
  74554. * @param control defines the control to remove
  74555. * @returns the current texture
  74556. */
  74557. removeControl(control: Control): AdvancedDynamicTexture;
  74558. /**
  74559. * Release all resources
  74560. */
  74561. dispose(): void;
  74562. private _onResize;
  74563. /** @hidden */
  74564. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74565. /**
  74566. * Get screen coordinates for a vector3
  74567. * @param position defines the position to project
  74568. * @param worldMatrix defines the world matrix to use
  74569. * @returns the projected position
  74570. */
  74571. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74572. private _checkUpdate;
  74573. private _clearMeasure;
  74574. private _render;
  74575. /** @hidden */
  74576. _changeCursor(cursor: string): void;
  74577. /** @hidden */
  74578. _registerLastControlDown(control: Control, pointerId: number): void;
  74579. private _doPicking;
  74580. /** @hidden */
  74581. _cleanControlAfterRemovalFromList(list: {
  74582. [pointerId: number]: Control;
  74583. }, control: Control): void;
  74584. /** @hidden */
  74585. _cleanControlAfterRemoval(control: Control): void;
  74586. /** Attach to all scene events required to support pointer events */
  74587. attach(): void;
  74588. /** @hidden */
  74589. private onClipboardCopy;
  74590. /** @hidden */
  74591. private onClipboardCut;
  74592. /** @hidden */
  74593. private onClipboardPaste;
  74594. /**
  74595. * Register the clipboard Events onto the canvas
  74596. */
  74597. registerClipboardEvents(): void;
  74598. /**
  74599. * Unregister the clipboard Events from the canvas
  74600. */
  74601. unRegisterClipboardEvents(): void;
  74602. /**
  74603. * Connect the texture to a hosting mesh to enable interactions
  74604. * @param mesh defines the mesh to attach to
  74605. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74606. */
  74607. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74608. /**
  74609. * Move the focus to a specific control
  74610. * @param control defines the control which will receive the focus
  74611. */
  74612. moveFocusToControl(control: IFocusableControl): void;
  74613. private _manageFocus;
  74614. private _attachToOnPointerOut;
  74615. /**
  74616. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74617. * @param mesh defines the mesh which will receive the texture
  74618. * @param width defines the texture width (1024 by default)
  74619. * @param height defines the texture height (1024 by default)
  74620. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74621. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74622. * @returns a new AdvancedDynamicTexture
  74623. */
  74624. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74625. /**
  74626. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74627. * In this mode the texture will rely on a layer for its rendering.
  74628. * This allows it to be treated like any other layer.
  74629. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74630. * LayerMask is set through advancedTexture.layer.layerMask
  74631. * @param name defines name for the texture
  74632. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74633. * @param scene defines the hsoting scene
  74634. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74635. * @returns a new AdvancedDynamicTexture
  74636. */
  74637. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74638. }
  74639. }
  74640. declare module BABYLON.GUI {
  74641. /**
  74642. * Root class used for all 2D controls
  74643. * @see http://doc.babylonjs.com/how_to/gui#controls
  74644. */
  74645. export class Control {
  74646. /** defines the name of the control */
  74647. name?: string | undefined;
  74648. /**
  74649. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74650. */
  74651. static AllowAlphaInheritance: boolean;
  74652. private _alpha;
  74653. private _alphaSet;
  74654. private _zIndex;
  74655. /** @hidden */
  74656. _host: AdvancedDynamicTexture;
  74657. /** Gets or sets the control parent */
  74658. parent: BABYLON.Nullable<Container>;
  74659. /** @hidden */
  74660. _currentMeasure: Measure;
  74661. private _fontFamily;
  74662. private _fontStyle;
  74663. private _fontWeight;
  74664. private _fontSize;
  74665. private _font;
  74666. /** @hidden */
  74667. _width: ValueAndUnit;
  74668. /** @hidden */
  74669. _height: ValueAndUnit;
  74670. /** @hidden */
  74671. protected _fontOffset: {
  74672. ascent: number;
  74673. height: number;
  74674. descent: number;
  74675. };
  74676. private _color;
  74677. private _style;
  74678. private _styleObserver;
  74679. /** @hidden */
  74680. protected _horizontalAlignment: number;
  74681. /** @hidden */
  74682. protected _verticalAlignment: number;
  74683. /** @hidden */
  74684. protected _isDirty: boolean;
  74685. /** @hidden */
  74686. protected _wasDirty: boolean;
  74687. /** @hidden */
  74688. _tempParentMeasure: Measure;
  74689. /** @hidden */
  74690. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74691. /** @hidden */
  74692. protected _cachedParentMeasure: Measure;
  74693. private _paddingLeft;
  74694. private _paddingRight;
  74695. private _paddingTop;
  74696. private _paddingBottom;
  74697. /** @hidden */
  74698. _left: ValueAndUnit;
  74699. /** @hidden */
  74700. _top: ValueAndUnit;
  74701. private _scaleX;
  74702. private _scaleY;
  74703. private _rotation;
  74704. private _transformCenterX;
  74705. private _transformCenterY;
  74706. /** @hidden */
  74707. _transformMatrix: Matrix2D;
  74708. /** @hidden */
  74709. protected _invertTransformMatrix: Matrix2D;
  74710. /** @hidden */
  74711. protected _transformedPosition: BABYLON.Vector2;
  74712. private _isMatrixDirty;
  74713. private _cachedOffsetX;
  74714. private _cachedOffsetY;
  74715. private _isVisible;
  74716. private _isHighlighted;
  74717. /** @hidden */
  74718. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74719. private _fontSet;
  74720. private _dummyVector2;
  74721. private _downCount;
  74722. private _enterCount;
  74723. private _doNotRender;
  74724. private _downPointerIds;
  74725. protected _isEnabled: boolean;
  74726. protected _disabledColor: string;
  74727. protected _disabledColorItem: string;
  74728. /** @hidden */
  74729. protected _rebuildLayout: boolean;
  74730. /** @hidden */
  74731. _customData: any;
  74732. /** @hidden */
  74733. _isClipped: boolean;
  74734. /** @hidden */
  74735. _automaticSize: boolean;
  74736. /** @hidden */
  74737. _tag: any;
  74738. /**
  74739. * 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
  74740. */
  74741. uniqueId: number;
  74742. /**
  74743. * Gets or sets an object used to store user defined information for the node
  74744. */
  74745. metadata: any;
  74746. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74747. isHitTestVisible: boolean;
  74748. /** Gets or sets a boolean indicating if the control can block pointer events */
  74749. isPointerBlocker: boolean;
  74750. /** Gets or sets a boolean indicating if the control can be focusable */
  74751. isFocusInvisible: boolean;
  74752. /**
  74753. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74754. * 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
  74755. */
  74756. clipChildren: boolean;
  74757. /**
  74758. * Gets or sets a boolean indicating that control content must be clipped
  74759. * 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
  74760. */
  74761. clipContent: boolean;
  74762. /**
  74763. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74764. */
  74765. useBitmapCache: boolean;
  74766. private _cacheData;
  74767. private _shadowOffsetX;
  74768. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74769. get shadowOffsetX(): number;
  74770. set shadowOffsetX(value: number);
  74771. private _shadowOffsetY;
  74772. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74773. get shadowOffsetY(): number;
  74774. set shadowOffsetY(value: number);
  74775. private _shadowBlur;
  74776. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74777. get shadowBlur(): number;
  74778. set shadowBlur(value: number);
  74779. private _shadowColor;
  74780. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74781. get shadowColor(): string;
  74782. set shadowColor(value: string);
  74783. /** Gets or sets the cursor to use when the control is hovered */
  74784. hoverCursor: string;
  74785. /** @hidden */
  74786. protected _linkOffsetX: ValueAndUnit;
  74787. /** @hidden */
  74788. protected _linkOffsetY: ValueAndUnit;
  74789. /** Gets the control type name */
  74790. get typeName(): string;
  74791. /**
  74792. * Get the current class name of the control.
  74793. * @returns current class name
  74794. */
  74795. getClassName(): string;
  74796. /**
  74797. * An event triggered when pointer wheel is scrolled
  74798. */
  74799. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74800. /**
  74801. * An event triggered when the pointer move over the control.
  74802. */
  74803. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74804. /**
  74805. * An event triggered when the pointer move out of the control.
  74806. */
  74807. onPointerOutObservable: BABYLON.Observable<Control>;
  74808. /**
  74809. * An event triggered when the pointer taps the control
  74810. */
  74811. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74812. /**
  74813. * An event triggered when pointer up
  74814. */
  74815. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74816. /**
  74817. * An event triggered when a control is clicked on
  74818. */
  74819. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74820. /**
  74821. * An event triggered when pointer enters the control
  74822. */
  74823. onPointerEnterObservable: BABYLON.Observable<Control>;
  74824. /**
  74825. * An event triggered when the control is marked as dirty
  74826. */
  74827. onDirtyObservable: BABYLON.Observable<Control>;
  74828. /**
  74829. * An event triggered before drawing the control
  74830. */
  74831. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74832. /**
  74833. * An event triggered after the control was drawn
  74834. */
  74835. onAfterDrawObservable: BABYLON.Observable<Control>;
  74836. /**
  74837. * An event triggered when the control has been disposed
  74838. */
  74839. onDisposeObservable: BABYLON.Observable<Control>;
  74840. /**
  74841. * Get the hosting AdvancedDynamicTexture
  74842. */
  74843. get host(): AdvancedDynamicTexture;
  74844. /** Gets or set information about font offsets (used to render and align text) */
  74845. get fontOffset(): {
  74846. ascent: number;
  74847. height: number;
  74848. descent: number;
  74849. };
  74850. set fontOffset(offset: {
  74851. ascent: number;
  74852. height: number;
  74853. descent: number;
  74854. });
  74855. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74856. get alpha(): number;
  74857. set alpha(value: number);
  74858. /**
  74859. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74860. */
  74861. get isHighlighted(): boolean;
  74862. set isHighlighted(value: boolean);
  74863. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74864. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74865. */
  74866. get scaleX(): number;
  74867. set scaleX(value: number);
  74868. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74869. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74870. */
  74871. get scaleY(): number;
  74872. set scaleY(value: number);
  74873. /** Gets or sets the rotation angle (0 by default)
  74874. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74875. */
  74876. get rotation(): number;
  74877. set rotation(value: number);
  74878. /** Gets or sets the transformation center on Y axis (0 by default)
  74879. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74880. */
  74881. get transformCenterY(): number;
  74882. set transformCenterY(value: number);
  74883. /** Gets or sets the transformation center on X axis (0 by default)
  74884. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74885. */
  74886. get transformCenterX(): number;
  74887. set transformCenterX(value: number);
  74888. /**
  74889. * Gets or sets the horizontal alignment
  74890. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74891. */
  74892. get horizontalAlignment(): number;
  74893. set horizontalAlignment(value: number);
  74894. /**
  74895. * Gets or sets the vertical alignment
  74896. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74897. */
  74898. get verticalAlignment(): number;
  74899. set verticalAlignment(value: number);
  74900. /**
  74901. * Gets or sets control width
  74902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74903. */
  74904. get width(): string | number;
  74905. set width(value: string | number);
  74906. /**
  74907. * Gets or sets the control width in pixel
  74908. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74909. */
  74910. get widthInPixels(): number;
  74911. set widthInPixels(value: number);
  74912. /**
  74913. * Gets or sets control height
  74914. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74915. */
  74916. get height(): string | number;
  74917. set height(value: string | number);
  74918. /**
  74919. * Gets or sets control height in pixel
  74920. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74921. */
  74922. get heightInPixels(): number;
  74923. set heightInPixels(value: number);
  74924. /** Gets or set font family */
  74925. get fontFamily(): string;
  74926. set fontFamily(value: string);
  74927. /** Gets or sets font style */
  74928. get fontStyle(): string;
  74929. set fontStyle(value: string);
  74930. /** Gets or sets font weight */
  74931. get fontWeight(): string;
  74932. set fontWeight(value: string);
  74933. /**
  74934. * Gets or sets style
  74935. * @see http://doc.babylonjs.com/how_to/gui#styles
  74936. */
  74937. get style(): BABYLON.Nullable<Style>;
  74938. set style(value: BABYLON.Nullable<Style>);
  74939. /** @hidden */
  74940. get _isFontSizeInPercentage(): boolean;
  74941. /** Gets or sets font size in pixels */
  74942. get fontSizeInPixels(): number;
  74943. set fontSizeInPixels(value: number);
  74944. /** Gets or sets font size */
  74945. get fontSize(): string | number;
  74946. set fontSize(value: string | number);
  74947. /** Gets or sets foreground color */
  74948. get color(): string;
  74949. set color(value: string);
  74950. /** Gets or sets z index which is used to reorder controls on the z axis */
  74951. get zIndex(): number;
  74952. set zIndex(value: number);
  74953. /** Gets or sets a boolean indicating if the control can be rendered */
  74954. get notRenderable(): boolean;
  74955. set notRenderable(value: boolean);
  74956. /** Gets or sets a boolean indicating if the control is visible */
  74957. get isVisible(): boolean;
  74958. set isVisible(value: boolean);
  74959. /** Gets a boolean indicating that the control needs to update its rendering */
  74960. get isDirty(): boolean;
  74961. /**
  74962. * Gets the current linked mesh (or null if none)
  74963. */
  74964. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74965. /**
  74966. * Gets or sets a value indicating the padding to use on the left of the control
  74967. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74968. */
  74969. get paddingLeft(): string | number;
  74970. set paddingLeft(value: string | number);
  74971. /**
  74972. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74974. */
  74975. get paddingLeftInPixels(): number;
  74976. set paddingLeftInPixels(value: number);
  74977. /**
  74978. * Gets or sets a value indicating the padding to use on the right of the control
  74979. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74980. */
  74981. get paddingRight(): string | number;
  74982. set paddingRight(value: string | number);
  74983. /**
  74984. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74985. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74986. */
  74987. get paddingRightInPixels(): number;
  74988. set paddingRightInPixels(value: number);
  74989. /**
  74990. * Gets or sets a value indicating the padding to use on the top of the control
  74991. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74992. */
  74993. get paddingTop(): string | number;
  74994. set paddingTop(value: string | number);
  74995. /**
  74996. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74997. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74998. */
  74999. get paddingTopInPixels(): number;
  75000. set paddingTopInPixels(value: number);
  75001. /**
  75002. * Gets or sets a value indicating the padding to use on the bottom of the control
  75003. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75004. */
  75005. get paddingBottom(): string | number;
  75006. set paddingBottom(value: string | number);
  75007. /**
  75008. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75009. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75010. */
  75011. get paddingBottomInPixels(): number;
  75012. set paddingBottomInPixels(value: number);
  75013. /**
  75014. * Gets or sets a value indicating the left coordinate of the control
  75015. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75016. */
  75017. get left(): string | number;
  75018. set left(value: string | number);
  75019. /**
  75020. * Gets or sets a value indicating the left coordinate in pixels of the control
  75021. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75022. */
  75023. get leftInPixels(): number;
  75024. set leftInPixels(value: number);
  75025. /**
  75026. * Gets or sets a value indicating the top coordinate of the control
  75027. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75028. */
  75029. get top(): string | number;
  75030. set top(value: string | number);
  75031. /**
  75032. * Gets or sets a value indicating the top coordinate in pixels of the control
  75033. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75034. */
  75035. get topInPixels(): number;
  75036. set topInPixels(value: number);
  75037. /**
  75038. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75039. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75040. */
  75041. get linkOffsetX(): string | number;
  75042. set linkOffsetX(value: string | number);
  75043. /**
  75044. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75045. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75046. */
  75047. get linkOffsetXInPixels(): number;
  75048. set linkOffsetXInPixels(value: number);
  75049. /**
  75050. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75051. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75052. */
  75053. get linkOffsetY(): string | number;
  75054. set linkOffsetY(value: string | number);
  75055. /**
  75056. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75057. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75058. */
  75059. get linkOffsetYInPixels(): number;
  75060. set linkOffsetYInPixels(value: number);
  75061. /** Gets the center coordinate on X axis */
  75062. get centerX(): number;
  75063. /** Gets the center coordinate on Y axis */
  75064. get centerY(): number;
  75065. /** Gets or sets if control is Enabled*/
  75066. get isEnabled(): boolean;
  75067. set isEnabled(value: boolean);
  75068. /** Gets or sets background color of control if it's disabled*/
  75069. get disabledColor(): string;
  75070. set disabledColor(value: string);
  75071. /** Gets or sets front color of control if it's disabled*/
  75072. get disabledColorItem(): string;
  75073. set disabledColorItem(value: string);
  75074. /**
  75075. * Creates a new control
  75076. * @param name defines the name of the control
  75077. */
  75078. constructor(
  75079. /** defines the name of the control */
  75080. name?: string | undefined);
  75081. /** @hidden */
  75082. protected _getTypeName(): string;
  75083. /**
  75084. * Gets the first ascendant in the hierarchy of the given type
  75085. * @param className defines the required type
  75086. * @returns the ascendant or null if not found
  75087. */
  75088. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75089. /** @hidden */
  75090. _resetFontCache(): void;
  75091. /**
  75092. * Determines if a container is an ascendant of the current control
  75093. * @param container defines the container to look for
  75094. * @returns true if the container is one of the ascendant of the control
  75095. */
  75096. isAscendant(container: Control): boolean;
  75097. /**
  75098. * Gets coordinates in local control space
  75099. * @param globalCoordinates defines the coordinates to transform
  75100. * @returns the new coordinates in local space
  75101. */
  75102. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75103. /**
  75104. * Gets coordinates in local control space
  75105. * @param globalCoordinates defines the coordinates to transform
  75106. * @param result defines the target vector2 where to store the result
  75107. * @returns the current control
  75108. */
  75109. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75110. /**
  75111. * Gets coordinates in parent local control space
  75112. * @param globalCoordinates defines the coordinates to transform
  75113. * @returns the new coordinates in parent local space
  75114. */
  75115. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75116. /**
  75117. * Move the current control to a vector3 position projected onto the screen.
  75118. * @param position defines the target position
  75119. * @param scene defines the hosting scene
  75120. */
  75121. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75122. /**
  75123. * Will store all controls that have this control as ascendant in a given array
  75124. * @param results defines the array where to store the descendants
  75125. * @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
  75126. * @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
  75127. */
  75128. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75129. /**
  75130. * Will return all controls that have this control as ascendant
  75131. * @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
  75132. * @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
  75133. * @return all child controls
  75134. */
  75135. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75136. /**
  75137. * Link current control with a target mesh
  75138. * @param mesh defines the mesh to link with
  75139. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75140. */
  75141. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75142. /** @hidden */
  75143. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75144. /** @hidden */
  75145. _offsetLeft(offset: number): void;
  75146. /** @hidden */
  75147. _offsetTop(offset: number): void;
  75148. /** @hidden */
  75149. _markMatrixAsDirty(): void;
  75150. /** @hidden */
  75151. _flagDescendantsAsMatrixDirty(): void;
  75152. /** @hidden */
  75153. _intersectsRect(rect: Measure): boolean;
  75154. /** @hidden */
  75155. protected invalidateRect(): void;
  75156. /** @hidden */
  75157. _markAsDirty(force?: boolean): void;
  75158. /** @hidden */
  75159. _markAllAsDirty(): void;
  75160. /** @hidden */
  75161. _link(host: AdvancedDynamicTexture): void;
  75162. /** @hidden */
  75163. protected _transform(context?: CanvasRenderingContext2D): void;
  75164. /** @hidden */
  75165. _renderHighlight(context: CanvasRenderingContext2D): void;
  75166. /** @hidden */
  75167. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75168. /** @hidden */
  75169. protected _applyStates(context: CanvasRenderingContext2D): void;
  75170. /** @hidden */
  75171. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75172. /** @hidden */
  75173. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75174. protected _evaluateClippingState(parentMeasure: Measure): void;
  75175. /** @hidden */
  75176. _measure(): void;
  75177. /** @hidden */
  75178. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75179. /** @hidden */
  75180. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75181. /** @hidden */
  75182. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75183. /** @hidden */
  75184. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75185. private static _ClipMeasure;
  75186. private _tmpMeasureA;
  75187. private _clip;
  75188. /** @hidden */
  75189. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75190. /** @hidden */
  75191. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75192. /**
  75193. * Tests if a given coordinates belong to the current control
  75194. * @param x defines x coordinate to test
  75195. * @param y defines y coordinate to test
  75196. * @returns true if the coordinates are inside the control
  75197. */
  75198. contains(x: number, y: number): boolean;
  75199. /** @hidden */
  75200. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75201. /** @hidden */
  75202. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75203. /** @hidden */
  75204. _onPointerEnter(target: Control): boolean;
  75205. /** @hidden */
  75206. _onPointerOut(target: Control, force?: boolean): void;
  75207. /** @hidden */
  75208. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75209. /** @hidden */
  75210. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75211. /** @hidden */
  75212. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75213. /** @hidden */
  75214. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75215. /** @hidden */
  75216. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75217. private _prepareFont;
  75218. /** Releases associated resources */
  75219. dispose(): void;
  75220. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75221. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75222. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75223. private static _VERTICAL_ALIGNMENT_TOP;
  75224. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75225. private static _VERTICAL_ALIGNMENT_CENTER;
  75226. /** HORIZONTAL_ALIGNMENT_LEFT */
  75227. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75228. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75229. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75230. /** HORIZONTAL_ALIGNMENT_CENTER */
  75231. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75232. /** VERTICAL_ALIGNMENT_TOP */
  75233. static get VERTICAL_ALIGNMENT_TOP(): number;
  75234. /** VERTICAL_ALIGNMENT_BOTTOM */
  75235. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75236. /** VERTICAL_ALIGNMENT_CENTER */
  75237. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75238. private static _FontHeightSizes;
  75239. /** @hidden */
  75240. static _GetFontOffset(font: string): {
  75241. ascent: number;
  75242. height: number;
  75243. descent: number;
  75244. };
  75245. /**
  75246. * Creates a stack panel that can be used to render headers
  75247. * @param control defines the control to associate with the header
  75248. * @param text defines the text of the header
  75249. * @param size defines the size of the header
  75250. * @param options defines options used to configure the header
  75251. * @returns a new StackPanel
  75252. * @ignore
  75253. * @hidden
  75254. */
  75255. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75256. isHorizontal: boolean;
  75257. controlFirst: boolean;
  75258. }) => any;
  75259. /** @hidden */
  75260. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75261. }
  75262. }
  75263. declare module BABYLON.GUI {
  75264. /**
  75265. * Root class for 2D containers
  75266. * @see http://doc.babylonjs.com/how_to/gui#containers
  75267. */
  75268. export class Container extends Control {
  75269. name?: string | undefined;
  75270. /** @hidden */
  75271. _children: Control[];
  75272. /** @hidden */
  75273. protected _measureForChildren: Measure;
  75274. /** @hidden */
  75275. protected _background: string;
  75276. /** @hidden */
  75277. protected _adaptWidthToChildren: boolean;
  75278. /** @hidden */
  75279. protected _adaptHeightToChildren: boolean;
  75280. /**
  75281. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75282. */
  75283. logLayoutCycleErrors: boolean;
  75284. /**
  75285. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75286. */
  75287. maxLayoutCycle: number;
  75288. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75289. get adaptHeightToChildren(): boolean;
  75290. set adaptHeightToChildren(value: boolean);
  75291. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75292. get adaptWidthToChildren(): boolean;
  75293. set adaptWidthToChildren(value: boolean);
  75294. /** Gets or sets background color */
  75295. get background(): string;
  75296. set background(value: string);
  75297. /** Gets the list of children */
  75298. get children(): Control[];
  75299. /**
  75300. * Creates a new Container
  75301. * @param name defines the name of the container
  75302. */
  75303. constructor(name?: string | undefined);
  75304. protected _getTypeName(): string;
  75305. _flagDescendantsAsMatrixDirty(): void;
  75306. /**
  75307. * Gets a child using its name
  75308. * @param name defines the child name to look for
  75309. * @returns the child control if found
  75310. */
  75311. getChildByName(name: string): BABYLON.Nullable<Control>;
  75312. /**
  75313. * Gets a child using its type and its name
  75314. * @param name defines the child name to look for
  75315. * @param type defines the child type to look for
  75316. * @returns the child control if found
  75317. */
  75318. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75319. /**
  75320. * Search for a specific control in children
  75321. * @param control defines the control to look for
  75322. * @returns true if the control is in child list
  75323. */
  75324. containsControl(control: Control): boolean;
  75325. /**
  75326. * Adds a new control to the current container
  75327. * @param control defines the control to add
  75328. * @returns the current container
  75329. */
  75330. addControl(control: BABYLON.Nullable<Control>): Container;
  75331. /**
  75332. * Removes all controls from the current container
  75333. * @returns the current container
  75334. */
  75335. clearControls(): Container;
  75336. /**
  75337. * Removes a control from the current container
  75338. * @param control defines the control to remove
  75339. * @returns the current container
  75340. */
  75341. removeControl(control: Control): Container;
  75342. /** @hidden */
  75343. _reOrderControl(control: Control): void;
  75344. /** @hidden */
  75345. _offsetLeft(offset: number): void;
  75346. /** @hidden */
  75347. _offsetTop(offset: number): void;
  75348. /** @hidden */
  75349. _markAllAsDirty(): void;
  75350. /** @hidden */
  75351. protected _localDraw(context: CanvasRenderingContext2D): void;
  75352. /** @hidden */
  75353. _link(host: AdvancedDynamicTexture): void;
  75354. /** @hidden */
  75355. protected _beforeLayout(): void;
  75356. /** @hidden */
  75357. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75358. /** @hidden */
  75359. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75360. protected _postMeasure(): void;
  75361. /** @hidden */
  75362. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75363. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75364. /** @hidden */
  75365. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75366. /** @hidden */
  75367. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75368. /** Releases associated resources */
  75369. dispose(): void;
  75370. }
  75371. }
  75372. declare module BABYLON.GUI {
  75373. /** Class used to create rectangle container */
  75374. export class Rectangle extends Container {
  75375. name?: string | undefined;
  75376. private _thickness;
  75377. private _cornerRadius;
  75378. /** Gets or sets border thickness */
  75379. get thickness(): number;
  75380. set thickness(value: number);
  75381. /** Gets or sets the corner radius angle */
  75382. get cornerRadius(): number;
  75383. set cornerRadius(value: number);
  75384. /**
  75385. * Creates a new Rectangle
  75386. * @param name defines the control name
  75387. */
  75388. constructor(name?: string | undefined);
  75389. protected _getTypeName(): string;
  75390. protected _localDraw(context: CanvasRenderingContext2D): void;
  75391. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75392. private _drawRoundedRect;
  75393. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75394. }
  75395. }
  75396. declare module BABYLON.GUI {
  75397. /**
  75398. * Enum that determines the text-wrapping mode to use.
  75399. */
  75400. export enum TextWrapping {
  75401. /**
  75402. * Clip the text when it's larger than Control.width; this is the default mode.
  75403. */
  75404. Clip = 0,
  75405. /**
  75406. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75407. */
  75408. WordWrap = 1,
  75409. /**
  75410. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75411. */
  75412. Ellipsis = 2
  75413. }
  75414. /**
  75415. * Class used to create text block control
  75416. */
  75417. export class TextBlock extends Control {
  75418. /**
  75419. * Defines the name of the control
  75420. */
  75421. name?: string | undefined;
  75422. private _text;
  75423. private _textWrapping;
  75424. private _textHorizontalAlignment;
  75425. private _textVerticalAlignment;
  75426. private _lines;
  75427. private _resizeToFit;
  75428. private _lineSpacing;
  75429. private _outlineWidth;
  75430. private _outlineColor;
  75431. /**
  75432. * An event triggered after the text is changed
  75433. */
  75434. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75435. /**
  75436. * An event triggered after the text was broken up into lines
  75437. */
  75438. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75439. /**
  75440. * Function used to split a string into words. By default, a string is split at each space character found
  75441. */
  75442. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75443. /**
  75444. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75445. */
  75446. get lines(): any[];
  75447. /**
  75448. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75449. */
  75450. get resizeToFit(): boolean;
  75451. /**
  75452. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75453. */
  75454. set resizeToFit(value: boolean);
  75455. /**
  75456. * Gets or sets a boolean indicating if text must be wrapped
  75457. */
  75458. get textWrapping(): TextWrapping | boolean;
  75459. /**
  75460. * Gets or sets a boolean indicating if text must be wrapped
  75461. */
  75462. set textWrapping(value: TextWrapping | boolean);
  75463. /**
  75464. * Gets or sets text to display
  75465. */
  75466. get text(): string;
  75467. /**
  75468. * Gets or sets text to display
  75469. */
  75470. set text(value: string);
  75471. /**
  75472. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75473. */
  75474. get textHorizontalAlignment(): number;
  75475. /**
  75476. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75477. */
  75478. set textHorizontalAlignment(value: number);
  75479. /**
  75480. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75481. */
  75482. get textVerticalAlignment(): number;
  75483. /**
  75484. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75485. */
  75486. set textVerticalAlignment(value: number);
  75487. /**
  75488. * Gets or sets line spacing value
  75489. */
  75490. set lineSpacing(value: string | number);
  75491. /**
  75492. * Gets or sets line spacing value
  75493. */
  75494. get lineSpacing(): string | number;
  75495. /**
  75496. * Gets or sets outlineWidth of the text to display
  75497. */
  75498. get outlineWidth(): number;
  75499. /**
  75500. * Gets or sets outlineWidth of the text to display
  75501. */
  75502. set outlineWidth(value: number);
  75503. /**
  75504. * Gets or sets outlineColor of the text to display
  75505. */
  75506. get outlineColor(): string;
  75507. /**
  75508. * Gets or sets outlineColor of the text to display
  75509. */
  75510. set outlineColor(value: string);
  75511. /**
  75512. * Creates a new TextBlock object
  75513. * @param name defines the name of the control
  75514. * @param text defines the text to display (emptry string by default)
  75515. */
  75516. constructor(
  75517. /**
  75518. * Defines the name of the control
  75519. */
  75520. name?: string | undefined, text?: string);
  75521. protected _getTypeName(): string;
  75522. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75523. private _drawText;
  75524. /** @hidden */
  75525. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75526. protected _applyStates(context: CanvasRenderingContext2D): void;
  75527. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75528. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75529. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75530. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75531. protected _renderLines(context: CanvasRenderingContext2D): void;
  75532. /**
  75533. * Given a width constraint applied on the text block, find the expected height
  75534. * @returns expected height
  75535. */
  75536. computeExpectedHeight(): number;
  75537. dispose(): void;
  75538. }
  75539. }
  75540. declare module BABYLON.GUI {
  75541. /**
  75542. * Class used to create 2D images
  75543. */
  75544. export class Image extends Control {
  75545. name?: string | undefined;
  75546. private _workingCanvas;
  75547. private _domImage;
  75548. private _imageWidth;
  75549. private _imageHeight;
  75550. private _loaded;
  75551. private _stretch;
  75552. private _source;
  75553. private _autoScale;
  75554. private _sourceLeft;
  75555. private _sourceTop;
  75556. private _sourceWidth;
  75557. private _sourceHeight;
  75558. private _svgAttributesComputationCompleted;
  75559. private _isSVG;
  75560. private _cellWidth;
  75561. private _cellHeight;
  75562. private _cellId;
  75563. private _populateNinePatchSlicesFromImage;
  75564. private _sliceLeft;
  75565. private _sliceRight;
  75566. private _sliceTop;
  75567. private _sliceBottom;
  75568. private _detectPointerOnOpaqueOnly;
  75569. /**
  75570. * BABYLON.Observable notified when the content is loaded
  75571. */
  75572. onImageLoadedObservable: BABYLON.Observable<Image>;
  75573. /**
  75574. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75575. */
  75576. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75577. /**
  75578. * Gets a boolean indicating that the content is loaded
  75579. */
  75580. get isLoaded(): boolean;
  75581. /**
  75582. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75583. */
  75584. get populateNinePatchSlicesFromImage(): boolean;
  75585. set populateNinePatchSlicesFromImage(value: boolean);
  75586. /**
  75587. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75588. * Beware using this as this will comsume more memory as the image has to be stored twice
  75589. */
  75590. get detectPointerOnOpaqueOnly(): boolean;
  75591. set detectPointerOnOpaqueOnly(value: boolean);
  75592. /**
  75593. * Gets or sets the left value for slicing (9-patch)
  75594. */
  75595. get sliceLeft(): number;
  75596. set sliceLeft(value: number);
  75597. /**
  75598. * Gets or sets the right value for slicing (9-patch)
  75599. */
  75600. get sliceRight(): number;
  75601. set sliceRight(value: number);
  75602. /**
  75603. * Gets or sets the top value for slicing (9-patch)
  75604. */
  75605. get sliceTop(): number;
  75606. set sliceTop(value: number);
  75607. /**
  75608. * Gets or sets the bottom value for slicing (9-patch)
  75609. */
  75610. get sliceBottom(): number;
  75611. set sliceBottom(value: number);
  75612. /**
  75613. * Gets or sets the left coordinate in the source image
  75614. */
  75615. get sourceLeft(): number;
  75616. set sourceLeft(value: number);
  75617. /**
  75618. * Gets or sets the top coordinate in the source image
  75619. */
  75620. get sourceTop(): number;
  75621. set sourceTop(value: number);
  75622. /**
  75623. * Gets or sets the width to capture in the source image
  75624. */
  75625. get sourceWidth(): number;
  75626. set sourceWidth(value: number);
  75627. /**
  75628. * Gets or sets the height to capture in the source image
  75629. */
  75630. get sourceHeight(): number;
  75631. set sourceHeight(value: number);
  75632. /** Indicates if the format of the image is SVG */
  75633. get isSVG(): boolean;
  75634. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75635. get svgAttributesComputationCompleted(): boolean;
  75636. /**
  75637. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75638. * @see http://doc.babylonjs.com/how_to/gui#image
  75639. */
  75640. get autoScale(): boolean;
  75641. set autoScale(value: boolean);
  75642. /** Gets or sets the streching mode used by the image */
  75643. get stretch(): number;
  75644. set stretch(value: number);
  75645. /** @hidden */
  75646. _rotate90(n: number, preserveProperties?: boolean): Image;
  75647. private _handleRotationForSVGImage;
  75648. private _rotate90SourceProperties;
  75649. /**
  75650. * Gets or sets the internal DOM image used to render the control
  75651. */
  75652. set domImage(value: HTMLImageElement);
  75653. get domImage(): HTMLImageElement;
  75654. private _onImageLoaded;
  75655. private _extractNinePatchSliceDataFromImage;
  75656. /**
  75657. * Gets or sets image source url
  75658. */
  75659. set source(value: BABYLON.Nullable<string>);
  75660. /**
  75661. * Checks for svg document with icon id present
  75662. */
  75663. private _svgCheck;
  75664. /**
  75665. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75666. * given external svg file and icon id
  75667. */
  75668. private _getSVGAttribs;
  75669. /**
  75670. * Gets or sets the cell width to use when animation sheet is enabled
  75671. * @see http://doc.babylonjs.com/how_to/gui#image
  75672. */
  75673. get cellWidth(): number;
  75674. set cellWidth(value: number);
  75675. /**
  75676. * Gets or sets the cell height to use when animation sheet is enabled
  75677. * @see http://doc.babylonjs.com/how_to/gui#image
  75678. */
  75679. get cellHeight(): number;
  75680. set cellHeight(value: number);
  75681. /**
  75682. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75683. * @see http://doc.babylonjs.com/how_to/gui#image
  75684. */
  75685. get cellId(): number;
  75686. set cellId(value: number);
  75687. /**
  75688. * Creates a new Image
  75689. * @param name defines the control name
  75690. * @param url defines the image url
  75691. */
  75692. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75693. /**
  75694. * Tests if a given coordinates belong to the current control
  75695. * @param x defines x coordinate to test
  75696. * @param y defines y coordinate to test
  75697. * @returns true if the coordinates are inside the control
  75698. */
  75699. contains(x: number, y: number): boolean;
  75700. protected _getTypeName(): string;
  75701. /** Force the control to synchronize with its content */
  75702. synchronizeSizeWithContent(): void;
  75703. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75704. private _prepareWorkingCanvasForOpaqueDetection;
  75705. private _drawImage;
  75706. _draw(context: CanvasRenderingContext2D): void;
  75707. private _renderCornerPatch;
  75708. private _renderNinePatch;
  75709. dispose(): void;
  75710. /** STRETCH_NONE */
  75711. static readonly STRETCH_NONE: number;
  75712. /** STRETCH_FILL */
  75713. static readonly STRETCH_FILL: number;
  75714. /** STRETCH_UNIFORM */
  75715. static readonly STRETCH_UNIFORM: number;
  75716. /** STRETCH_EXTEND */
  75717. static readonly STRETCH_EXTEND: number;
  75718. /** NINE_PATCH */
  75719. static readonly STRETCH_NINE_PATCH: number;
  75720. }
  75721. }
  75722. declare module BABYLON.GUI {
  75723. /**
  75724. * Class used to create 2D buttons
  75725. */
  75726. export class Button extends Rectangle {
  75727. name?: string | undefined;
  75728. /**
  75729. * Function called to generate a pointer enter animation
  75730. */
  75731. pointerEnterAnimation: () => void;
  75732. /**
  75733. * Function called to generate a pointer out animation
  75734. */
  75735. pointerOutAnimation: () => void;
  75736. /**
  75737. * Function called to generate a pointer down animation
  75738. */
  75739. pointerDownAnimation: () => void;
  75740. /**
  75741. * Function called to generate a pointer up animation
  75742. */
  75743. pointerUpAnimation: () => void;
  75744. /**
  75745. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75746. */
  75747. delegatePickingToChildren: boolean;
  75748. private _image;
  75749. /**
  75750. * Returns the image part of the button (if any)
  75751. */
  75752. get image(): BABYLON.Nullable<Image>;
  75753. private _textBlock;
  75754. /**
  75755. * Returns the image part of the button (if any)
  75756. */
  75757. get textBlock(): BABYLON.Nullable<TextBlock>;
  75758. /**
  75759. * Creates a new Button
  75760. * @param name defines the name of the button
  75761. */
  75762. constructor(name?: string | undefined);
  75763. protected _getTypeName(): string;
  75764. /** @hidden */
  75765. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75766. /** @hidden */
  75767. _onPointerEnter(target: Control): boolean;
  75768. /** @hidden */
  75769. _onPointerOut(target: Control, force?: boolean): void;
  75770. /** @hidden */
  75771. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75772. /** @hidden */
  75773. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75774. /**
  75775. * Creates a new button made with an image and a text
  75776. * @param name defines the name of the button
  75777. * @param text defines the text of the button
  75778. * @param imageUrl defines the url of the image
  75779. * @returns a new Button
  75780. */
  75781. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75782. /**
  75783. * Creates a new button made with an image
  75784. * @param name defines the name of the button
  75785. * @param imageUrl defines the url of the image
  75786. * @returns a new Button
  75787. */
  75788. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75789. /**
  75790. * Creates a new button made with a text
  75791. * @param name defines the name of the button
  75792. * @param text defines the text of the button
  75793. * @returns a new Button
  75794. */
  75795. static CreateSimpleButton(name: string, text: string): Button;
  75796. /**
  75797. * Creates a new button made with an image and a centered text
  75798. * @param name defines the name of the button
  75799. * @param text defines the text of the button
  75800. * @param imageUrl defines the url of the image
  75801. * @returns a new Button
  75802. */
  75803. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75804. }
  75805. }
  75806. declare module BABYLON.GUI {
  75807. /**
  75808. * Class used to create a 2D stack panel container
  75809. */
  75810. export class StackPanel extends Container {
  75811. name?: string | undefined;
  75812. private _isVertical;
  75813. private _manualWidth;
  75814. private _manualHeight;
  75815. private _doNotTrackManualChanges;
  75816. /**
  75817. * Gets or sets a boolean indicating that layou warnings should be ignored
  75818. */
  75819. ignoreLayoutWarnings: boolean;
  75820. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75821. get isVertical(): boolean;
  75822. set isVertical(value: boolean);
  75823. /**
  75824. * Gets or sets panel width.
  75825. * This value should not be set when in horizontal mode as it will be computed automatically
  75826. */
  75827. set width(value: string | number);
  75828. get width(): string | number;
  75829. /**
  75830. * Gets or sets panel height.
  75831. * This value should not be set when in vertical mode as it will be computed automatically
  75832. */
  75833. set height(value: string | number);
  75834. get height(): string | number;
  75835. /**
  75836. * Creates a new StackPanel
  75837. * @param name defines control name
  75838. */
  75839. constructor(name?: string | undefined);
  75840. protected _getTypeName(): string;
  75841. /** @hidden */
  75842. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75843. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75844. protected _postMeasure(): void;
  75845. }
  75846. }
  75847. declare module BABYLON.GUI {
  75848. /**
  75849. * Class used to represent a 2D checkbox
  75850. */
  75851. export class Checkbox extends Control {
  75852. name?: string | undefined;
  75853. private _isChecked;
  75854. private _background;
  75855. private _checkSizeRatio;
  75856. private _thickness;
  75857. /** Gets or sets border thickness */
  75858. get thickness(): number;
  75859. set thickness(value: number);
  75860. /**
  75861. * BABYLON.Observable raised when isChecked property changes
  75862. */
  75863. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75864. /** Gets or sets a value indicating the ratio between overall size and check size */
  75865. get checkSizeRatio(): number;
  75866. set checkSizeRatio(value: number);
  75867. /** Gets or sets background color */
  75868. get background(): string;
  75869. set background(value: string);
  75870. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75871. get isChecked(): boolean;
  75872. set isChecked(value: boolean);
  75873. /**
  75874. * Creates a new CheckBox
  75875. * @param name defines the control name
  75876. */
  75877. constructor(name?: string | undefined);
  75878. protected _getTypeName(): string;
  75879. /** @hidden */
  75880. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75881. /** @hidden */
  75882. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75883. /**
  75884. * Utility function to easily create a checkbox with a header
  75885. * @param title defines the label to use for the header
  75886. * @param onValueChanged defines the callback to call when value changes
  75887. * @returns a StackPanel containing the checkbox and a textBlock
  75888. */
  75889. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75890. }
  75891. }
  75892. declare module BABYLON.GUI {
  75893. /**
  75894. * Class used to store key control properties
  75895. */
  75896. export class KeyPropertySet {
  75897. /** Width */
  75898. width?: string;
  75899. /** Height */
  75900. height?: string;
  75901. /** Left padding */
  75902. paddingLeft?: string;
  75903. /** Right padding */
  75904. paddingRight?: string;
  75905. /** Top padding */
  75906. paddingTop?: string;
  75907. /** Bottom padding */
  75908. paddingBottom?: string;
  75909. /** Foreground color */
  75910. color?: string;
  75911. /** Background color */
  75912. background?: string;
  75913. }
  75914. /**
  75915. * Class used to create virtual keyboard
  75916. */
  75917. export class VirtualKeyboard extends StackPanel {
  75918. /** BABYLON.Observable raised when a key is pressed */
  75919. onKeyPressObservable: BABYLON.Observable<string>;
  75920. /** Gets or sets default key button width */
  75921. defaultButtonWidth: string;
  75922. /** Gets or sets default key button height */
  75923. defaultButtonHeight: string;
  75924. /** Gets or sets default key button left padding */
  75925. defaultButtonPaddingLeft: string;
  75926. /** Gets or sets default key button right padding */
  75927. defaultButtonPaddingRight: string;
  75928. /** Gets or sets default key button top padding */
  75929. defaultButtonPaddingTop: string;
  75930. /** Gets or sets default key button bottom padding */
  75931. defaultButtonPaddingBottom: string;
  75932. /** Gets or sets default key button foreground color */
  75933. defaultButtonColor: string;
  75934. /** Gets or sets default key button background color */
  75935. defaultButtonBackground: string;
  75936. /** Gets or sets shift button foreground color */
  75937. shiftButtonColor: string;
  75938. /** Gets or sets shift button thickness*/
  75939. selectedShiftThickness: number;
  75940. /** Gets shift key state */
  75941. shiftState: number;
  75942. protected _getTypeName(): string;
  75943. private _createKey;
  75944. /**
  75945. * Adds a new row of keys
  75946. * @param keys defines the list of keys to add
  75947. * @param propertySets defines the associated property sets
  75948. */
  75949. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75950. /**
  75951. * Set the shift key to a specific state
  75952. * @param shiftState defines the new shift state
  75953. */
  75954. applyShiftState(shiftState: number): void;
  75955. private _currentlyConnectedInputText;
  75956. private _connectedInputTexts;
  75957. private _onKeyPressObserver;
  75958. /** Gets the input text control currently attached to the keyboard */
  75959. get connectedInputText(): BABYLON.Nullable<InputText>;
  75960. /**
  75961. * Connects the keyboard with an input text control
  75962. *
  75963. * @param input defines the target control
  75964. */
  75965. connect(input: InputText): void;
  75966. /**
  75967. * Disconnects the keyboard from connected InputText controls
  75968. *
  75969. * @param input optionally defines a target control, otherwise all are disconnected
  75970. */
  75971. disconnect(input?: InputText): void;
  75972. private _removeConnectedInputObservables;
  75973. /**
  75974. * Release all resources
  75975. */
  75976. dispose(): void;
  75977. /**
  75978. * Creates a new keyboard using a default layout
  75979. *
  75980. * @param name defines control name
  75981. * @returns a new VirtualKeyboard
  75982. */
  75983. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75984. }
  75985. }
  75986. declare module BABYLON.GUI {
  75987. /**
  75988. * Class used to create input text control
  75989. */
  75990. export class InputText extends Control implements IFocusableControl {
  75991. name?: string | undefined;
  75992. private _text;
  75993. private _placeholderText;
  75994. private _background;
  75995. private _focusedBackground;
  75996. private _focusedColor;
  75997. private _placeholderColor;
  75998. private _thickness;
  75999. private _margin;
  76000. private _autoStretchWidth;
  76001. private _maxWidth;
  76002. private _isFocused;
  76003. private _blinkTimeout;
  76004. private _blinkIsEven;
  76005. private _cursorOffset;
  76006. private _scrollLeft;
  76007. private _textWidth;
  76008. private _clickedCoordinate;
  76009. private _deadKey;
  76010. private _addKey;
  76011. private _currentKey;
  76012. private _isTextHighlightOn;
  76013. private _textHighlightColor;
  76014. private _highligherOpacity;
  76015. private _highlightedText;
  76016. private _startHighlightIndex;
  76017. private _endHighlightIndex;
  76018. private _cursorIndex;
  76019. private _onFocusSelectAll;
  76020. private _isPointerDown;
  76021. private _onClipboardObserver;
  76022. private _onPointerDblTapObserver;
  76023. /** @hidden */
  76024. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76025. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76026. promptMessage: string;
  76027. /** Force disable prompt on mobile device */
  76028. disableMobilePrompt: boolean;
  76029. /** BABYLON.Observable raised when the text changes */
  76030. onTextChangedObservable: BABYLON.Observable<InputText>;
  76031. /** BABYLON.Observable raised just before an entered character is to be added */
  76032. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76033. /** BABYLON.Observable raised when the control gets the focus */
  76034. onFocusObservable: BABYLON.Observable<InputText>;
  76035. /** BABYLON.Observable raised when the control loses the focus */
  76036. onBlurObservable: BABYLON.Observable<InputText>;
  76037. /**Observable raised when the text is highlighted */
  76038. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76039. /**Observable raised when copy event is triggered */
  76040. onTextCopyObservable: BABYLON.Observable<InputText>;
  76041. /** BABYLON.Observable raised when cut event is triggered */
  76042. onTextCutObservable: BABYLON.Observable<InputText>;
  76043. /** BABYLON.Observable raised when paste event is triggered */
  76044. onTextPasteObservable: BABYLON.Observable<InputText>;
  76045. /** BABYLON.Observable raised when a key event was processed */
  76046. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76047. /** Gets or sets the maximum width allowed by the control */
  76048. get maxWidth(): string | number;
  76049. /** Gets the maximum width allowed by the control in pixels */
  76050. get maxWidthInPixels(): number;
  76051. set maxWidth(value: string | number);
  76052. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76053. get highligherOpacity(): number;
  76054. set highligherOpacity(value: number);
  76055. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76056. get onFocusSelectAll(): boolean;
  76057. set onFocusSelectAll(value: boolean);
  76058. /** Gets or sets the text hightlight color */
  76059. get textHighlightColor(): string;
  76060. set textHighlightColor(value: string);
  76061. /** Gets or sets control margin */
  76062. get margin(): string;
  76063. /** Gets control margin in pixels */
  76064. get marginInPixels(): number;
  76065. set margin(value: string);
  76066. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76067. get autoStretchWidth(): boolean;
  76068. set autoStretchWidth(value: boolean);
  76069. /** Gets or sets border thickness */
  76070. get thickness(): number;
  76071. set thickness(value: number);
  76072. /** Gets or sets the background color when focused */
  76073. get focusedBackground(): string;
  76074. set focusedBackground(value: string);
  76075. /** Gets or sets the background color when focused */
  76076. get focusedColor(): string;
  76077. set focusedColor(value: string);
  76078. /** Gets or sets the background color */
  76079. get background(): string;
  76080. set background(value: string);
  76081. /** Gets or sets the placeholder color */
  76082. get placeholderColor(): string;
  76083. set placeholderColor(value: string);
  76084. /** Gets or sets the text displayed when the control is empty */
  76085. get placeholderText(): string;
  76086. set placeholderText(value: string);
  76087. /** Gets or sets the dead key flag */
  76088. get deadKey(): boolean;
  76089. set deadKey(flag: boolean);
  76090. /** Gets or sets the highlight text */
  76091. get highlightedText(): string;
  76092. set highlightedText(text: string);
  76093. /** Gets or sets if the current key should be added */
  76094. get addKey(): boolean;
  76095. set addKey(flag: boolean);
  76096. /** Gets or sets the value of the current key being entered */
  76097. get currentKey(): string;
  76098. set currentKey(key: string);
  76099. /** Gets or sets the text displayed in the control */
  76100. get text(): string;
  76101. set text(value: string);
  76102. /** Gets or sets control width */
  76103. get width(): string | number;
  76104. set width(value: string | number);
  76105. /**
  76106. * Creates a new InputText
  76107. * @param name defines the control name
  76108. * @param text defines the text of the control
  76109. */
  76110. constructor(name?: string | undefined, text?: string);
  76111. /** @hidden */
  76112. onBlur(): void;
  76113. /** @hidden */
  76114. onFocus(): void;
  76115. protected _getTypeName(): string;
  76116. /**
  76117. * Function called to get the list of controls that should not steal the focus from this control
  76118. * @returns an array of controls
  76119. */
  76120. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76121. /** @hidden */
  76122. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76123. /** @hidden */
  76124. private _updateValueFromCursorIndex;
  76125. /** @hidden */
  76126. private _processDblClick;
  76127. /** @hidden */
  76128. private _selectAllText;
  76129. /**
  76130. * Handles the keyboard event
  76131. * @param evt Defines the KeyboardEvent
  76132. */
  76133. processKeyboard(evt: KeyboardEvent): void;
  76134. /** @hidden */
  76135. private _onCopyText;
  76136. /** @hidden */
  76137. private _onCutText;
  76138. /** @hidden */
  76139. private _onPasteText;
  76140. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76141. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76142. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76143. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76144. protected _beforeRenderText(text: string): string;
  76145. dispose(): void;
  76146. }
  76147. }
  76148. declare module BABYLON.GUI {
  76149. /**
  76150. * Class used to create a 2D grid container
  76151. */
  76152. export class Grid extends Container {
  76153. name?: string | undefined;
  76154. private _rowDefinitions;
  76155. private _columnDefinitions;
  76156. private _cells;
  76157. private _childControls;
  76158. /**
  76159. * Gets the number of columns
  76160. */
  76161. get columnCount(): number;
  76162. /**
  76163. * Gets the number of rows
  76164. */
  76165. get rowCount(): number;
  76166. /** Gets the list of children */
  76167. get children(): Control[];
  76168. /** Gets the list of cells (e.g. the containers) */
  76169. get cells(): {
  76170. [key: string]: Container;
  76171. };
  76172. /**
  76173. * Gets the definition of a specific row
  76174. * @param index defines the index of the row
  76175. * @returns the row definition
  76176. */
  76177. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76178. /**
  76179. * Gets the definition of a specific column
  76180. * @param index defines the index of the column
  76181. * @returns the column definition
  76182. */
  76183. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76184. /**
  76185. * Adds a new row to the grid
  76186. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76187. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76188. * @returns the current grid
  76189. */
  76190. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76191. /**
  76192. * Adds a new column to the grid
  76193. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76194. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76195. * @returns the current grid
  76196. */
  76197. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76198. /**
  76199. * Update a row definition
  76200. * @param index defines the index of the row to update
  76201. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76202. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76203. * @returns the current grid
  76204. */
  76205. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76206. /**
  76207. * Update a column definition
  76208. * @param index defines the index of the column to update
  76209. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76210. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76211. * @returns the current grid
  76212. */
  76213. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76214. /**
  76215. * Gets the list of children stored in a specific cell
  76216. * @param row defines the row to check
  76217. * @param column defines the column to check
  76218. * @returns the list of controls
  76219. */
  76220. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76221. /**
  76222. * Gets a string representing the child cell info (row x column)
  76223. * @param child defines the control to get info from
  76224. * @returns a string containing the child cell info (row x column)
  76225. */
  76226. getChildCellInfo(child: Control): string;
  76227. private _removeCell;
  76228. private _offsetCell;
  76229. /**
  76230. * Remove a column definition at specified index
  76231. * @param index defines the index of the column to remove
  76232. * @returns the current grid
  76233. */
  76234. removeColumnDefinition(index: number): Grid;
  76235. /**
  76236. * Remove a row definition at specified index
  76237. * @param index defines the index of the row to remove
  76238. * @returns the current grid
  76239. */
  76240. removeRowDefinition(index: number): Grid;
  76241. /**
  76242. * Adds a new control to the current grid
  76243. * @param control defines the control to add
  76244. * @param row defines the row where to add the control (0 by default)
  76245. * @param column defines the column where to add the control (0 by default)
  76246. * @returns the current grid
  76247. */
  76248. addControl(control: Control, row?: number, column?: number): Grid;
  76249. /**
  76250. * Removes a control from the current container
  76251. * @param control defines the control to remove
  76252. * @returns the current container
  76253. */
  76254. removeControl(control: Control): Container;
  76255. /**
  76256. * Creates a new Grid
  76257. * @param name defines control name
  76258. */
  76259. constructor(name?: string | undefined);
  76260. protected _getTypeName(): string;
  76261. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76262. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76263. _flagDescendantsAsMatrixDirty(): void;
  76264. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76265. /** Releases associated resources */
  76266. dispose(): void;
  76267. }
  76268. }
  76269. declare module BABYLON.GUI {
  76270. /** Class used to create color pickers */
  76271. export class ColorPicker extends Control {
  76272. name?: string | undefined;
  76273. private static _Epsilon;
  76274. private _colorWheelCanvas;
  76275. private _value;
  76276. private _tmpColor;
  76277. private _pointerStartedOnSquare;
  76278. private _pointerStartedOnWheel;
  76279. private _squareLeft;
  76280. private _squareTop;
  76281. private _squareSize;
  76282. private _h;
  76283. private _s;
  76284. private _v;
  76285. private _lastPointerDownID;
  76286. /**
  76287. * BABYLON.Observable raised when the value changes
  76288. */
  76289. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76290. /** Gets or sets the color of the color picker */
  76291. get value(): BABYLON.Color3;
  76292. set value(value: BABYLON.Color3);
  76293. /**
  76294. * Gets or sets control width
  76295. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76296. */
  76297. get width(): string | number;
  76298. set width(value: string | number);
  76299. /**
  76300. * Gets or sets control height
  76301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76302. */
  76303. get height(): string | number;
  76304. /** Gets or sets control height */
  76305. set height(value: string | number);
  76306. /** Gets or sets control size */
  76307. get size(): string | number;
  76308. set size(value: string | number);
  76309. /**
  76310. * Creates a new ColorPicker
  76311. * @param name defines the control name
  76312. */
  76313. constructor(name?: string | undefined);
  76314. protected _getTypeName(): string;
  76315. /** @hidden */
  76316. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76317. private _updateSquareProps;
  76318. private _drawGradientSquare;
  76319. private _drawCircle;
  76320. private _createColorWheelCanvas;
  76321. /** @hidden */
  76322. _draw(context: CanvasRenderingContext2D): void;
  76323. private _pointerIsDown;
  76324. private _updateValueFromPointer;
  76325. private _isPointOnSquare;
  76326. private _isPointOnWheel;
  76327. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76328. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76329. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76330. /**
  76331. * This function expands the color picker by creating a color picker dialog with manual
  76332. * color value input and the ability to save colors into an array to be used later in
  76333. * subsequent launches of the dialogue.
  76334. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76335. * @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.
  76336. * @returns picked color as a hex string and the saved colors array as hex strings.
  76337. */
  76338. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76339. pickerWidth?: string;
  76340. pickerHeight?: string;
  76341. headerHeight?: string;
  76342. lastColor?: string;
  76343. swatchLimit?: number;
  76344. numSwatchesPerLine?: number;
  76345. savedColors?: Array<string>;
  76346. }): Promise<{
  76347. savedColors?: string[];
  76348. pickedColor: string;
  76349. }>;
  76350. }
  76351. }
  76352. declare module BABYLON.GUI {
  76353. /** Class used to create 2D ellipse containers */
  76354. export class Ellipse extends Container {
  76355. name?: string | undefined;
  76356. private _thickness;
  76357. /** Gets or sets border thickness */
  76358. get thickness(): number;
  76359. set thickness(value: number);
  76360. /**
  76361. * Creates a new Ellipse
  76362. * @param name defines the control name
  76363. */
  76364. constructor(name?: string | undefined);
  76365. protected _getTypeName(): string;
  76366. protected _localDraw(context: CanvasRenderingContext2D): void;
  76367. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76368. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76369. }
  76370. }
  76371. declare module BABYLON.GUI {
  76372. /**
  76373. * Class used to create a password control
  76374. */
  76375. export class InputPassword extends InputText {
  76376. protected _beforeRenderText(text: string): string;
  76377. }
  76378. }
  76379. declare module BABYLON.GUI {
  76380. /** Class used to render 2D lines */
  76381. export class Line extends Control {
  76382. name?: string | undefined;
  76383. private _lineWidth;
  76384. private _x1;
  76385. private _y1;
  76386. private _x2;
  76387. private _y2;
  76388. private _dash;
  76389. private _connectedControl;
  76390. private _connectedControlDirtyObserver;
  76391. /** Gets or sets the dash pattern */
  76392. get dash(): Array<number>;
  76393. set dash(value: Array<number>);
  76394. /** Gets or sets the control connected with the line end */
  76395. get connectedControl(): Control;
  76396. set connectedControl(value: Control);
  76397. /** Gets or sets start coordinates on X axis */
  76398. get x1(): string | number;
  76399. set x1(value: string | number);
  76400. /** Gets or sets start coordinates on Y axis */
  76401. get y1(): string | number;
  76402. set y1(value: string | number);
  76403. /** Gets or sets end coordinates on X axis */
  76404. get x2(): string | number;
  76405. set x2(value: string | number);
  76406. /** Gets or sets end coordinates on Y axis */
  76407. get y2(): string | number;
  76408. set y2(value: string | number);
  76409. /** Gets or sets line width */
  76410. get lineWidth(): number;
  76411. set lineWidth(value: number);
  76412. /** Gets or sets horizontal alignment */
  76413. set horizontalAlignment(value: number);
  76414. /** Gets or sets vertical alignment */
  76415. set verticalAlignment(value: number);
  76416. private get _effectiveX2();
  76417. private get _effectiveY2();
  76418. /**
  76419. * Creates a new Line
  76420. * @param name defines the control name
  76421. */
  76422. constructor(name?: string | undefined);
  76423. protected _getTypeName(): string;
  76424. _draw(context: CanvasRenderingContext2D): void;
  76425. _measure(): void;
  76426. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76427. /**
  76428. * Move one end of the line given 3D cartesian coordinates.
  76429. * @param position Targeted world position
  76430. * @param scene BABYLON.Scene
  76431. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76432. */
  76433. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76434. /**
  76435. * Move one end of the line to a position in screen absolute space.
  76436. * @param projectedPosition Position in screen absolute space (X, Y)
  76437. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76438. */
  76439. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76440. }
  76441. }
  76442. declare module BABYLON.GUI {
  76443. /**
  76444. * Class used to store a point for a MultiLine object.
  76445. * The point can be pure 2D coordinates, a mesh or a control
  76446. */
  76447. export class MultiLinePoint {
  76448. private _multiLine;
  76449. private _x;
  76450. private _y;
  76451. private _control;
  76452. private _mesh;
  76453. private _controlObserver;
  76454. private _meshObserver;
  76455. /** @hidden */
  76456. _point: BABYLON.Vector2;
  76457. /**
  76458. * Creates a new MultiLinePoint
  76459. * @param multiLine defines the source MultiLine object
  76460. */
  76461. constructor(multiLine: MultiLine);
  76462. /** Gets or sets x coordinate */
  76463. get x(): string | number;
  76464. set x(value: string | number);
  76465. /** Gets or sets y coordinate */
  76466. get y(): string | number;
  76467. set y(value: string | number);
  76468. /** Gets or sets the control associated with this point */
  76469. get control(): BABYLON.Nullable<Control>;
  76470. set control(value: BABYLON.Nullable<Control>);
  76471. /** Gets or sets the mesh associated with this point */
  76472. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76473. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76474. /** Resets links */
  76475. resetLinks(): void;
  76476. /**
  76477. * Gets a translation vector
  76478. * @returns the translation vector
  76479. */
  76480. translate(): BABYLON.Vector2;
  76481. private _translatePoint;
  76482. /** Release associated resources */
  76483. dispose(): void;
  76484. }
  76485. }
  76486. declare module BABYLON.GUI {
  76487. /**
  76488. * Class used to create multi line control
  76489. */
  76490. export class MultiLine extends Control {
  76491. name?: string | undefined;
  76492. private _lineWidth;
  76493. private _dash;
  76494. private _points;
  76495. private _minX;
  76496. private _minY;
  76497. private _maxX;
  76498. private _maxY;
  76499. /**
  76500. * Creates a new MultiLine
  76501. * @param name defines the control name
  76502. */
  76503. constructor(name?: string | undefined);
  76504. /** Gets or sets dash pattern */
  76505. get dash(): Array<number>;
  76506. set dash(value: Array<number>);
  76507. /**
  76508. * Gets point stored at specified index
  76509. * @param index defines the index to look for
  76510. * @returns the requested point if found
  76511. */
  76512. getAt(index: number): MultiLinePoint;
  76513. /** Function called when a point is updated */
  76514. onPointUpdate: () => void;
  76515. /**
  76516. * Adds new points to the point collection
  76517. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76518. * @returns the list of created MultiLinePoint
  76519. */
  76520. add(...items: (AbstractMesh | Control | {
  76521. x: string | number;
  76522. y: string | number;
  76523. })[]): MultiLinePoint[];
  76524. /**
  76525. * Adds a new point to the point collection
  76526. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76527. * @returns the created MultiLinePoint
  76528. */
  76529. push(item?: (AbstractMesh | Control | {
  76530. x: string | number;
  76531. y: string | number;
  76532. })): MultiLinePoint;
  76533. /**
  76534. * Remove a specific value or point from the active point collection
  76535. * @param value defines the value or point to remove
  76536. */
  76537. remove(value: number | MultiLinePoint): void;
  76538. /**
  76539. * Resets this object to initial state (no point)
  76540. */
  76541. reset(): void;
  76542. /**
  76543. * Resets all links
  76544. */
  76545. resetLinks(): void;
  76546. /** Gets or sets line width */
  76547. get lineWidth(): number;
  76548. set lineWidth(value: number);
  76549. set horizontalAlignment(value: number);
  76550. set verticalAlignment(value: number);
  76551. protected _getTypeName(): string;
  76552. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76553. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76554. _measure(): void;
  76555. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76556. dispose(): void;
  76557. }
  76558. }
  76559. declare module BABYLON.GUI {
  76560. /**
  76561. * Class used to create radio button controls
  76562. */
  76563. export class RadioButton extends Control {
  76564. name?: string | undefined;
  76565. private _isChecked;
  76566. private _background;
  76567. private _checkSizeRatio;
  76568. private _thickness;
  76569. /** Gets or sets border thickness */
  76570. get thickness(): number;
  76571. set thickness(value: number);
  76572. /** Gets or sets group name */
  76573. group: string;
  76574. /** BABYLON.Observable raised when isChecked is changed */
  76575. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76576. /** Gets or sets a value indicating the ratio between overall size and check size */
  76577. get checkSizeRatio(): number;
  76578. set checkSizeRatio(value: number);
  76579. /** Gets or sets background color */
  76580. get background(): string;
  76581. set background(value: string);
  76582. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76583. get isChecked(): boolean;
  76584. set isChecked(value: boolean);
  76585. /**
  76586. * Creates a new RadioButton
  76587. * @param name defines the control name
  76588. */
  76589. constructor(name?: string | undefined);
  76590. protected _getTypeName(): string;
  76591. _draw(context: CanvasRenderingContext2D): void;
  76592. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76593. /**
  76594. * Utility function to easily create a radio button with a header
  76595. * @param title defines the label to use for the header
  76596. * @param group defines the group to use for the radio button
  76597. * @param isChecked defines the initial state of the radio button
  76598. * @param onValueChanged defines the callback to call when value changes
  76599. * @returns a StackPanel containing the radio button and a textBlock
  76600. */
  76601. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76602. }
  76603. }
  76604. declare module BABYLON.GUI {
  76605. /**
  76606. * Class used to create slider controls
  76607. */
  76608. export class BaseSlider extends Control {
  76609. name?: string | undefined;
  76610. protected _thumbWidth: ValueAndUnit;
  76611. private _minimum;
  76612. private _maximum;
  76613. private _value;
  76614. private _isVertical;
  76615. protected _barOffset: ValueAndUnit;
  76616. private _isThumbClamped;
  76617. protected _displayThumb: boolean;
  76618. private _step;
  76619. private _lastPointerDownID;
  76620. protected _effectiveBarOffset: number;
  76621. protected _renderLeft: number;
  76622. protected _renderTop: number;
  76623. protected _renderWidth: number;
  76624. protected _renderHeight: number;
  76625. protected _backgroundBoxLength: number;
  76626. protected _backgroundBoxThickness: number;
  76627. protected _effectiveThumbThickness: number;
  76628. /** BABYLON.Observable raised when the sldier value changes */
  76629. onValueChangedObservable: BABYLON.Observable<number>;
  76630. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76631. get displayThumb(): boolean;
  76632. set displayThumb(value: boolean);
  76633. /** Gets or sets a step to apply to values (0 by default) */
  76634. get step(): number;
  76635. set step(value: number);
  76636. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76637. get barOffset(): string | number;
  76638. /** Gets main bar offset in pixels*/
  76639. get barOffsetInPixels(): number;
  76640. set barOffset(value: string | number);
  76641. /** Gets or sets thumb width */
  76642. get thumbWidth(): string | number;
  76643. /** Gets thumb width in pixels */
  76644. get thumbWidthInPixels(): number;
  76645. set thumbWidth(value: string | number);
  76646. /** Gets or sets minimum value */
  76647. get minimum(): number;
  76648. set minimum(value: number);
  76649. /** Gets or sets maximum value */
  76650. get maximum(): number;
  76651. set maximum(value: number);
  76652. /** Gets or sets current value */
  76653. get value(): number;
  76654. set value(value: number);
  76655. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76656. get isVertical(): boolean;
  76657. set isVertical(value: boolean);
  76658. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76659. get isThumbClamped(): boolean;
  76660. set isThumbClamped(value: boolean);
  76661. /**
  76662. * Creates a new BaseSlider
  76663. * @param name defines the control name
  76664. */
  76665. constructor(name?: string | undefined);
  76666. protected _getTypeName(): string;
  76667. protected _getThumbPosition(): number;
  76668. protected _getThumbThickness(type: string): number;
  76669. protected _prepareRenderingData(type: string): void;
  76670. private _pointerIsDown;
  76671. /** @hidden */
  76672. protected _updateValueFromPointer(x: number, y: number): void;
  76673. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76674. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76675. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76676. }
  76677. }
  76678. declare module BABYLON.GUI {
  76679. /**
  76680. * Class used to create slider controls
  76681. */
  76682. export class Slider extends BaseSlider {
  76683. name?: string | undefined;
  76684. private _background;
  76685. private _borderColor;
  76686. private _isThumbCircle;
  76687. protected _displayValueBar: boolean;
  76688. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76689. get displayValueBar(): boolean;
  76690. set displayValueBar(value: boolean);
  76691. /** Gets or sets border color */
  76692. get borderColor(): string;
  76693. set borderColor(value: string);
  76694. /** Gets or sets background color */
  76695. get background(): string;
  76696. set background(value: string);
  76697. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76698. get isThumbCircle(): boolean;
  76699. set isThumbCircle(value: boolean);
  76700. /**
  76701. * Creates a new Slider
  76702. * @param name defines the control name
  76703. */
  76704. constructor(name?: string | undefined);
  76705. protected _getTypeName(): string;
  76706. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76707. }
  76708. }
  76709. declare module BABYLON.GUI {
  76710. /** Class used to create a RadioGroup
  76711. * which contains groups of radio buttons
  76712. */
  76713. export class SelectorGroup {
  76714. /** name of SelectorGroup */
  76715. name: string;
  76716. private _groupPanel;
  76717. private _selectors;
  76718. private _groupHeader;
  76719. /**
  76720. * Creates a new SelectorGroup
  76721. * @param name of group, used as a group heading
  76722. */
  76723. constructor(
  76724. /** name of SelectorGroup */
  76725. name: string);
  76726. /** Gets the groupPanel of the SelectorGroup */
  76727. get groupPanel(): StackPanel;
  76728. /** Gets the selectors array */
  76729. get selectors(): StackPanel[];
  76730. /** Gets and sets the group header */
  76731. get header(): string;
  76732. set header(label: string);
  76733. /** @hidden */
  76734. private _addGroupHeader;
  76735. /** @hidden*/
  76736. _getSelector(selectorNb: number): StackPanel | undefined;
  76737. /** Removes the selector at the given position
  76738. * @param selectorNb the position of the selector within the group
  76739. */
  76740. removeSelector(selectorNb: number): void;
  76741. }
  76742. /** Class used to create a CheckboxGroup
  76743. * which contains groups of checkbox buttons
  76744. */
  76745. export class CheckboxGroup extends SelectorGroup {
  76746. /** Adds a checkbox as a control
  76747. * @param text is the label for the selector
  76748. * @param func is the function called when the Selector is checked
  76749. * @param checked is true when Selector is checked
  76750. */
  76751. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76752. /** @hidden */
  76753. _setSelectorLabel(selectorNb: number, label: string): void;
  76754. /** @hidden */
  76755. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76756. /** @hidden */
  76757. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76758. /** @hidden */
  76759. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76760. }
  76761. /** Class used to create a RadioGroup
  76762. * which contains groups of radio buttons
  76763. */
  76764. export class RadioGroup extends SelectorGroup {
  76765. private _selectNb;
  76766. /** Adds a radio button as a control
  76767. * @param label is the label for the selector
  76768. * @param func is the function called when the Selector is checked
  76769. * @param checked is true when Selector is checked
  76770. */
  76771. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76772. /** @hidden */
  76773. _setSelectorLabel(selectorNb: number, label: string): void;
  76774. /** @hidden */
  76775. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76776. /** @hidden */
  76777. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76778. /** @hidden */
  76779. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76780. }
  76781. /** Class used to create a SliderGroup
  76782. * which contains groups of slider buttons
  76783. */
  76784. export class SliderGroup extends SelectorGroup {
  76785. /**
  76786. * Adds a slider to the SelectorGroup
  76787. * @param label is the label for the SliderBar
  76788. * @param func is the function called when the Slider moves
  76789. * @param unit is a string describing the units used, eg degrees or metres
  76790. * @param min is the minimum value for the Slider
  76791. * @param max is the maximum value for the Slider
  76792. * @param value is the start value for the Slider between min and max
  76793. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76794. */
  76795. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76796. /** @hidden */
  76797. _setSelectorLabel(selectorNb: number, label: string): void;
  76798. /** @hidden */
  76799. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76800. /** @hidden */
  76801. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76802. /** @hidden */
  76803. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76804. }
  76805. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76806. * @see http://doc.babylonjs.com/how_to/selector
  76807. */
  76808. export class SelectionPanel extends Rectangle {
  76809. /** name of SelectionPanel */
  76810. name: string;
  76811. /** an array of SelectionGroups */
  76812. groups: SelectorGroup[];
  76813. private _panel;
  76814. private _buttonColor;
  76815. private _buttonBackground;
  76816. private _headerColor;
  76817. private _barColor;
  76818. private _barHeight;
  76819. private _spacerHeight;
  76820. private _labelColor;
  76821. private _groups;
  76822. private _bars;
  76823. /**
  76824. * Creates a new SelectionPanel
  76825. * @param name of SelectionPanel
  76826. * @param groups is an array of SelectionGroups
  76827. */
  76828. constructor(
  76829. /** name of SelectionPanel */
  76830. name: string,
  76831. /** an array of SelectionGroups */
  76832. groups?: SelectorGroup[]);
  76833. protected _getTypeName(): string;
  76834. /** Gets or sets the headerColor */
  76835. get headerColor(): string;
  76836. set headerColor(color: string);
  76837. private _setHeaderColor;
  76838. /** Gets or sets the button color */
  76839. get buttonColor(): string;
  76840. set buttonColor(color: string);
  76841. private _setbuttonColor;
  76842. /** Gets or sets the label color */
  76843. get labelColor(): string;
  76844. set labelColor(color: string);
  76845. private _setLabelColor;
  76846. /** Gets or sets the button background */
  76847. get buttonBackground(): string;
  76848. set buttonBackground(color: string);
  76849. private _setButtonBackground;
  76850. /** Gets or sets the color of separator bar */
  76851. get barColor(): string;
  76852. set barColor(color: string);
  76853. private _setBarColor;
  76854. /** Gets or sets the height of separator bar */
  76855. get barHeight(): string;
  76856. set barHeight(value: string);
  76857. private _setBarHeight;
  76858. /** Gets or sets the height of spacers*/
  76859. get spacerHeight(): string;
  76860. set spacerHeight(value: string);
  76861. private _setSpacerHeight;
  76862. /** Adds a bar between groups */
  76863. private _addSpacer;
  76864. /** Add a group to the selection panel
  76865. * @param group is the selector group to add
  76866. */
  76867. addGroup(group: SelectorGroup): void;
  76868. /** Remove the group from the given position
  76869. * @param groupNb is the position of the group in the list
  76870. */
  76871. removeGroup(groupNb: number): void;
  76872. /** Change a group header label
  76873. * @param label is the new group header label
  76874. * @param groupNb is the number of the group to relabel
  76875. * */
  76876. setHeaderName(label: string, groupNb: number): void;
  76877. /** Change selector label to the one given
  76878. * @param label is the new selector label
  76879. * @param groupNb is the number of the groupcontaining the selector
  76880. * @param selectorNb is the number of the selector within a group to relabel
  76881. * */
  76882. relabel(label: string, groupNb: number, selectorNb: number): void;
  76883. /** For a given group position remove the selector at the given position
  76884. * @param groupNb is the number of the group to remove the selector from
  76885. * @param selectorNb is the number of the selector within the group
  76886. */
  76887. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76888. /** For a given group position of correct type add a checkbox button
  76889. * @param groupNb is the number of the group to remove the selector from
  76890. * @param label is the label for the selector
  76891. * @param func is the function called when the Selector is checked
  76892. * @param checked is true when Selector is checked
  76893. */
  76894. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76895. /** For a given group position of correct type add a radio button
  76896. * @param groupNb is the number of the group to remove the selector from
  76897. * @param label is the label for the selector
  76898. * @param func is the function called when the Selector is checked
  76899. * @param checked is true when Selector is checked
  76900. */
  76901. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76902. /**
  76903. * For a given slider group add a slider
  76904. * @param groupNb is the number of the group to add the slider to
  76905. * @param label is the label for the Slider
  76906. * @param func is the function called when the Slider moves
  76907. * @param unit is a string describing the units used, eg degrees or metres
  76908. * @param min is the minimum value for the Slider
  76909. * @param max is the maximum value for the Slider
  76910. * @param value is the start value for the Slider between min and max
  76911. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76912. */
  76913. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76914. }
  76915. }
  76916. declare module BABYLON.GUI {
  76917. /**
  76918. * Class used to hold a the container for ScrollViewer
  76919. * @hidden
  76920. */
  76921. export class _ScrollViewerWindow extends Container {
  76922. parentClientWidth: number;
  76923. parentClientHeight: number;
  76924. private _freezeControls;
  76925. private _parentMeasure;
  76926. private _oldLeft;
  76927. private _oldTop;
  76928. get freezeControls(): boolean;
  76929. set freezeControls(value: boolean);
  76930. private _bucketWidth;
  76931. private _bucketHeight;
  76932. private _buckets;
  76933. private _bucketLen;
  76934. get bucketWidth(): number;
  76935. get bucketHeight(): number;
  76936. setBucketSizes(width: number, height: number): void;
  76937. private _useBuckets;
  76938. private _makeBuckets;
  76939. private _dispatchInBuckets;
  76940. private _updateMeasures;
  76941. private _updateChildrenMeasures;
  76942. private _restoreMeasures;
  76943. /**
  76944. * Creates a new ScrollViewerWindow
  76945. * @param name of ScrollViewerWindow
  76946. */
  76947. constructor(name?: string);
  76948. protected _getTypeName(): string;
  76949. /** @hidden */
  76950. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76951. /** @hidden */
  76952. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76953. private _scrollChildren;
  76954. private _scrollChildrenWithBuckets;
  76955. /** @hidden */
  76956. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76957. protected _postMeasure(): void;
  76958. }
  76959. }
  76960. declare module BABYLON.GUI {
  76961. /**
  76962. * Class used to create slider controls
  76963. */
  76964. export class ScrollBar extends BaseSlider {
  76965. name?: string | undefined;
  76966. private _background;
  76967. private _borderColor;
  76968. private _tempMeasure;
  76969. /** Gets or sets border color */
  76970. get borderColor(): string;
  76971. set borderColor(value: string);
  76972. /** Gets or sets background color */
  76973. get background(): string;
  76974. set background(value: string);
  76975. /**
  76976. * Creates a new Slider
  76977. * @param name defines the control name
  76978. */
  76979. constructor(name?: string | undefined);
  76980. protected _getTypeName(): string;
  76981. protected _getThumbThickness(): number;
  76982. _draw(context: CanvasRenderingContext2D): void;
  76983. private _first;
  76984. private _originX;
  76985. private _originY;
  76986. /** @hidden */
  76987. protected _updateValueFromPointer(x: number, y: number): void;
  76988. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76989. }
  76990. }
  76991. declare module BABYLON.GUI {
  76992. /**
  76993. * Class used to create slider controls
  76994. */
  76995. export class ImageScrollBar extends BaseSlider {
  76996. name?: string | undefined;
  76997. private _backgroundBaseImage;
  76998. private _backgroundImage;
  76999. private _thumbImage;
  77000. private _thumbBaseImage;
  77001. private _thumbLength;
  77002. private _thumbHeight;
  77003. private _barImageHeight;
  77004. private _tempMeasure;
  77005. /** Number of 90° rotation to apply on the images when in vertical mode */
  77006. num90RotationInVerticalMode: number;
  77007. /**
  77008. * Gets or sets the image used to render the background for horizontal bar
  77009. */
  77010. get backgroundImage(): Image;
  77011. set backgroundImage(value: Image);
  77012. /**
  77013. * Gets or sets the image used to render the thumb
  77014. */
  77015. get thumbImage(): Image;
  77016. set thumbImage(value: Image);
  77017. /**
  77018. * Gets or sets the length of the thumb
  77019. */
  77020. get thumbLength(): number;
  77021. set thumbLength(value: number);
  77022. /**
  77023. * Gets or sets the height of the thumb
  77024. */
  77025. get thumbHeight(): number;
  77026. set thumbHeight(value: number);
  77027. /**
  77028. * Gets or sets the height of the bar image
  77029. */
  77030. get barImageHeight(): number;
  77031. set barImageHeight(value: number);
  77032. /**
  77033. * Creates a new ImageScrollBar
  77034. * @param name defines the control name
  77035. */
  77036. constructor(name?: string | undefined);
  77037. protected _getTypeName(): string;
  77038. protected _getThumbThickness(): number;
  77039. _draw(context: CanvasRenderingContext2D): void;
  77040. private _first;
  77041. private _originX;
  77042. private _originY;
  77043. /** @hidden */
  77044. protected _updateValueFromPointer(x: number, y: number): void;
  77045. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77046. }
  77047. }
  77048. declare module BABYLON.GUI {
  77049. /**
  77050. * Class used to hold a viewer window and sliders in a grid
  77051. */
  77052. export class ScrollViewer extends Rectangle {
  77053. private _grid;
  77054. private _horizontalBarSpace;
  77055. private _verticalBarSpace;
  77056. private _dragSpace;
  77057. private _horizontalBar;
  77058. private _verticalBar;
  77059. private _barColor;
  77060. private _barBackground;
  77061. private _barImage;
  77062. private _horizontalBarImage;
  77063. private _verticalBarImage;
  77064. private _barBackgroundImage;
  77065. private _horizontalBarBackgroundImage;
  77066. private _verticalBarBackgroundImage;
  77067. private _barSize;
  77068. private _window;
  77069. private _pointerIsOver;
  77070. private _wheelPrecision;
  77071. private _onWheelObserver;
  77072. private _clientWidth;
  77073. private _clientHeight;
  77074. private _useImageBar;
  77075. private _thumbLength;
  77076. private _thumbHeight;
  77077. private _barImageHeight;
  77078. private _horizontalBarImageHeight;
  77079. private _verticalBarImageHeight;
  77080. private _oldWindowContentsWidth;
  77081. private _oldWindowContentsHeight;
  77082. /**
  77083. * Gets the horizontal scrollbar
  77084. */
  77085. get horizontalBar(): ScrollBar | ImageScrollBar;
  77086. /**
  77087. * Gets the vertical scrollbar
  77088. */
  77089. get verticalBar(): ScrollBar | ImageScrollBar;
  77090. /**
  77091. * Adds a new control to the current container
  77092. * @param control defines the control to add
  77093. * @returns the current container
  77094. */
  77095. addControl(control: BABYLON.Nullable<Control>): Container;
  77096. /**
  77097. * Removes a control from the current container
  77098. * @param control defines the control to remove
  77099. * @returns the current container
  77100. */
  77101. removeControl(control: Control): Container;
  77102. /** Gets the list of children */
  77103. get children(): Control[];
  77104. _flagDescendantsAsMatrixDirty(): void;
  77105. /**
  77106. * Freezes or unfreezes the controls in the window.
  77107. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77108. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77109. */
  77110. get freezeControls(): boolean;
  77111. set freezeControls(value: boolean);
  77112. /** Gets the bucket width */
  77113. get bucketWidth(): number;
  77114. /** Gets the bucket height */
  77115. get bucketHeight(): number;
  77116. /**
  77117. * Sets the bucket sizes.
  77118. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77119. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77120. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77121. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77122. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77123. * used), that's why it is not enabled by default.
  77124. * @param width width of the bucket
  77125. * @param height height of the bucket
  77126. */
  77127. setBucketSizes(width: number, height: number): void;
  77128. private _forceHorizontalBar;
  77129. private _forceVerticalBar;
  77130. /**
  77131. * Forces the horizontal scroll bar to be displayed
  77132. */
  77133. get forceHorizontalBar(): boolean;
  77134. set forceHorizontalBar(value: boolean);
  77135. /**
  77136. * Forces the vertical scroll bar to be displayed
  77137. */
  77138. get forceVerticalBar(): boolean;
  77139. set forceVerticalBar(value: boolean);
  77140. /**
  77141. * Creates a new ScrollViewer
  77142. * @param name of ScrollViewer
  77143. */
  77144. constructor(name?: string, isImageBased?: boolean);
  77145. /** Reset the scroll viewer window to initial size */
  77146. resetWindow(): void;
  77147. protected _getTypeName(): string;
  77148. private _buildClientSizes;
  77149. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77150. protected _postMeasure(): void;
  77151. /**
  77152. * Gets or sets the mouse wheel precision
  77153. * from 0 to 1 with a default value of 0.05
  77154. * */
  77155. get wheelPrecision(): number;
  77156. set wheelPrecision(value: number);
  77157. /** Gets or sets the scroll bar container background color */
  77158. get scrollBackground(): string;
  77159. set scrollBackground(color: string);
  77160. /** Gets or sets the bar color */
  77161. get barColor(): string;
  77162. set barColor(color: string);
  77163. /** Gets or sets the bar image */
  77164. get thumbImage(): Image;
  77165. set thumbImage(value: Image);
  77166. /** Gets or sets the horizontal bar image */
  77167. get horizontalThumbImage(): Image;
  77168. set horizontalThumbImage(value: Image);
  77169. /** Gets or sets the vertical bar image */
  77170. get verticalThumbImage(): Image;
  77171. set verticalThumbImage(value: Image);
  77172. /** Gets or sets the size of the bar */
  77173. get barSize(): number;
  77174. set barSize(value: number);
  77175. /** Gets or sets the length of the thumb */
  77176. get thumbLength(): number;
  77177. set thumbLength(value: number);
  77178. /** Gets or sets the height of the thumb */
  77179. get thumbHeight(): number;
  77180. set thumbHeight(value: number);
  77181. /** Gets or sets the height of the bar image */
  77182. get barImageHeight(): number;
  77183. set barImageHeight(value: number);
  77184. /** Gets or sets the height of the horizontal bar image */
  77185. get horizontalBarImageHeight(): number;
  77186. set horizontalBarImageHeight(value: number);
  77187. /** Gets or sets the height of the vertical bar image */
  77188. get verticalBarImageHeight(): number;
  77189. set verticalBarImageHeight(value: number);
  77190. /** Gets or sets the bar background */
  77191. get barBackground(): string;
  77192. set barBackground(color: string);
  77193. /** Gets or sets the bar background image */
  77194. get barImage(): Image;
  77195. set barImage(value: Image);
  77196. /** Gets or sets the horizontal bar background image */
  77197. get horizontalBarImage(): Image;
  77198. set horizontalBarImage(value: Image);
  77199. /** Gets or sets the vertical bar background image */
  77200. get verticalBarImage(): Image;
  77201. set verticalBarImage(value: Image);
  77202. private _setWindowPosition;
  77203. /** @hidden */
  77204. private _updateScroller;
  77205. _link(host: AdvancedDynamicTexture): void;
  77206. /** @hidden */
  77207. private _addBar;
  77208. /** @hidden */
  77209. private _attachWheel;
  77210. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77211. /** Releases associated resources */
  77212. dispose(): void;
  77213. }
  77214. }
  77215. declare module BABYLON.GUI {
  77216. /** Class used to render a grid */
  77217. export class DisplayGrid extends Control {
  77218. name?: string | undefined;
  77219. private _cellWidth;
  77220. private _cellHeight;
  77221. private _minorLineTickness;
  77222. private _minorLineColor;
  77223. private _majorLineTickness;
  77224. private _majorLineColor;
  77225. private _majorLineFrequency;
  77226. private _background;
  77227. private _displayMajorLines;
  77228. private _displayMinorLines;
  77229. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77230. get displayMinorLines(): boolean;
  77231. set displayMinorLines(value: boolean);
  77232. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77233. get displayMajorLines(): boolean;
  77234. set displayMajorLines(value: boolean);
  77235. /** Gets or sets background color (Black by default) */
  77236. get background(): string;
  77237. set background(value: string);
  77238. /** Gets or sets the width of each cell (20 by default) */
  77239. get cellWidth(): number;
  77240. set cellWidth(value: number);
  77241. /** Gets or sets the height of each cell (20 by default) */
  77242. get cellHeight(): number;
  77243. set cellHeight(value: number);
  77244. /** Gets or sets the tickness of minor lines (1 by default) */
  77245. get minorLineTickness(): number;
  77246. set minorLineTickness(value: number);
  77247. /** Gets or sets the color of minor lines (DarkGray by default) */
  77248. get minorLineColor(): string;
  77249. set minorLineColor(value: string);
  77250. /** Gets or sets the tickness of major lines (2 by default) */
  77251. get majorLineTickness(): number;
  77252. set majorLineTickness(value: number);
  77253. /** Gets or sets the color of major lines (White by default) */
  77254. get majorLineColor(): string;
  77255. set majorLineColor(value: string);
  77256. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77257. get majorLineFrequency(): number;
  77258. set majorLineFrequency(value: number);
  77259. /**
  77260. * Creates a new GridDisplayRectangle
  77261. * @param name defines the control name
  77262. */
  77263. constructor(name?: string | undefined);
  77264. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77265. protected _getTypeName(): string;
  77266. }
  77267. }
  77268. declare module BABYLON.GUI {
  77269. /**
  77270. * Class used to create slider controls based on images
  77271. */
  77272. export class ImageBasedSlider extends BaseSlider {
  77273. name?: string | undefined;
  77274. private _backgroundImage;
  77275. private _thumbImage;
  77276. private _valueBarImage;
  77277. private _tempMeasure;
  77278. get displayThumb(): boolean;
  77279. set displayThumb(value: boolean);
  77280. /**
  77281. * Gets or sets the image used to render the background
  77282. */
  77283. get backgroundImage(): Image;
  77284. set backgroundImage(value: Image);
  77285. /**
  77286. * Gets or sets the image used to render the value bar
  77287. */
  77288. get valueBarImage(): Image;
  77289. set valueBarImage(value: Image);
  77290. /**
  77291. * Gets or sets the image used to render the thumb
  77292. */
  77293. get thumbImage(): Image;
  77294. set thumbImage(value: Image);
  77295. /**
  77296. * Creates a new ImageBasedSlider
  77297. * @param name defines the control name
  77298. */
  77299. constructor(name?: string | undefined);
  77300. protected _getTypeName(): string;
  77301. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77302. }
  77303. }
  77304. declare module BABYLON.GUI {
  77305. /**
  77306. * Forcing an export so that this code will execute
  77307. * @hidden
  77308. */
  77309. const name = "Statics";
  77310. }
  77311. declare module BABYLON.GUI {
  77312. /**
  77313. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77314. */
  77315. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77316. /**
  77317. * Define the instrumented AdvancedDynamicTexture.
  77318. */
  77319. texture: AdvancedDynamicTexture;
  77320. private _captureRenderTime;
  77321. private _renderTime;
  77322. private _captureLayoutTime;
  77323. private _layoutTime;
  77324. private _onBeginRenderObserver;
  77325. private _onEndRenderObserver;
  77326. private _onBeginLayoutObserver;
  77327. private _onEndLayoutObserver;
  77328. /**
  77329. * Gets the perf counter used to capture render time
  77330. */
  77331. get renderTimeCounter(): BABYLON.PerfCounter;
  77332. /**
  77333. * Gets the perf counter used to capture layout time
  77334. */
  77335. get layoutTimeCounter(): BABYLON.PerfCounter;
  77336. /**
  77337. * Enable or disable the render time capture
  77338. */
  77339. get captureRenderTime(): boolean;
  77340. set captureRenderTime(value: boolean);
  77341. /**
  77342. * Enable or disable the layout time capture
  77343. */
  77344. get captureLayoutTime(): boolean;
  77345. set captureLayoutTime(value: boolean);
  77346. /**
  77347. * Instantiates a new advanced dynamic texture instrumentation.
  77348. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77349. * @param texture Defines the AdvancedDynamicTexture to instrument
  77350. */
  77351. constructor(
  77352. /**
  77353. * Define the instrumented AdvancedDynamicTexture.
  77354. */
  77355. texture: AdvancedDynamicTexture);
  77356. /**
  77357. * Dispose and release associated resources.
  77358. */
  77359. dispose(): void;
  77360. }
  77361. }
  77362. declare module BABYLON.GUI {
  77363. /**
  77364. * Class used to load GUI via XML.
  77365. */
  77366. export class XmlLoader {
  77367. private _nodes;
  77368. private _nodeTypes;
  77369. private _isLoaded;
  77370. private _objectAttributes;
  77371. private _parentClass;
  77372. /**
  77373. * Create a new xml loader
  77374. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77375. */
  77376. constructor(parentClass?: null);
  77377. private _getChainElement;
  77378. private _getClassAttribute;
  77379. private _createGuiElement;
  77380. private _parseGrid;
  77381. private _parseElement;
  77382. private _prepareSourceElement;
  77383. private _parseElementsFromSource;
  77384. private _parseXml;
  77385. /**
  77386. * Gets if the loading has finished.
  77387. * @returns whether the loading has finished or not
  77388. */
  77389. isLoaded(): boolean;
  77390. /**
  77391. * Gets a loaded node / control by id.
  77392. * @param id the Controls id set in the xml
  77393. * @returns element of type Control
  77394. */
  77395. getNodeById(id: string): any;
  77396. /**
  77397. * Gets all loaded nodes / controls
  77398. * @returns Array of controls
  77399. */
  77400. getNodes(): any;
  77401. /**
  77402. * Initiates the xml layout loading
  77403. * @param xmlFile defines the xml layout to load
  77404. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77405. * @param callback defines the callback called on layout load.
  77406. */
  77407. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77408. }
  77409. }
  77410. declare module BABYLON.GUI {
  77411. /**
  77412. * Class used to create containers for controls
  77413. */
  77414. export class Container3D extends Control3D {
  77415. private _blockLayout;
  77416. /**
  77417. * Gets the list of child controls
  77418. */
  77419. protected _children: Control3D[];
  77420. /**
  77421. * Gets the list of child controls
  77422. */
  77423. get children(): Array<Control3D>;
  77424. /**
  77425. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77426. * This is helpful to optimize layout operation when adding multiple children in a row
  77427. */
  77428. get blockLayout(): boolean;
  77429. set blockLayout(value: boolean);
  77430. /**
  77431. * Creates a new container
  77432. * @param name defines the container name
  77433. */
  77434. constructor(name?: string);
  77435. /**
  77436. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77437. * @returns the current container
  77438. */
  77439. updateLayout(): Container3D;
  77440. /**
  77441. * Gets a boolean indicating if the given control is in the children of this control
  77442. * @param control defines the control to check
  77443. * @returns true if the control is in the child list
  77444. */
  77445. containsControl(control: Control3D): boolean;
  77446. /**
  77447. * Adds a control to the children of this control
  77448. * @param control defines the control to add
  77449. * @returns the current container
  77450. */
  77451. addControl(control: Control3D): Container3D;
  77452. /**
  77453. * This function will be called everytime a new control is added
  77454. */
  77455. protected _arrangeChildren(): void;
  77456. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77457. /**
  77458. * Removes a control from the children of this control
  77459. * @param control defines the control to remove
  77460. * @returns the current container
  77461. */
  77462. removeControl(control: Control3D): Container3D;
  77463. protected _getTypeName(): string;
  77464. /**
  77465. * Releases all associated resources
  77466. */
  77467. dispose(): void;
  77468. /** Control rotation will remain unchanged */
  77469. static readonly UNSET_ORIENTATION: number;
  77470. /** Control will rotate to make it look at sphere central axis */
  77471. static readonly FACEORIGIN_ORIENTATION: number;
  77472. /** Control will rotate to make it look back at sphere central axis */
  77473. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77474. /** Control will rotate to look at z axis (0, 0, 1) */
  77475. static readonly FACEFORWARD_ORIENTATION: number;
  77476. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77477. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77478. }
  77479. }
  77480. declare module BABYLON.GUI {
  77481. /**
  77482. * Class used to manage 3D user interface
  77483. * @see http://doc.babylonjs.com/how_to/gui3d
  77484. */
  77485. export class GUI3DManager implements BABYLON.IDisposable {
  77486. private _scene;
  77487. private _sceneDisposeObserver;
  77488. private _utilityLayer;
  77489. private _rootContainer;
  77490. private _pointerObserver;
  77491. private _pointerOutObserver;
  77492. /** @hidden */
  77493. _lastPickedControl: Control3D;
  77494. /** @hidden */
  77495. _lastControlOver: {
  77496. [pointerId: number]: Control3D;
  77497. };
  77498. /** @hidden */
  77499. _lastControlDown: {
  77500. [pointerId: number]: Control3D;
  77501. };
  77502. /**
  77503. * BABYLON.Observable raised when the point picked by the pointer events changed
  77504. */
  77505. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77506. /** @hidden */
  77507. _sharedMaterials: {
  77508. [key: string]: BABYLON.Material;
  77509. };
  77510. /** Gets the hosting scene */
  77511. get scene(): BABYLON.Scene;
  77512. /** Gets associated utility layer */
  77513. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77514. /**
  77515. * Creates a new GUI3DManager
  77516. * @param scene
  77517. */
  77518. constructor(scene?: BABYLON.Scene);
  77519. private _handlePointerOut;
  77520. private _doPicking;
  77521. /**
  77522. * Gets the root container
  77523. */
  77524. get rootContainer(): Container3D;
  77525. /**
  77526. * Gets a boolean indicating if the given control is in the root child list
  77527. * @param control defines the control to check
  77528. * @returns true if the control is in the root child list
  77529. */
  77530. containsControl(control: Control3D): boolean;
  77531. /**
  77532. * Adds a control to the root child list
  77533. * @param control defines the control to add
  77534. * @returns the current manager
  77535. */
  77536. addControl(control: Control3D): GUI3DManager;
  77537. /**
  77538. * Removes a control from the root child list
  77539. * @param control defines the control to remove
  77540. * @returns the current container
  77541. */
  77542. removeControl(control: Control3D): GUI3DManager;
  77543. /**
  77544. * Releases all associated resources
  77545. */
  77546. dispose(): void;
  77547. }
  77548. }
  77549. declare module BABYLON.GUI {
  77550. /**
  77551. * Class used to transport BABYLON.Vector3 information for pointer events
  77552. */
  77553. export class Vector3WithInfo extends BABYLON.Vector3 {
  77554. /** defines the current mouse button index */
  77555. buttonIndex: number;
  77556. /**
  77557. * Creates a new Vector3WithInfo
  77558. * @param source defines the vector3 data to transport
  77559. * @param buttonIndex defines the current mouse button index
  77560. */
  77561. constructor(source: BABYLON.Vector3,
  77562. /** defines the current mouse button index */
  77563. buttonIndex?: number);
  77564. }
  77565. }
  77566. declare module BABYLON.GUI {
  77567. /**
  77568. * Class used as base class for controls
  77569. */
  77570. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77571. /** Defines the control name */
  77572. name?: string | undefined;
  77573. /** @hidden */
  77574. _host: GUI3DManager;
  77575. private _node;
  77576. private _downCount;
  77577. private _enterCount;
  77578. private _downPointerIds;
  77579. private _isVisible;
  77580. /** Gets or sets the control position in world space */
  77581. get position(): BABYLON.Vector3;
  77582. set position(value: BABYLON.Vector3);
  77583. /** Gets or sets the control scaling in world space */
  77584. get scaling(): BABYLON.Vector3;
  77585. set scaling(value: BABYLON.Vector3);
  77586. /** Callback used to start pointer enter animation */
  77587. pointerEnterAnimation: () => void;
  77588. /** Callback used to start pointer out animation */
  77589. pointerOutAnimation: () => void;
  77590. /** Callback used to start pointer down animation */
  77591. pointerDownAnimation: () => void;
  77592. /** Callback used to start pointer up animation */
  77593. pointerUpAnimation: () => void;
  77594. /**
  77595. * An event triggered when the pointer move over the control
  77596. */
  77597. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77598. /**
  77599. * An event triggered when the pointer move out of the control
  77600. */
  77601. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77602. /**
  77603. * An event triggered when the pointer taps the control
  77604. */
  77605. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77606. /**
  77607. * An event triggered when pointer is up
  77608. */
  77609. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77610. /**
  77611. * An event triggered when a control is clicked on (with a mouse)
  77612. */
  77613. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77614. /**
  77615. * An event triggered when pointer enters the control
  77616. */
  77617. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77618. /**
  77619. * Gets or sets the parent container
  77620. */
  77621. parent: BABYLON.Nullable<Container3D>;
  77622. private _behaviors;
  77623. /**
  77624. * Gets the list of attached behaviors
  77625. * @see http://doc.babylonjs.com/features/behaviour
  77626. */
  77627. get behaviors(): BABYLON.Behavior<Control3D>[];
  77628. /**
  77629. * Attach a behavior to the control
  77630. * @see http://doc.babylonjs.com/features/behaviour
  77631. * @param behavior defines the behavior to attach
  77632. * @returns the current control
  77633. */
  77634. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77635. /**
  77636. * Remove an attached behavior
  77637. * @see http://doc.babylonjs.com/features/behaviour
  77638. * @param behavior defines the behavior to attach
  77639. * @returns the current control
  77640. */
  77641. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77642. /**
  77643. * Gets an attached behavior by name
  77644. * @param name defines the name of the behavior to look for
  77645. * @see http://doc.babylonjs.com/features/behaviour
  77646. * @returns null if behavior was not found else the requested behavior
  77647. */
  77648. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77649. /** Gets or sets a boolean indicating if the control is visible */
  77650. get isVisible(): boolean;
  77651. set isVisible(value: boolean);
  77652. /**
  77653. * Creates a new control
  77654. * @param name defines the control name
  77655. */
  77656. constructor(
  77657. /** Defines the control name */
  77658. name?: string | undefined);
  77659. /**
  77660. * Gets a string representing the class name
  77661. */
  77662. get typeName(): string;
  77663. /**
  77664. * Get the current class name of the control.
  77665. * @returns current class name
  77666. */
  77667. getClassName(): string;
  77668. protected _getTypeName(): string;
  77669. /**
  77670. * Gets the transform node used by this control
  77671. */
  77672. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77673. /**
  77674. * Gets the mesh used to render this control
  77675. */
  77676. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77677. /**
  77678. * Link the control as child of the given node
  77679. * @param node defines the node to link to. Use null to unlink the control
  77680. * @returns the current control
  77681. */
  77682. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77683. /** @hidden **/
  77684. _prepareNode(scene: BABYLON.Scene): void;
  77685. /**
  77686. * Node creation.
  77687. * Can be overriden by children
  77688. * @param scene defines the scene where the node must be attached
  77689. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77690. */
  77691. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77692. /**
  77693. * Affect a material to the given mesh
  77694. * @param mesh defines the mesh which will represent the control
  77695. */
  77696. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77697. /** @hidden */
  77698. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77699. /** @hidden */
  77700. _onPointerEnter(target: Control3D): boolean;
  77701. /** @hidden */
  77702. _onPointerOut(target: Control3D): void;
  77703. /** @hidden */
  77704. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77705. /** @hidden */
  77706. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77707. /** @hidden */
  77708. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77709. /** @hidden */
  77710. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77711. /** @hidden */
  77712. _disposeNode(): void;
  77713. /**
  77714. * Releases all associated resources
  77715. */
  77716. dispose(): void;
  77717. }
  77718. }
  77719. declare module BABYLON.GUI {
  77720. /**
  77721. * Class used as a root to all buttons
  77722. */
  77723. export class AbstractButton3D extends Control3D {
  77724. /**
  77725. * Creates a new button
  77726. * @param name defines the control name
  77727. */
  77728. constructor(name?: string);
  77729. protected _getTypeName(): string;
  77730. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77731. }
  77732. }
  77733. declare module BABYLON.GUI {
  77734. /**
  77735. * Class used to create a button in 3D
  77736. */
  77737. export class Button3D extends AbstractButton3D {
  77738. /** @hidden */
  77739. protected _currentMaterial: BABYLON.Material;
  77740. private _facadeTexture;
  77741. private _content;
  77742. private _contentResolution;
  77743. private _contentScaleRatio;
  77744. /**
  77745. * Gets or sets the texture resolution used to render content (512 by default)
  77746. */
  77747. get contentResolution(): BABYLON.int;
  77748. set contentResolution(value: BABYLON.int);
  77749. /**
  77750. * Gets or sets the texture scale ratio used to render content (2 by default)
  77751. */
  77752. get contentScaleRatio(): number;
  77753. set contentScaleRatio(value: number);
  77754. protected _disposeFacadeTexture(): void;
  77755. protected _resetContent(): void;
  77756. /**
  77757. * Creates a new button
  77758. * @param name defines the control name
  77759. */
  77760. constructor(name?: string);
  77761. /**
  77762. * Gets or sets the GUI 2D content used to display the button's facade
  77763. */
  77764. get content(): Control;
  77765. set content(value: Control);
  77766. /**
  77767. * Apply the facade texture (created from the content property).
  77768. * This function can be overloaded by child classes
  77769. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77770. */
  77771. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77772. protected _getTypeName(): string;
  77773. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77774. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77775. /**
  77776. * Releases all associated resources
  77777. */
  77778. dispose(): void;
  77779. }
  77780. }
  77781. declare module BABYLON.GUI {
  77782. /**
  77783. * Abstract class used to create a container panel deployed on the surface of a volume
  77784. */
  77785. export abstract class VolumeBasedPanel extends Container3D {
  77786. private _columns;
  77787. private _rows;
  77788. private _rowThenColum;
  77789. private _orientation;
  77790. protected _cellWidth: number;
  77791. protected _cellHeight: number;
  77792. /**
  77793. * Gets or sets the distance between elements
  77794. */
  77795. margin: number;
  77796. /**
  77797. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77798. * | Value | Type | Description |
  77799. * | ----- | ----------------------------------- | ----------- |
  77800. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77801. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77802. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77803. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77804. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77805. */
  77806. get orientation(): number;
  77807. set orientation(value: number);
  77808. /**
  77809. * Gets or sets the number of columns requested (10 by default).
  77810. * The panel will automatically compute the number of rows based on number of child controls.
  77811. */
  77812. get columns(): BABYLON.int;
  77813. set columns(value: BABYLON.int);
  77814. /**
  77815. * Gets or sets a the number of rows requested.
  77816. * The panel will automatically compute the number of columns based on number of child controls.
  77817. */
  77818. get rows(): BABYLON.int;
  77819. set rows(value: BABYLON.int);
  77820. /**
  77821. * Creates new VolumeBasedPanel
  77822. */
  77823. constructor();
  77824. protected _arrangeChildren(): void;
  77825. /** Child classes must implement this function to provide correct control positioning */
  77826. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77827. /** Child classes can implement this function to provide additional processing */
  77828. protected _finalProcessing(): void;
  77829. }
  77830. }
  77831. declare module BABYLON.GUI {
  77832. /**
  77833. * Class used to create a container panel deployed on the surface of a cylinder
  77834. */
  77835. export class CylinderPanel extends VolumeBasedPanel {
  77836. private _radius;
  77837. /**
  77838. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77839. */
  77840. get radius(): BABYLON.float;
  77841. set radius(value: BABYLON.float);
  77842. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77843. private _cylindricalMapping;
  77844. }
  77845. }
  77846. declare module BABYLON.GUI {
  77847. /** @hidden */
  77848. export var fluentVertexShader: {
  77849. name: string;
  77850. shader: string;
  77851. };
  77852. }
  77853. declare module BABYLON.GUI {
  77854. /** @hidden */
  77855. export var fluentPixelShader: {
  77856. name: string;
  77857. shader: string;
  77858. };
  77859. }
  77860. declare module BABYLON.GUI {
  77861. /** @hidden */
  77862. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77863. INNERGLOW: boolean;
  77864. BORDER: boolean;
  77865. HOVERLIGHT: boolean;
  77866. TEXTURE: boolean;
  77867. constructor();
  77868. }
  77869. /**
  77870. * Class used to render controls with fluent desgin
  77871. */
  77872. export class FluentMaterial extends BABYLON.PushMaterial {
  77873. /**
  77874. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77875. */
  77876. innerGlowColorIntensity: number;
  77877. /**
  77878. * Gets or sets the inner glow color (white by default)
  77879. */
  77880. innerGlowColor: BABYLON.Color3;
  77881. /**
  77882. * Gets or sets alpha value (default is 1.0)
  77883. */
  77884. alpha: number;
  77885. /**
  77886. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77887. */
  77888. albedoColor: BABYLON.Color3;
  77889. /**
  77890. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77891. */
  77892. renderBorders: boolean;
  77893. /**
  77894. * Gets or sets border width (default is 0.5)
  77895. */
  77896. borderWidth: number;
  77897. /**
  77898. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77899. */
  77900. edgeSmoothingValue: number;
  77901. /**
  77902. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77903. */
  77904. borderMinValue: number;
  77905. /**
  77906. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77907. */
  77908. renderHoverLight: boolean;
  77909. /**
  77910. * Gets or sets the radius used to render the hover light (default is 1.0)
  77911. */
  77912. hoverRadius: number;
  77913. /**
  77914. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77915. */
  77916. hoverColor: BABYLON.Color4;
  77917. /**
  77918. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77919. */
  77920. hoverPosition: BABYLON.Vector3;
  77921. private _albedoTexture;
  77922. /** Gets or sets the texture to use for albedo color */
  77923. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77924. /**
  77925. * Creates a new Fluent material
  77926. * @param name defines the name of the material
  77927. * @param scene defines the hosting scene
  77928. */
  77929. constructor(name: string, scene: BABYLON.Scene);
  77930. needAlphaBlending(): boolean;
  77931. needAlphaTesting(): boolean;
  77932. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77933. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77934. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77935. getActiveTextures(): BABYLON.BaseTexture[];
  77936. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77937. dispose(forceDisposeEffect?: boolean): void;
  77938. clone(name: string): FluentMaterial;
  77939. serialize(): any;
  77940. getClassName(): string;
  77941. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77942. }
  77943. }
  77944. declare module BABYLON.GUI {
  77945. /**
  77946. * Class used to create a holographic button in 3D
  77947. */
  77948. export class HolographicButton extends Button3D {
  77949. private _backPlate;
  77950. private _textPlate;
  77951. private _frontPlate;
  77952. private _text;
  77953. private _imageUrl;
  77954. private _shareMaterials;
  77955. private _frontMaterial;
  77956. private _backMaterial;
  77957. private _plateMaterial;
  77958. private _pickedPointObserver;
  77959. private _tooltipFade;
  77960. private _tooltipTextBlock;
  77961. private _tooltipTexture;
  77962. private _tooltipMesh;
  77963. private _tooltipHoverObserver;
  77964. private _tooltipOutObserver;
  77965. private _disposeTooltip;
  77966. /**
  77967. * Rendering ground id of all the mesh in the button
  77968. */
  77969. set renderingGroupId(id: number);
  77970. get renderingGroupId(): number;
  77971. /**
  77972. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77973. */
  77974. set tooltipText(text: BABYLON.Nullable<string>);
  77975. get tooltipText(): BABYLON.Nullable<string>;
  77976. /**
  77977. * Gets or sets text for the button
  77978. */
  77979. get text(): string;
  77980. set text(value: string);
  77981. /**
  77982. * Gets or sets the image url for the button
  77983. */
  77984. get imageUrl(): string;
  77985. set imageUrl(value: string);
  77986. /**
  77987. * Gets the back material used by this button
  77988. */
  77989. get backMaterial(): FluentMaterial;
  77990. /**
  77991. * Gets the front material used by this button
  77992. */
  77993. get frontMaterial(): FluentMaterial;
  77994. /**
  77995. * Gets the plate material used by this button
  77996. */
  77997. get plateMaterial(): BABYLON.StandardMaterial;
  77998. /**
  77999. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78000. */
  78001. get shareMaterials(): boolean;
  78002. /**
  78003. * Creates a new button
  78004. * @param name defines the control name
  78005. */
  78006. constructor(name?: string, shareMaterials?: boolean);
  78007. protected _getTypeName(): string;
  78008. private _rebuildContent;
  78009. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78010. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78011. private _createBackMaterial;
  78012. private _createFrontMaterial;
  78013. private _createPlateMaterial;
  78014. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78015. /**
  78016. * Releases all associated resources
  78017. */
  78018. dispose(): void;
  78019. }
  78020. }
  78021. declare module BABYLON.GUI {
  78022. /**
  78023. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78024. */
  78025. export class MeshButton3D extends Button3D {
  78026. /** @hidden */
  78027. protected _currentMesh: BABYLON.Mesh;
  78028. /**
  78029. * Creates a new 3D button based on a mesh
  78030. * @param mesh mesh to become a 3D button
  78031. * @param name defines the control name
  78032. */
  78033. constructor(mesh: BABYLON.Mesh, name?: string);
  78034. protected _getTypeName(): string;
  78035. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78036. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78037. }
  78038. }
  78039. declare module BABYLON.GUI {
  78040. /**
  78041. * Class used to create a container panel deployed on the surface of a plane
  78042. */
  78043. export class PlanePanel extends VolumeBasedPanel {
  78044. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78045. }
  78046. }
  78047. declare module BABYLON.GUI {
  78048. /**
  78049. * Class used to create a container panel where items get randomized planar mapping
  78050. */
  78051. export class ScatterPanel extends VolumeBasedPanel {
  78052. private _iteration;
  78053. /**
  78054. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78055. */
  78056. get iteration(): BABYLON.float;
  78057. set iteration(value: BABYLON.float);
  78058. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78059. private _scatterMapping;
  78060. protected _finalProcessing(): void;
  78061. }
  78062. }
  78063. declare module BABYLON.GUI {
  78064. /**
  78065. * Class used to create a container panel deployed on the surface of a sphere
  78066. */
  78067. export class SpherePanel extends VolumeBasedPanel {
  78068. private _radius;
  78069. /**
  78070. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78071. */
  78072. get radius(): BABYLON.float;
  78073. set radius(value: BABYLON.float);
  78074. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78075. private _sphericalMapping;
  78076. }
  78077. }
  78078. declare module BABYLON.GUI {
  78079. /**
  78080. * Class used to create a stack panel in 3D on XY plane
  78081. */
  78082. export class StackPanel3D extends Container3D {
  78083. private _isVertical;
  78084. /**
  78085. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78086. */
  78087. get isVertical(): boolean;
  78088. set isVertical(value: boolean);
  78089. /**
  78090. * Gets or sets the distance between elements
  78091. */
  78092. margin: number;
  78093. /**
  78094. * Creates new StackPanel
  78095. * @param isVertical
  78096. */
  78097. constructor(isVertical?: boolean);
  78098. protected _arrangeChildren(): void;
  78099. }
  78100. }
  78101. declare module BABYLON {
  78102. /**
  78103. * Configuration for glTF validation
  78104. */
  78105. export interface IGLTFValidationConfiguration {
  78106. /**
  78107. * The url of the glTF validator.
  78108. */
  78109. url: string;
  78110. }
  78111. /**
  78112. * glTF validation
  78113. */
  78114. export class GLTFValidation {
  78115. /**
  78116. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78117. */
  78118. static Configuration: IGLTFValidationConfiguration;
  78119. private static _LoadScriptPromise;
  78120. /**
  78121. * Validate a glTF asset using the glTF-Validator.
  78122. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78123. * @param rootUrl The root url for the glTF
  78124. * @param fileName The file name for the glTF
  78125. * @param getExternalResource The callback to get external resources for the glTF validator
  78126. * @returns A promise that resolves with the glTF validation results once complete
  78127. */
  78128. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78129. }
  78130. }
  78131. declare module BABYLON {
  78132. /**
  78133. * Mode that determines the coordinate system to use.
  78134. */
  78135. export enum GLTFLoaderCoordinateSystemMode {
  78136. /**
  78137. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78138. */
  78139. AUTO = 0,
  78140. /**
  78141. * Sets the useRightHandedSystem flag on the scene.
  78142. */
  78143. FORCE_RIGHT_HANDED = 1
  78144. }
  78145. /**
  78146. * Mode that determines what animations will start.
  78147. */
  78148. export enum GLTFLoaderAnimationStartMode {
  78149. /**
  78150. * No animation will start.
  78151. */
  78152. NONE = 0,
  78153. /**
  78154. * The first animation will start.
  78155. */
  78156. FIRST = 1,
  78157. /**
  78158. * All animations will start.
  78159. */
  78160. ALL = 2
  78161. }
  78162. /**
  78163. * Interface that contains the data for the glTF asset.
  78164. */
  78165. export interface IGLTFLoaderData {
  78166. /**
  78167. * The object that represents the glTF JSON.
  78168. */
  78169. json: Object;
  78170. /**
  78171. * The BIN chunk of a binary glTF.
  78172. */
  78173. bin: Nullable<IDataBuffer>;
  78174. }
  78175. /**
  78176. * Interface for extending the loader.
  78177. */
  78178. export interface IGLTFLoaderExtension {
  78179. /**
  78180. * The name of this extension.
  78181. */
  78182. readonly name: string;
  78183. /**
  78184. * Defines whether this extension is enabled.
  78185. */
  78186. enabled: boolean;
  78187. /**
  78188. * Defines the order of this extension.
  78189. * The loader sorts the extensions using these values when loading.
  78190. */
  78191. order?: number;
  78192. }
  78193. /**
  78194. * Loader state.
  78195. */
  78196. export enum GLTFLoaderState {
  78197. /**
  78198. * The asset is loading.
  78199. */
  78200. LOADING = 0,
  78201. /**
  78202. * The asset is ready for rendering.
  78203. */
  78204. READY = 1,
  78205. /**
  78206. * The asset is completely loaded.
  78207. */
  78208. COMPLETE = 2
  78209. }
  78210. /** @hidden */
  78211. export interface IImportMeshAsyncOutput {
  78212. meshes: AbstractMesh[];
  78213. particleSystems: IParticleSystem[];
  78214. skeletons: Skeleton[];
  78215. animationGroups: AnimationGroup[];
  78216. lights: Light[];
  78217. transformNodes: TransformNode[];
  78218. }
  78219. /** @hidden */
  78220. export interface IGLTFLoader extends IDisposable {
  78221. readonly state: Nullable<GLTFLoaderState>;
  78222. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78223. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78224. }
  78225. /**
  78226. * File loader for loading glTF files into a scene.
  78227. */
  78228. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78229. /** @hidden */
  78230. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78231. /** @hidden */
  78232. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78233. /**
  78234. * Raised when the asset has been parsed
  78235. */
  78236. onParsedObservable: Observable<IGLTFLoaderData>;
  78237. private _onParsedObserver;
  78238. /**
  78239. * Raised when the asset has been parsed
  78240. */
  78241. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78242. /**
  78243. * 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.
  78244. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78245. * Defaults to true.
  78246. * @hidden
  78247. */
  78248. static IncrementalLoading: boolean;
  78249. /**
  78250. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78251. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78252. * @hidden
  78253. */
  78254. static HomogeneousCoordinates: boolean;
  78255. /**
  78256. * The coordinate system mode. Defaults to AUTO.
  78257. */
  78258. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78259. /**
  78260. * The animation start mode. Defaults to FIRST.
  78261. */
  78262. animationStartMode: GLTFLoaderAnimationStartMode;
  78263. /**
  78264. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78265. */
  78266. compileMaterials: boolean;
  78267. /**
  78268. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78269. */
  78270. useClipPlane: boolean;
  78271. /**
  78272. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78273. */
  78274. compileShadowGenerators: boolean;
  78275. /**
  78276. * Defines if the Alpha blended materials are only applied as coverage.
  78277. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78278. * If true, no extra effects are applied to transparent pixels.
  78279. */
  78280. transparencyAsCoverage: boolean;
  78281. /**
  78282. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78283. * Enabling will disable offline support and glTF validator.
  78284. * Defaults to false.
  78285. */
  78286. useRangeRequests: boolean;
  78287. /**
  78288. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78289. */
  78290. createInstances: boolean;
  78291. /**
  78292. * Function called before loading a url referenced by the asset.
  78293. */
  78294. preprocessUrlAsync: (url: string) => Promise<string>;
  78295. /**
  78296. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78297. */
  78298. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78299. private _onMeshLoadedObserver;
  78300. /**
  78301. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78302. */
  78303. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78304. /**
  78305. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78306. */
  78307. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78308. private _onTextureLoadedObserver;
  78309. /**
  78310. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78311. */
  78312. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78313. /**
  78314. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78315. */
  78316. readonly onMaterialLoadedObservable: Observable<Material>;
  78317. private _onMaterialLoadedObserver;
  78318. /**
  78319. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78320. */
  78321. set onMaterialLoaded(callback: (material: Material) => void);
  78322. /**
  78323. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78324. */
  78325. readonly onCameraLoadedObservable: Observable<Camera>;
  78326. private _onCameraLoadedObserver;
  78327. /**
  78328. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78329. */
  78330. set onCameraLoaded(callback: (camera: Camera) => void);
  78331. /**
  78332. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78333. * For assets with LODs, raised when all of the LODs are complete.
  78334. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78335. */
  78336. readonly onCompleteObservable: Observable<void>;
  78337. private _onCompleteObserver;
  78338. /**
  78339. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78340. * For assets with LODs, raised when all of the LODs are complete.
  78341. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78342. */
  78343. set onComplete(callback: () => void);
  78344. /**
  78345. * Observable raised when an error occurs.
  78346. */
  78347. readonly onErrorObservable: Observable<any>;
  78348. private _onErrorObserver;
  78349. /**
  78350. * Callback raised when an error occurs.
  78351. */
  78352. set onError(callback: (reason: any) => void);
  78353. /**
  78354. * Observable raised after the loader is disposed.
  78355. */
  78356. readonly onDisposeObservable: Observable<void>;
  78357. private _onDisposeObserver;
  78358. /**
  78359. * Callback raised after the loader is disposed.
  78360. */
  78361. set onDispose(callback: () => void);
  78362. /**
  78363. * Observable raised after a loader extension is created.
  78364. * Set additional options for a loader extension in this event.
  78365. */
  78366. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78367. private _onExtensionLoadedObserver;
  78368. /**
  78369. * Callback raised after a loader extension is created.
  78370. */
  78371. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78372. /**
  78373. * Defines if the loader logging is enabled.
  78374. */
  78375. get loggingEnabled(): boolean;
  78376. set loggingEnabled(value: boolean);
  78377. /**
  78378. * Defines if the loader should capture performance counters.
  78379. */
  78380. get capturePerformanceCounters(): boolean;
  78381. set capturePerformanceCounters(value: boolean);
  78382. /**
  78383. * Defines if the loader should validate the asset.
  78384. */
  78385. validate: boolean;
  78386. /**
  78387. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78388. */
  78389. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78390. private _onValidatedObserver;
  78391. /**
  78392. * Callback raised after a loader extension is created.
  78393. */
  78394. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78395. private _loader;
  78396. /**
  78397. * Name of the loader ("gltf")
  78398. */
  78399. name: string;
  78400. /** @hidden */
  78401. extensions: ISceneLoaderPluginExtensions;
  78402. /**
  78403. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78404. */
  78405. dispose(): void;
  78406. /** @hidden */
  78407. _clear(): void;
  78408. /** @hidden */
  78409. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78410. /** @hidden */
  78411. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78412. /** @hidden */
  78413. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78414. meshes: AbstractMesh[];
  78415. particleSystems: IParticleSystem[];
  78416. skeletons: Skeleton[];
  78417. animationGroups: AnimationGroup[];
  78418. }>;
  78419. /** @hidden */
  78420. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78421. /** @hidden */
  78422. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78423. /** @hidden */
  78424. canDirectLoad(data: string): boolean;
  78425. /** @hidden */
  78426. directLoad(scene: Scene, data: string): any;
  78427. /**
  78428. * The callback that allows custom handling of the root url based on the response url.
  78429. * @param rootUrl the original root url
  78430. * @param responseURL the response url if available
  78431. * @returns the new root url
  78432. */
  78433. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78434. /** @hidden */
  78435. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78436. /**
  78437. * The loader state or null if the loader is not active.
  78438. */
  78439. get loaderState(): Nullable<GLTFLoaderState>;
  78440. /**
  78441. * Returns a promise that resolves when the asset is completely loaded.
  78442. * @returns a promise that resolves when the asset is completely loaded.
  78443. */
  78444. whenCompleteAsync(): Promise<void>;
  78445. private _validate;
  78446. private _getLoader;
  78447. private _parseJson;
  78448. private _unpackBinaryAsync;
  78449. private _unpackBinaryV1Async;
  78450. private _unpackBinaryV2Async;
  78451. private static _parseVersion;
  78452. private static _compareVersion;
  78453. private static readonly _logSpaces;
  78454. private _logIndentLevel;
  78455. private _loggingEnabled;
  78456. /** @hidden */
  78457. _log: (message: string) => void;
  78458. /** @hidden */
  78459. _logOpen(message: string): void;
  78460. /** @hidden */
  78461. _logClose(): void;
  78462. private _logEnabled;
  78463. private _logDisabled;
  78464. private _capturePerformanceCounters;
  78465. /** @hidden */
  78466. _startPerformanceCounter: (counterName: string) => void;
  78467. /** @hidden */
  78468. _endPerformanceCounter: (counterName: string) => void;
  78469. private _startPerformanceCounterEnabled;
  78470. private _startPerformanceCounterDisabled;
  78471. private _endPerformanceCounterEnabled;
  78472. private _endPerformanceCounterDisabled;
  78473. }
  78474. }
  78475. declare module BABYLON.GLTF1 {
  78476. /**
  78477. * Enums
  78478. * @hidden
  78479. */
  78480. export enum EComponentType {
  78481. BYTE = 5120,
  78482. UNSIGNED_BYTE = 5121,
  78483. SHORT = 5122,
  78484. UNSIGNED_SHORT = 5123,
  78485. FLOAT = 5126
  78486. }
  78487. /** @hidden */
  78488. export enum EShaderType {
  78489. FRAGMENT = 35632,
  78490. VERTEX = 35633
  78491. }
  78492. /** @hidden */
  78493. export enum EParameterType {
  78494. BYTE = 5120,
  78495. UNSIGNED_BYTE = 5121,
  78496. SHORT = 5122,
  78497. UNSIGNED_SHORT = 5123,
  78498. INT = 5124,
  78499. UNSIGNED_INT = 5125,
  78500. FLOAT = 5126,
  78501. FLOAT_VEC2 = 35664,
  78502. FLOAT_VEC3 = 35665,
  78503. FLOAT_VEC4 = 35666,
  78504. INT_VEC2 = 35667,
  78505. INT_VEC3 = 35668,
  78506. INT_VEC4 = 35669,
  78507. BOOL = 35670,
  78508. BOOL_VEC2 = 35671,
  78509. BOOL_VEC3 = 35672,
  78510. BOOL_VEC4 = 35673,
  78511. FLOAT_MAT2 = 35674,
  78512. FLOAT_MAT3 = 35675,
  78513. FLOAT_MAT4 = 35676,
  78514. SAMPLER_2D = 35678
  78515. }
  78516. /** @hidden */
  78517. export enum ETextureWrapMode {
  78518. CLAMP_TO_EDGE = 33071,
  78519. MIRRORED_REPEAT = 33648,
  78520. REPEAT = 10497
  78521. }
  78522. /** @hidden */
  78523. export enum ETextureFilterType {
  78524. NEAREST = 9728,
  78525. LINEAR = 9728,
  78526. NEAREST_MIPMAP_NEAREST = 9984,
  78527. LINEAR_MIPMAP_NEAREST = 9985,
  78528. NEAREST_MIPMAP_LINEAR = 9986,
  78529. LINEAR_MIPMAP_LINEAR = 9987
  78530. }
  78531. /** @hidden */
  78532. export enum ETextureFormat {
  78533. ALPHA = 6406,
  78534. RGB = 6407,
  78535. RGBA = 6408,
  78536. LUMINANCE = 6409,
  78537. LUMINANCE_ALPHA = 6410
  78538. }
  78539. /** @hidden */
  78540. export enum ECullingType {
  78541. FRONT = 1028,
  78542. BACK = 1029,
  78543. FRONT_AND_BACK = 1032
  78544. }
  78545. /** @hidden */
  78546. export enum EBlendingFunction {
  78547. ZERO = 0,
  78548. ONE = 1,
  78549. SRC_COLOR = 768,
  78550. ONE_MINUS_SRC_COLOR = 769,
  78551. DST_COLOR = 774,
  78552. ONE_MINUS_DST_COLOR = 775,
  78553. SRC_ALPHA = 770,
  78554. ONE_MINUS_SRC_ALPHA = 771,
  78555. DST_ALPHA = 772,
  78556. ONE_MINUS_DST_ALPHA = 773,
  78557. CONSTANT_COLOR = 32769,
  78558. ONE_MINUS_CONSTANT_COLOR = 32770,
  78559. CONSTANT_ALPHA = 32771,
  78560. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78561. SRC_ALPHA_SATURATE = 776
  78562. }
  78563. /** @hidden */
  78564. export interface IGLTFProperty {
  78565. extensions?: {
  78566. [key: string]: any;
  78567. };
  78568. extras?: Object;
  78569. }
  78570. /** @hidden */
  78571. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78572. name?: string;
  78573. }
  78574. /** @hidden */
  78575. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78576. bufferView: string;
  78577. byteOffset: number;
  78578. byteStride: number;
  78579. count: number;
  78580. type: string;
  78581. componentType: EComponentType;
  78582. max?: number[];
  78583. min?: number[];
  78584. name?: string;
  78585. }
  78586. /** @hidden */
  78587. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78588. buffer: string;
  78589. byteOffset: number;
  78590. byteLength: number;
  78591. byteStride: number;
  78592. target?: number;
  78593. }
  78594. /** @hidden */
  78595. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78596. uri: string;
  78597. byteLength?: number;
  78598. type?: string;
  78599. }
  78600. /** @hidden */
  78601. export interface IGLTFShader extends IGLTFChildRootProperty {
  78602. uri: string;
  78603. type: EShaderType;
  78604. }
  78605. /** @hidden */
  78606. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78607. attributes: string[];
  78608. fragmentShader: string;
  78609. vertexShader: string;
  78610. }
  78611. /** @hidden */
  78612. export interface IGLTFTechniqueParameter {
  78613. type: number;
  78614. count?: number;
  78615. semantic?: string;
  78616. node?: string;
  78617. value?: number | boolean | string | Array<any>;
  78618. source?: string;
  78619. babylonValue?: any;
  78620. }
  78621. /** @hidden */
  78622. export interface IGLTFTechniqueCommonProfile {
  78623. lightingModel: string;
  78624. texcoordBindings: Object;
  78625. parameters?: Array<any>;
  78626. }
  78627. /** @hidden */
  78628. export interface IGLTFTechniqueStatesFunctions {
  78629. blendColor?: number[];
  78630. blendEquationSeparate?: number[];
  78631. blendFuncSeparate?: number[];
  78632. colorMask: boolean[];
  78633. cullFace: number[];
  78634. }
  78635. /** @hidden */
  78636. export interface IGLTFTechniqueStates {
  78637. enable: number[];
  78638. functions: IGLTFTechniqueStatesFunctions;
  78639. }
  78640. /** @hidden */
  78641. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78642. parameters: {
  78643. [key: string]: IGLTFTechniqueParameter;
  78644. };
  78645. program: string;
  78646. attributes: {
  78647. [key: string]: string;
  78648. };
  78649. uniforms: {
  78650. [key: string]: string;
  78651. };
  78652. states: IGLTFTechniqueStates;
  78653. }
  78654. /** @hidden */
  78655. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78656. technique?: string;
  78657. values: string[];
  78658. }
  78659. /** @hidden */
  78660. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78661. attributes: {
  78662. [key: string]: string;
  78663. };
  78664. indices: string;
  78665. material: string;
  78666. mode?: number;
  78667. }
  78668. /** @hidden */
  78669. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78670. primitives: IGLTFMeshPrimitive[];
  78671. }
  78672. /** @hidden */
  78673. export interface IGLTFImage extends IGLTFChildRootProperty {
  78674. uri: string;
  78675. }
  78676. /** @hidden */
  78677. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78678. magFilter?: number;
  78679. minFilter?: number;
  78680. wrapS?: number;
  78681. wrapT?: number;
  78682. }
  78683. /** @hidden */
  78684. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78685. sampler: string;
  78686. source: string;
  78687. format?: ETextureFormat;
  78688. internalFormat?: ETextureFormat;
  78689. target?: number;
  78690. type?: number;
  78691. babylonTexture?: Texture;
  78692. }
  78693. /** @hidden */
  78694. export interface IGLTFAmbienLight {
  78695. color?: number[];
  78696. }
  78697. /** @hidden */
  78698. export interface IGLTFDirectionalLight {
  78699. color?: number[];
  78700. }
  78701. /** @hidden */
  78702. export interface IGLTFPointLight {
  78703. color?: number[];
  78704. constantAttenuation?: number;
  78705. linearAttenuation?: number;
  78706. quadraticAttenuation?: number;
  78707. }
  78708. /** @hidden */
  78709. export interface IGLTFSpotLight {
  78710. color?: number[];
  78711. constantAttenuation?: number;
  78712. fallOfAngle?: number;
  78713. fallOffExponent?: number;
  78714. linearAttenuation?: number;
  78715. quadraticAttenuation?: number;
  78716. }
  78717. /** @hidden */
  78718. export interface IGLTFLight extends IGLTFChildRootProperty {
  78719. type: string;
  78720. }
  78721. /** @hidden */
  78722. export interface IGLTFCameraOrthographic {
  78723. xmag: number;
  78724. ymag: number;
  78725. zfar: number;
  78726. znear: number;
  78727. }
  78728. /** @hidden */
  78729. export interface IGLTFCameraPerspective {
  78730. aspectRatio: number;
  78731. yfov: number;
  78732. zfar: number;
  78733. znear: number;
  78734. }
  78735. /** @hidden */
  78736. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78737. type: string;
  78738. }
  78739. /** @hidden */
  78740. export interface IGLTFAnimationChannelTarget {
  78741. id: string;
  78742. path: string;
  78743. }
  78744. /** @hidden */
  78745. export interface IGLTFAnimationChannel {
  78746. sampler: string;
  78747. target: IGLTFAnimationChannelTarget;
  78748. }
  78749. /** @hidden */
  78750. export interface IGLTFAnimationSampler {
  78751. input: string;
  78752. output: string;
  78753. interpolation?: string;
  78754. }
  78755. /** @hidden */
  78756. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78757. channels?: IGLTFAnimationChannel[];
  78758. parameters?: {
  78759. [key: string]: string;
  78760. };
  78761. samplers?: {
  78762. [key: string]: IGLTFAnimationSampler;
  78763. };
  78764. }
  78765. /** @hidden */
  78766. export interface IGLTFNodeInstanceSkin {
  78767. skeletons: string[];
  78768. skin: string;
  78769. meshes: string[];
  78770. }
  78771. /** @hidden */
  78772. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78773. bindShapeMatrix: number[];
  78774. inverseBindMatrices: string;
  78775. jointNames: string[];
  78776. babylonSkeleton?: Skeleton;
  78777. }
  78778. /** @hidden */
  78779. export interface IGLTFNode extends IGLTFChildRootProperty {
  78780. camera?: string;
  78781. children: string[];
  78782. skin?: string;
  78783. jointName?: string;
  78784. light?: string;
  78785. matrix: number[];
  78786. mesh?: string;
  78787. meshes?: string[];
  78788. rotation?: number[];
  78789. scale?: number[];
  78790. translation?: number[];
  78791. babylonNode?: Node;
  78792. }
  78793. /** @hidden */
  78794. export interface IGLTFScene extends IGLTFChildRootProperty {
  78795. nodes: string[];
  78796. }
  78797. /** @hidden */
  78798. export interface IGLTFRuntime {
  78799. extensions: {
  78800. [key: string]: any;
  78801. };
  78802. accessors: {
  78803. [key: string]: IGLTFAccessor;
  78804. };
  78805. buffers: {
  78806. [key: string]: IGLTFBuffer;
  78807. };
  78808. bufferViews: {
  78809. [key: string]: IGLTFBufferView;
  78810. };
  78811. meshes: {
  78812. [key: string]: IGLTFMesh;
  78813. };
  78814. lights: {
  78815. [key: string]: IGLTFLight;
  78816. };
  78817. cameras: {
  78818. [key: string]: IGLTFCamera;
  78819. };
  78820. nodes: {
  78821. [key: string]: IGLTFNode;
  78822. };
  78823. images: {
  78824. [key: string]: IGLTFImage;
  78825. };
  78826. textures: {
  78827. [key: string]: IGLTFTexture;
  78828. };
  78829. shaders: {
  78830. [key: string]: IGLTFShader;
  78831. };
  78832. programs: {
  78833. [key: string]: IGLTFProgram;
  78834. };
  78835. samplers: {
  78836. [key: string]: IGLTFSampler;
  78837. };
  78838. techniques: {
  78839. [key: string]: IGLTFTechnique;
  78840. };
  78841. materials: {
  78842. [key: string]: IGLTFMaterial;
  78843. };
  78844. animations: {
  78845. [key: string]: IGLTFAnimation;
  78846. };
  78847. skins: {
  78848. [key: string]: IGLTFSkins;
  78849. };
  78850. currentScene?: Object;
  78851. scenes: {
  78852. [key: string]: IGLTFScene;
  78853. };
  78854. extensionsUsed: string[];
  78855. extensionsRequired?: string[];
  78856. buffersCount: number;
  78857. shaderscount: number;
  78858. scene: Scene;
  78859. rootUrl: string;
  78860. loadedBufferCount: number;
  78861. loadedBufferViews: {
  78862. [name: string]: ArrayBufferView;
  78863. };
  78864. loadedShaderCount: number;
  78865. importOnlyMeshes: boolean;
  78866. importMeshesNames?: string[];
  78867. dummyNodes: Node[];
  78868. forAssetContainer: boolean;
  78869. }
  78870. /** @hidden */
  78871. export interface INodeToRoot {
  78872. bone: Bone;
  78873. node: IGLTFNode;
  78874. id: string;
  78875. }
  78876. /** @hidden */
  78877. export interface IJointNode {
  78878. node: IGLTFNode;
  78879. id: string;
  78880. }
  78881. }
  78882. declare module BABYLON.GLTF1 {
  78883. /**
  78884. * Utils functions for GLTF
  78885. * @hidden
  78886. */
  78887. export class GLTFUtils {
  78888. /**
  78889. * Sets the given "parameter" matrix
  78890. * @param scene: the Scene object
  78891. * @param source: the source node where to pick the matrix
  78892. * @param parameter: the GLTF technique parameter
  78893. * @param uniformName: the name of the shader's uniform
  78894. * @param shaderMaterial: the shader material
  78895. */
  78896. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78897. /**
  78898. * Sets the given "parameter" matrix
  78899. * @param shaderMaterial: the shader material
  78900. * @param uniform: the name of the shader's uniform
  78901. * @param value: the value of the uniform
  78902. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78903. */
  78904. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78905. /**
  78906. * Returns the wrap mode of the texture
  78907. * @param mode: the mode value
  78908. */
  78909. static GetWrapMode(mode: number): number;
  78910. /**
  78911. * Returns the byte stride giving an accessor
  78912. * @param accessor: the GLTF accessor objet
  78913. */
  78914. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78915. /**
  78916. * Returns the texture filter mode giving a mode value
  78917. * @param mode: the filter mode value
  78918. */
  78919. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78920. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78921. /**
  78922. * Returns a buffer from its accessor
  78923. * @param gltfRuntime: the GLTF runtime
  78924. * @param accessor: the GLTF accessor
  78925. */
  78926. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78927. /**
  78928. * Decodes a buffer view into a string
  78929. * @param view: the buffer view
  78930. */
  78931. static DecodeBufferToText(view: ArrayBufferView): string;
  78932. /**
  78933. * Returns the default material of gltf. Related to
  78934. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78935. * @param scene: the Babylon.js scene
  78936. */
  78937. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78938. private static _DefaultMaterial;
  78939. }
  78940. }
  78941. declare module BABYLON.GLTF1 {
  78942. /**
  78943. * Implementation of the base glTF spec
  78944. * @hidden
  78945. */
  78946. export class GLTFLoaderBase {
  78947. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78948. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78949. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78950. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78951. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78952. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78953. }
  78954. /**
  78955. * glTF V1 Loader
  78956. * @hidden
  78957. */
  78958. export class GLTFLoader implements IGLTFLoader {
  78959. static Extensions: {
  78960. [name: string]: GLTFLoaderExtension;
  78961. };
  78962. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78963. state: Nullable<GLTFLoaderState>;
  78964. dispose(): void;
  78965. private _importMeshAsync;
  78966. /**
  78967. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78968. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78969. * @param scene the scene the meshes should be added to
  78970. * @param forAssetContainer defines if the entities must be stored in the scene
  78971. * @param data gltf data containing information of the meshes in a loaded file
  78972. * @param rootUrl root url to load from
  78973. * @param onProgress event that fires when loading progress has occured
  78974. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78975. */
  78976. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78977. private _loadAsync;
  78978. /**
  78979. * Imports all objects from a loaded gltf file and adds them to the scene
  78980. * @param scene the scene the objects should be added to
  78981. * @param data gltf data containing information of the meshes in a loaded file
  78982. * @param rootUrl root url to load from
  78983. * @param onProgress event that fires when loading progress has occured
  78984. * @returns a promise which completes when objects have been loaded to the scene
  78985. */
  78986. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78987. private _loadShadersAsync;
  78988. private _loadBuffersAsync;
  78989. private _createNodes;
  78990. }
  78991. /** @hidden */
  78992. export abstract class GLTFLoaderExtension {
  78993. private _name;
  78994. constructor(name: string);
  78995. get name(): string;
  78996. /**
  78997. * Defines an override for loading the runtime
  78998. * Return true to stop further extensions from loading the runtime
  78999. */
  79000. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79001. /**
  79002. * Defines an onverride for creating gltf runtime
  79003. * Return true to stop further extensions from creating the runtime
  79004. */
  79005. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79006. /**
  79007. * Defines an override for loading buffers
  79008. * Return true to stop further extensions from loading this buffer
  79009. */
  79010. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79011. /**
  79012. * Defines an override for loading texture buffers
  79013. * Return true to stop further extensions from loading this texture data
  79014. */
  79015. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79016. /**
  79017. * Defines an override for creating textures
  79018. * Return true to stop further extensions from loading this texture
  79019. */
  79020. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79021. /**
  79022. * Defines an override for loading shader strings
  79023. * Return true to stop further extensions from loading this shader data
  79024. */
  79025. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79026. /**
  79027. * Defines an override for loading materials
  79028. * Return true to stop further extensions from loading this material
  79029. */
  79030. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79031. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79032. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79033. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79034. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79035. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79036. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79037. private static LoadTextureBufferAsync;
  79038. private static CreateTextureAsync;
  79039. private static ApplyExtensions;
  79040. }
  79041. }
  79042. declare module BABYLON.GLTF1 {
  79043. /** @hidden */
  79044. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79045. private _bin;
  79046. constructor();
  79047. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79048. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79049. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79050. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79051. }
  79052. }
  79053. declare module BABYLON.GLTF1 {
  79054. /** @hidden */
  79055. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79056. constructor();
  79057. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79058. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79059. private _loadTexture;
  79060. }
  79061. }
  79062. declare module BABYLON.GLTF2.Loader {
  79063. /**
  79064. * Loader interface with an index field.
  79065. */
  79066. export interface IArrayItem {
  79067. /**
  79068. * The index of this item in the array.
  79069. */
  79070. index: number;
  79071. }
  79072. /**
  79073. * Loader interface with additional members.
  79074. */
  79075. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79076. /** @hidden */
  79077. _data?: Promise<ArrayBufferView>;
  79078. /** @hidden */
  79079. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79080. }
  79081. /**
  79082. * Loader interface with additional members.
  79083. */
  79084. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79085. }
  79086. /** @hidden */
  79087. export interface _IAnimationSamplerData {
  79088. input: Float32Array;
  79089. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79090. output: Float32Array;
  79091. }
  79092. /**
  79093. * Loader interface with additional members.
  79094. */
  79095. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79096. /** @hidden */
  79097. _data?: Promise<_IAnimationSamplerData>;
  79098. }
  79099. /**
  79100. * Loader interface with additional members.
  79101. */
  79102. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79103. channels: IAnimationChannel[];
  79104. samplers: IAnimationSampler[];
  79105. /** @hidden */
  79106. _babylonAnimationGroup?: AnimationGroup;
  79107. }
  79108. /**
  79109. * Loader interface with additional members.
  79110. */
  79111. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79112. /** @hidden */
  79113. _data?: Promise<ArrayBufferView>;
  79114. }
  79115. /**
  79116. * Loader interface with additional members.
  79117. */
  79118. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79119. /** @hidden */
  79120. _data?: Promise<ArrayBufferView>;
  79121. /** @hidden */
  79122. _babylonBuffer?: Promise<Buffer>;
  79123. }
  79124. /**
  79125. * Loader interface with additional members.
  79126. */
  79127. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79128. }
  79129. /**
  79130. * Loader interface with additional members.
  79131. */
  79132. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79133. /** @hidden */
  79134. _data?: Promise<ArrayBufferView>;
  79135. }
  79136. /**
  79137. * Loader interface with additional members.
  79138. */
  79139. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79140. }
  79141. /**
  79142. * Loader interface with additional members.
  79143. */
  79144. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79145. }
  79146. /**
  79147. * Loader interface with additional members.
  79148. */
  79149. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79150. baseColorTexture?: ITextureInfo;
  79151. metallicRoughnessTexture?: ITextureInfo;
  79152. }
  79153. /**
  79154. * Loader interface with additional members.
  79155. */
  79156. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79157. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79158. normalTexture?: IMaterialNormalTextureInfo;
  79159. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79160. emissiveTexture?: ITextureInfo;
  79161. /** @hidden */
  79162. _data?: {
  79163. [babylonDrawMode: number]: {
  79164. babylonMaterial: Material;
  79165. babylonMeshes: AbstractMesh[];
  79166. promise: Promise<void>;
  79167. };
  79168. };
  79169. }
  79170. /**
  79171. * Loader interface with additional members.
  79172. */
  79173. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79174. primitives: IMeshPrimitive[];
  79175. }
  79176. /**
  79177. * Loader interface with additional members.
  79178. */
  79179. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79180. /** @hidden */
  79181. _instanceData?: {
  79182. babylonSourceMesh: Mesh;
  79183. promise: Promise<any>;
  79184. };
  79185. }
  79186. /**
  79187. * Loader interface with additional members.
  79188. */
  79189. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79190. /**
  79191. * The parent glTF node.
  79192. */
  79193. parent?: INode;
  79194. /** @hidden */
  79195. _babylonTransformNode?: TransformNode;
  79196. /** @hidden */
  79197. _primitiveBabylonMeshes?: AbstractMesh[];
  79198. /** @hidden */
  79199. _babylonBones?: Bone[];
  79200. /** @hidden */
  79201. _numMorphTargets?: number;
  79202. }
  79203. /** @hidden */
  79204. export interface _ISamplerData {
  79205. noMipMaps: boolean;
  79206. samplingMode: number;
  79207. wrapU: number;
  79208. wrapV: number;
  79209. }
  79210. /**
  79211. * Loader interface with additional members.
  79212. */
  79213. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79214. /** @hidden */
  79215. _data?: _ISamplerData;
  79216. }
  79217. /**
  79218. * Loader interface with additional members.
  79219. */
  79220. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79221. }
  79222. /**
  79223. * Loader interface with additional members.
  79224. */
  79225. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79226. /** @hidden */
  79227. _data?: {
  79228. babylonSkeleton: Skeleton;
  79229. promise: Promise<void>;
  79230. };
  79231. }
  79232. /**
  79233. * Loader interface with additional members.
  79234. */
  79235. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79236. }
  79237. /**
  79238. * Loader interface with additional members.
  79239. */
  79240. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79241. }
  79242. /**
  79243. * Loader interface with additional members.
  79244. */
  79245. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79246. accessors?: IAccessor[];
  79247. animations?: IAnimation[];
  79248. buffers?: IBuffer[];
  79249. bufferViews?: IBufferView[];
  79250. cameras?: ICamera[];
  79251. images?: IImage[];
  79252. materials?: IMaterial[];
  79253. meshes?: IMesh[];
  79254. nodes?: INode[];
  79255. samplers?: ISampler[];
  79256. scenes?: IScene[];
  79257. skins?: ISkin[];
  79258. textures?: ITexture[];
  79259. }
  79260. }
  79261. declare module BABYLON.GLTF2 {
  79262. /**
  79263. * Interface for a glTF loader extension.
  79264. */
  79265. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79266. /**
  79267. * Called after the loader state changes to LOADING.
  79268. */
  79269. onLoading?(): void;
  79270. /**
  79271. * Called after the loader state changes to READY.
  79272. */
  79273. onReady?(): void;
  79274. /**
  79275. * Define this method to modify the default behavior when loading scenes.
  79276. * @param context The context when loading the asset
  79277. * @param scene The glTF scene property
  79278. * @returns A promise that resolves when the load is complete or null if not handled
  79279. */
  79280. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79281. /**
  79282. * Define this method to modify the default behavior when loading nodes.
  79283. * @param context The context when loading the asset
  79284. * @param node The glTF node property
  79285. * @param assign A function called synchronously after parsing the glTF properties
  79286. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79287. */
  79288. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79289. /**
  79290. * Define this method to modify the default behavior when loading cameras.
  79291. * @param context The context when loading the asset
  79292. * @param camera The glTF camera property
  79293. * @param assign A function called synchronously after parsing the glTF properties
  79294. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79295. */
  79296. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79297. /**
  79298. * @hidden
  79299. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79300. * @param context The context when loading the asset
  79301. * @param primitive The glTF mesh primitive property
  79302. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79303. */
  79304. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79305. /**
  79306. * @hidden
  79307. * Define this method to modify the default behavior when loading data for mesh primitives.
  79308. * @param context The context when loading the asset
  79309. * @param name The mesh name when loading the asset
  79310. * @param node The glTF node when loading the asset
  79311. * @param mesh The glTF mesh when loading the asset
  79312. * @param primitive The glTF mesh primitive property
  79313. * @param assign A function called synchronously after parsing the glTF properties
  79314. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79315. */
  79316. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79317. /**
  79318. * @hidden
  79319. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79320. * @param context The context when loading the asset
  79321. * @param material The glTF material property
  79322. * @param assign A function called synchronously after parsing the glTF properties
  79323. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79324. */
  79325. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79326. /**
  79327. * Define this method to modify the default behavior when creating materials.
  79328. * @param context The context when loading the asset
  79329. * @param material The glTF material property
  79330. * @param babylonDrawMode The draw mode for the Babylon material
  79331. * @returns The Babylon material or null if not handled
  79332. */
  79333. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79334. /**
  79335. * Define this method to modify the default behavior when loading material properties.
  79336. * @param context The context when loading the asset
  79337. * @param material The glTF material property
  79338. * @param babylonMaterial The Babylon material
  79339. * @returns A promise that resolves when the load is complete or null if not handled
  79340. */
  79341. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79342. /**
  79343. * Define this method to modify the default behavior when loading texture infos.
  79344. * @param context The context when loading the asset
  79345. * @param textureInfo The glTF texture info property
  79346. * @param assign A function called synchronously after parsing the glTF properties
  79347. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79348. */
  79349. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79350. /**
  79351. * @hidden
  79352. * Define this method to modify the default behavior when loading textures.
  79353. * @param context The context when loading the asset
  79354. * @param texture The glTF texture property
  79355. * @param assign A function called synchronously after parsing the glTF properties
  79356. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79357. */
  79358. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79359. /**
  79360. * Define this method to modify the default behavior when loading animations.
  79361. * @param context The context when loading the asset
  79362. * @param animation The glTF animation property
  79363. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79364. */
  79365. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79366. /**
  79367. * @hidden
  79368. * Define this method to modify the default behavior when loading skins.
  79369. * @param context The context when loading the asset
  79370. * @param node The glTF node property
  79371. * @param skin The glTF skin property
  79372. * @returns A promise that resolves when the load is complete or null if not handled
  79373. */
  79374. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79375. /**
  79376. * @hidden
  79377. * Define this method to modify the default behavior when loading uris.
  79378. * @param context The context when loading the asset
  79379. * @param property The glTF property associated with the uri
  79380. * @param uri The uri to load
  79381. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79382. */
  79383. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79384. /**
  79385. * Define this method to modify the default behavior when loading buffer views.
  79386. * @param context The context when loading the asset
  79387. * @param bufferView The glTF buffer view property
  79388. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79389. */
  79390. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79391. /**
  79392. * Define this method to modify the default behavior when loading buffers.
  79393. * @param context The context when loading the asset
  79394. * @param buffer The glTF buffer property
  79395. * @param byteOffset The byte offset to load
  79396. * @param byteLength The byte length to load
  79397. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79398. */
  79399. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79400. }
  79401. }
  79402. declare module BABYLON.GLTF2 {
  79403. /**
  79404. * Helper class for working with arrays when loading the glTF asset
  79405. */
  79406. export class ArrayItem {
  79407. /**
  79408. * Gets an item from the given array.
  79409. * @param context The context when loading the asset
  79410. * @param array The array to get the item from
  79411. * @param index The index to the array
  79412. * @returns The array item
  79413. */
  79414. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79415. /**
  79416. * Assign an `index` field to each item of the given array.
  79417. * @param array The array of items
  79418. */
  79419. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79420. }
  79421. /**
  79422. * The glTF 2.0 loader
  79423. */
  79424. export class GLTFLoader implements IGLTFLoader {
  79425. /** @hidden */
  79426. _completePromises: Promise<any>[];
  79427. /** @hidden */
  79428. _forAssetContainer: boolean;
  79429. /** Storage */
  79430. _babylonLights: Light[];
  79431. /** @hidden */
  79432. _disableInstancedMesh: number;
  79433. private _disposed;
  79434. private _parent;
  79435. private _state;
  79436. private _extensions;
  79437. private _rootUrl;
  79438. private _fileName;
  79439. private _uniqueRootUrl;
  79440. private _gltf;
  79441. private _bin;
  79442. private _babylonScene;
  79443. private _rootBabylonMesh;
  79444. private _defaultBabylonMaterialData;
  79445. private _progressCallback?;
  79446. private _requests;
  79447. private static _RegisteredExtensions;
  79448. /**
  79449. * The default glTF sampler.
  79450. */
  79451. static readonly DefaultSampler: ISampler;
  79452. /**
  79453. * Registers a loader extension.
  79454. * @param name The name of the loader extension.
  79455. * @param factory The factory function that creates the loader extension.
  79456. */
  79457. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79458. /**
  79459. * Unregisters a loader extension.
  79460. * @param name The name of the loader extension.
  79461. * @returns A boolean indicating whether the extension has been unregistered
  79462. */
  79463. static UnregisterExtension(name: string): boolean;
  79464. /**
  79465. * The loader state.
  79466. */
  79467. get state(): Nullable<GLTFLoaderState>;
  79468. /**
  79469. * The object that represents the glTF JSON.
  79470. */
  79471. get gltf(): IGLTF;
  79472. /**
  79473. * The BIN chunk of a binary glTF.
  79474. */
  79475. get bin(): Nullable<IDataBuffer>;
  79476. /**
  79477. * The parent file loader.
  79478. */
  79479. get parent(): GLTFFileLoader;
  79480. /**
  79481. * The Babylon scene when loading the asset.
  79482. */
  79483. get babylonScene(): Scene;
  79484. /**
  79485. * The root Babylon mesh when loading the asset.
  79486. */
  79487. get rootBabylonMesh(): Mesh;
  79488. /** @hidden */
  79489. constructor(parent: GLTFFileLoader);
  79490. /** @hidden */
  79491. dispose(): void;
  79492. /** @hidden */
  79493. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79494. /** @hidden */
  79495. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79496. private _loadAsync;
  79497. private _loadData;
  79498. private _setupData;
  79499. private _loadExtensions;
  79500. private _checkExtensions;
  79501. private _setState;
  79502. private _createRootNode;
  79503. /**
  79504. * Loads a glTF scene.
  79505. * @param context The context when loading the asset
  79506. * @param scene The glTF scene property
  79507. * @returns A promise that resolves when the load is complete
  79508. */
  79509. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79510. private _forEachPrimitive;
  79511. private _getMeshes;
  79512. private _getTransformNodes;
  79513. private _getSkeletons;
  79514. private _getAnimationGroups;
  79515. private _startAnimations;
  79516. /**
  79517. * Loads a glTF node.
  79518. * @param context The context when loading the asset
  79519. * @param node The glTF node property
  79520. * @param assign A function called synchronously after parsing the glTF properties
  79521. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79522. */
  79523. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79524. private _loadMeshAsync;
  79525. /**
  79526. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79527. * @param context The context when loading the asset
  79528. * @param name The mesh name when loading the asset
  79529. * @param node The glTF node when loading the asset
  79530. * @param mesh The glTF mesh when loading the asset
  79531. * @param primitive The glTF mesh primitive property
  79532. * @param assign A function called synchronously after parsing the glTF properties
  79533. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79534. */
  79535. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79536. private _loadVertexDataAsync;
  79537. private _createMorphTargets;
  79538. private _loadMorphTargetsAsync;
  79539. private _loadMorphTargetVertexDataAsync;
  79540. private static _LoadTransform;
  79541. private _loadSkinAsync;
  79542. private _loadBones;
  79543. private _loadBone;
  79544. private _loadSkinInverseBindMatricesDataAsync;
  79545. private _updateBoneMatrices;
  79546. private _getNodeMatrix;
  79547. /**
  79548. * Loads a glTF camera.
  79549. * @param context The context when loading the asset
  79550. * @param camera The glTF camera property
  79551. * @param assign A function called synchronously after parsing the glTF properties
  79552. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79553. */
  79554. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79555. private _loadAnimationsAsync;
  79556. /**
  79557. * Loads a glTF animation.
  79558. * @param context The context when loading the asset
  79559. * @param animation The glTF animation property
  79560. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79561. */
  79562. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79563. /**
  79564. * @hidden Loads a glTF animation channel.
  79565. * @param context The context when loading the asset
  79566. * @param animationContext The context of the animation when loading the asset
  79567. * @param animation The glTF animation property
  79568. * @param channel The glTF animation channel property
  79569. * @param babylonAnimationGroup The babylon animation group property
  79570. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79571. * @returns A void promise when the channel load is complete
  79572. */
  79573. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79574. private _loadAnimationSamplerAsync;
  79575. private _loadBufferAsync;
  79576. /**
  79577. * Loads a glTF buffer view.
  79578. * @param context The context when loading the asset
  79579. * @param bufferView The glTF buffer view property
  79580. * @returns A promise that resolves with the loaded data when the load is complete
  79581. */
  79582. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79583. private _loadAccessorAsync;
  79584. /** @hidden */
  79585. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79586. private _loadIndicesAccessorAsync;
  79587. private _loadVertexBufferViewAsync;
  79588. private _loadVertexAccessorAsync;
  79589. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79590. /** @hidden */
  79591. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79592. private _createDefaultMaterial;
  79593. /**
  79594. * Creates a Babylon material from a glTF material.
  79595. * @param context The context when loading the asset
  79596. * @param material The glTF material property
  79597. * @param babylonDrawMode The draw mode for the Babylon material
  79598. * @returns The Babylon material
  79599. */
  79600. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79601. /**
  79602. * Loads properties from a glTF material into a Babylon material.
  79603. * @param context The context when loading the asset
  79604. * @param material The glTF material property
  79605. * @param babylonMaterial The Babylon material
  79606. * @returns A promise that resolves when the load is complete
  79607. */
  79608. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79609. /**
  79610. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79611. * @param context The context when loading the asset
  79612. * @param material The glTF material property
  79613. * @param babylonMaterial The Babylon material
  79614. * @returns A promise that resolves when the load is complete
  79615. */
  79616. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79617. /**
  79618. * Loads the alpha properties from a glTF material into a Babylon material.
  79619. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79620. * @param context The context when loading the asset
  79621. * @param material The glTF material property
  79622. * @param babylonMaterial The Babylon material
  79623. */
  79624. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79625. /**
  79626. * Loads a glTF texture info.
  79627. * @param context The context when loading the asset
  79628. * @param textureInfo The glTF texture info property
  79629. * @param assign A function called synchronously after parsing the glTF properties
  79630. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79631. */
  79632. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79633. /** @hidden */
  79634. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79635. /** @hidden */
  79636. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79637. private _loadSampler;
  79638. /**
  79639. * Loads a glTF image.
  79640. * @param context The context when loading the asset
  79641. * @param image The glTF image property
  79642. * @returns A promise that resolves with the loaded data when the load is complete
  79643. */
  79644. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79645. /**
  79646. * Loads a glTF uri.
  79647. * @param context The context when loading the asset
  79648. * @param property The glTF property associated with the uri
  79649. * @param uri The base64 or relative uri
  79650. * @returns A promise that resolves with the loaded data when the load is complete
  79651. */
  79652. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79653. private _onProgress;
  79654. /**
  79655. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79656. * @param babylonObject the Babylon object with metadata
  79657. * @param pointer the JSON pointer
  79658. */
  79659. static AddPointerMetadata(babylonObject: {
  79660. metadata: any;
  79661. }, pointer: string): void;
  79662. private static _GetTextureWrapMode;
  79663. private static _GetTextureSamplingMode;
  79664. private static _GetTypedArrayConstructor;
  79665. private static _GetTypedArray;
  79666. private static _GetNumComponents;
  79667. private static _ValidateUri;
  79668. private static _GetDrawMode;
  79669. private _compileMaterialsAsync;
  79670. private _compileShadowGeneratorsAsync;
  79671. private _forEachExtensions;
  79672. private _applyExtensions;
  79673. private _extensionsOnLoading;
  79674. private _extensionsOnReady;
  79675. private _extensionsLoadSceneAsync;
  79676. private _extensionsLoadNodeAsync;
  79677. private _extensionsLoadCameraAsync;
  79678. private _extensionsLoadVertexDataAsync;
  79679. private _extensionsLoadMeshPrimitiveAsync;
  79680. private _extensionsLoadMaterialAsync;
  79681. private _extensionsCreateMaterial;
  79682. private _extensionsLoadMaterialPropertiesAsync;
  79683. private _extensionsLoadTextureInfoAsync;
  79684. private _extensionsLoadTextureAsync;
  79685. private _extensionsLoadAnimationAsync;
  79686. private _extensionsLoadSkinAsync;
  79687. private _extensionsLoadUriAsync;
  79688. private _extensionsLoadBufferViewAsync;
  79689. private _extensionsLoadBufferAsync;
  79690. /**
  79691. * Helper method called by a loader extension to load an glTF extension.
  79692. * @param context The context when loading the asset
  79693. * @param property The glTF property to load the extension from
  79694. * @param extensionName The name of the extension to load
  79695. * @param actionAsync The action to run
  79696. * @returns The promise returned by actionAsync or null if the extension does not exist
  79697. */
  79698. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79699. /**
  79700. * Helper method called by a loader extension to load a glTF extra.
  79701. * @param context The context when loading the asset
  79702. * @param property The glTF property to load the extra from
  79703. * @param extensionName The name of the extension to load
  79704. * @param actionAsync The action to run
  79705. * @returns The promise returned by actionAsync or null if the extra does not exist
  79706. */
  79707. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79708. /**
  79709. * Checks for presence of an extension.
  79710. * @param name The name of the extension to check
  79711. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79712. */
  79713. isExtensionUsed(name: string): boolean;
  79714. /**
  79715. * Increments the indentation level and logs a message.
  79716. * @param message The message to log
  79717. */
  79718. logOpen(message: string): void;
  79719. /**
  79720. * Decrements the indentation level.
  79721. */
  79722. logClose(): void;
  79723. /**
  79724. * Logs a message
  79725. * @param message The message to log
  79726. */
  79727. log(message: string): void;
  79728. /**
  79729. * Starts a performance counter.
  79730. * @param counterName The name of the performance counter
  79731. */
  79732. startPerformanceCounter(counterName: string): void;
  79733. /**
  79734. * Ends a performance counter.
  79735. * @param counterName The name of the performance counter
  79736. */
  79737. endPerformanceCounter(counterName: string): void;
  79738. }
  79739. }
  79740. declare module BABYLON.GLTF2.Loader.Extensions {
  79741. /**
  79742. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79743. */
  79744. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79745. /**
  79746. * The name of this extension.
  79747. */
  79748. readonly name: string;
  79749. /**
  79750. * Defines whether this extension is enabled.
  79751. */
  79752. enabled: boolean;
  79753. private _loader;
  79754. private _lights?;
  79755. /** @hidden */
  79756. constructor(loader: GLTFLoader);
  79757. /** @hidden */
  79758. dispose(): void;
  79759. /** @hidden */
  79760. onLoading(): void;
  79761. /** @hidden */
  79762. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79763. private _loadLightAsync;
  79764. }
  79765. }
  79766. declare module BABYLON.GLTF2.Loader.Extensions {
  79767. /**
  79768. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79769. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79770. * !!! Experimental Extension Subject to Changes !!!
  79771. */
  79772. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79773. /**
  79774. * The name of this extension.
  79775. */
  79776. readonly name: string;
  79777. /**
  79778. * Defines whether this extension is enabled.
  79779. */
  79780. enabled: boolean;
  79781. private _loader;
  79782. /** @hidden */
  79783. constructor(loader: GLTFLoader);
  79784. /** @hidden */
  79785. dispose(): void;
  79786. /** @hidden */
  79787. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79788. }
  79789. }
  79790. declare module BABYLON.GLTF2.Loader.Extensions {
  79791. /**
  79792. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79793. */
  79794. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79795. /**
  79796. * The name of this extension.
  79797. */
  79798. readonly name: string;
  79799. /**
  79800. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79801. */
  79802. dracoCompression?: DracoCompression;
  79803. /**
  79804. * Defines whether this extension is enabled.
  79805. */
  79806. enabled: boolean;
  79807. private _loader;
  79808. /** @hidden */
  79809. constructor(loader: GLTFLoader);
  79810. /** @hidden */
  79811. dispose(): void;
  79812. /** @hidden */
  79813. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79814. }
  79815. }
  79816. declare module BABYLON.GLTF2.Loader.Extensions {
  79817. /**
  79818. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79819. */
  79820. export class KHR_lights implements IGLTFLoaderExtension {
  79821. /**
  79822. * The name of this extension.
  79823. */
  79824. readonly name: string;
  79825. /**
  79826. * Defines whether this extension is enabled.
  79827. */
  79828. enabled: boolean;
  79829. private _loader;
  79830. private _lights?;
  79831. /** @hidden */
  79832. constructor(loader: GLTFLoader);
  79833. /** @hidden */
  79834. dispose(): void;
  79835. /** @hidden */
  79836. onLoading(): void;
  79837. /** @hidden */
  79838. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79839. }
  79840. }
  79841. declare module BABYLON.GLTF2.Loader.Extensions {
  79842. /**
  79843. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79844. */
  79845. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79846. /**
  79847. * The name of this extension.
  79848. */
  79849. readonly name: string;
  79850. /**
  79851. * Defines whether this extension is enabled.
  79852. */
  79853. enabled: boolean;
  79854. /**
  79855. * Defines a number that determines the order the extensions are applied.
  79856. */
  79857. order: number;
  79858. private _loader;
  79859. /** @hidden */
  79860. constructor(loader: GLTFLoader);
  79861. /** @hidden */
  79862. dispose(): void;
  79863. /** @hidden */
  79864. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79865. private _loadSpecularGlossinessPropertiesAsync;
  79866. }
  79867. }
  79868. declare module BABYLON.GLTF2.Loader.Extensions {
  79869. /**
  79870. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79871. */
  79872. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79873. /**
  79874. * The name of this extension.
  79875. */
  79876. readonly name: string;
  79877. /**
  79878. * Defines whether this extension is enabled.
  79879. */
  79880. enabled: boolean;
  79881. /**
  79882. * Defines a number that determines the order the extensions are applied.
  79883. */
  79884. order: number;
  79885. private _loader;
  79886. /** @hidden */
  79887. constructor(loader: GLTFLoader);
  79888. /** @hidden */
  79889. dispose(): void;
  79890. /** @hidden */
  79891. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79892. private _loadUnlitPropertiesAsync;
  79893. }
  79894. }
  79895. declare module BABYLON.GLTF2.Loader.Extensions {
  79896. /**
  79897. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79898. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79899. * !!! Experimental Extension Subject to Changes !!!
  79900. */
  79901. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79902. /**
  79903. * The name of this extension.
  79904. */
  79905. readonly name: string;
  79906. /**
  79907. * Defines whether this extension is enabled.
  79908. */
  79909. enabled: boolean;
  79910. /**
  79911. * Defines a number that determines the order the extensions are applied.
  79912. */
  79913. order: number;
  79914. private _loader;
  79915. /** @hidden */
  79916. constructor(loader: GLTFLoader);
  79917. /** @hidden */
  79918. dispose(): void;
  79919. /** @hidden */
  79920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79921. private _loadClearCoatPropertiesAsync;
  79922. }
  79923. }
  79924. declare module BABYLON.GLTF2.Loader.Extensions {
  79925. /**
  79926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79927. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79928. * !!! Experimental Extension Subject to Changes !!!
  79929. */
  79930. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79931. /**
  79932. * The name of this extension.
  79933. */
  79934. readonly name: string;
  79935. /**
  79936. * Defines whether this extension is enabled.
  79937. */
  79938. enabled: boolean;
  79939. /**
  79940. * Defines a number that determines the order the extensions are applied.
  79941. */
  79942. order: number;
  79943. private _loader;
  79944. /** @hidden */
  79945. constructor(loader: GLTFLoader);
  79946. /** @hidden */
  79947. dispose(): void;
  79948. /** @hidden */
  79949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79950. private _loadSheenPropertiesAsync;
  79951. }
  79952. }
  79953. declare module BABYLON.GLTF2.Loader.Extensions {
  79954. /**
  79955. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79956. * !!! Experimental Extension Subject to Changes !!!
  79957. */
  79958. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79959. /**
  79960. * The name of this extension.
  79961. */
  79962. readonly name: string;
  79963. /**
  79964. * Defines whether this extension is enabled.
  79965. */
  79966. enabled: boolean;
  79967. /**
  79968. * Defines a number that determines the order the extensions are applied.
  79969. */
  79970. order: number;
  79971. private _loader;
  79972. /** @hidden */
  79973. constructor(loader: GLTFLoader);
  79974. /** @hidden */
  79975. dispose(): void;
  79976. /** @hidden */
  79977. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79978. private _loadSpecularPropertiesAsync;
  79979. }
  79980. }
  79981. declare module BABYLON.GLTF2.Loader.Extensions {
  79982. /**
  79983. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79984. * !!! Experimental Extension Subject to Changes !!!
  79985. */
  79986. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79987. /**
  79988. * Default ior Value from the spec.
  79989. */
  79990. private static readonly _DEFAULT_IOR;
  79991. /**
  79992. * The name of this extension.
  79993. */
  79994. readonly name: string;
  79995. /**
  79996. * Defines whether this extension is enabled.
  79997. */
  79998. enabled: boolean;
  79999. /**
  80000. * Defines a number that determines the order the extensions are applied.
  80001. */
  80002. order: number;
  80003. private _loader;
  80004. /** @hidden */
  80005. constructor(loader: GLTFLoader);
  80006. /** @hidden */
  80007. dispose(): void;
  80008. /** @hidden */
  80009. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80010. private _loadIorPropertiesAsync;
  80011. }
  80012. }
  80013. declare module BABYLON.GLTF2.Loader.Extensions {
  80014. /**
  80015. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80016. * !!! Experimental Extension Subject to Changes !!!
  80017. */
  80018. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80019. /**
  80020. * The name of this extension.
  80021. */
  80022. readonly name: string;
  80023. /**
  80024. * Defines whether this extension is enabled.
  80025. */
  80026. enabled: boolean;
  80027. private _loader;
  80028. /**
  80029. * The default variant name.
  80030. */
  80031. defaultVariant: string | undefined;
  80032. private _tagsToMap;
  80033. /** @hidden */
  80034. constructor(loader: GLTFLoader);
  80035. /** @hidden */
  80036. dispose(): void;
  80037. /**
  80038. * Return a list of available variants for this asset.
  80039. * @returns {string[]}
  80040. */
  80041. getVariants(): string[];
  80042. /**
  80043. * Select a variant by providing a list of variant tag names.
  80044. *
  80045. * @param {(string | string[])} variantName
  80046. */
  80047. selectVariant(variantName: string | string[]): void;
  80048. /**
  80049. * Select a variant by providing a single variant tag.
  80050. *
  80051. * @param {string} variantName
  80052. */
  80053. selectVariantTag(variantName: string): void;
  80054. /** @hidden */
  80055. onLoading(): void;
  80056. /** @hidden */
  80057. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80058. }
  80059. }
  80060. declare module BABYLON.GLTF2.Loader.Extensions {
  80061. /**
  80062. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80063. * !!! Experimental Extension Subject to Changes !!!
  80064. */
  80065. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80066. /**
  80067. * The name of this extension.
  80068. */
  80069. readonly name: string;
  80070. /**
  80071. * Defines whether this extension is enabled.
  80072. */
  80073. enabled: boolean;
  80074. /**
  80075. * Defines a number that determines the order the extensions are applied.
  80076. */
  80077. order: number;
  80078. private _loader;
  80079. /** @hidden */
  80080. constructor(loader: GLTFLoader);
  80081. /** @hidden */
  80082. dispose(): void;
  80083. /** @hidden */
  80084. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80085. private _loadTransparentPropertiesAsync;
  80086. }
  80087. }
  80088. declare module BABYLON.GLTF2.Loader.Extensions {
  80089. /**
  80090. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80091. */
  80092. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80093. /**
  80094. * The name of this extension.
  80095. */
  80096. readonly name: string;
  80097. /**
  80098. * Defines whether this extension is enabled.
  80099. */
  80100. enabled: boolean;
  80101. /** @hidden */
  80102. constructor(loader: GLTFLoader);
  80103. /** @hidden */
  80104. dispose(): void;
  80105. }
  80106. }
  80107. declare module BABYLON.GLTF2.Loader.Extensions {
  80108. /**
  80109. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80110. * !!! Experimental Extension Subject to Changes !!!
  80111. */
  80112. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80113. /** The name of this extension. */
  80114. readonly name: string;
  80115. /** Defines whether this extension is enabled. */
  80116. enabled: boolean;
  80117. private _loader;
  80118. /** @hidden */
  80119. constructor(loader: GLTFLoader);
  80120. /** @hidden */
  80121. dispose(): void;
  80122. /** @hidden */
  80123. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80124. }
  80125. }
  80126. declare module BABYLON.GLTF2.Loader.Extensions {
  80127. /**
  80128. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80129. */
  80130. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80131. /**
  80132. * The name of this extension.
  80133. */
  80134. readonly name: string;
  80135. /**
  80136. * Defines whether this extension is enabled.
  80137. */
  80138. enabled: boolean;
  80139. private _loader;
  80140. /** @hidden */
  80141. constructor(loader: GLTFLoader);
  80142. /** @hidden */
  80143. dispose(): void;
  80144. /** @hidden */
  80145. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80146. }
  80147. }
  80148. declare module BABYLON.GLTF2.Loader.Extensions {
  80149. /**
  80150. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80151. * !!! Experimental Extension Subject to Changes !!!
  80152. */
  80153. export class KHR_xmp implements IGLTFLoaderExtension {
  80154. /**
  80155. * The name of this extension.
  80156. */
  80157. readonly name: string;
  80158. /**
  80159. * Defines whether this extension is enabled.
  80160. */
  80161. enabled: boolean;
  80162. /**
  80163. * Defines a number that determines the order the extensions are applied.
  80164. */
  80165. order: number;
  80166. private _loader;
  80167. /** @hidden */
  80168. constructor(loader: GLTFLoader);
  80169. /** @hidden */
  80170. dispose(): void;
  80171. /**
  80172. * Called after the loader state changes to LOADING.
  80173. */
  80174. onLoading(): void;
  80175. }
  80176. }
  80177. declare module BABYLON.GLTF2.Loader.Extensions {
  80178. /**
  80179. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80180. */
  80181. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80182. /**
  80183. * The name of this extension.
  80184. */
  80185. readonly name: string;
  80186. /**
  80187. * Defines whether this extension is enabled.
  80188. */
  80189. enabled: boolean;
  80190. private _loader;
  80191. private _clips;
  80192. private _emitters;
  80193. /** @hidden */
  80194. constructor(loader: GLTFLoader);
  80195. /** @hidden */
  80196. dispose(): void;
  80197. /** @hidden */
  80198. onLoading(): void;
  80199. /** @hidden */
  80200. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80201. /** @hidden */
  80202. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80203. /** @hidden */
  80204. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80205. private _loadClipAsync;
  80206. private _loadEmitterAsync;
  80207. private _getEventAction;
  80208. private _loadAnimationEventAsync;
  80209. }
  80210. }
  80211. declare module BABYLON.GLTF2.Loader.Extensions {
  80212. /**
  80213. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80214. */
  80215. export class MSFT_lod implements IGLTFLoaderExtension {
  80216. /**
  80217. * The name of this extension.
  80218. */
  80219. readonly name: string;
  80220. /**
  80221. * Defines whether this extension is enabled.
  80222. */
  80223. enabled: boolean;
  80224. /**
  80225. * Defines a number that determines the order the extensions are applied.
  80226. */
  80227. order: number;
  80228. /**
  80229. * Maximum number of LODs to load, starting from the lowest LOD.
  80230. */
  80231. maxLODsToLoad: number;
  80232. /**
  80233. * Observable raised when all node LODs of one level are loaded.
  80234. * The event data is the index of the loaded LOD starting from zero.
  80235. * Dispose the loader to cancel the loading of the next level of LODs.
  80236. */
  80237. onNodeLODsLoadedObservable: Observable<number>;
  80238. /**
  80239. * Observable raised when all material LODs of one level are loaded.
  80240. * The event data is the index of the loaded LOD starting from zero.
  80241. * Dispose the loader to cancel the loading of the next level of LODs.
  80242. */
  80243. onMaterialLODsLoadedObservable: Observable<number>;
  80244. private _loader;
  80245. private _nodeIndexLOD;
  80246. private _nodeSignalLODs;
  80247. private _nodePromiseLODs;
  80248. private _materialIndexLOD;
  80249. private _materialSignalLODs;
  80250. private _materialPromiseLODs;
  80251. private _indexLOD;
  80252. private _bufferLODs;
  80253. /** @hidden */
  80254. constructor(loader: GLTFLoader);
  80255. /** @hidden */
  80256. dispose(): void;
  80257. /** @hidden */
  80258. onReady(): void;
  80259. /** @hidden */
  80260. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80261. /** @hidden */
  80262. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80263. /** @hidden */
  80264. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80265. /** @hidden */
  80266. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80267. /** @hidden */
  80268. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80269. private _loadBufferLOD;
  80270. /**
  80271. * Gets an array of LOD properties from lowest to highest.
  80272. */
  80273. private _getLODs;
  80274. private _disposeTransformNode;
  80275. private _disposeMaterials;
  80276. }
  80277. }
  80278. declare module BABYLON.GLTF2.Loader.Extensions {
  80279. /** @hidden */
  80280. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80281. readonly name: string;
  80282. enabled: boolean;
  80283. private _loader;
  80284. constructor(loader: GLTFLoader);
  80285. dispose(): void;
  80286. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80287. }
  80288. }
  80289. declare module BABYLON.GLTF2.Loader.Extensions {
  80290. /** @hidden */
  80291. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80292. readonly name: string;
  80293. enabled: boolean;
  80294. private _loader;
  80295. constructor(loader: GLTFLoader);
  80296. dispose(): void;
  80297. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80298. }
  80299. }
  80300. declare module BABYLON.GLTF2.Loader.Extensions {
  80301. /**
  80302. * Store glTF extras (if present) in BJS objects' metadata
  80303. */
  80304. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80305. /**
  80306. * The name of this extension.
  80307. */
  80308. readonly name: string;
  80309. /**
  80310. * Defines whether this extension is enabled.
  80311. */
  80312. enabled: boolean;
  80313. private _loader;
  80314. private _assignExtras;
  80315. /** @hidden */
  80316. constructor(loader: GLTFLoader);
  80317. /** @hidden */
  80318. dispose(): void;
  80319. /** @hidden */
  80320. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80321. /** @hidden */
  80322. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80323. /** @hidden */
  80324. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80325. }
  80326. }
  80327. declare module BABYLON {
  80328. /**
  80329. * Class reading and parsing the MTL file bundled with the obj file.
  80330. */
  80331. export class MTLFileLoader {
  80332. /**
  80333. * Invert Y-Axis of referenced textures on load
  80334. */
  80335. static INVERT_TEXTURE_Y: boolean;
  80336. /**
  80337. * All material loaded from the mtl will be set here
  80338. */
  80339. materials: StandardMaterial[];
  80340. /**
  80341. * This function will read the mtl file and create each material described inside
  80342. * This function could be improve by adding :
  80343. * -some component missing (Ni, Tf...)
  80344. * -including the specific options available
  80345. *
  80346. * @param scene defines the scene the material will be created in
  80347. * @param data defines the mtl data to parse
  80348. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80349. * @param forAssetContainer defines if the material should be registered in the scene
  80350. */
  80351. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80352. /**
  80353. * Gets the texture for the material.
  80354. *
  80355. * If the material is imported from input file,
  80356. * We sanitize the url to ensure it takes the textre from aside the material.
  80357. *
  80358. * @param rootUrl The root url to load from
  80359. * @param value The value stored in the mtl
  80360. * @return The Texture
  80361. */
  80362. private static _getTexture;
  80363. }
  80364. }
  80365. declare module BABYLON {
  80366. /**
  80367. * Options for loading OBJ/MTL files
  80368. */
  80369. type MeshLoadOptions = {
  80370. /**
  80371. * Defines if UVs are optimized by default during load.
  80372. */
  80373. OptimizeWithUV: boolean;
  80374. /**
  80375. * Defines custom scaling of UV coordinates of loaded meshes.
  80376. */
  80377. UVScaling: Vector2;
  80378. /**
  80379. * Invert model on y-axis (does a model scaling inversion)
  80380. */
  80381. InvertY: boolean;
  80382. /**
  80383. * Invert Y-Axis of referenced textures on load
  80384. */
  80385. InvertTextureY: boolean;
  80386. /**
  80387. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80388. */
  80389. ImportVertexColors: boolean;
  80390. /**
  80391. * Compute the normals for the model, even if normals are present in the file.
  80392. */
  80393. ComputeNormals: boolean;
  80394. /**
  80395. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80396. */
  80397. SkipMaterials: boolean;
  80398. /**
  80399. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80400. */
  80401. MaterialLoadingFailsSilently: boolean;
  80402. };
  80403. /**
  80404. * OBJ file type loader.
  80405. * This is a babylon scene loader plugin.
  80406. */
  80407. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80408. /**
  80409. * Defines if UVs are optimized by default during load.
  80410. */
  80411. static OPTIMIZE_WITH_UV: boolean;
  80412. /**
  80413. * Invert model on y-axis (does a model scaling inversion)
  80414. */
  80415. static INVERT_Y: boolean;
  80416. /**
  80417. * Invert Y-Axis of referenced textures on load
  80418. */
  80419. static get INVERT_TEXTURE_Y(): boolean;
  80420. static set INVERT_TEXTURE_Y(value: boolean);
  80421. /**
  80422. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80423. */
  80424. static IMPORT_VERTEX_COLORS: boolean;
  80425. /**
  80426. * Compute the normals for the model, even if normals are present in the file.
  80427. */
  80428. static COMPUTE_NORMALS: boolean;
  80429. /**
  80430. * Defines custom scaling of UV coordinates of loaded meshes.
  80431. */
  80432. static UV_SCALING: Vector2;
  80433. /**
  80434. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80435. */
  80436. static SKIP_MATERIALS: boolean;
  80437. /**
  80438. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80439. *
  80440. * Defaults to true for backwards compatibility.
  80441. */
  80442. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80443. /**
  80444. * Defines the name of the plugin.
  80445. */
  80446. name: string;
  80447. /**
  80448. * Defines the extension the plugin is able to load.
  80449. */
  80450. extensions: string;
  80451. /** @hidden */
  80452. obj: RegExp;
  80453. /** @hidden */
  80454. group: RegExp;
  80455. /** @hidden */
  80456. mtllib: RegExp;
  80457. /** @hidden */
  80458. usemtl: RegExp;
  80459. /** @hidden */
  80460. smooth: RegExp;
  80461. /** @hidden */
  80462. vertexPattern: RegExp;
  80463. /** @hidden */
  80464. normalPattern: RegExp;
  80465. /** @hidden */
  80466. uvPattern: RegExp;
  80467. /** @hidden */
  80468. facePattern1: RegExp;
  80469. /** @hidden */
  80470. facePattern2: RegExp;
  80471. /** @hidden */
  80472. facePattern3: RegExp;
  80473. /** @hidden */
  80474. facePattern4: RegExp;
  80475. /** @hidden */
  80476. facePattern5: RegExp;
  80477. private _forAssetContainer;
  80478. private _meshLoadOptions;
  80479. /**
  80480. * Creates loader for .OBJ files
  80481. *
  80482. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80483. */
  80484. constructor(meshLoadOptions?: MeshLoadOptions);
  80485. private static get currentMeshLoadOptions();
  80486. /**
  80487. * Calls synchronously the MTL file attached to this obj.
  80488. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80489. * Without this function materials are not displayed in the first frame (but displayed after).
  80490. * In consequence it is impossible to get material information in your HTML file
  80491. *
  80492. * @param url The URL of the MTL file
  80493. * @param rootUrl
  80494. * @param onSuccess Callback function to be called when the MTL file is loaded
  80495. * @private
  80496. */
  80497. private _loadMTL;
  80498. /**
  80499. * Instantiates a OBJ file loader plugin.
  80500. * @returns the created plugin
  80501. */
  80502. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80503. /**
  80504. * If the data string can be loaded directly.
  80505. *
  80506. * @param data string containing the file data
  80507. * @returns if the data can be loaded directly
  80508. */
  80509. canDirectLoad(data: string): boolean;
  80510. /**
  80511. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80512. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80513. * @param scene the scene the meshes should be added to
  80514. * @param data the OBJ data to load
  80515. * @param rootUrl root url to load from
  80516. * @param onProgress event that fires when loading progress has occured
  80517. * @param fileName Defines the name of the file to load
  80518. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80519. */
  80520. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80521. meshes: AbstractMesh[];
  80522. particleSystems: IParticleSystem[];
  80523. skeletons: Skeleton[];
  80524. animationGroups: AnimationGroup[];
  80525. }>;
  80526. /**
  80527. * Imports all objects from the loaded OBJ data and adds them to the scene
  80528. * @param scene the scene the objects should be added to
  80529. * @param data the OBJ data to load
  80530. * @param rootUrl root url to load from
  80531. * @param onProgress event that fires when loading progress has occured
  80532. * @param fileName Defines the name of the file to load
  80533. * @returns a promise which completes when objects have been loaded to the scene
  80534. */
  80535. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80536. /**
  80537. * Load into an asset container.
  80538. * @param scene The scene to load into
  80539. * @param data The data to import
  80540. * @param rootUrl The root url for scene and resources
  80541. * @param onProgress The callback when the load progresses
  80542. * @param fileName Defines the name of the file to load
  80543. * @returns The loaded asset container
  80544. */
  80545. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80546. /**
  80547. * Read the OBJ file and create an Array of meshes.
  80548. * Each mesh contains all information given by the OBJ and the MTL file.
  80549. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80550. *
  80551. * @param meshesNames
  80552. * @param scene Scene The scene where are displayed the data
  80553. * @param data String The content of the obj file
  80554. * @param rootUrl String The path to the folder
  80555. * @returns Array<AbstractMesh>
  80556. * @private
  80557. */
  80558. private _parseSolid;
  80559. }
  80560. }
  80561. declare module BABYLON {
  80562. /**
  80563. * STL file type loader.
  80564. * This is a babylon scene loader plugin.
  80565. */
  80566. export class STLFileLoader implements ISceneLoaderPlugin {
  80567. /** @hidden */
  80568. solidPattern: RegExp;
  80569. /** @hidden */
  80570. facetsPattern: RegExp;
  80571. /** @hidden */
  80572. normalPattern: RegExp;
  80573. /** @hidden */
  80574. vertexPattern: RegExp;
  80575. /**
  80576. * Defines the name of the plugin.
  80577. */
  80578. name: string;
  80579. /**
  80580. * Defines the extensions the stl loader is able to load.
  80581. * force data to come in as an ArrayBuffer
  80582. * we'll convert to string if it looks like it's an ASCII .stl
  80583. */
  80584. extensions: ISceneLoaderPluginExtensions;
  80585. /**
  80586. * Import meshes into a scene.
  80587. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80588. * @param scene The scene to import into
  80589. * @param data The data to import
  80590. * @param rootUrl The root url for scene and resources
  80591. * @param meshes The meshes array to import into
  80592. * @param particleSystems The particle systems array to import into
  80593. * @param skeletons The skeletons array to import into
  80594. * @param onError The callback when import fails
  80595. * @returns True if successful or false otherwise
  80596. */
  80597. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80598. /**
  80599. * Load into a scene.
  80600. * @param scene The scene to load into
  80601. * @param data The data to import
  80602. * @param rootUrl The root url for scene and resources
  80603. * @param onError The callback when import fails
  80604. * @returns true if successful or false otherwise
  80605. */
  80606. load(scene: Scene, data: any, rootUrl: string): boolean;
  80607. /**
  80608. * Load into an asset container.
  80609. * @param scene The scene to load into
  80610. * @param data The data to import
  80611. * @param rootUrl The root url for scene and resources
  80612. * @param onError The callback when import fails
  80613. * @returns The loaded asset container
  80614. */
  80615. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80616. private _isBinary;
  80617. private _parseBinary;
  80618. private _parseASCII;
  80619. }
  80620. }
  80621. declare module BABYLON {
  80622. /**
  80623. * Class for generating OBJ data from a Babylon scene.
  80624. */
  80625. export class OBJExport {
  80626. /**
  80627. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80628. * @param mesh defines the list of meshes to serialize
  80629. * @param materials defines if materials should be exported
  80630. * @param matlibname defines the name of the associated mtl file
  80631. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80632. * @returns the OBJ content
  80633. */
  80634. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80635. /**
  80636. * Exports the material(s) of a mesh in .MTL file format (text)
  80637. * @param mesh defines the mesh to extract the material from
  80638. * @returns the mtl content
  80639. */
  80640. static MTL(mesh: Mesh): string;
  80641. }
  80642. }
  80643. declare module BABYLON {
  80644. /** @hidden */
  80645. export var __IGLTFExporterExtension: number;
  80646. /**
  80647. * Interface for extending the exporter
  80648. * @hidden
  80649. */
  80650. export interface IGLTFExporterExtension {
  80651. /**
  80652. * The name of this extension
  80653. */
  80654. readonly name: string;
  80655. /**
  80656. * Defines whether this extension is enabled
  80657. */
  80658. enabled: boolean;
  80659. /**
  80660. * Defines whether this extension is required
  80661. */
  80662. required: boolean;
  80663. }
  80664. }
  80665. declare module BABYLON.GLTF2.Exporter {
  80666. /** @hidden */
  80667. export var __IGLTFExporterExtensionV2: number;
  80668. /**
  80669. * Interface for a glTF exporter extension
  80670. * @hidden
  80671. */
  80672. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80673. /**
  80674. * Define this method to modify the default behavior before exporting a texture
  80675. * @param context The context when loading the asset
  80676. * @param babylonTexture The Babylon.js texture
  80677. * @param mimeType The mime-type of the generated image
  80678. * @returns A promise that resolves with the exported texture
  80679. */
  80680. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80681. /**
  80682. * Define this method to get notified when a texture info is created
  80683. * @param context The context when loading the asset
  80684. * @param textureInfo The glTF texture info
  80685. * @param babylonTexture The Babylon.js texture
  80686. */
  80687. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80688. /**
  80689. * Define this method to modify the default behavior when exporting texture info
  80690. * @param context The context when loading the asset
  80691. * @param meshPrimitive glTF mesh primitive
  80692. * @param babylonSubMesh Babylon submesh
  80693. * @param binaryWriter glTF serializer binary writer instance
  80694. * @returns nullable IMeshPrimitive promise
  80695. */
  80696. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80697. /**
  80698. * Define this method to modify the default behavior when exporting a node
  80699. * @param context The context when exporting the node
  80700. * @param node glTF node
  80701. * @param babylonNode BabylonJS node
  80702. * @returns nullable INode promise
  80703. */
  80704. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80705. [key: number]: number;
  80706. }): Promise<Nullable<INode>>;
  80707. /**
  80708. * Define this method to modify the default behavior when exporting a material
  80709. * @param material glTF material
  80710. * @param babylonMaterial BabylonJS material
  80711. * @returns nullable IMaterial promise
  80712. */
  80713. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80714. /**
  80715. * Define this method to return additional textures to export from a material
  80716. * @param material glTF material
  80717. * @param babylonMaterial BabylonJS material
  80718. * @returns List of textures
  80719. */
  80720. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80721. /** Gets a boolean indicating that this extension was used */
  80722. wasUsed: boolean;
  80723. /** Gets a boolean indicating that this extension is required for the file to work */
  80724. required: boolean;
  80725. /**
  80726. * Called after the exporter state changes to EXPORTING
  80727. */
  80728. onExporting?(): void;
  80729. }
  80730. }
  80731. declare module BABYLON.GLTF2.Exporter {
  80732. /**
  80733. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80734. * @hidden
  80735. */
  80736. export class _GLTFMaterialExporter {
  80737. /**
  80738. * Represents the dielectric specular values for R, G and B
  80739. */
  80740. private static readonly _DielectricSpecular;
  80741. /**
  80742. * Allows the maximum specular power to be defined for material calculations
  80743. */
  80744. private static readonly _MaxSpecularPower;
  80745. /**
  80746. * Mapping to store textures
  80747. */
  80748. private _textureMap;
  80749. /**
  80750. * Numeric tolerance value
  80751. */
  80752. private static readonly _Epsilon;
  80753. /**
  80754. * Reference to the glTF Exporter
  80755. */
  80756. private _exporter;
  80757. constructor(exporter: _Exporter);
  80758. /**
  80759. * Specifies if two colors are approximately equal in value
  80760. * @param color1 first color to compare to
  80761. * @param color2 second color to compare to
  80762. * @param epsilon threshold value
  80763. */
  80764. private static FuzzyEquals;
  80765. /**
  80766. * Gets the materials from a Babylon scene and converts them to glTF materials
  80767. * @param scene babylonjs scene
  80768. * @param mimeType texture mime type
  80769. * @param images array of images
  80770. * @param textures array of textures
  80771. * @param materials array of materials
  80772. * @param imageData mapping of texture names to base64 textures
  80773. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80774. */
  80775. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80776. /**
  80777. * Makes a copy of the glTF material without the texture parameters
  80778. * @param originalMaterial original glTF material
  80779. * @returns glTF material without texture parameters
  80780. */
  80781. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80782. /**
  80783. * Specifies if the material has any texture parameters present
  80784. * @param material glTF Material
  80785. * @returns boolean specifying if texture parameters are present
  80786. */
  80787. _hasTexturesPresent(material: IMaterial): boolean;
  80788. /**
  80789. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80790. * @param babylonStandardMaterial
  80791. * @returns glTF Metallic Roughness Material representation
  80792. */
  80793. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80794. /**
  80795. * Computes the metallic factor
  80796. * @param diffuse diffused value
  80797. * @param specular specular value
  80798. * @param oneMinusSpecularStrength one minus the specular strength
  80799. * @returns metallic value
  80800. */
  80801. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80802. /**
  80803. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80804. * @param glTFMaterial glTF material
  80805. * @param babylonMaterial Babylon material
  80806. */
  80807. private static _SetAlphaMode;
  80808. /**
  80809. * Converts a Babylon Standard Material to a glTF Material
  80810. * @param babylonStandardMaterial BJS Standard Material
  80811. * @param mimeType mime type to use for the textures
  80812. * @param images array of glTF image interfaces
  80813. * @param textures array of glTF texture interfaces
  80814. * @param materials array of glTF material interfaces
  80815. * @param imageData map of image file name to data
  80816. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80817. */
  80818. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80819. private _finishMaterial;
  80820. /**
  80821. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80822. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80823. * @param mimeType mime type to use for the textures
  80824. * @param images array of glTF image interfaces
  80825. * @param textures array of glTF texture interfaces
  80826. * @param materials array of glTF material interfaces
  80827. * @param imageData map of image file name to data
  80828. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80829. */
  80830. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80831. /**
  80832. * Converts an image typed array buffer to a base64 image
  80833. * @param buffer typed array buffer
  80834. * @param width width of the image
  80835. * @param height height of the image
  80836. * @param mimeType mimetype of the image
  80837. * @returns base64 image string
  80838. */
  80839. private _createBase64FromCanvasAsync;
  80840. /**
  80841. * Generates a white texture based on the specified width and height
  80842. * @param width width of the texture in pixels
  80843. * @param height height of the texture in pixels
  80844. * @param scene babylonjs scene
  80845. * @returns white texture
  80846. */
  80847. private _createWhiteTexture;
  80848. /**
  80849. * 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
  80850. * @param texture1 first texture to resize
  80851. * @param texture2 second texture to resize
  80852. * @param scene babylonjs scene
  80853. * @returns resized textures or null
  80854. */
  80855. private _resizeTexturesToSameDimensions;
  80856. /**
  80857. * Converts an array of pixels to a Float32Array
  80858. * Throws an error if the pixel format is not supported
  80859. * @param pixels - array buffer containing pixel values
  80860. * @returns Float32 of pixels
  80861. */
  80862. private _convertPixelArrayToFloat32;
  80863. /**
  80864. * Convert Specular Glossiness Textures to Metallic Roughness
  80865. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80866. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80867. * @param diffuseTexture texture used to store diffuse information
  80868. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80869. * @param factors specular glossiness material factors
  80870. * @param mimeType the mime type to use for the texture
  80871. * @returns pbr metallic roughness interface or null
  80872. */
  80873. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80874. /**
  80875. * Converts specular glossiness material properties to metallic roughness
  80876. * @param specularGlossiness interface with specular glossiness material properties
  80877. * @returns interface with metallic roughness material properties
  80878. */
  80879. private _convertSpecularGlossinessToMetallicRoughness;
  80880. /**
  80881. * Calculates the surface reflectance, independent of lighting conditions
  80882. * @param color Color source to calculate brightness from
  80883. * @returns number representing the perceived brightness, or zero if color is undefined
  80884. */
  80885. private _getPerceivedBrightness;
  80886. /**
  80887. * Returns the maximum color component value
  80888. * @param color
  80889. * @returns maximum color component value, or zero if color is null or undefined
  80890. */
  80891. private _getMaxComponent;
  80892. /**
  80893. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80894. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80895. * @param mimeType mime type to use for the textures
  80896. * @param images array of glTF image interfaces
  80897. * @param textures array of glTF texture interfaces
  80898. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80899. * @param imageData map of image file name to data
  80900. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80901. * @returns glTF PBR Metallic Roughness factors
  80902. */
  80903. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80904. private _getGLTFTextureSampler;
  80905. private _getGLTFTextureWrapMode;
  80906. private _getGLTFTextureWrapModesSampler;
  80907. /**
  80908. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80909. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80910. * @param mimeType mime type to use for the textures
  80911. * @param images array of glTF image interfaces
  80912. * @param textures array of glTF texture interfaces
  80913. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80914. * @param imageData map of image file name to data
  80915. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80916. * @returns glTF PBR Metallic Roughness factors
  80917. */
  80918. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80919. /**
  80920. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80921. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80922. * @param mimeType mime type to use for the textures
  80923. * @param images array of glTF image interfaces
  80924. * @param textures array of glTF texture interfaces
  80925. * @param materials array of glTF material interfaces
  80926. * @param imageData map of image file name to data
  80927. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80928. */
  80929. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80930. private setMetallicRoughnessPbrMaterial;
  80931. private getPixelsFromTexture;
  80932. /**
  80933. * Extracts a texture from a Babylon texture into file data and glTF data
  80934. * @param babylonTexture Babylon texture to extract
  80935. * @param mimeType Mime Type of the babylonTexture
  80936. * @return glTF texture info, or null if the texture format is not supported
  80937. */
  80938. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80939. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80940. /**
  80941. * Builds a texture from base64 string
  80942. * @param base64Texture base64 texture string
  80943. * @param baseTextureName Name to use for the texture
  80944. * @param mimeType image mime type for the texture
  80945. * @param images array of images
  80946. * @param textures array of textures
  80947. * @param imageData map of image data
  80948. * @returns glTF texture info, or null if the texture format is not supported
  80949. */
  80950. private _getTextureInfoFromBase64;
  80951. }
  80952. }
  80953. declare module BABYLON {
  80954. /**
  80955. * Class for holding and downloading glTF file data
  80956. */
  80957. export class GLTFData {
  80958. /**
  80959. * Object which contains the file name as the key and its data as the value
  80960. */
  80961. glTFFiles: {
  80962. [fileName: string]: string | Blob;
  80963. };
  80964. /**
  80965. * Initializes the glTF file object
  80966. */
  80967. constructor();
  80968. /**
  80969. * Downloads the glTF data as files based on their names and data
  80970. */
  80971. downloadFiles(): void;
  80972. }
  80973. }
  80974. declare module BABYLON {
  80975. /**
  80976. * Holds a collection of exporter options and parameters
  80977. */
  80978. export interface IExportOptions {
  80979. /**
  80980. * Function which indicates whether a babylon node should be exported or not
  80981. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80982. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80983. */
  80984. shouldExportNode?(node: Node): boolean;
  80985. /**
  80986. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80987. * @param metadata source metadata to read from
  80988. * @returns the data to store to glTF node extras
  80989. */
  80990. metadataSelector?(metadata: any): any;
  80991. /**
  80992. * The sample rate to bake animation curves
  80993. */
  80994. animationSampleRate?: number;
  80995. /**
  80996. * Begin serialization without waiting for the scene to be ready
  80997. */
  80998. exportWithoutWaitingForScene?: boolean;
  80999. /**
  81000. * Indicates if coordinate system swapping root nodes should be included in export
  81001. */
  81002. includeCoordinateSystemConversionNodes?: boolean;
  81003. }
  81004. /**
  81005. * Class for generating glTF data from a Babylon scene.
  81006. */
  81007. export class GLTF2Export {
  81008. /**
  81009. * Exports the geometry of the scene to .gltf file format asynchronously
  81010. * @param scene Babylon scene with scene hierarchy information
  81011. * @param filePrefix File prefix to use when generating the glTF file
  81012. * @param options Exporter options
  81013. * @returns Returns an object with a .gltf file and associates texture names
  81014. * as keys and their data and paths as values
  81015. */
  81016. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81017. private static _PreExportAsync;
  81018. private static _PostExportAsync;
  81019. /**
  81020. * Exports the geometry of the scene to .glb file format asychronously
  81021. * @param scene Babylon scene with scene hierarchy information
  81022. * @param filePrefix File prefix to use when generating glb file
  81023. * @param options Exporter options
  81024. * @returns Returns an object with a .glb filename as key and data as value
  81025. */
  81026. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81027. }
  81028. }
  81029. declare module BABYLON.GLTF2.Exporter {
  81030. /**
  81031. * @hidden
  81032. */
  81033. export class _GLTFUtilities {
  81034. /**
  81035. * Creates a buffer view based on the supplied arguments
  81036. * @param bufferIndex index value of the specified buffer
  81037. * @param byteOffset byte offset value
  81038. * @param byteLength byte length of the bufferView
  81039. * @param byteStride byte distance between conequential elements
  81040. * @param name name of the buffer view
  81041. * @returns bufferView for glTF
  81042. */
  81043. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81044. /**
  81045. * Creates an accessor based on the supplied arguments
  81046. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81047. * @param name The name of the accessor
  81048. * @param type The type of the accessor
  81049. * @param componentType The datatype of components in the attribute
  81050. * @param count The number of attributes referenced by this accessor
  81051. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81052. * @param min Minimum value of each component in this attribute
  81053. * @param max Maximum value of each component in this attribute
  81054. * @returns accessor for glTF
  81055. */
  81056. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81057. /**
  81058. * Calculates the minimum and maximum values of an array of position floats
  81059. * @param positions Positions array of a mesh
  81060. * @param vertexStart Starting vertex offset to calculate min and max values
  81061. * @param vertexCount Number of vertices to check for min and max values
  81062. * @returns min number array and max number array
  81063. */
  81064. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81065. min: number[];
  81066. max: number[];
  81067. };
  81068. /**
  81069. * Converts a new right-handed Vector3
  81070. * @param vector vector3 array
  81071. * @returns right-handed Vector3
  81072. */
  81073. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81074. /**
  81075. * Converts a Vector3 to right-handed
  81076. * @param vector Vector3 to convert to right-handed
  81077. */
  81078. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81079. /**
  81080. * Converts a three element number array to right-handed
  81081. * @param vector number array to convert to right-handed
  81082. */
  81083. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81084. /**
  81085. * Converts a new right-handed Vector3
  81086. * @param vector vector3 array
  81087. * @returns right-handed Vector3
  81088. */
  81089. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81090. /**
  81091. * Converts a Vector3 to right-handed
  81092. * @param vector Vector3 to convert to right-handed
  81093. */
  81094. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81095. /**
  81096. * Converts a three element number array to right-handed
  81097. * @param vector number array to convert to right-handed
  81098. */
  81099. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81100. /**
  81101. * Converts a Vector4 to right-handed
  81102. * @param vector Vector4 to convert to right-handed
  81103. */
  81104. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81105. /**
  81106. * Converts a Vector4 to right-handed
  81107. * @param vector Vector4 to convert to right-handed
  81108. */
  81109. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81110. /**
  81111. * Converts a Quaternion to right-handed
  81112. * @param quaternion Source quaternion to convert to right-handed
  81113. */
  81114. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81115. /**
  81116. * Converts a Quaternion to right-handed
  81117. * @param quaternion Source quaternion to convert to right-handed
  81118. */
  81119. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81120. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81121. }
  81122. }
  81123. declare module BABYLON.GLTF2.Exporter {
  81124. /**
  81125. * Converts Babylon Scene into glTF 2.0.
  81126. * @hidden
  81127. */
  81128. export class _Exporter {
  81129. /**
  81130. * Stores the glTF to export
  81131. */
  81132. _glTF: IGLTF;
  81133. /**
  81134. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81135. */
  81136. _bufferViews: IBufferView[];
  81137. /**
  81138. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81139. */
  81140. _accessors: IAccessor[];
  81141. /**
  81142. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81143. */
  81144. _nodes: INode[];
  81145. /**
  81146. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81147. */
  81148. private _scenes;
  81149. /**
  81150. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81151. */
  81152. private _meshes;
  81153. /**
  81154. * Stores all the generated material information, which represents the appearance of each primitive
  81155. */
  81156. _materials: IMaterial[];
  81157. _materialMap: {
  81158. [materialID: number]: number;
  81159. };
  81160. /**
  81161. * Stores all the generated texture information, which is referenced by glTF materials
  81162. */
  81163. _textures: ITexture[];
  81164. /**
  81165. * Stores all the generated image information, which is referenced by glTF textures
  81166. */
  81167. _images: IImage[];
  81168. /**
  81169. * Stores all the texture samplers
  81170. */
  81171. _samplers: ISampler[];
  81172. /**
  81173. * Stores all the generated animation samplers, which is referenced by glTF animations
  81174. */
  81175. /**
  81176. * Stores the animations for glTF models
  81177. */
  81178. private _animations;
  81179. /**
  81180. * Stores the total amount of bytes stored in the glTF buffer
  81181. */
  81182. private _totalByteLength;
  81183. /**
  81184. * Stores a reference to the Babylon scene containing the source geometry and material information
  81185. */
  81186. _babylonScene: Scene;
  81187. /**
  81188. * Stores a map of the image data, where the key is the file name and the value
  81189. * is the image data
  81190. */
  81191. _imageData: {
  81192. [fileName: string]: {
  81193. data: Uint8Array;
  81194. mimeType: ImageMimeType;
  81195. };
  81196. };
  81197. /**
  81198. * Stores a map of the unique id of a node to its index in the node array
  81199. */
  81200. _nodeMap: {
  81201. [key: number]: number;
  81202. };
  81203. /**
  81204. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81205. */
  81206. _convertToRightHandedSystem: boolean;
  81207. /**
  81208. * Specifies if a Babylon node should be converted to right-handed on export
  81209. */
  81210. _convertToRightHandedSystemMap: {
  81211. [nodeId: number]: boolean;
  81212. };
  81213. _includeCoordinateSystemConversionNodes: boolean;
  81214. /**
  81215. * Baked animation sample rate
  81216. */
  81217. private _animationSampleRate;
  81218. private _options;
  81219. private _localEngine;
  81220. _glTFMaterialExporter: _GLTFMaterialExporter;
  81221. private _extensions;
  81222. private static _ExtensionNames;
  81223. private static _ExtensionFactories;
  81224. private _applyExtension;
  81225. private _applyExtensions;
  81226. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81227. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81228. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81229. [key: number]: number;
  81230. }): Promise<Nullable<INode>>;
  81231. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81232. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81233. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81234. private _forEachExtensions;
  81235. private _extensionsOnExporting;
  81236. /**
  81237. * Load glTF serializer extensions
  81238. */
  81239. private _loadExtensions;
  81240. /**
  81241. * Creates a glTF Exporter instance, which can accept optional exporter options
  81242. * @param babylonScene Babylon scene object
  81243. * @param options Options to modify the behavior of the exporter
  81244. */
  81245. constructor(babylonScene: Scene, options?: IExportOptions);
  81246. dispose(): void;
  81247. /**
  81248. * Registers a glTF exporter extension
  81249. * @param name Name of the extension to export
  81250. * @param factory The factory function that creates the exporter extension
  81251. */
  81252. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81253. /**
  81254. * Un-registers an exporter extension
  81255. * @param name The name fo the exporter extension
  81256. * @returns A boolean indicating whether the extension has been un-registered
  81257. */
  81258. static UnregisterExtension(name: string): boolean;
  81259. /**
  81260. * Lazy load a local engine
  81261. */
  81262. _getLocalEngine(): Engine;
  81263. private reorderIndicesBasedOnPrimitiveMode;
  81264. /**
  81265. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81266. * clock-wise during export to glTF
  81267. * @param submesh BabylonJS submesh
  81268. * @param primitiveMode Primitive mode of the mesh
  81269. * @param sideOrientation the winding order of the submesh
  81270. * @param vertexBufferKind The type of vertex attribute
  81271. * @param meshAttributeArray The vertex attribute data
  81272. * @param byteOffset The offset to the binary data
  81273. * @param binaryWriter The binary data for the glTF file
  81274. * @param convertToRightHandedSystem Converts the values to right-handed
  81275. */
  81276. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81277. /**
  81278. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81279. * clock-wise during export to glTF
  81280. * @param submesh BabylonJS submesh
  81281. * @param primitiveMode Primitive mode of the mesh
  81282. * @param sideOrientation the winding order of the submesh
  81283. * @param vertexBufferKind The type of vertex attribute
  81284. * @param meshAttributeArray The vertex attribute data
  81285. * @param byteOffset The offset to the binary data
  81286. * @param binaryWriter The binary data for the glTF file
  81287. * @param convertToRightHandedSystem Converts the values to right-handed
  81288. */
  81289. private reorderTriangleFillMode;
  81290. /**
  81291. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81292. * clock-wise during export to glTF
  81293. * @param submesh BabylonJS submesh
  81294. * @param primitiveMode Primitive mode of the mesh
  81295. * @param sideOrientation the winding order of the submesh
  81296. * @param vertexBufferKind The type of vertex attribute
  81297. * @param meshAttributeArray The vertex attribute data
  81298. * @param byteOffset The offset to the binary data
  81299. * @param binaryWriter The binary data for the glTF file
  81300. * @param convertToRightHandedSystem Converts the values to right-handed
  81301. */
  81302. private reorderTriangleStripDrawMode;
  81303. /**
  81304. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81305. * clock-wise during export to glTF
  81306. * @param submesh BabylonJS submesh
  81307. * @param primitiveMode Primitive mode of the mesh
  81308. * @param sideOrientation the winding order of the submesh
  81309. * @param vertexBufferKind The type of vertex attribute
  81310. * @param meshAttributeArray The vertex attribute data
  81311. * @param byteOffset The offset to the binary data
  81312. * @param binaryWriter The binary data for the glTF file
  81313. * @param convertToRightHandedSystem Converts the values to right-handed
  81314. */
  81315. private reorderTriangleFanMode;
  81316. /**
  81317. * Writes the vertex attribute data to binary
  81318. * @param vertices The vertices to write to the binary writer
  81319. * @param byteOffset The offset into the binary writer to overwrite binary data
  81320. * @param vertexAttributeKind The vertex attribute type
  81321. * @param meshAttributeArray The vertex attribute data
  81322. * @param binaryWriter The writer containing the binary data
  81323. * @param convertToRightHandedSystem Converts the values to right-handed
  81324. */
  81325. private writeVertexAttributeData;
  81326. /**
  81327. * Writes mesh attribute data to a data buffer
  81328. * Returns the bytelength of the data
  81329. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81330. * @param meshAttributeArray Array containing the attribute data
  81331. * @param binaryWriter The buffer to write the binary data to
  81332. * @param indices Used to specify the order of the vertex data
  81333. * @param convertToRightHandedSystem Converts the values to right-handed
  81334. */
  81335. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81336. /**
  81337. * Generates glTF json data
  81338. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81339. * @param glTFPrefix Text to use when prefixing a glTF file
  81340. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81341. * @returns json data as string
  81342. */
  81343. private generateJSON;
  81344. /**
  81345. * Generates data for .gltf and .bin files based on the glTF prefix string
  81346. * @param glTFPrefix Text to use when prefixing a glTF file
  81347. * @param dispose Dispose the exporter
  81348. * @returns GLTFData with glTF file data
  81349. */
  81350. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81351. /**
  81352. * Creates a binary buffer for glTF
  81353. * @returns array buffer for binary data
  81354. */
  81355. private _generateBinaryAsync;
  81356. /**
  81357. * Pads the number to a multiple of 4
  81358. * @param num number to pad
  81359. * @returns padded number
  81360. */
  81361. private _getPadding;
  81362. /**
  81363. * @hidden
  81364. */
  81365. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81366. /**
  81367. * Sets the TRS for each node
  81368. * @param node glTF Node for storing the transformation data
  81369. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81370. * @param convertToRightHandedSystem Converts the values to right-handed
  81371. */
  81372. private setNodeTransformation;
  81373. private getVertexBufferFromMesh;
  81374. /**
  81375. * Creates a bufferview based on the vertices type for the Babylon mesh
  81376. * @param kind Indicates the type of vertices data
  81377. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81378. * @param binaryWriter The buffer to write the bufferview data to
  81379. * @param convertToRightHandedSystem Converts the values to right-handed
  81380. */
  81381. private createBufferViewKind;
  81382. /**
  81383. * The primitive mode of the Babylon mesh
  81384. * @param babylonMesh The BabylonJS mesh
  81385. */
  81386. private getMeshPrimitiveMode;
  81387. /**
  81388. * Sets the primitive mode of the glTF mesh primitive
  81389. * @param meshPrimitive glTF mesh primitive
  81390. * @param primitiveMode The primitive mode
  81391. */
  81392. private setPrimitiveMode;
  81393. /**
  81394. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81395. * @param meshPrimitive glTF mesh primitive
  81396. * @param attributeKind vertex attribute
  81397. * @returns boolean specifying if uv coordinates are present
  81398. */
  81399. private setAttributeKind;
  81400. /**
  81401. * Sets data for the primitive attributes of each submesh
  81402. * @param mesh glTF Mesh object to store the primitive attribute information
  81403. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81404. * @param binaryWriter Buffer to write the attribute data to
  81405. * @param convertToRightHandedSystem Converts the values to right-handed
  81406. */
  81407. private setPrimitiveAttributesAsync;
  81408. /**
  81409. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81410. * @param node The node to check
  81411. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81412. */
  81413. private isBabylonCoordinateSystemConvertingNode;
  81414. /**
  81415. * Creates a glTF scene based on the array of meshes
  81416. * Returns the the total byte offset
  81417. * @param babylonScene Babylon scene to get the mesh data from
  81418. * @param binaryWriter Buffer to write binary data to
  81419. */
  81420. private createSceneAsync;
  81421. /**
  81422. * Creates a mapping of Node unique id to node index and handles animations
  81423. * @param babylonScene Babylon Scene
  81424. * @param nodes Babylon transform nodes
  81425. * @param binaryWriter Buffer to write binary data to
  81426. * @returns Node mapping of unique id to index
  81427. */
  81428. private createNodeMapAndAnimationsAsync;
  81429. /**
  81430. * Creates a glTF node from a Babylon mesh
  81431. * @param babylonMesh Source Babylon mesh
  81432. * @param binaryWriter Buffer for storing geometry data
  81433. * @param convertToRightHandedSystem Converts the values to right-handed
  81434. * @param nodeMap Node mapping of unique id to glTF node index
  81435. * @returns glTF node
  81436. */
  81437. private createNodeAsync;
  81438. }
  81439. /**
  81440. * @hidden
  81441. *
  81442. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81443. */
  81444. export class _BinaryWriter {
  81445. /**
  81446. * Array buffer which stores all binary data
  81447. */
  81448. private _arrayBuffer;
  81449. /**
  81450. * View of the array buffer
  81451. */
  81452. private _dataView;
  81453. /**
  81454. * byte offset of data in array buffer
  81455. */
  81456. private _byteOffset;
  81457. /**
  81458. * Initialize binary writer with an initial byte length
  81459. * @param byteLength Initial byte length of the array buffer
  81460. */
  81461. constructor(byteLength: number);
  81462. /**
  81463. * Resize the array buffer to the specified byte length
  81464. * @param byteLength
  81465. */
  81466. private resizeBuffer;
  81467. /**
  81468. * Get an array buffer with the length of the byte offset
  81469. * @returns ArrayBuffer resized to the byte offset
  81470. */
  81471. getArrayBuffer(): ArrayBuffer;
  81472. /**
  81473. * Get the byte offset of the array buffer
  81474. * @returns byte offset
  81475. */
  81476. getByteOffset(): number;
  81477. /**
  81478. * Stores an UInt8 in the array buffer
  81479. * @param entry
  81480. * @param byteOffset If defined, specifies where to set the value as an offset.
  81481. */
  81482. setUInt8(entry: number, byteOffset?: number): void;
  81483. /**
  81484. * Gets an UInt32 in the array buffer
  81485. * @param entry
  81486. * @param byteOffset If defined, specifies where to set the value as an offset.
  81487. */
  81488. getUInt32(byteOffset: number): number;
  81489. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81490. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81491. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81492. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81493. /**
  81494. * Stores a Float32 in the array buffer
  81495. * @param entry
  81496. */
  81497. setFloat32(entry: number, byteOffset?: number): void;
  81498. /**
  81499. * Stores an UInt32 in the array buffer
  81500. * @param entry
  81501. * @param byteOffset If defined, specifies where to set the value as an offset.
  81502. */
  81503. setUInt32(entry: number, byteOffset?: number): void;
  81504. }
  81505. }
  81506. declare module BABYLON.GLTF2.Exporter {
  81507. /**
  81508. * @hidden
  81509. * Interface to store animation data.
  81510. */
  81511. export interface _IAnimationData {
  81512. /**
  81513. * Keyframe data.
  81514. */
  81515. inputs: number[];
  81516. /**
  81517. * Value data.
  81518. */
  81519. outputs: number[][];
  81520. /**
  81521. * Animation interpolation data.
  81522. */
  81523. samplerInterpolation: AnimationSamplerInterpolation;
  81524. /**
  81525. * Minimum keyframe value.
  81526. */
  81527. inputsMin: number;
  81528. /**
  81529. * Maximum keyframe value.
  81530. */
  81531. inputsMax: number;
  81532. }
  81533. /**
  81534. * @hidden
  81535. */
  81536. export interface _IAnimationInfo {
  81537. /**
  81538. * The target channel for the animation
  81539. */
  81540. animationChannelTargetPath: AnimationChannelTargetPath;
  81541. /**
  81542. * The glTF accessor type for the data.
  81543. */
  81544. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81545. /**
  81546. * Specifies if quaternions should be used.
  81547. */
  81548. useQuaternion: boolean;
  81549. }
  81550. /**
  81551. * @hidden
  81552. * Utility class for generating glTF animation data from BabylonJS.
  81553. */
  81554. export class _GLTFAnimation {
  81555. /**
  81556. * @ignore
  81557. *
  81558. * Creates glTF channel animation from BabylonJS animation.
  81559. * @param babylonTransformNode - BabylonJS mesh.
  81560. * @param animation - animation.
  81561. * @param animationChannelTargetPath - The target animation channel.
  81562. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81563. * @param useQuaternion - Specifies if quaternions are used.
  81564. * @returns nullable IAnimationData
  81565. */
  81566. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81567. private static _DeduceAnimationInfo;
  81568. /**
  81569. * @ignore
  81570. * Create node animations from the transform node animations
  81571. * @param babylonNode
  81572. * @param runtimeGLTFAnimation
  81573. * @param idleGLTFAnimations
  81574. * @param nodeMap
  81575. * @param nodes
  81576. * @param binaryWriter
  81577. * @param bufferViews
  81578. * @param accessors
  81579. * @param convertToRightHandedSystem
  81580. * @param animationSampleRate
  81581. */
  81582. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81583. [key: number]: number;
  81584. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81585. /**
  81586. * @ignore
  81587. * Create node animations from the animation groups
  81588. * @param babylonScene
  81589. * @param glTFAnimations
  81590. * @param nodeMap
  81591. * @param nodes
  81592. * @param binaryWriter
  81593. * @param bufferViews
  81594. * @param accessors
  81595. * @param convertToRightHandedSystemMap
  81596. * @param animationSampleRate
  81597. */
  81598. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81599. [key: number]: number;
  81600. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81601. [nodeId: number]: boolean;
  81602. }, animationSampleRate: number): void;
  81603. private static AddAnimation;
  81604. /**
  81605. * Create a baked animation
  81606. * @param babylonTransformNode BabylonJS mesh
  81607. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81608. * @param animationChannelTargetPath animation target channel
  81609. * @param minFrame minimum animation frame
  81610. * @param maxFrame maximum animation frame
  81611. * @param fps frames per second of the animation
  81612. * @param inputs input key frames of the animation
  81613. * @param outputs output key frame data of the animation
  81614. * @param convertToRightHandedSystem converts the values to right-handed
  81615. * @param useQuaternion specifies if quaternions should be used
  81616. */
  81617. private static _CreateBakedAnimation;
  81618. private static _ConvertFactorToVector3OrQuaternion;
  81619. private static _SetInterpolatedValue;
  81620. /**
  81621. * Creates linear animation from the animation key frames
  81622. * @param babylonTransformNode BabylonJS mesh
  81623. * @param animation BabylonJS animation
  81624. * @param animationChannelTargetPath The target animation channel
  81625. * @param frameDelta The difference between the last and first frame of the animation
  81626. * @param inputs Array to store the key frame times
  81627. * @param outputs Array to store the key frame data
  81628. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81629. * @param useQuaternion Specifies if quaternions are used in the animation
  81630. */
  81631. private static _CreateLinearOrStepAnimation;
  81632. /**
  81633. * Creates cubic spline animation from the animation key frames
  81634. * @param babylonTransformNode BabylonJS mesh
  81635. * @param animation BabylonJS animation
  81636. * @param animationChannelTargetPath The target animation channel
  81637. * @param frameDelta The difference between the last and first frame of the animation
  81638. * @param inputs Array to store the key frame times
  81639. * @param outputs Array to store the key frame data
  81640. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81641. * @param useQuaternion Specifies if quaternions are used in the animation
  81642. */
  81643. private static _CreateCubicSplineAnimation;
  81644. private static _GetBasePositionRotationOrScale;
  81645. /**
  81646. * Adds a key frame value
  81647. * @param keyFrame
  81648. * @param animation
  81649. * @param outputs
  81650. * @param animationChannelTargetPath
  81651. * @param basePositionRotationOrScale
  81652. * @param convertToRightHandedSystem
  81653. * @param useQuaternion
  81654. */
  81655. private static _AddKeyframeValue;
  81656. /**
  81657. * Determine the interpolation based on the key frames
  81658. * @param keyFrames
  81659. * @param animationChannelTargetPath
  81660. * @param useQuaternion
  81661. */
  81662. private static _DeduceInterpolation;
  81663. /**
  81664. * Adds an input tangent or output tangent to the output data
  81665. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81666. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81667. * @param outputs The animation data by keyframe
  81668. * @param animationChannelTargetPath The target animation channel
  81669. * @param interpolation The interpolation type
  81670. * @param keyFrame The key frame with the animation data
  81671. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81672. * @param useQuaternion Specifies if quaternions are used
  81673. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81674. */
  81675. private static AddSplineTangent;
  81676. /**
  81677. * Get the minimum and maximum key frames' frame values
  81678. * @param keyFrames animation key frames
  81679. * @returns the minimum and maximum key frame value
  81680. */
  81681. private static calculateMinMaxKeyFrames;
  81682. }
  81683. }
  81684. declare module BABYLON.GLTF2.Exporter {
  81685. /** @hidden */
  81686. export var textureTransformPixelShader: {
  81687. name: string;
  81688. shader: string;
  81689. };
  81690. }
  81691. declare module BABYLON.GLTF2.Exporter.Extensions {
  81692. /**
  81693. * @hidden
  81694. */
  81695. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81696. private _recordedTextures;
  81697. /** Name of this extension */
  81698. readonly name: string;
  81699. /** Defines whether this extension is enabled */
  81700. enabled: boolean;
  81701. /** Defines whether this extension is required */
  81702. required: boolean;
  81703. /** Reference to the glTF exporter */
  81704. private _wasUsed;
  81705. constructor(exporter: _Exporter);
  81706. dispose(): void;
  81707. /** @hidden */
  81708. get wasUsed(): boolean;
  81709. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81710. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81711. /**
  81712. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81713. * @param babylonTexture
  81714. * @param offset
  81715. * @param rotation
  81716. * @param scale
  81717. * @param scene
  81718. */
  81719. private _textureTransformTextureAsync;
  81720. }
  81721. }
  81722. declare module BABYLON.GLTF2.Exporter.Extensions {
  81723. /**
  81724. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81725. */
  81726. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81727. /** The name of this extension. */
  81728. readonly name: string;
  81729. /** Defines whether this extension is enabled. */
  81730. enabled: boolean;
  81731. /** Defines whether this extension is required */
  81732. required: boolean;
  81733. /** Reference to the glTF exporter */
  81734. private _exporter;
  81735. private _lights;
  81736. /** @hidden */
  81737. constructor(exporter: _Exporter);
  81738. /** @hidden */
  81739. dispose(): void;
  81740. /** @hidden */
  81741. get wasUsed(): boolean;
  81742. /** @hidden */
  81743. onExporting(): void;
  81744. /**
  81745. * Define this method to modify the default behavior when exporting a node
  81746. * @param context The context when exporting the node
  81747. * @param node glTF node
  81748. * @param babylonNode BabylonJS node
  81749. * @param nodeMap Node mapping of unique id to glTF node index
  81750. * @returns nullable INode promise
  81751. */
  81752. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81753. [key: number]: number;
  81754. }): Promise<Nullable<INode>>;
  81755. }
  81756. }
  81757. declare module BABYLON.GLTF2.Exporter.Extensions {
  81758. /**
  81759. * @hidden
  81760. */
  81761. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81762. /** Name of this extension */
  81763. readonly name: string;
  81764. /** Defines whether this extension is enabled */
  81765. enabled: boolean;
  81766. /** Defines whether this extension is required */
  81767. required: boolean;
  81768. /** Reference to the glTF exporter */
  81769. private _textureInfos;
  81770. private _exportedTextures;
  81771. private _wasUsed;
  81772. constructor(exporter: _Exporter);
  81773. dispose(): void;
  81774. /** @hidden */
  81775. get wasUsed(): boolean;
  81776. private _getTextureIndex;
  81777. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81778. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81779. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81780. }
  81781. }
  81782. declare module BABYLON {
  81783. /**
  81784. * Class for generating STL data from a Babylon scene.
  81785. */
  81786. export class STLExport {
  81787. /**
  81788. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81789. * @param meshes list defines the mesh to serialize
  81790. * @param download triggers the automatic download of the file.
  81791. * @param fileName changes the downloads fileName.
  81792. * @param binary changes the STL to a binary type.
  81793. * @param isLittleEndian toggle for binary type exporter.
  81794. * @returns the STL as UTF8 string
  81795. */
  81796. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81797. }
  81798. }
  81799. declare module "babylonjs-gltf2interface" {
  81800. export = BABYLON.GLTF2;
  81801. }
  81802. /**
  81803. * Module for glTF 2.0 Interface
  81804. */
  81805. declare module BABYLON.GLTF2 {
  81806. /**
  81807. * The datatype of the components in the attribute
  81808. */
  81809. const enum AccessorComponentType {
  81810. /**
  81811. * Byte
  81812. */
  81813. BYTE = 5120,
  81814. /**
  81815. * Unsigned Byte
  81816. */
  81817. UNSIGNED_BYTE = 5121,
  81818. /**
  81819. * Short
  81820. */
  81821. SHORT = 5122,
  81822. /**
  81823. * Unsigned Short
  81824. */
  81825. UNSIGNED_SHORT = 5123,
  81826. /**
  81827. * Unsigned Int
  81828. */
  81829. UNSIGNED_INT = 5125,
  81830. /**
  81831. * Float
  81832. */
  81833. FLOAT = 5126,
  81834. }
  81835. /**
  81836. * Specifies if the attirbute is a scalar, vector, or matrix
  81837. */
  81838. const enum AccessorType {
  81839. /**
  81840. * Scalar
  81841. */
  81842. SCALAR = "SCALAR",
  81843. /**
  81844. * Vector2
  81845. */
  81846. VEC2 = "VEC2",
  81847. /**
  81848. * Vector3
  81849. */
  81850. VEC3 = "VEC3",
  81851. /**
  81852. * Vector4
  81853. */
  81854. VEC4 = "VEC4",
  81855. /**
  81856. * Matrix2x2
  81857. */
  81858. MAT2 = "MAT2",
  81859. /**
  81860. * Matrix3x3
  81861. */
  81862. MAT3 = "MAT3",
  81863. /**
  81864. * Matrix4x4
  81865. */
  81866. MAT4 = "MAT4",
  81867. }
  81868. /**
  81869. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81870. */
  81871. const enum AnimationChannelTargetPath {
  81872. /**
  81873. * Translation
  81874. */
  81875. TRANSLATION = "translation",
  81876. /**
  81877. * Rotation
  81878. */
  81879. ROTATION = "rotation",
  81880. /**
  81881. * Scale
  81882. */
  81883. SCALE = "scale",
  81884. /**
  81885. * Weights
  81886. */
  81887. WEIGHTS = "weights",
  81888. }
  81889. /**
  81890. * Interpolation algorithm
  81891. */
  81892. const enum AnimationSamplerInterpolation {
  81893. /**
  81894. * The animated values are linearly interpolated between keyframes
  81895. */
  81896. LINEAR = "LINEAR",
  81897. /**
  81898. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81899. */
  81900. STEP = "STEP",
  81901. /**
  81902. * The animation's interpolation is computed using a cubic spline with specified tangents
  81903. */
  81904. CUBICSPLINE = "CUBICSPLINE",
  81905. }
  81906. /**
  81907. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81908. */
  81909. const enum CameraType {
  81910. /**
  81911. * A perspective camera containing properties to create a perspective projection matrix
  81912. */
  81913. PERSPECTIVE = "perspective",
  81914. /**
  81915. * An orthographic camera containing properties to create an orthographic projection matrix
  81916. */
  81917. ORTHOGRAPHIC = "orthographic",
  81918. }
  81919. /**
  81920. * The mime-type of the image
  81921. */
  81922. const enum ImageMimeType {
  81923. /**
  81924. * JPEG Mime-type
  81925. */
  81926. JPEG = "image/jpeg",
  81927. /**
  81928. * PNG Mime-type
  81929. */
  81930. PNG = "image/png",
  81931. }
  81932. /**
  81933. * The alpha rendering mode of the material
  81934. */
  81935. const enum MaterialAlphaMode {
  81936. /**
  81937. * The alpha value is ignored and the rendered output is fully opaque
  81938. */
  81939. OPAQUE = "OPAQUE",
  81940. /**
  81941. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81942. */
  81943. MASK = "MASK",
  81944. /**
  81945. * 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)
  81946. */
  81947. BLEND = "BLEND",
  81948. }
  81949. /**
  81950. * The type of the primitives to render
  81951. */
  81952. const enum MeshPrimitiveMode {
  81953. /**
  81954. * Points
  81955. */
  81956. POINTS = 0,
  81957. /**
  81958. * Lines
  81959. */
  81960. LINES = 1,
  81961. /**
  81962. * Line Loop
  81963. */
  81964. LINE_LOOP = 2,
  81965. /**
  81966. * Line Strip
  81967. */
  81968. LINE_STRIP = 3,
  81969. /**
  81970. * Triangles
  81971. */
  81972. TRIANGLES = 4,
  81973. /**
  81974. * Triangle Strip
  81975. */
  81976. TRIANGLE_STRIP = 5,
  81977. /**
  81978. * Triangle Fan
  81979. */
  81980. TRIANGLE_FAN = 6,
  81981. }
  81982. /**
  81983. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81984. */
  81985. const enum TextureMagFilter {
  81986. /**
  81987. * Nearest
  81988. */
  81989. NEAREST = 9728,
  81990. /**
  81991. * Linear
  81992. */
  81993. LINEAR = 9729,
  81994. }
  81995. /**
  81996. * Minification filter. All valid values correspond to WebGL enums
  81997. */
  81998. const enum TextureMinFilter {
  81999. /**
  82000. * Nearest
  82001. */
  82002. NEAREST = 9728,
  82003. /**
  82004. * Linear
  82005. */
  82006. LINEAR = 9729,
  82007. /**
  82008. * Nearest Mip-Map Nearest
  82009. */
  82010. NEAREST_MIPMAP_NEAREST = 9984,
  82011. /**
  82012. * Linear Mipmap Nearest
  82013. */
  82014. LINEAR_MIPMAP_NEAREST = 9985,
  82015. /**
  82016. * Nearest Mipmap Linear
  82017. */
  82018. NEAREST_MIPMAP_LINEAR = 9986,
  82019. /**
  82020. * Linear Mipmap Linear
  82021. */
  82022. LINEAR_MIPMAP_LINEAR = 9987,
  82023. }
  82024. /**
  82025. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82026. */
  82027. const enum TextureWrapMode {
  82028. /**
  82029. * Clamp to Edge
  82030. */
  82031. CLAMP_TO_EDGE = 33071,
  82032. /**
  82033. * Mirrored Repeat
  82034. */
  82035. MIRRORED_REPEAT = 33648,
  82036. /**
  82037. * Repeat
  82038. */
  82039. REPEAT = 10497,
  82040. }
  82041. /**
  82042. * glTF Property
  82043. */
  82044. interface IProperty {
  82045. /**
  82046. * Dictionary object with extension-specific objects
  82047. */
  82048. extensions?: {
  82049. [key: string]: any;
  82050. };
  82051. /**
  82052. * Application-Specific data
  82053. */
  82054. extras?: any;
  82055. }
  82056. /**
  82057. * glTF Child of Root Property
  82058. */
  82059. interface IChildRootProperty extends IProperty {
  82060. /**
  82061. * The user-defined name of this object
  82062. */
  82063. name?: string;
  82064. }
  82065. /**
  82066. * Indices of those attributes that deviate from their initialization value
  82067. */
  82068. interface IAccessorSparseIndices extends IProperty {
  82069. /**
  82070. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82071. */
  82072. bufferView: number;
  82073. /**
  82074. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82075. */
  82076. byteOffset?: number;
  82077. /**
  82078. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82079. */
  82080. componentType: AccessorComponentType;
  82081. }
  82082. /**
  82083. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82084. */
  82085. interface IAccessorSparseValues extends IProperty {
  82086. /**
  82087. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82088. */
  82089. bufferView: number;
  82090. /**
  82091. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82092. */
  82093. byteOffset?: number;
  82094. }
  82095. /**
  82096. * Sparse storage of attributes that deviate from their initialization value
  82097. */
  82098. interface IAccessorSparse extends IProperty {
  82099. /**
  82100. * The number of attributes encoded in this sparse accessor
  82101. */
  82102. count: number;
  82103. /**
  82104. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82105. */
  82106. indices: IAccessorSparseIndices;
  82107. /**
  82108. * 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
  82109. */
  82110. values: IAccessorSparseValues;
  82111. }
  82112. /**
  82113. * 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
  82114. */
  82115. interface IAccessor extends IChildRootProperty {
  82116. /**
  82117. * The index of the bufferview
  82118. */
  82119. bufferView?: number;
  82120. /**
  82121. * The offset relative to the start of the bufferView in bytes
  82122. */
  82123. byteOffset?: number;
  82124. /**
  82125. * The datatype of components in the attribute
  82126. */
  82127. componentType: AccessorComponentType;
  82128. /**
  82129. * Specifies whether integer data values should be normalized
  82130. */
  82131. normalized?: boolean;
  82132. /**
  82133. * The number of attributes referenced by this accessor
  82134. */
  82135. count: number;
  82136. /**
  82137. * Specifies if the attribute is a scalar, vector, or matrix
  82138. */
  82139. type: AccessorType;
  82140. /**
  82141. * Maximum value of each component in this attribute
  82142. */
  82143. max?: number[];
  82144. /**
  82145. * Minimum value of each component in this attribute
  82146. */
  82147. min?: number[];
  82148. /**
  82149. * Sparse storage of attributes that deviate from their initialization value
  82150. */
  82151. sparse?: IAccessorSparse;
  82152. }
  82153. /**
  82154. * Targets an animation's sampler at a node's property
  82155. */
  82156. interface IAnimationChannel extends IProperty {
  82157. /**
  82158. * The index of a sampler in this animation used to compute the value for the target
  82159. */
  82160. sampler: number;
  82161. /**
  82162. * The index of the node and TRS property to target
  82163. */
  82164. target: IAnimationChannelTarget;
  82165. }
  82166. /**
  82167. * The index of the node and TRS property that an animation channel targets
  82168. */
  82169. interface IAnimationChannelTarget extends IProperty {
  82170. /**
  82171. * The index of the node to target
  82172. */
  82173. node: number;
  82174. /**
  82175. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82176. */
  82177. path: AnimationChannelTargetPath;
  82178. }
  82179. /**
  82180. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82181. */
  82182. interface IAnimationSampler extends IProperty {
  82183. /**
  82184. * The index of an accessor containing keyframe input values, e.g., time
  82185. */
  82186. input: number;
  82187. /**
  82188. * Interpolation algorithm
  82189. */
  82190. interpolation?: AnimationSamplerInterpolation;
  82191. /**
  82192. * The index of an accessor, containing keyframe output values
  82193. */
  82194. output: number;
  82195. }
  82196. /**
  82197. * A keyframe animation
  82198. */
  82199. interface IAnimation extends IChildRootProperty {
  82200. /**
  82201. * An array of channels, each of which targets an animation's sampler at a node's property
  82202. */
  82203. channels: IAnimationChannel[];
  82204. /**
  82205. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82206. */
  82207. samplers: IAnimationSampler[];
  82208. }
  82209. /**
  82210. * Metadata about the glTF asset
  82211. */
  82212. interface IAsset extends IChildRootProperty {
  82213. /**
  82214. * A copyright message suitable for display to credit the content creator
  82215. */
  82216. copyright?: string;
  82217. /**
  82218. * Tool that generated this glTF model. Useful for debugging
  82219. */
  82220. generator?: string;
  82221. /**
  82222. * The glTF version that this asset targets
  82223. */
  82224. version: string;
  82225. /**
  82226. * The minimum glTF version that this asset targets
  82227. */
  82228. minVersion?: string;
  82229. }
  82230. /**
  82231. * A buffer points to binary geometry, animation, or skins
  82232. */
  82233. interface IBuffer extends IChildRootProperty {
  82234. /**
  82235. * 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
  82236. */
  82237. uri?: string;
  82238. /**
  82239. * The length of the buffer in bytes
  82240. */
  82241. byteLength: number;
  82242. }
  82243. /**
  82244. * A view into a buffer generally representing a subset of the buffer
  82245. */
  82246. interface IBufferView extends IChildRootProperty {
  82247. /**
  82248. * The index of the buffer
  82249. */
  82250. buffer: number;
  82251. /**
  82252. * The offset into the buffer in bytes
  82253. */
  82254. byteOffset?: number;
  82255. /**
  82256. * The lenth of the bufferView in bytes
  82257. */
  82258. byteLength: number;
  82259. /**
  82260. * The stride, in bytes
  82261. */
  82262. byteStride?: number;
  82263. }
  82264. /**
  82265. * An orthographic camera containing properties to create an orthographic projection matrix
  82266. */
  82267. interface ICameraOrthographic extends IProperty {
  82268. /**
  82269. * The floating-point horizontal magnification of the view. Must not be zero
  82270. */
  82271. xmag: number;
  82272. /**
  82273. * The floating-point vertical magnification of the view. Must not be zero
  82274. */
  82275. ymag: number;
  82276. /**
  82277. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82278. */
  82279. zfar: number;
  82280. /**
  82281. * The floating-point distance to the near clipping plane
  82282. */
  82283. znear: number;
  82284. }
  82285. /**
  82286. * A perspective camera containing properties to create a perspective projection matrix
  82287. */
  82288. interface ICameraPerspective extends IProperty {
  82289. /**
  82290. * The floating-point aspect ratio of the field of view
  82291. */
  82292. aspectRatio?: number;
  82293. /**
  82294. * The floating-point vertical field of view in radians
  82295. */
  82296. yfov: number;
  82297. /**
  82298. * The floating-point distance to the far clipping plane
  82299. */
  82300. zfar?: number;
  82301. /**
  82302. * The floating-point distance to the near clipping plane
  82303. */
  82304. znear: number;
  82305. }
  82306. /**
  82307. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82308. */
  82309. interface ICamera extends IChildRootProperty {
  82310. /**
  82311. * An orthographic camera containing properties to create an orthographic projection matrix
  82312. */
  82313. orthographic?: ICameraOrthographic;
  82314. /**
  82315. * A perspective camera containing properties to create a perspective projection matrix
  82316. */
  82317. perspective?: ICameraPerspective;
  82318. /**
  82319. * Specifies if the camera uses a perspective or orthographic projection
  82320. */
  82321. type: CameraType;
  82322. }
  82323. /**
  82324. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82325. */
  82326. interface IImage extends IChildRootProperty {
  82327. /**
  82328. * 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
  82329. */
  82330. uri?: string;
  82331. /**
  82332. * The image's MIME type
  82333. */
  82334. mimeType?: ImageMimeType;
  82335. /**
  82336. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82337. */
  82338. bufferView?: number;
  82339. }
  82340. /**
  82341. * Material Normal Texture Info
  82342. */
  82343. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82344. /**
  82345. * The scalar multiplier applied to each normal vector of the normal texture
  82346. */
  82347. scale?: number;
  82348. }
  82349. /**
  82350. * Material Occlusion Texture Info
  82351. */
  82352. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82353. /**
  82354. * A scalar multiplier controlling the amount of occlusion applied
  82355. */
  82356. strength?: number;
  82357. }
  82358. /**
  82359. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82360. */
  82361. interface IMaterialPbrMetallicRoughness {
  82362. /**
  82363. * The material's base color factor
  82364. */
  82365. baseColorFactor?: number[];
  82366. /**
  82367. * The base color texture
  82368. */
  82369. baseColorTexture?: ITextureInfo;
  82370. /**
  82371. * The metalness of the material
  82372. */
  82373. metallicFactor?: number;
  82374. /**
  82375. * The roughness of the material
  82376. */
  82377. roughnessFactor?: number;
  82378. /**
  82379. * The metallic-roughness texture
  82380. */
  82381. metallicRoughnessTexture?: ITextureInfo;
  82382. }
  82383. /**
  82384. * The material appearance of a primitive
  82385. */
  82386. interface IMaterial extends IChildRootProperty {
  82387. /**
  82388. * 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
  82389. */
  82390. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82391. /**
  82392. * The normal map texture
  82393. */
  82394. normalTexture?: IMaterialNormalTextureInfo;
  82395. /**
  82396. * The occlusion map texture
  82397. */
  82398. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82399. /**
  82400. * The emissive map texture
  82401. */
  82402. emissiveTexture?: ITextureInfo;
  82403. /**
  82404. * 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
  82405. */
  82406. emissiveFactor?: number[];
  82407. /**
  82408. * The alpha rendering mode of the material
  82409. */
  82410. alphaMode?: MaterialAlphaMode;
  82411. /**
  82412. * The alpha cutoff value of the material
  82413. */
  82414. alphaCutoff?: number;
  82415. /**
  82416. * Specifies whether the material is double sided
  82417. */
  82418. doubleSided?: boolean;
  82419. }
  82420. /**
  82421. * Geometry to be rendered with the given material
  82422. */
  82423. interface IMeshPrimitive extends IProperty {
  82424. /**
  82425. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82426. */
  82427. attributes: {
  82428. [name: string]: number;
  82429. };
  82430. /**
  82431. * The index of the accessor that contains the indices
  82432. */
  82433. indices?: number;
  82434. /**
  82435. * The index of the material to apply to this primitive when rendering
  82436. */
  82437. material?: number;
  82438. /**
  82439. * The type of primitives to render. All valid values correspond to WebGL enums
  82440. */
  82441. mode?: MeshPrimitiveMode;
  82442. /**
  82443. * 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
  82444. */
  82445. targets?: {
  82446. [name: string]: number;
  82447. }[];
  82448. }
  82449. /**
  82450. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82451. */
  82452. interface IMesh extends IChildRootProperty {
  82453. /**
  82454. * An array of primitives, each defining geometry to be rendered with a material
  82455. */
  82456. primitives: IMeshPrimitive[];
  82457. /**
  82458. * Array of weights to be applied to the Morph Targets
  82459. */
  82460. weights?: number[];
  82461. }
  82462. /**
  82463. * A node in the node hierarchy
  82464. */
  82465. interface INode extends IChildRootProperty {
  82466. /**
  82467. * The index of the camera referenced by this node
  82468. */
  82469. camera?: number;
  82470. /**
  82471. * The indices of this node's children
  82472. */
  82473. children?: number[];
  82474. /**
  82475. * The index of the skin referenced by this node
  82476. */
  82477. skin?: number;
  82478. /**
  82479. * A floating-point 4x4 transformation matrix stored in column-major order
  82480. */
  82481. matrix?: number[];
  82482. /**
  82483. * The index of the mesh in this node
  82484. */
  82485. mesh?: number;
  82486. /**
  82487. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82488. */
  82489. rotation?: number[];
  82490. /**
  82491. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82492. */
  82493. scale?: number[];
  82494. /**
  82495. * The node's translation along the x, y, and z axes
  82496. */
  82497. translation?: number[];
  82498. /**
  82499. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82500. */
  82501. weights?: number[];
  82502. }
  82503. /**
  82504. * Texture sampler properties for filtering and wrapping modes
  82505. */
  82506. interface ISampler extends IChildRootProperty {
  82507. /**
  82508. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82509. */
  82510. magFilter?: TextureMagFilter;
  82511. /**
  82512. * Minification filter. All valid values correspond to WebGL enums
  82513. */
  82514. minFilter?: TextureMinFilter;
  82515. /**
  82516. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82517. */
  82518. wrapS?: TextureWrapMode;
  82519. /**
  82520. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82521. */
  82522. wrapT?: TextureWrapMode;
  82523. }
  82524. /**
  82525. * The root nodes of a scene
  82526. */
  82527. interface IScene extends IChildRootProperty {
  82528. /**
  82529. * The indices of each root node
  82530. */
  82531. nodes: number[];
  82532. }
  82533. /**
  82534. * Joints and matrices defining a skin
  82535. */
  82536. interface ISkin extends IChildRootProperty {
  82537. /**
  82538. * 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
  82539. */
  82540. inverseBindMatrices?: number;
  82541. /**
  82542. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82543. */
  82544. skeleton?: number;
  82545. /**
  82546. * 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)
  82547. */
  82548. joints: number[];
  82549. }
  82550. /**
  82551. * A texture and its sampler
  82552. */
  82553. interface ITexture extends IChildRootProperty {
  82554. /**
  82555. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82556. */
  82557. sampler?: number;
  82558. /**
  82559. * The index of the image used by this texture
  82560. */
  82561. source: number;
  82562. }
  82563. /**
  82564. * Reference to a texture
  82565. */
  82566. interface ITextureInfo extends IProperty {
  82567. /**
  82568. * The index of the texture
  82569. */
  82570. index: number;
  82571. /**
  82572. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82573. */
  82574. texCoord?: number;
  82575. }
  82576. /**
  82577. * The root object for a glTF asset
  82578. */
  82579. interface IGLTF extends IProperty {
  82580. /**
  82581. * An array of accessors. An accessor is a typed view into a bufferView
  82582. */
  82583. accessors?: IAccessor[];
  82584. /**
  82585. * An array of keyframe animations
  82586. */
  82587. animations?: IAnimation[];
  82588. /**
  82589. * Metadata about the glTF asset
  82590. */
  82591. asset: IAsset;
  82592. /**
  82593. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82594. */
  82595. buffers?: IBuffer[];
  82596. /**
  82597. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82598. */
  82599. bufferViews?: IBufferView[];
  82600. /**
  82601. * An array of cameras
  82602. */
  82603. cameras?: ICamera[];
  82604. /**
  82605. * Names of glTF extensions used somewhere in this asset
  82606. */
  82607. extensionsUsed?: string[];
  82608. /**
  82609. * Names of glTF extensions required to properly load this asset
  82610. */
  82611. extensionsRequired?: string[];
  82612. /**
  82613. * An array of images. An image defines data used to create a texture
  82614. */
  82615. images?: IImage[];
  82616. /**
  82617. * An array of materials. A material defines the appearance of a primitive
  82618. */
  82619. materials?: IMaterial[];
  82620. /**
  82621. * An array of meshes. A mesh is a set of primitives to be rendered
  82622. */
  82623. meshes?: IMesh[];
  82624. /**
  82625. * An array of nodes
  82626. */
  82627. nodes?: INode[];
  82628. /**
  82629. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82630. */
  82631. samplers?: ISampler[];
  82632. /**
  82633. * The index of the default scene
  82634. */
  82635. scene?: number;
  82636. /**
  82637. * An array of scenes
  82638. */
  82639. scenes?: IScene[];
  82640. /**
  82641. * An array of skins. A skin is defined by joints and matrices
  82642. */
  82643. skins?: ISkin[];
  82644. /**
  82645. * An array of textures
  82646. */
  82647. textures?: ITexture[];
  82648. }
  82649. /**
  82650. * The glTF validation results
  82651. * @ignore
  82652. */
  82653. interface IGLTFValidationResults {
  82654. info: {
  82655. generator: string;
  82656. hasAnimations: boolean;
  82657. hasDefaultScene: boolean;
  82658. hasMaterials: boolean;
  82659. hasMorphTargets: boolean;
  82660. hasSkins: boolean;
  82661. hasTextures: boolean;
  82662. maxAttributesUsed: number;
  82663. primitivesCount: number
  82664. };
  82665. issues: {
  82666. messages: Array<string>;
  82667. numErrors: number;
  82668. numHints: number;
  82669. numInfos: number;
  82670. numWarnings: number;
  82671. truncated: boolean
  82672. };
  82673. mimeType: string;
  82674. uri: string;
  82675. validatedAt: string;
  82676. validatorVersion: string;
  82677. }
  82678. /**
  82679. * The glTF validation options
  82680. */
  82681. interface IGLTFValidationOptions {
  82682. /** Uri to use */
  82683. uri?: string;
  82684. /** Function used to load external resources */
  82685. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82686. /** Boolean indicating that we need to validate accessor data */
  82687. validateAccessorData?: boolean;
  82688. /** max number of issues allowed */
  82689. maxIssues?: number;
  82690. /** Ignored issues */
  82691. ignoredIssues?: Array<string>;
  82692. /** Value to override severy settings */
  82693. severityOverrides?: Object;
  82694. }
  82695. /**
  82696. * The glTF validator object
  82697. * @ignore
  82698. */
  82699. interface IGLTFValidator {
  82700. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82701. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82702. }
  82703. }
  82704. declare module BABYLON {
  82705. /** @hidden */
  82706. export var cellPixelShader: {
  82707. name: string;
  82708. shader: string;
  82709. };
  82710. }
  82711. declare module BABYLON {
  82712. /** @hidden */
  82713. export var cellVertexShader: {
  82714. name: string;
  82715. shader: string;
  82716. };
  82717. }
  82718. declare module BABYLON {
  82719. export class CellMaterial extends BABYLON.PushMaterial {
  82720. private _diffuseTexture;
  82721. diffuseTexture: BABYLON.BaseTexture;
  82722. diffuseColor: BABYLON.Color3;
  82723. _computeHighLevel: boolean;
  82724. computeHighLevel: boolean;
  82725. private _disableLighting;
  82726. disableLighting: boolean;
  82727. private _maxSimultaneousLights;
  82728. maxSimultaneousLights: number;
  82729. constructor(name: string, scene: BABYLON.Scene);
  82730. needAlphaBlending(): boolean;
  82731. needAlphaTesting(): boolean;
  82732. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82733. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82734. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82735. getAnimatables(): BABYLON.IAnimatable[];
  82736. getActiveTextures(): BABYLON.BaseTexture[];
  82737. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82738. dispose(forceDisposeEffect?: boolean): void;
  82739. getClassName(): string;
  82740. clone(name: string): CellMaterial;
  82741. serialize(): any;
  82742. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82743. }
  82744. }
  82745. declare module BABYLON {
  82746. export class CustomShaderStructure {
  82747. FragmentStore: string;
  82748. VertexStore: string;
  82749. constructor();
  82750. }
  82751. export class ShaderSpecialParts {
  82752. constructor();
  82753. Fragment_Begin: string;
  82754. Fragment_Definitions: string;
  82755. Fragment_MainBegin: string;
  82756. Fragment_Custom_Diffuse: string;
  82757. Fragment_Before_Lights: string;
  82758. Fragment_Before_Fog: string;
  82759. Fragment_Custom_Alpha: string;
  82760. Fragment_Before_FragColor: string;
  82761. Vertex_Begin: string;
  82762. Vertex_Definitions: string;
  82763. Vertex_MainBegin: string;
  82764. Vertex_Before_PositionUpdated: string;
  82765. Vertex_Before_NormalUpdated: string;
  82766. Vertex_After_WorldPosComputed: string;
  82767. Vertex_MainEnd: string;
  82768. }
  82769. export class CustomMaterial extends BABYLON.StandardMaterial {
  82770. static ShaderIndexer: number;
  82771. CustomParts: ShaderSpecialParts;
  82772. _isCreatedShader: boolean;
  82773. _createdShaderName: string;
  82774. _customUniform: string[];
  82775. _newUniforms: string[];
  82776. _newUniformInstances: {
  82777. [name: string]: any;
  82778. };
  82779. _newSamplerInstances: {
  82780. [name: string]: BABYLON.Texture;
  82781. };
  82782. _customAttributes: string[];
  82783. FragmentShader: string;
  82784. VertexShader: string;
  82785. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82786. ReviewUniform(name: string, arr: string[]): string[];
  82787. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82788. constructor(name: string, scene: BABYLON.Scene);
  82789. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82790. AddAttribute(name: string): CustomMaterial;
  82791. Fragment_Begin(shaderPart: string): CustomMaterial;
  82792. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82793. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82794. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82795. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82796. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82797. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82798. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82799. Vertex_Begin(shaderPart: string): CustomMaterial;
  82800. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82801. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82802. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82803. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82804. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82805. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. export class ShaderAlebdoParts {
  82810. constructor();
  82811. Fragment_Begin: string;
  82812. Fragment_Definitions: string;
  82813. Fragment_MainBegin: string;
  82814. Fragment_Custom_Albedo: string;
  82815. Fragment_Before_Lights: string;
  82816. Fragment_Custom_MetallicRoughness: string;
  82817. Fragment_Custom_MicroSurface: string;
  82818. Fragment_Before_Fog: string;
  82819. Fragment_Custom_Alpha: string;
  82820. Fragment_Before_FragColor: string;
  82821. Vertex_Begin: string;
  82822. Vertex_Definitions: string;
  82823. Vertex_MainBegin: string;
  82824. Vertex_Before_PositionUpdated: string;
  82825. Vertex_Before_NormalUpdated: string;
  82826. Vertex_After_WorldPosComputed: string;
  82827. Vertex_MainEnd: string;
  82828. }
  82829. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82830. static ShaderIndexer: number;
  82831. CustomParts: ShaderAlebdoParts;
  82832. _isCreatedShader: boolean;
  82833. _createdShaderName: string;
  82834. _customUniform: string[];
  82835. _newUniforms: string[];
  82836. _newUniformInstances: {
  82837. [name: string]: any;
  82838. };
  82839. _newSamplerInstances: {
  82840. [name: string]: BABYLON.Texture;
  82841. };
  82842. _customAttributes: string[];
  82843. FragmentShader: string;
  82844. VertexShader: string;
  82845. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82846. ReviewUniform(name: string, arr: string[]): string[];
  82847. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82848. constructor(name: string, scene: BABYLON.Scene);
  82849. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82850. AddAttribute(name: string): PBRCustomMaterial;
  82851. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82852. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82853. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82854. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82855. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82856. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82857. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82858. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82859. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82860. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82861. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82862. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82863. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82864. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82865. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82866. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82867. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82868. }
  82869. }
  82870. declare module BABYLON {
  82871. /** @hidden */
  82872. export var firePixelShader: {
  82873. name: string;
  82874. shader: string;
  82875. };
  82876. }
  82877. declare module BABYLON {
  82878. /** @hidden */
  82879. export var fireVertexShader: {
  82880. name: string;
  82881. shader: string;
  82882. };
  82883. }
  82884. declare module BABYLON {
  82885. export class FireMaterial extends BABYLON.PushMaterial {
  82886. private _diffuseTexture;
  82887. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82888. private _distortionTexture;
  82889. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82890. private _opacityTexture;
  82891. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82892. diffuseColor: BABYLON.Color3;
  82893. speed: number;
  82894. private _scaledDiffuse;
  82895. private _lastTime;
  82896. constructor(name: string, scene: BABYLON.Scene);
  82897. needAlphaBlending(): boolean;
  82898. needAlphaTesting(): boolean;
  82899. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82900. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82901. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82902. getAnimatables(): BABYLON.IAnimatable[];
  82903. getActiveTextures(): BABYLON.BaseTexture[];
  82904. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82905. getClassName(): string;
  82906. dispose(forceDisposeEffect?: boolean): void;
  82907. clone(name: string): FireMaterial;
  82908. serialize(): any;
  82909. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82910. }
  82911. }
  82912. declare module BABYLON {
  82913. /** @hidden */
  82914. export var furPixelShader: {
  82915. name: string;
  82916. shader: string;
  82917. };
  82918. }
  82919. declare module BABYLON {
  82920. /** @hidden */
  82921. export var furVertexShader: {
  82922. name: string;
  82923. shader: string;
  82924. };
  82925. }
  82926. declare module BABYLON {
  82927. export class FurMaterial extends BABYLON.PushMaterial {
  82928. private _diffuseTexture;
  82929. diffuseTexture: BABYLON.BaseTexture;
  82930. private _heightTexture;
  82931. heightTexture: BABYLON.BaseTexture;
  82932. diffuseColor: BABYLON.Color3;
  82933. furLength: number;
  82934. furAngle: number;
  82935. furColor: BABYLON.Color3;
  82936. furOffset: number;
  82937. furSpacing: number;
  82938. furGravity: BABYLON.Vector3;
  82939. furSpeed: number;
  82940. furDensity: number;
  82941. furOcclusion: number;
  82942. furTexture: BABYLON.DynamicTexture;
  82943. private _disableLighting;
  82944. disableLighting: boolean;
  82945. private _maxSimultaneousLights;
  82946. maxSimultaneousLights: number;
  82947. highLevelFur: boolean;
  82948. _meshes: BABYLON.AbstractMesh[];
  82949. private _furTime;
  82950. constructor(name: string, scene: BABYLON.Scene);
  82951. get furTime(): number;
  82952. set furTime(furTime: number);
  82953. needAlphaBlending(): boolean;
  82954. needAlphaTesting(): boolean;
  82955. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82956. updateFur(): void;
  82957. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82958. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82959. getAnimatables(): BABYLON.IAnimatable[];
  82960. getActiveTextures(): BABYLON.BaseTexture[];
  82961. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82962. dispose(forceDisposeEffect?: boolean): void;
  82963. clone(name: string): FurMaterial;
  82964. serialize(): any;
  82965. getClassName(): string;
  82966. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82967. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82968. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82969. }
  82970. }
  82971. declare module BABYLON {
  82972. /** @hidden */
  82973. export var gradientPixelShader: {
  82974. name: string;
  82975. shader: string;
  82976. };
  82977. }
  82978. declare module BABYLON {
  82979. /** @hidden */
  82980. export var gradientVertexShader: {
  82981. name: string;
  82982. shader: string;
  82983. };
  82984. }
  82985. declare module BABYLON {
  82986. export class GradientMaterial extends BABYLON.PushMaterial {
  82987. private _maxSimultaneousLights;
  82988. maxSimultaneousLights: number;
  82989. topColor: BABYLON.Color3;
  82990. topColorAlpha: number;
  82991. bottomColor: BABYLON.Color3;
  82992. bottomColorAlpha: number;
  82993. offset: number;
  82994. scale: number;
  82995. smoothness: number;
  82996. private _disableLighting;
  82997. disableLighting: boolean;
  82998. constructor(name: string, scene: BABYLON.Scene);
  82999. needAlphaBlending(): boolean;
  83000. needAlphaTesting(): boolean;
  83001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83004. getAnimatables(): BABYLON.IAnimatable[];
  83005. dispose(forceDisposeEffect?: boolean): void;
  83006. clone(name: string): GradientMaterial;
  83007. serialize(): any;
  83008. getClassName(): string;
  83009. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83010. }
  83011. }
  83012. declare module BABYLON {
  83013. /** @hidden */
  83014. export var gridPixelShader: {
  83015. name: string;
  83016. shader: string;
  83017. };
  83018. }
  83019. declare module BABYLON {
  83020. /** @hidden */
  83021. export var gridVertexShader: {
  83022. name: string;
  83023. shader: string;
  83024. };
  83025. }
  83026. declare module BABYLON {
  83027. /**
  83028. * The grid materials allows you to wrap any shape with a grid.
  83029. * Colors are customizable.
  83030. */
  83031. export class GridMaterial extends BABYLON.PushMaterial {
  83032. /**
  83033. * Main color of the grid (e.g. between lines)
  83034. */
  83035. mainColor: BABYLON.Color3;
  83036. /**
  83037. * Color of the grid lines.
  83038. */
  83039. lineColor: BABYLON.Color3;
  83040. /**
  83041. * The scale of the grid compared to unit.
  83042. */
  83043. gridRatio: number;
  83044. /**
  83045. * Allows setting an offset for the grid lines.
  83046. */
  83047. gridOffset: BABYLON.Vector3;
  83048. /**
  83049. * The frequency of thicker lines.
  83050. */
  83051. majorUnitFrequency: number;
  83052. /**
  83053. * The visibility of minor units in the grid.
  83054. */
  83055. minorUnitVisibility: number;
  83056. /**
  83057. * The grid opacity outside of the lines.
  83058. */
  83059. opacity: number;
  83060. /**
  83061. * Determine RBG output is premultiplied by alpha value.
  83062. */
  83063. preMultiplyAlpha: boolean;
  83064. private _opacityTexture;
  83065. opacityTexture: BABYLON.BaseTexture;
  83066. private _gridControl;
  83067. /**
  83068. * constructor
  83069. * @param name The name given to the material in order to identify it afterwards.
  83070. * @param scene The scene the material is used in.
  83071. */
  83072. constructor(name: string, scene: BABYLON.Scene);
  83073. /**
  83074. * Returns wehter or not the grid requires alpha blending.
  83075. */
  83076. needAlphaBlending(): boolean;
  83077. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83078. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83079. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83080. /**
  83081. * Dispose the material and its associated resources.
  83082. * @param forceDisposeEffect will also dispose the used effect when true
  83083. */
  83084. dispose(forceDisposeEffect?: boolean): void;
  83085. clone(name: string): GridMaterial;
  83086. serialize(): any;
  83087. getClassName(): string;
  83088. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83089. }
  83090. }
  83091. declare module BABYLON {
  83092. /** @hidden */
  83093. export var lavaPixelShader: {
  83094. name: string;
  83095. shader: string;
  83096. };
  83097. }
  83098. declare module BABYLON {
  83099. /** @hidden */
  83100. export var lavaVertexShader: {
  83101. name: string;
  83102. shader: string;
  83103. };
  83104. }
  83105. declare module BABYLON {
  83106. export class LavaMaterial extends BABYLON.PushMaterial {
  83107. private _diffuseTexture;
  83108. diffuseTexture: BABYLON.BaseTexture;
  83109. noiseTexture: BABYLON.BaseTexture;
  83110. fogColor: BABYLON.Color3;
  83111. speed: number;
  83112. movingSpeed: number;
  83113. lowFrequencySpeed: number;
  83114. fogDensity: number;
  83115. private _lastTime;
  83116. diffuseColor: BABYLON.Color3;
  83117. private _disableLighting;
  83118. disableLighting: boolean;
  83119. private _unlit;
  83120. unlit: boolean;
  83121. private _maxSimultaneousLights;
  83122. maxSimultaneousLights: number;
  83123. private _scaledDiffuse;
  83124. constructor(name: string, scene: BABYLON.Scene);
  83125. needAlphaBlending(): boolean;
  83126. needAlphaTesting(): boolean;
  83127. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83128. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83129. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83130. getAnimatables(): BABYLON.IAnimatable[];
  83131. getActiveTextures(): BABYLON.BaseTexture[];
  83132. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83133. dispose(forceDisposeEffect?: boolean): void;
  83134. clone(name: string): LavaMaterial;
  83135. serialize(): any;
  83136. getClassName(): string;
  83137. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83138. }
  83139. }
  83140. declare module BABYLON {
  83141. /** @hidden */
  83142. export var mixPixelShader: {
  83143. name: string;
  83144. shader: string;
  83145. };
  83146. }
  83147. declare module BABYLON {
  83148. /** @hidden */
  83149. export var mixVertexShader: {
  83150. name: string;
  83151. shader: string;
  83152. };
  83153. }
  83154. declare module BABYLON {
  83155. export class MixMaterial extends BABYLON.PushMaterial {
  83156. /**
  83157. * Mix textures
  83158. */
  83159. private _mixTexture1;
  83160. mixTexture1: BABYLON.BaseTexture;
  83161. private _mixTexture2;
  83162. mixTexture2: BABYLON.BaseTexture;
  83163. /**
  83164. * Diffuse textures
  83165. */
  83166. private _diffuseTexture1;
  83167. diffuseTexture1: BABYLON.Texture;
  83168. private _diffuseTexture2;
  83169. diffuseTexture2: BABYLON.Texture;
  83170. private _diffuseTexture3;
  83171. diffuseTexture3: BABYLON.Texture;
  83172. private _diffuseTexture4;
  83173. diffuseTexture4: BABYLON.Texture;
  83174. private _diffuseTexture5;
  83175. diffuseTexture5: BABYLON.Texture;
  83176. private _diffuseTexture6;
  83177. diffuseTexture6: BABYLON.Texture;
  83178. private _diffuseTexture7;
  83179. diffuseTexture7: BABYLON.Texture;
  83180. private _diffuseTexture8;
  83181. diffuseTexture8: BABYLON.Texture;
  83182. /**
  83183. * Uniforms
  83184. */
  83185. diffuseColor: BABYLON.Color3;
  83186. specularColor: BABYLON.Color3;
  83187. specularPower: number;
  83188. private _disableLighting;
  83189. disableLighting: boolean;
  83190. private _maxSimultaneousLights;
  83191. maxSimultaneousLights: number;
  83192. constructor(name: string, scene: BABYLON.Scene);
  83193. needAlphaBlending(): boolean;
  83194. needAlphaTesting(): boolean;
  83195. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83196. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83197. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83198. getAnimatables(): BABYLON.IAnimatable[];
  83199. getActiveTextures(): BABYLON.BaseTexture[];
  83200. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83201. dispose(forceDisposeEffect?: boolean): void;
  83202. clone(name: string): MixMaterial;
  83203. serialize(): any;
  83204. getClassName(): string;
  83205. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /** @hidden */
  83210. export var normalPixelShader: {
  83211. name: string;
  83212. shader: string;
  83213. };
  83214. }
  83215. declare module BABYLON {
  83216. /** @hidden */
  83217. export var normalVertexShader: {
  83218. name: string;
  83219. shader: string;
  83220. };
  83221. }
  83222. declare module BABYLON {
  83223. export class NormalMaterial extends BABYLON.PushMaterial {
  83224. private _diffuseTexture;
  83225. diffuseTexture: BABYLON.BaseTexture;
  83226. diffuseColor: BABYLON.Color3;
  83227. private _disableLighting;
  83228. disableLighting: boolean;
  83229. private _maxSimultaneousLights;
  83230. maxSimultaneousLights: number;
  83231. constructor(name: string, scene: BABYLON.Scene);
  83232. needAlphaBlending(): boolean;
  83233. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83234. needAlphaTesting(): boolean;
  83235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83238. getAnimatables(): BABYLON.IAnimatable[];
  83239. getActiveTextures(): BABYLON.BaseTexture[];
  83240. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83241. dispose(forceDisposeEffect?: boolean): void;
  83242. clone(name: string): NormalMaterial;
  83243. serialize(): any;
  83244. getClassName(): string;
  83245. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83246. }
  83247. }
  83248. declare module BABYLON {
  83249. /** @hidden */
  83250. export var shadowOnlyPixelShader: {
  83251. name: string;
  83252. shader: string;
  83253. };
  83254. }
  83255. declare module BABYLON {
  83256. /** @hidden */
  83257. export var shadowOnlyVertexShader: {
  83258. name: string;
  83259. shader: string;
  83260. };
  83261. }
  83262. declare module BABYLON {
  83263. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83264. private _activeLight;
  83265. private _needAlphaBlending;
  83266. constructor(name: string, scene: BABYLON.Scene);
  83267. shadowColor: BABYLON.Color3;
  83268. needAlphaBlending(): boolean;
  83269. needAlphaTesting(): boolean;
  83270. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83271. get activeLight(): BABYLON.IShadowLight;
  83272. set activeLight(light: BABYLON.IShadowLight);
  83273. private _getFirstShadowLightForMesh;
  83274. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83275. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83276. clone(name: string): ShadowOnlyMaterial;
  83277. serialize(): any;
  83278. getClassName(): string;
  83279. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83280. }
  83281. }
  83282. declare module BABYLON {
  83283. /** @hidden */
  83284. export var simplePixelShader: {
  83285. name: string;
  83286. shader: string;
  83287. };
  83288. }
  83289. declare module BABYLON {
  83290. /** @hidden */
  83291. export var simpleVertexShader: {
  83292. name: string;
  83293. shader: string;
  83294. };
  83295. }
  83296. declare module BABYLON {
  83297. export class SimpleMaterial extends BABYLON.PushMaterial {
  83298. private _diffuseTexture;
  83299. diffuseTexture: BABYLON.BaseTexture;
  83300. diffuseColor: BABYLON.Color3;
  83301. private _disableLighting;
  83302. disableLighting: boolean;
  83303. private _maxSimultaneousLights;
  83304. maxSimultaneousLights: number;
  83305. constructor(name: string, scene: BABYLON.Scene);
  83306. needAlphaBlending(): boolean;
  83307. needAlphaTesting(): boolean;
  83308. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83310. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83311. getAnimatables(): BABYLON.IAnimatable[];
  83312. getActiveTextures(): BABYLON.BaseTexture[];
  83313. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83314. dispose(forceDisposeEffect?: boolean): void;
  83315. clone(name: string): SimpleMaterial;
  83316. serialize(): any;
  83317. getClassName(): string;
  83318. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83319. }
  83320. }
  83321. declare module BABYLON {
  83322. /** @hidden */
  83323. export var skyPixelShader: {
  83324. name: string;
  83325. shader: string;
  83326. };
  83327. }
  83328. declare module BABYLON {
  83329. /** @hidden */
  83330. export var skyVertexShader: {
  83331. name: string;
  83332. shader: string;
  83333. };
  83334. }
  83335. declare module BABYLON {
  83336. /**
  83337. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83338. * @see https://doc.babylonjs.com/extensions/sky
  83339. */
  83340. export class SkyMaterial extends BABYLON.PushMaterial {
  83341. /**
  83342. * Defines the overall luminance of sky in interval ]0, 1[.
  83343. */
  83344. luminance: number;
  83345. /**
  83346. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83347. */
  83348. turbidity: number;
  83349. /**
  83350. * Defines the sky appearance (light intensity).
  83351. */
  83352. rayleigh: number;
  83353. /**
  83354. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83355. */
  83356. mieCoefficient: number;
  83357. /**
  83358. * Defines the amount of haze particles following the Mie scattering theory.
  83359. */
  83360. mieDirectionalG: number;
  83361. /**
  83362. * Defines the distance of the sun according to the active scene camera.
  83363. */
  83364. distance: number;
  83365. /**
  83366. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83367. * "inclined".
  83368. */
  83369. inclination: number;
  83370. /**
  83371. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83372. * an object direction and a reference direction.
  83373. */
  83374. azimuth: number;
  83375. /**
  83376. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83377. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83378. */
  83379. sunPosition: BABYLON.Vector3;
  83380. /**
  83381. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83382. * .sunPosition property.
  83383. */
  83384. useSunPosition: boolean;
  83385. /**
  83386. * Defines an offset vector used to get a horizon offset.
  83387. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83388. */
  83389. cameraOffset: BABYLON.Vector3;
  83390. private _cameraPosition;
  83391. /**
  83392. * Instantiates a new sky material.
  83393. * This material allows to create dynamic and texture free
  83394. * effects for skyboxes by taking care of the atmosphere state.
  83395. * @see https://doc.babylonjs.com/extensions/sky
  83396. * @param name Define the name of the material in the scene
  83397. * @param scene Define the scene the material belong to
  83398. */
  83399. constructor(name: string, scene: BABYLON.Scene);
  83400. /**
  83401. * Specifies if the material will require alpha blending
  83402. * @returns a boolean specifying if alpha blending is needed
  83403. */
  83404. needAlphaBlending(): boolean;
  83405. /**
  83406. * Specifies if this material should be rendered in alpha test mode
  83407. * @returns false as the sky material doesn't need alpha testing.
  83408. */
  83409. needAlphaTesting(): boolean;
  83410. /**
  83411. * Get the texture used for alpha test purpose.
  83412. * @returns null as the sky material has no texture.
  83413. */
  83414. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83415. /**
  83416. * Get if the submesh is ready to be used and all its information available.
  83417. * Child classes can use it to update shaders
  83418. * @param mesh defines the mesh to check
  83419. * @param subMesh defines which submesh to check
  83420. * @param useInstances specifies that instances should be used
  83421. * @returns a boolean indicating that the submesh is ready or not
  83422. */
  83423. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83424. /**
  83425. * Binds the submesh to this material by preparing the effect and shader to draw
  83426. * @param world defines the world transformation matrix
  83427. * @param mesh defines the mesh containing the submesh
  83428. * @param subMesh defines the submesh to bind the material to
  83429. */
  83430. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83431. /**
  83432. * Get the list of animatables in the material.
  83433. * @returns the list of animatables object used in the material
  83434. */
  83435. getAnimatables(): BABYLON.IAnimatable[];
  83436. /**
  83437. * Disposes the material
  83438. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83439. */
  83440. dispose(forceDisposeEffect?: boolean): void;
  83441. /**
  83442. * Makes a duplicate of the material, and gives it a new name
  83443. * @param name defines the new name for the duplicated material
  83444. * @returns the cloned material
  83445. */
  83446. clone(name: string): SkyMaterial;
  83447. /**
  83448. * Serializes this material in a JSON representation
  83449. * @returns the serialized material object
  83450. */
  83451. serialize(): any;
  83452. /**
  83453. * Gets the current class name of the material e.g. "SkyMaterial"
  83454. * Mainly use in serialization.
  83455. * @returns the class name
  83456. */
  83457. getClassName(): string;
  83458. /**
  83459. * Creates a sky material from parsed material data
  83460. * @param source defines the JSON representation of the material
  83461. * @param scene defines the hosting scene
  83462. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83463. * @returns a new sky material
  83464. */
  83465. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83466. }
  83467. }
  83468. declare module BABYLON {
  83469. /** @hidden */
  83470. export var terrainPixelShader: {
  83471. name: string;
  83472. shader: string;
  83473. };
  83474. }
  83475. declare module BABYLON {
  83476. /** @hidden */
  83477. export var terrainVertexShader: {
  83478. name: string;
  83479. shader: string;
  83480. };
  83481. }
  83482. declare module BABYLON {
  83483. export class TerrainMaterial extends BABYLON.PushMaterial {
  83484. private _mixTexture;
  83485. mixTexture: BABYLON.BaseTexture;
  83486. private _diffuseTexture1;
  83487. diffuseTexture1: BABYLON.Texture;
  83488. private _diffuseTexture2;
  83489. diffuseTexture2: BABYLON.Texture;
  83490. private _diffuseTexture3;
  83491. diffuseTexture3: BABYLON.Texture;
  83492. private _bumpTexture1;
  83493. bumpTexture1: BABYLON.Texture;
  83494. private _bumpTexture2;
  83495. bumpTexture2: BABYLON.Texture;
  83496. private _bumpTexture3;
  83497. bumpTexture3: BABYLON.Texture;
  83498. diffuseColor: BABYLON.Color3;
  83499. specularColor: BABYLON.Color3;
  83500. specularPower: number;
  83501. private _disableLighting;
  83502. disableLighting: boolean;
  83503. private _maxSimultaneousLights;
  83504. maxSimultaneousLights: number;
  83505. constructor(name: string, scene: BABYLON.Scene);
  83506. needAlphaBlending(): boolean;
  83507. needAlphaTesting(): boolean;
  83508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83511. getAnimatables(): BABYLON.IAnimatable[];
  83512. getActiveTextures(): BABYLON.BaseTexture[];
  83513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83514. dispose(forceDisposeEffect?: boolean): void;
  83515. clone(name: string): TerrainMaterial;
  83516. serialize(): any;
  83517. getClassName(): string;
  83518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83519. }
  83520. }
  83521. declare module BABYLON {
  83522. /** @hidden */
  83523. export var triplanarPixelShader: {
  83524. name: string;
  83525. shader: string;
  83526. };
  83527. }
  83528. declare module BABYLON {
  83529. /** @hidden */
  83530. export var triplanarVertexShader: {
  83531. name: string;
  83532. shader: string;
  83533. };
  83534. }
  83535. declare module BABYLON {
  83536. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83537. mixTexture: BABYLON.BaseTexture;
  83538. private _diffuseTextureX;
  83539. diffuseTextureX: BABYLON.BaseTexture;
  83540. private _diffuseTextureY;
  83541. diffuseTextureY: BABYLON.BaseTexture;
  83542. private _diffuseTextureZ;
  83543. diffuseTextureZ: BABYLON.BaseTexture;
  83544. private _normalTextureX;
  83545. normalTextureX: BABYLON.BaseTexture;
  83546. private _normalTextureY;
  83547. normalTextureY: BABYLON.BaseTexture;
  83548. private _normalTextureZ;
  83549. normalTextureZ: BABYLON.BaseTexture;
  83550. tileSize: number;
  83551. diffuseColor: BABYLON.Color3;
  83552. specularColor: BABYLON.Color3;
  83553. specularPower: number;
  83554. private _disableLighting;
  83555. disableLighting: boolean;
  83556. private _maxSimultaneousLights;
  83557. maxSimultaneousLights: number;
  83558. constructor(name: string, scene: BABYLON.Scene);
  83559. needAlphaBlending(): boolean;
  83560. needAlphaTesting(): boolean;
  83561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83564. getAnimatables(): BABYLON.IAnimatable[];
  83565. getActiveTextures(): BABYLON.BaseTexture[];
  83566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83567. dispose(forceDisposeEffect?: boolean): void;
  83568. clone(name: string): TriPlanarMaterial;
  83569. serialize(): any;
  83570. getClassName(): string;
  83571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83572. }
  83573. }
  83574. declare module BABYLON {
  83575. /** @hidden */
  83576. export var waterPixelShader: {
  83577. name: string;
  83578. shader: string;
  83579. };
  83580. }
  83581. declare module BABYLON {
  83582. /** @hidden */
  83583. export var waterVertexShader: {
  83584. name: string;
  83585. shader: string;
  83586. };
  83587. }
  83588. declare module BABYLON {
  83589. export class WaterMaterial extends BABYLON.PushMaterial {
  83590. renderTargetSize: BABYLON.Vector2;
  83591. private _bumpTexture;
  83592. bumpTexture: BABYLON.BaseTexture;
  83593. diffuseColor: BABYLON.Color3;
  83594. specularColor: BABYLON.Color3;
  83595. specularPower: number;
  83596. private _disableLighting;
  83597. disableLighting: boolean;
  83598. private _maxSimultaneousLights;
  83599. maxSimultaneousLights: number;
  83600. /**
  83601. * @param {number}: Represents the wind force
  83602. */
  83603. windForce: number;
  83604. /**
  83605. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83606. */
  83607. windDirection: BABYLON.Vector2;
  83608. /**
  83609. * @param {number}: Wave height, represents the height of the waves
  83610. */
  83611. waveHeight: number;
  83612. /**
  83613. * @param {number}: Bump height, represents the bump height related to the bump map
  83614. */
  83615. bumpHeight: number;
  83616. /**
  83617. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83618. */
  83619. private _bumpSuperimpose;
  83620. bumpSuperimpose: boolean;
  83621. /**
  83622. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83623. */
  83624. private _fresnelSeparate;
  83625. fresnelSeparate: boolean;
  83626. /**
  83627. * @param {boolean}: bump Waves modify the reflection.
  83628. */
  83629. private _bumpAffectsReflection;
  83630. bumpAffectsReflection: boolean;
  83631. /**
  83632. * @param {number}: The water color blended with the refraction (near)
  83633. */
  83634. waterColor: BABYLON.Color3;
  83635. /**
  83636. * @param {number}: The blend factor related to the water color
  83637. */
  83638. colorBlendFactor: number;
  83639. /**
  83640. * @param {number}: The water color blended with the reflection (far)
  83641. */
  83642. waterColor2: BABYLON.Color3;
  83643. /**
  83644. * @param {number}: The blend factor related to the water color (reflection, far)
  83645. */
  83646. colorBlendFactor2: number;
  83647. /**
  83648. * @param {number}: Represents the maximum length of a wave
  83649. */
  83650. waveLength: number;
  83651. /**
  83652. * @param {number}: Defines the waves speed
  83653. */
  83654. waveSpeed: number;
  83655. /**
  83656. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83657. * will avoid calculating useless pixels in the pixel shader of the water material.
  83658. */
  83659. disableClipPlane: boolean;
  83660. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83661. private _mesh;
  83662. private _refractionRTT;
  83663. private _reflectionRTT;
  83664. private _reflectionTransform;
  83665. private _lastTime;
  83666. private _lastDeltaTime;
  83667. private _useLogarithmicDepth;
  83668. private _waitingRenderList;
  83669. private _imageProcessingConfiguration;
  83670. private _imageProcessingObserver;
  83671. /**
  83672. * Gets a boolean indicating that current material needs to register RTT
  83673. */
  83674. get hasRenderTargetTextures(): boolean;
  83675. /**
  83676. * Constructor
  83677. */
  83678. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83679. get useLogarithmicDepth(): boolean;
  83680. set useLogarithmicDepth(value: boolean);
  83681. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83682. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83683. addToRenderList(node: any): void;
  83684. enableRenderTargets(enable: boolean): void;
  83685. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83686. get renderTargetsEnabled(): boolean;
  83687. needAlphaBlending(): boolean;
  83688. needAlphaTesting(): boolean;
  83689. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83690. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83691. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83692. private _createRenderTargets;
  83693. getAnimatables(): BABYLON.IAnimatable[];
  83694. getActiveTextures(): BABYLON.BaseTexture[];
  83695. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83696. dispose(forceDisposeEffect?: boolean): void;
  83697. clone(name: string): WaterMaterial;
  83698. serialize(): any;
  83699. getClassName(): string;
  83700. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83701. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83702. }
  83703. }
  83704. declare module BABYLON {
  83705. /** @hidden */
  83706. export var asciiartPixelShader: {
  83707. name: string;
  83708. shader: string;
  83709. };
  83710. }
  83711. declare module BABYLON {
  83712. /**
  83713. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83714. *
  83715. * It basically takes care rendering the font front the given font size to a texture.
  83716. * This is used later on in the postprocess.
  83717. */
  83718. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83719. private _font;
  83720. private _text;
  83721. private _charSize;
  83722. /**
  83723. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83724. */
  83725. get charSize(): number;
  83726. /**
  83727. * Create a new instance of the Ascii Art FontTexture class
  83728. * @param name the name of the texture
  83729. * @param font the font to use, use the W3C CSS notation
  83730. * @param text the caracter set to use in the rendering.
  83731. * @param scene the scene that owns the texture
  83732. */
  83733. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83734. /**
  83735. * Gets the max char width of a font.
  83736. * @param font the font to use, use the W3C CSS notation
  83737. * @return the max char width
  83738. */
  83739. private getFontWidth;
  83740. /**
  83741. * Gets the max char height of a font.
  83742. * @param font the font to use, use the W3C CSS notation
  83743. * @return the max char height
  83744. */
  83745. private getFontHeight;
  83746. /**
  83747. * Clones the current AsciiArtTexture.
  83748. * @return the clone of the texture.
  83749. */
  83750. clone(): AsciiArtFontTexture;
  83751. /**
  83752. * Parses a json object representing the texture and returns an instance of it.
  83753. * @param source the source JSON representation
  83754. * @param scene the scene to create the texture for
  83755. * @return the parsed texture
  83756. */
  83757. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83758. }
  83759. /**
  83760. * Option available in the Ascii Art Post Process.
  83761. */
  83762. export interface IAsciiArtPostProcessOptions {
  83763. /**
  83764. * The font to use following the w3c font definition.
  83765. */
  83766. font?: string;
  83767. /**
  83768. * The character set to use in the postprocess.
  83769. */
  83770. characterSet?: string;
  83771. /**
  83772. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83773. * This number is defined between 0 and 1;
  83774. */
  83775. mixToTile?: number;
  83776. /**
  83777. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83778. * This number is defined between 0 and 1;
  83779. */
  83780. mixToNormal?: number;
  83781. }
  83782. /**
  83783. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83784. *
  83785. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83786. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83787. */
  83788. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83789. /**
  83790. * The font texture used to render the char in the post process.
  83791. */
  83792. private _asciiArtFontTexture;
  83793. /**
  83794. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83795. * This number is defined between 0 and 1;
  83796. */
  83797. mixToTile: number;
  83798. /**
  83799. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83800. * This number is defined between 0 and 1;
  83801. */
  83802. mixToNormal: number;
  83803. /**
  83804. * Instantiates a new Ascii Art Post Process.
  83805. * @param name the name to give to the postprocess
  83806. * @camera the camera to apply the post process to.
  83807. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83808. */
  83809. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83810. }
  83811. }
  83812. declare module BABYLON {
  83813. /** @hidden */
  83814. export var digitalrainPixelShader: {
  83815. name: string;
  83816. shader: string;
  83817. };
  83818. }
  83819. declare module BABYLON {
  83820. /**
  83821. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83822. *
  83823. * It basically takes care rendering the font front the given font size to a texture.
  83824. * This is used later on in the postprocess.
  83825. */
  83826. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83827. private _font;
  83828. private _text;
  83829. private _charSize;
  83830. /**
  83831. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83832. */
  83833. get charSize(): number;
  83834. /**
  83835. * Create a new instance of the Digital Rain FontTexture class
  83836. * @param name the name of the texture
  83837. * @param font the font to use, use the W3C CSS notation
  83838. * @param text the caracter set to use in the rendering.
  83839. * @param scene the scene that owns the texture
  83840. */
  83841. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83842. /**
  83843. * Gets the max char width of a font.
  83844. * @param font the font to use, use the W3C CSS notation
  83845. * @return the max char width
  83846. */
  83847. private getFontWidth;
  83848. /**
  83849. * Gets the max char height of a font.
  83850. * @param font the font to use, use the W3C CSS notation
  83851. * @return the max char height
  83852. */
  83853. private getFontHeight;
  83854. /**
  83855. * Clones the current DigitalRainFontTexture.
  83856. * @return the clone of the texture.
  83857. */
  83858. clone(): DigitalRainFontTexture;
  83859. /**
  83860. * Parses a json object representing the texture and returns an instance of it.
  83861. * @param source the source JSON representation
  83862. * @param scene the scene to create the texture for
  83863. * @return the parsed texture
  83864. */
  83865. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83866. }
  83867. /**
  83868. * Option available in the Digital Rain Post Process.
  83869. */
  83870. export interface IDigitalRainPostProcessOptions {
  83871. /**
  83872. * The font to use following the w3c font definition.
  83873. */
  83874. font?: string;
  83875. /**
  83876. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83877. * This number is defined between 0 and 1;
  83878. */
  83879. mixToTile?: number;
  83880. /**
  83881. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83882. * This number is defined between 0 and 1;
  83883. */
  83884. mixToNormal?: number;
  83885. }
  83886. /**
  83887. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83888. *
  83889. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83890. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83891. */
  83892. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83893. /**
  83894. * The font texture used to render the char in the post process.
  83895. */
  83896. private _digitalRainFontTexture;
  83897. /**
  83898. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83899. * This number is defined between 0 and 1;
  83900. */
  83901. mixToTile: number;
  83902. /**
  83903. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83904. * This number is defined between 0 and 1;
  83905. */
  83906. mixToNormal: number;
  83907. /**
  83908. * Instantiates a new Digital Rain Post Process.
  83909. * @param name the name to give to the postprocess
  83910. * @camera the camera to apply the post process to.
  83911. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83912. */
  83913. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83914. }
  83915. }
  83916. declare module BABYLON {
  83917. /** @hidden */
  83918. export var brickProceduralTexturePixelShader: {
  83919. name: string;
  83920. shader: string;
  83921. };
  83922. }
  83923. declare module BABYLON {
  83924. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83925. private _numberOfBricksHeight;
  83926. private _numberOfBricksWidth;
  83927. private _jointColor;
  83928. private _brickColor;
  83929. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83930. updateShaderUniforms(): void;
  83931. get numberOfBricksHeight(): number;
  83932. set numberOfBricksHeight(value: number);
  83933. get numberOfBricksWidth(): number;
  83934. set numberOfBricksWidth(value: number);
  83935. get jointColor(): BABYLON.Color3;
  83936. set jointColor(value: BABYLON.Color3);
  83937. get brickColor(): BABYLON.Color3;
  83938. set brickColor(value: BABYLON.Color3);
  83939. /**
  83940. * Serializes this brick procedural texture
  83941. * @returns a serialized brick procedural texture object
  83942. */
  83943. serialize(): any;
  83944. /**
  83945. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83946. * @param parsedTexture defines parsed texture data
  83947. * @param scene defines the current scene
  83948. * @param rootUrl defines the root URL containing brick procedural texture information
  83949. * @returns a parsed Brick Procedural BABYLON.Texture
  83950. */
  83951. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83952. }
  83953. }
  83954. declare module BABYLON {
  83955. /** @hidden */
  83956. export var cloudProceduralTexturePixelShader: {
  83957. name: string;
  83958. shader: string;
  83959. };
  83960. }
  83961. declare module BABYLON {
  83962. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83963. private _skyColor;
  83964. private _cloudColor;
  83965. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83966. updateShaderUniforms(): void;
  83967. get skyColor(): BABYLON.Color4;
  83968. set skyColor(value: BABYLON.Color4);
  83969. get cloudColor(): BABYLON.Color4;
  83970. set cloudColor(value: BABYLON.Color4);
  83971. /**
  83972. * Serializes this cloud procedural texture
  83973. * @returns a serialized cloud procedural texture object
  83974. */
  83975. serialize(): any;
  83976. /**
  83977. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83978. * @param parsedTexture defines parsed texture data
  83979. * @param scene defines the current scene
  83980. * @param rootUrl defines the root URL containing cloud procedural texture information
  83981. * @returns a parsed Cloud Procedural BABYLON.Texture
  83982. */
  83983. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83984. }
  83985. }
  83986. declare module BABYLON {
  83987. /** @hidden */
  83988. export var fireProceduralTexturePixelShader: {
  83989. name: string;
  83990. shader: string;
  83991. };
  83992. }
  83993. declare module BABYLON {
  83994. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83995. private _time;
  83996. private _speed;
  83997. private _autoGenerateTime;
  83998. private _fireColors;
  83999. private _alphaThreshold;
  84000. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84001. updateShaderUniforms(): void;
  84002. render(useCameraPostProcess?: boolean): void;
  84003. static get PurpleFireColors(): BABYLON.Color3[];
  84004. static get GreenFireColors(): BABYLON.Color3[];
  84005. static get RedFireColors(): BABYLON.Color3[];
  84006. static get BlueFireColors(): BABYLON.Color3[];
  84007. get autoGenerateTime(): boolean;
  84008. set autoGenerateTime(value: boolean);
  84009. get fireColors(): BABYLON.Color3[];
  84010. set fireColors(value: BABYLON.Color3[]);
  84011. get time(): number;
  84012. set time(value: number);
  84013. get speed(): BABYLON.Vector2;
  84014. set speed(value: BABYLON.Vector2);
  84015. get alphaThreshold(): number;
  84016. set alphaThreshold(value: number);
  84017. /**
  84018. * Serializes this fire procedural texture
  84019. * @returns a serialized fire procedural texture object
  84020. */
  84021. serialize(): any;
  84022. /**
  84023. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84024. * @param parsedTexture defines parsed texture data
  84025. * @param scene defines the current scene
  84026. * @param rootUrl defines the root URL containing fire procedural texture information
  84027. * @returns a parsed Fire Procedural BABYLON.Texture
  84028. */
  84029. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84030. }
  84031. }
  84032. declare module BABYLON {
  84033. /** @hidden */
  84034. export var grassProceduralTexturePixelShader: {
  84035. name: string;
  84036. shader: string;
  84037. };
  84038. }
  84039. declare module BABYLON {
  84040. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84041. private _grassColors;
  84042. private _groundColor;
  84043. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84044. updateShaderUniforms(): void;
  84045. get grassColors(): BABYLON.Color3[];
  84046. set grassColors(value: BABYLON.Color3[]);
  84047. get groundColor(): BABYLON.Color3;
  84048. set groundColor(value: BABYLON.Color3);
  84049. /**
  84050. * Serializes this grass procedural texture
  84051. * @returns a serialized grass procedural texture object
  84052. */
  84053. serialize(): any;
  84054. /**
  84055. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84056. * @param parsedTexture defines parsed texture data
  84057. * @param scene defines the current scene
  84058. * @param rootUrl defines the root URL containing grass procedural texture information
  84059. * @returns a parsed Grass Procedural BABYLON.Texture
  84060. */
  84061. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84062. }
  84063. }
  84064. declare module BABYLON {
  84065. /** @hidden */
  84066. export var marbleProceduralTexturePixelShader: {
  84067. name: string;
  84068. shader: string;
  84069. };
  84070. }
  84071. declare module BABYLON {
  84072. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84073. private _numberOfTilesHeight;
  84074. private _numberOfTilesWidth;
  84075. private _amplitude;
  84076. private _jointColor;
  84077. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84078. updateShaderUniforms(): void;
  84079. get numberOfTilesHeight(): number;
  84080. set numberOfTilesHeight(value: number);
  84081. get amplitude(): number;
  84082. set amplitude(value: number);
  84083. get numberOfTilesWidth(): number;
  84084. set numberOfTilesWidth(value: number);
  84085. get jointColor(): BABYLON.Color3;
  84086. set jointColor(value: BABYLON.Color3);
  84087. /**
  84088. * Serializes this marble procedural texture
  84089. * @returns a serialized marble procedural texture object
  84090. */
  84091. serialize(): any;
  84092. /**
  84093. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84094. * @param parsedTexture defines parsed texture data
  84095. * @param scene defines the current scene
  84096. * @param rootUrl defines the root URL containing marble procedural texture information
  84097. * @returns a parsed Marble Procedural BABYLON.Texture
  84098. */
  84099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84100. }
  84101. }
  84102. declare module BABYLON {
  84103. /** @hidden */
  84104. export var normalMapProceduralTexturePixelShader: {
  84105. name: string;
  84106. shader: string;
  84107. };
  84108. }
  84109. declare module BABYLON {
  84110. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84111. private _baseTexture;
  84112. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84113. updateShaderUniforms(): void;
  84114. render(useCameraPostProcess?: boolean): void;
  84115. resize(size: any, generateMipMaps: any): void;
  84116. get baseTexture(): BABYLON.Texture;
  84117. set baseTexture(texture: BABYLON.Texture);
  84118. /**
  84119. * Serializes this normal map procedural texture
  84120. * @returns a serialized normal map procedural texture object
  84121. */
  84122. serialize(): any;
  84123. /**
  84124. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84125. * @param parsedTexture defines parsed texture data
  84126. * @param scene defines the current scene
  84127. * @param rootUrl defines the root URL containing normal map procedural texture information
  84128. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84129. */
  84130. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84131. }
  84132. }
  84133. declare module BABYLON {
  84134. /** @hidden */
  84135. export var perlinNoiseProceduralTexturePixelShader: {
  84136. name: string;
  84137. shader: string;
  84138. };
  84139. }
  84140. declare module BABYLON {
  84141. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84142. time: number;
  84143. timeScale: number;
  84144. translationSpeed: number;
  84145. private _currentTranslation;
  84146. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84147. updateShaderUniforms(): void;
  84148. render(useCameraPostProcess?: boolean): void;
  84149. resize(size: any, generateMipMaps: any): void;
  84150. /**
  84151. * Serializes this perlin noise procedural texture
  84152. * @returns a serialized perlin noise procedural texture object
  84153. */
  84154. serialize(): any;
  84155. /**
  84156. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84157. * @param parsedTexture defines parsed texture data
  84158. * @param scene defines the current scene
  84159. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84160. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84161. */
  84162. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84163. }
  84164. }
  84165. declare module BABYLON {
  84166. /** @hidden */
  84167. export var roadProceduralTexturePixelShader: {
  84168. name: string;
  84169. shader: string;
  84170. };
  84171. }
  84172. declare module BABYLON {
  84173. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84174. private _roadColor;
  84175. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84176. updateShaderUniforms(): void;
  84177. get roadColor(): BABYLON.Color3;
  84178. set roadColor(value: BABYLON.Color3);
  84179. /**
  84180. * Serializes this road procedural texture
  84181. * @returns a serialized road procedural texture object
  84182. */
  84183. serialize(): any;
  84184. /**
  84185. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84186. * @param parsedTexture defines parsed texture data
  84187. * @param scene defines the current scene
  84188. * @param rootUrl defines the root URL containing road procedural texture information
  84189. * @returns a parsed Road Procedural BABYLON.Texture
  84190. */
  84191. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84192. }
  84193. }
  84194. declare module BABYLON {
  84195. /** @hidden */
  84196. export var starfieldProceduralTexturePixelShader: {
  84197. name: string;
  84198. shader: string;
  84199. };
  84200. }
  84201. declare module BABYLON {
  84202. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84203. private _time;
  84204. private _alpha;
  84205. private _beta;
  84206. private _zoom;
  84207. private _formuparam;
  84208. private _stepsize;
  84209. private _tile;
  84210. private _brightness;
  84211. private _darkmatter;
  84212. private _distfading;
  84213. private _saturation;
  84214. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84215. updateShaderUniforms(): void;
  84216. get time(): number;
  84217. set time(value: number);
  84218. get alpha(): number;
  84219. set alpha(value: number);
  84220. get beta(): number;
  84221. set beta(value: number);
  84222. get formuparam(): number;
  84223. set formuparam(value: number);
  84224. get stepsize(): number;
  84225. set stepsize(value: number);
  84226. get zoom(): number;
  84227. set zoom(value: number);
  84228. get tile(): number;
  84229. set tile(value: number);
  84230. get brightness(): number;
  84231. set brightness(value: number);
  84232. get darkmatter(): number;
  84233. set darkmatter(value: number);
  84234. get distfading(): number;
  84235. set distfading(value: number);
  84236. get saturation(): number;
  84237. set saturation(value: number);
  84238. /**
  84239. * Serializes this starfield procedural texture
  84240. * @returns a serialized starfield procedural texture object
  84241. */
  84242. serialize(): any;
  84243. /**
  84244. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84245. * @param parsedTexture defines parsed texture data
  84246. * @param scene defines the current scene
  84247. * @param rootUrl defines the root URL containing startfield procedural texture information
  84248. * @returns a parsed Starfield Procedural BABYLON.Texture
  84249. */
  84250. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84251. }
  84252. }
  84253. declare module BABYLON {
  84254. /** @hidden */
  84255. export var woodProceduralTexturePixelShader: {
  84256. name: string;
  84257. shader: string;
  84258. };
  84259. }
  84260. declare module BABYLON {
  84261. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84262. private _ampScale;
  84263. private _woodColor;
  84264. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84265. updateShaderUniforms(): void;
  84266. get ampScale(): number;
  84267. set ampScale(value: number);
  84268. get woodColor(): BABYLON.Color3;
  84269. set woodColor(value: BABYLON.Color3);
  84270. /**
  84271. * Serializes this wood procedural texture
  84272. * @returns a serialized wood procedural texture object
  84273. */
  84274. serialize(): any;
  84275. /**
  84276. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84277. * @param parsedTexture defines parsed texture data
  84278. * @param scene defines the current scene
  84279. * @param rootUrl defines the root URL containing wood procedural texture information
  84280. * @returns a parsed Wood Procedural BABYLON.Texture
  84281. */
  84282. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84283. }
  84284. }