documentation.d.ts 3.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364
  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. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1754. * @param start start value
  1755. * @param end target value
  1756. * @param amount amount to lerp between
  1757. * @returns the lerped value
  1758. */
  1759. static Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * 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".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * 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"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * 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"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * 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)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * 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
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. 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;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. 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;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * 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"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * 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".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * 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"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * 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".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * 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.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * 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)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @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
  4932. * @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
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. 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);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float 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. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector 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. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. 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;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. constructor(rootUrl: string, scene: Scene, 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);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * 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;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * 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).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * 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).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * 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.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * 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.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * 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.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * 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.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * 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.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * 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.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * 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).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * 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).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * 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.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * 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.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * 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.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * 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.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * 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.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * 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.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * 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).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * 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).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * 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.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * 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.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * 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.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * 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.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * 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.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * 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.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * 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).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * 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).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * 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.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * 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.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * 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.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * 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.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * 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.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * 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.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * 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)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var shadowMapFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragmentDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var clipPlaneFragment: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var shadowMapFragment: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var shadowMapPixelShader: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var bonesDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var morphTargetsVertexGlobalDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var morphTargetsVertexDeclaration: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var instancesDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var helperFunctions: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexDeclaration: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var clipPlaneVertexDeclaration: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var morphTargetsVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var instancesVertex: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var bonesVertex: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /** @hidden */
  9452. export var shadowMapVertexNormalBias: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module BABYLON {
  9458. /** @hidden */
  9459. export var shadowMapVertexMetric: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module BABYLON {
  9465. /** @hidden */
  9466. export var clipPlaneVertex: {
  9467. name: string;
  9468. shader: string;
  9469. };
  9470. }
  9471. declare module BABYLON {
  9472. /** @hidden */
  9473. export var shadowMapVertexShader: {
  9474. name: string;
  9475. shader: string;
  9476. };
  9477. }
  9478. declare module BABYLON {
  9479. /** @hidden */
  9480. export var depthBoxBlurPixelShader: {
  9481. name: string;
  9482. shader: string;
  9483. };
  9484. }
  9485. declare module BABYLON {
  9486. /**
  9487. * Class representing a ray with position and direction
  9488. */
  9489. export class Ray {
  9490. /** origin point */
  9491. origin: Vector3;
  9492. /** direction */
  9493. direction: Vector3;
  9494. /** length of the ray */
  9495. length: number;
  9496. private static readonly TmpVector3;
  9497. private _tmpRay;
  9498. /**
  9499. * Creates a new ray
  9500. * @param origin origin point
  9501. * @param direction direction
  9502. * @param length length of the ray
  9503. */
  9504. constructor(
  9505. /** origin point */
  9506. origin: Vector3,
  9507. /** direction */
  9508. direction: Vector3,
  9509. /** length of the ray */
  9510. length?: number);
  9511. /**
  9512. * Checks if the ray intersects a box
  9513. * This does not account for the ray lenght by design to improve perfs.
  9514. * @param minimum bound of the box
  9515. * @param maximum bound of the box
  9516. * @param intersectionTreshold extra extend to be added to the box in all direction
  9517. * @returns if the box was hit
  9518. */
  9519. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9520. /**
  9521. * Checks if the ray intersects a box
  9522. * This does not account for the ray lenght by design to improve perfs.
  9523. * @param box the bounding box to check
  9524. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9525. * @returns if the box was hit
  9526. */
  9527. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9528. /**
  9529. * If the ray hits a sphere
  9530. * @param sphere the bounding sphere to check
  9531. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9532. * @returns true if it hits the sphere
  9533. */
  9534. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9535. /**
  9536. * If the ray hits a triange
  9537. * @param vertex0 triangle vertex
  9538. * @param vertex1 triangle vertex
  9539. * @param vertex2 triangle vertex
  9540. * @returns intersection information if hit
  9541. */
  9542. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9543. /**
  9544. * Checks if ray intersects a plane
  9545. * @param plane the plane to check
  9546. * @returns the distance away it was hit
  9547. */
  9548. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9549. /**
  9550. * Calculate the intercept of a ray on a given axis
  9551. * @param axis to check 'x' | 'y' | 'z'
  9552. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9553. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9554. */
  9555. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9556. /**
  9557. * Checks if ray intersects a mesh
  9558. * @param mesh the mesh to check
  9559. * @param fastCheck if only the bounding box should checked
  9560. * @returns picking info of the intersecton
  9561. */
  9562. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9563. /**
  9564. * Checks if ray intersects a mesh
  9565. * @param meshes the meshes to check
  9566. * @param fastCheck if only the bounding box should checked
  9567. * @param results array to store result in
  9568. * @returns Array of picking infos
  9569. */
  9570. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9571. private _comparePickingInfo;
  9572. private static smallnum;
  9573. private static rayl;
  9574. /**
  9575. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9576. * @param sega the first point of the segment to test the intersection against
  9577. * @param segb the second point of the segment to test the intersection against
  9578. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9579. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9580. */
  9581. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9582. /**
  9583. * Update the ray from viewport position
  9584. * @param x position
  9585. * @param y y position
  9586. * @param viewportWidth viewport width
  9587. * @param viewportHeight viewport height
  9588. * @param world world matrix
  9589. * @param view view matrix
  9590. * @param projection projection matrix
  9591. * @returns this ray updated
  9592. */
  9593. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9594. /**
  9595. * Creates a ray with origin and direction of 0,0,0
  9596. * @returns the new ray
  9597. */
  9598. static Zero(): Ray;
  9599. /**
  9600. * Creates a new ray from screen space and viewport
  9601. * @param x position
  9602. * @param y y position
  9603. * @param viewportWidth viewport width
  9604. * @param viewportHeight viewport height
  9605. * @param world world matrix
  9606. * @param view view matrix
  9607. * @param projection projection matrix
  9608. * @returns new ray
  9609. */
  9610. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9611. /**
  9612. * 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
  9613. * transformed to the given world matrix.
  9614. * @param origin The origin point
  9615. * @param end The end point
  9616. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9617. * @returns the new ray
  9618. */
  9619. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9620. /**
  9621. * Transforms a ray by a matrix
  9622. * @param ray ray to transform
  9623. * @param matrix matrix to apply
  9624. * @returns the resulting new ray
  9625. */
  9626. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9627. /**
  9628. * Transforms a ray by a matrix
  9629. * @param ray ray to transform
  9630. * @param matrix matrix to apply
  9631. * @param result ray to store result in
  9632. */
  9633. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9634. /**
  9635. * Unproject a ray from screen space to object space
  9636. * @param sourceX defines the screen space x coordinate to use
  9637. * @param sourceY defines the screen space y coordinate to use
  9638. * @param viewportWidth defines the current width of the viewport
  9639. * @param viewportHeight defines the current height of the viewport
  9640. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9641. * @param view defines the view matrix to use
  9642. * @param projection defines the projection matrix to use
  9643. */
  9644. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9645. }
  9646. /**
  9647. * Type used to define predicate used to select faces when a mesh intersection is detected
  9648. */
  9649. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9650. interface Scene {
  9651. /** @hidden */
  9652. _tempPickingRay: Nullable<Ray>;
  9653. /** @hidden */
  9654. _cachedRayForTransform: Ray;
  9655. /** @hidden */
  9656. _pickWithRayInverseMatrix: Matrix;
  9657. /** @hidden */
  9658. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9659. /** @hidden */
  9660. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9661. }
  9662. }
  9663. declare module BABYLON {
  9664. /**
  9665. * Groups all the scene component constants in one place to ease maintenance.
  9666. * @hidden
  9667. */
  9668. export class SceneComponentConstants {
  9669. static readonly NAME_EFFECTLAYER: string;
  9670. static readonly NAME_LAYER: string;
  9671. static readonly NAME_LENSFLARESYSTEM: string;
  9672. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9673. static readonly NAME_PARTICLESYSTEM: string;
  9674. static readonly NAME_GAMEPAD: string;
  9675. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9676. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9677. static readonly NAME_DEPTHRENDERER: string;
  9678. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9679. static readonly NAME_SPRITE: string;
  9680. static readonly NAME_OUTLINERENDERER: string;
  9681. static readonly NAME_PROCEDURALTEXTURE: string;
  9682. static readonly NAME_SHADOWGENERATOR: string;
  9683. static readonly NAME_OCTREE: string;
  9684. static readonly NAME_PHYSICSENGINE: string;
  9685. static readonly NAME_AUDIO: string;
  9686. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9687. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9688. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9689. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9690. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9691. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9692. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9693. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9694. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9695. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9696. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9697. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9698. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9699. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9700. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9701. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9702. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9703. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9704. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9705. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9706. static readonly STEP_AFTERRENDER_AUDIO: number;
  9707. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9708. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9709. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9710. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9711. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9712. static readonly STEP_POINTERMOVE_SPRITE: number;
  9713. static readonly STEP_POINTERDOWN_SPRITE: number;
  9714. static readonly STEP_POINTERUP_SPRITE: number;
  9715. }
  9716. /**
  9717. * This represents a scene component.
  9718. *
  9719. * This is used to decouple the dependency the scene is having on the different workloads like
  9720. * layers, post processes...
  9721. */
  9722. export interface ISceneComponent {
  9723. /**
  9724. * The name of the component. Each component must have a unique name.
  9725. */
  9726. name: string;
  9727. /**
  9728. * The scene the component belongs to.
  9729. */
  9730. scene: Scene;
  9731. /**
  9732. * Register the component to one instance of a scene.
  9733. */
  9734. register(): void;
  9735. /**
  9736. * Rebuilds the elements related to this component in case of
  9737. * context lost for instance.
  9738. */
  9739. rebuild(): void;
  9740. /**
  9741. * Disposes the component and the associated ressources.
  9742. */
  9743. dispose(): void;
  9744. }
  9745. /**
  9746. * This represents a SERIALIZABLE scene component.
  9747. *
  9748. * This extends Scene Component to add Serialization methods on top.
  9749. */
  9750. export interface ISceneSerializableComponent extends ISceneComponent {
  9751. /**
  9752. * Adds all the elements from the container to the scene
  9753. * @param container the container holding the elements
  9754. */
  9755. addFromContainer(container: AbstractScene): void;
  9756. /**
  9757. * Removes all the elements in the container from the scene
  9758. * @param container contains the elements to remove
  9759. * @param dispose if the removed element should be disposed (default: false)
  9760. */
  9761. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9762. /**
  9763. * Serializes the component data to the specified json object
  9764. * @param serializationObject The object to serialize to
  9765. */
  9766. serialize(serializationObject: any): void;
  9767. }
  9768. /**
  9769. * Strong typing of a Mesh related stage step action
  9770. */
  9771. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9772. /**
  9773. * Strong typing of a Evaluate Sub Mesh related stage step action
  9774. */
  9775. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9776. /**
  9777. * Strong typing of a Active Mesh related stage step action
  9778. */
  9779. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9780. /**
  9781. * Strong typing of a Camera related stage step action
  9782. */
  9783. export type CameraStageAction = (camera: Camera) => void;
  9784. /**
  9785. * Strong typing of a Camera Frame buffer related stage step action
  9786. */
  9787. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9788. /**
  9789. * Strong typing of a Render Target related stage step action
  9790. */
  9791. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9792. /**
  9793. * Strong typing of a RenderingGroup related stage step action
  9794. */
  9795. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9796. /**
  9797. * Strong typing of a Mesh Render related stage step action
  9798. */
  9799. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9800. /**
  9801. * Strong typing of a simple stage step action
  9802. */
  9803. export type SimpleStageAction = () => void;
  9804. /**
  9805. * Strong typing of a render target action.
  9806. */
  9807. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9808. /**
  9809. * Strong typing of a pointer move action.
  9810. */
  9811. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9812. /**
  9813. * Strong typing of a pointer up/down action.
  9814. */
  9815. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9816. /**
  9817. * Representation of a stage in the scene (Basically a list of ordered steps)
  9818. * @hidden
  9819. */
  9820. export class Stage<T extends Function> extends Array<{
  9821. index: number;
  9822. component: ISceneComponent;
  9823. action: T;
  9824. }> {
  9825. /**
  9826. * Hide ctor from the rest of the world.
  9827. * @param items The items to add.
  9828. */
  9829. private constructor();
  9830. /**
  9831. * Creates a new Stage.
  9832. * @returns A new instance of a Stage
  9833. */
  9834. static Create<T extends Function>(): Stage<T>;
  9835. /**
  9836. * Registers a step in an ordered way in the targeted stage.
  9837. * @param index Defines the position to register the step in
  9838. * @param component Defines the component attached to the step
  9839. * @param action Defines the action to launch during the step
  9840. */
  9841. registerStep(index: number, component: ISceneComponent, action: T): void;
  9842. /**
  9843. * Clears all the steps from the stage.
  9844. */
  9845. clear(): void;
  9846. }
  9847. }
  9848. declare module BABYLON {
  9849. interface Scene {
  9850. /** @hidden */
  9851. _pointerOverSprite: Nullable<Sprite>;
  9852. /** @hidden */
  9853. _pickedDownSprite: Nullable<Sprite>;
  9854. /** @hidden */
  9855. _tempSpritePickingRay: Nullable<Ray>;
  9856. /**
  9857. * All of the sprite managers added to this scene
  9858. * @see http://doc.babylonjs.com/babylon101/sprites
  9859. */
  9860. spriteManagers: Array<ISpriteManager>;
  9861. /**
  9862. * An event triggered when sprites rendering is about to start
  9863. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9864. */
  9865. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9866. /**
  9867. * An event triggered when sprites rendering is done
  9868. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9869. */
  9870. onAfterSpritesRenderingObservable: Observable<Scene>;
  9871. /** @hidden */
  9872. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9873. /** Launch a ray to try to pick a sprite in the scene
  9874. * @param x position on screen
  9875. * @param y position on screen
  9876. * @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
  9877. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9878. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9879. * @returns a PickingInfo
  9880. */
  9881. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9882. /** Use the given ray to pick a sprite in the scene
  9883. * @param ray The ray (in world space) to use to pick meshes
  9884. * @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
  9885. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9886. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9887. * @returns a PickingInfo
  9888. */
  9889. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9890. /** @hidden */
  9891. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9892. /** Launch a ray to try to pick sprites in the scene
  9893. * @param x position on screen
  9894. * @param y position on screen
  9895. * @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
  9896. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9897. * @returns a PickingInfo array
  9898. */
  9899. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9900. /** Use the given ray to pick sprites in the scene
  9901. * @param ray The ray (in world space) to use to pick meshes
  9902. * @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
  9903. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9904. * @returns a PickingInfo array
  9905. */
  9906. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9907. /**
  9908. * Force the sprite under the pointer
  9909. * @param sprite defines the sprite to use
  9910. */
  9911. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9912. /**
  9913. * Gets the sprite under the pointer
  9914. * @returns a Sprite or null if no sprite is under the pointer
  9915. */
  9916. getPointerOverSprite(): Nullable<Sprite>;
  9917. }
  9918. /**
  9919. * Defines the sprite scene component responsible to manage sprites
  9920. * in a given scene.
  9921. */
  9922. export class SpriteSceneComponent implements ISceneComponent {
  9923. /**
  9924. * The component name helpfull to identify the component in the list of scene components.
  9925. */
  9926. readonly name: string;
  9927. /**
  9928. * The scene the component belongs to.
  9929. */
  9930. scene: Scene;
  9931. /** @hidden */
  9932. private _spritePredicate;
  9933. /**
  9934. * Creates a new instance of the component for the given scene
  9935. * @param scene Defines the scene to register the component in
  9936. */
  9937. constructor(scene: Scene);
  9938. /**
  9939. * Registers the component in a given scene
  9940. */
  9941. register(): void;
  9942. /**
  9943. * Rebuilds the elements related to this component in case of
  9944. * context lost for instance.
  9945. */
  9946. rebuild(): void;
  9947. /**
  9948. * Disposes the component and the associated ressources.
  9949. */
  9950. dispose(): void;
  9951. private _pickSpriteButKeepRay;
  9952. private _pointerMove;
  9953. private _pointerDown;
  9954. private _pointerUp;
  9955. }
  9956. }
  9957. declare module BABYLON {
  9958. /** @hidden */
  9959. export var fogFragmentDeclaration: {
  9960. name: string;
  9961. shader: string;
  9962. };
  9963. }
  9964. declare module BABYLON {
  9965. /** @hidden */
  9966. export var fogFragment: {
  9967. name: string;
  9968. shader: string;
  9969. };
  9970. }
  9971. declare module BABYLON {
  9972. /** @hidden */
  9973. export var spritesPixelShader: {
  9974. name: string;
  9975. shader: string;
  9976. };
  9977. }
  9978. declare module BABYLON {
  9979. /** @hidden */
  9980. export var fogVertexDeclaration: {
  9981. name: string;
  9982. shader: string;
  9983. };
  9984. }
  9985. declare module BABYLON {
  9986. /** @hidden */
  9987. export var spritesVertexShader: {
  9988. name: string;
  9989. shader: string;
  9990. };
  9991. }
  9992. declare module BABYLON {
  9993. /**
  9994. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9995. */
  9996. export interface ISpriteManager extends IDisposable {
  9997. /**
  9998. * Restricts the camera to viewing objects with the same layerMask.
  9999. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10000. */
  10001. layerMask: number;
  10002. /**
  10003. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10004. */
  10005. isPickable: boolean;
  10006. /**
  10007. * Specifies the rendering group id for this mesh (0 by default)
  10008. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10009. */
  10010. renderingGroupId: number;
  10011. /**
  10012. * Defines the list of sprites managed by the manager.
  10013. */
  10014. sprites: Array<Sprite>;
  10015. /**
  10016. * Tests the intersection of a sprite with a specific ray.
  10017. * @param ray The ray we are sending to test the collision
  10018. * @param camera The camera space we are sending rays in
  10019. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10020. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10021. * @returns picking info or null.
  10022. */
  10023. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10024. /**
  10025. * Intersects the sprites with a ray
  10026. * @param ray defines the ray to intersect with
  10027. * @param camera defines the current active camera
  10028. * @param predicate defines a predicate used to select candidate sprites
  10029. * @returns null if no hit or a PickingInfo array
  10030. */
  10031. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10032. /**
  10033. * Renders the list of sprites on screen.
  10034. */
  10035. render(): void;
  10036. }
  10037. /**
  10038. * Class used to manage multiple sprites on the same spritesheet
  10039. * @see http://doc.babylonjs.com/babylon101/sprites
  10040. */
  10041. export class SpriteManager implements ISpriteManager {
  10042. /** defines the manager's name */
  10043. name: string;
  10044. /** Gets the list of sprites */
  10045. sprites: Sprite[];
  10046. /** Gets or sets the rendering group id (0 by default) */
  10047. renderingGroupId: number;
  10048. /** Gets or sets camera layer mask */
  10049. layerMask: number;
  10050. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10051. fogEnabled: boolean;
  10052. /** Gets or sets a boolean indicating if the sprites are pickable */
  10053. isPickable: boolean;
  10054. /** Defines the default width of a cell in the spritesheet */
  10055. cellWidth: number;
  10056. /** Defines the default height of a cell in the spritesheet */
  10057. cellHeight: number;
  10058. /** Associative array from JSON sprite data file */
  10059. private _cellData;
  10060. /** Array of sprite names from JSON sprite data file */
  10061. private _spriteMap;
  10062. /** True when packed cell data from JSON file is ready*/
  10063. private _packedAndReady;
  10064. private _textureContent;
  10065. /**
  10066. * An event triggered when the manager is disposed.
  10067. */
  10068. onDisposeObservable: Observable<SpriteManager>;
  10069. private _onDisposeObserver;
  10070. /**
  10071. * Callback called when the manager is disposed
  10072. */
  10073. set onDispose(callback: () => void);
  10074. private _capacity;
  10075. private _fromPacked;
  10076. private _spriteTexture;
  10077. private _epsilon;
  10078. private _scene;
  10079. private _vertexData;
  10080. private _buffer;
  10081. private _vertexBuffers;
  10082. private _indexBuffer;
  10083. private _effectBase;
  10084. private _effectFog;
  10085. /**
  10086. * Gets or sets the spritesheet texture
  10087. */
  10088. get texture(): Texture;
  10089. set texture(value: Texture);
  10090. private _blendMode;
  10091. /**
  10092. * Blend mode use to render the particle, it can be any of
  10093. * the static Constants.ALPHA_x properties provided in this class.
  10094. * Default value is Constants.ALPHA_COMBINE
  10095. */
  10096. get blendMode(): number;
  10097. set blendMode(blendMode: number);
  10098. /** Disables writing to the depth buffer when rendering the sprites.
  10099. * It can be handy to disable depth writing when using textures without alpha channel
  10100. * and setting some specific blend modes.
  10101. */
  10102. disableDepthWrite: boolean;
  10103. /**
  10104. * Creates a new sprite manager
  10105. * @param name defines the manager's name
  10106. * @param imgUrl defines the sprite sheet url
  10107. * @param capacity defines the maximum allowed number of sprites
  10108. * @param cellSize defines the size of a sprite cell
  10109. * @param scene defines the hosting scene
  10110. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10111. * @param samplingMode defines the smapling mode to use with spritesheet
  10112. * @param fromPacked set to false; do not alter
  10113. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10114. */
  10115. constructor(
  10116. /** defines the manager's name */
  10117. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10118. private _makePacked;
  10119. private _appendSpriteVertex;
  10120. private _checkTextureAlpha;
  10121. /**
  10122. * Intersects the sprites with a ray
  10123. * @param ray defines the ray to intersect with
  10124. * @param camera defines the current active camera
  10125. * @param predicate defines a predicate used to select candidate sprites
  10126. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10127. * @returns null if no hit or a PickingInfo
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Render all child sprites
  10140. */
  10141. render(): void;
  10142. /**
  10143. * Release associated resources
  10144. */
  10145. dispose(): void;
  10146. }
  10147. }
  10148. declare module BABYLON {
  10149. /** Interface used by value gradients (color, factor, ...) */
  10150. export interface IValueGradient {
  10151. /**
  10152. * Gets or sets the gradient value (between 0 and 1)
  10153. */
  10154. gradient: number;
  10155. }
  10156. /** Class used to store color4 gradient */
  10157. export class ColorGradient implements IValueGradient {
  10158. /**
  10159. * Gets or sets the gradient value (between 0 and 1)
  10160. */
  10161. gradient: number;
  10162. /**
  10163. * Gets or sets first associated color
  10164. */
  10165. color1: Color4;
  10166. /**
  10167. * Gets or sets second associated color
  10168. */
  10169. color2?: Color4 | undefined;
  10170. /**
  10171. * Creates a new color4 gradient
  10172. * @param gradient gets or sets the gradient value (between 0 and 1)
  10173. * @param color1 gets or sets first associated color
  10174. * @param color2 gets or sets first second color
  10175. */
  10176. constructor(
  10177. /**
  10178. * Gets or sets the gradient value (between 0 and 1)
  10179. */
  10180. gradient: number,
  10181. /**
  10182. * Gets or sets first associated color
  10183. */
  10184. color1: Color4,
  10185. /**
  10186. * Gets or sets second associated color
  10187. */
  10188. color2?: Color4 | undefined);
  10189. /**
  10190. * Will get a color picked randomly between color1 and color2.
  10191. * If color2 is undefined then color1 will be used
  10192. * @param result defines the target Color4 to store the result in
  10193. */
  10194. getColorToRef(result: Color4): void;
  10195. }
  10196. /** Class used to store color 3 gradient */
  10197. export class Color3Gradient implements IValueGradient {
  10198. /**
  10199. * Gets or sets the gradient value (between 0 and 1)
  10200. */
  10201. gradient: number;
  10202. /**
  10203. * Gets or sets the associated color
  10204. */
  10205. color: Color3;
  10206. /**
  10207. * Creates a new color3 gradient
  10208. * @param gradient gets or sets the gradient value (between 0 and 1)
  10209. * @param color gets or sets associated color
  10210. */
  10211. constructor(
  10212. /**
  10213. * Gets or sets the gradient value (between 0 and 1)
  10214. */
  10215. gradient: number,
  10216. /**
  10217. * Gets or sets the associated color
  10218. */
  10219. color: Color3);
  10220. }
  10221. /** Class used to store factor gradient */
  10222. export class FactorGradient implements IValueGradient {
  10223. /**
  10224. * Gets or sets the gradient value (between 0 and 1)
  10225. */
  10226. gradient: number;
  10227. /**
  10228. * Gets or sets first associated factor
  10229. */
  10230. factor1: number;
  10231. /**
  10232. * Gets or sets second associated factor
  10233. */
  10234. factor2?: number | undefined;
  10235. /**
  10236. * Creates a new factor gradient
  10237. * @param gradient gets or sets the gradient value (between 0 and 1)
  10238. * @param factor1 gets or sets first associated factor
  10239. * @param factor2 gets or sets second associated factor
  10240. */
  10241. constructor(
  10242. /**
  10243. * Gets or sets the gradient value (between 0 and 1)
  10244. */
  10245. gradient: number,
  10246. /**
  10247. * Gets or sets first associated factor
  10248. */
  10249. factor1: number,
  10250. /**
  10251. * Gets or sets second associated factor
  10252. */
  10253. factor2?: number | undefined);
  10254. /**
  10255. * Will get a number picked randomly between factor1 and factor2.
  10256. * If factor2 is undefined then factor1 will be used
  10257. * @returns the picked number
  10258. */
  10259. getFactor(): number;
  10260. }
  10261. /**
  10262. * Helper used to simplify some generic gradient tasks
  10263. */
  10264. export class GradientHelper {
  10265. /**
  10266. * Gets the current gradient from an array of IValueGradient
  10267. * @param ratio defines the current ratio to get
  10268. * @param gradients defines the array of IValueGradient
  10269. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10270. */
  10271. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10272. }
  10273. }
  10274. declare module BABYLON {
  10275. /**
  10276. * Interface for the size containing width and height
  10277. */
  10278. export interface ISize {
  10279. /**
  10280. * Width
  10281. */
  10282. width: number;
  10283. /**
  10284. * Heighht
  10285. */
  10286. height: number;
  10287. }
  10288. /**
  10289. * Size containing widht and height
  10290. */
  10291. export class Size implements ISize {
  10292. /**
  10293. * Width
  10294. */
  10295. width: number;
  10296. /**
  10297. * Height
  10298. */
  10299. height: number;
  10300. /**
  10301. * Creates a Size object from the given width and height (floats).
  10302. * @param width width of the new size
  10303. * @param height height of the new size
  10304. */
  10305. constructor(width: number, height: number);
  10306. /**
  10307. * Returns a string with the Size width and height
  10308. * @returns a string with the Size width and height
  10309. */
  10310. toString(): string;
  10311. /**
  10312. * "Size"
  10313. * @returns the string "Size"
  10314. */
  10315. getClassName(): string;
  10316. /**
  10317. * Returns the Size hash code.
  10318. * @returns a hash code for a unique width and height
  10319. */
  10320. getHashCode(): number;
  10321. /**
  10322. * Updates the current size from the given one.
  10323. * @param src the given size
  10324. */
  10325. copyFrom(src: Size): void;
  10326. /**
  10327. * Updates in place the current Size from the given floats.
  10328. * @param width width of the new size
  10329. * @param height height of the new size
  10330. * @returns the updated Size.
  10331. */
  10332. copyFromFloats(width: number, height: number): Size;
  10333. /**
  10334. * Updates in place the current Size from the given floats.
  10335. * @param width width to set
  10336. * @param height height to set
  10337. * @returns the updated Size.
  10338. */
  10339. set(width: number, height: number): Size;
  10340. /**
  10341. * Multiplies the width and height by numbers
  10342. * @param w factor to multiple the width by
  10343. * @param h factor to multiple the height by
  10344. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10345. */
  10346. multiplyByFloats(w: number, h: number): Size;
  10347. /**
  10348. * Clones the size
  10349. * @returns a new Size copied from the given one.
  10350. */
  10351. clone(): Size;
  10352. /**
  10353. * True if the current Size and the given one width and height are strictly equal.
  10354. * @param other the other size to compare against
  10355. * @returns True if the current Size and the given one width and height are strictly equal.
  10356. */
  10357. equals(other: Size): boolean;
  10358. /**
  10359. * The surface of the Size : width * height (float).
  10360. */
  10361. get surface(): number;
  10362. /**
  10363. * Create a new size of zero
  10364. * @returns a new Size set to (0.0, 0.0)
  10365. */
  10366. static Zero(): Size;
  10367. /**
  10368. * Sums the width and height of two sizes
  10369. * @param otherSize size to add to this size
  10370. * @returns a new Size set as the addition result of the current Size and the given one.
  10371. */
  10372. add(otherSize: Size): Size;
  10373. /**
  10374. * Subtracts the width and height of two
  10375. * @param otherSize size to subtract to this size
  10376. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10377. */
  10378. subtract(otherSize: Size): Size;
  10379. /**
  10380. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10381. * @param start starting size to lerp between
  10382. * @param end end size to lerp between
  10383. * @param amount amount to lerp between the start and end values
  10384. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10385. */
  10386. static Lerp(start: Size, end: Size, amount: number): Size;
  10387. }
  10388. }
  10389. declare module BABYLON {
  10390. interface ThinEngine {
  10391. /**
  10392. * Creates a dynamic texture
  10393. * @param width defines the width of the texture
  10394. * @param height defines the height of the texture
  10395. * @param generateMipMaps defines if the engine should generate the mip levels
  10396. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10397. * @returns the dynamic texture inside an InternalTexture
  10398. */
  10399. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10400. /**
  10401. * Update the content of a dynamic texture
  10402. * @param texture defines the texture to update
  10403. * @param canvas defines the canvas containing the source
  10404. * @param invertY defines if data must be stored with Y axis inverted
  10405. * @param premulAlpha defines if alpha is stored as premultiplied
  10406. * @param format defines the format of the data
  10407. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10408. */
  10409. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10410. }
  10411. }
  10412. declare module BABYLON {
  10413. /**
  10414. * Helper class used to generate a canvas to manipulate images
  10415. */
  10416. export class CanvasGenerator {
  10417. /**
  10418. * Create a new canvas (or offscreen canvas depending on the context)
  10419. * @param width defines the expected width
  10420. * @param height defines the expected height
  10421. * @return a new canvas or offscreen canvas
  10422. */
  10423. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10424. }
  10425. }
  10426. declare module BABYLON {
  10427. /**
  10428. * A class extending Texture allowing drawing on a texture
  10429. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10430. */
  10431. export class DynamicTexture extends Texture {
  10432. private _generateMipMaps;
  10433. private _canvas;
  10434. private _context;
  10435. private _engine;
  10436. /**
  10437. * Creates a DynamicTexture
  10438. * @param name defines the name of the texture
  10439. * @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
  10440. * @param scene defines the scene where you want the texture
  10441. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10442. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10443. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10444. */
  10445. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10446. /**
  10447. * Get the current class name of the texture useful for serialization or dynamic coding.
  10448. * @returns "DynamicTexture"
  10449. */
  10450. getClassName(): string;
  10451. /**
  10452. * Gets the current state of canRescale
  10453. */
  10454. get canRescale(): boolean;
  10455. private _recreate;
  10456. /**
  10457. * Scales the texture
  10458. * @param ratio the scale factor to apply to both width and height
  10459. */
  10460. scale(ratio: number): void;
  10461. /**
  10462. * Resizes the texture
  10463. * @param width the new width
  10464. * @param height the new height
  10465. */
  10466. scaleTo(width: number, height: number): void;
  10467. /**
  10468. * Gets the context of the canvas used by the texture
  10469. * @returns the canvas context of the dynamic texture
  10470. */
  10471. getContext(): CanvasRenderingContext2D;
  10472. /**
  10473. * Clears the texture
  10474. */
  10475. clear(): void;
  10476. /**
  10477. * Updates the texture
  10478. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10479. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10480. */
  10481. update(invertY?: boolean, premulAlpha?: boolean): void;
  10482. /**
  10483. * Draws text onto the texture
  10484. * @param text defines the text to be drawn
  10485. * @param x defines the placement of the text from the left
  10486. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10487. * @param font defines the font to be used with font-style, font-size, font-name
  10488. * @param color defines the color used for the text
  10489. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10490. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10491. * @param update defines whether texture is immediately update (default is true)
  10492. */
  10493. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10494. /**
  10495. * Clones the texture
  10496. * @returns the clone of the texture.
  10497. */
  10498. clone(): DynamicTexture;
  10499. /**
  10500. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10501. * @returns a serialized dynamic texture object
  10502. */
  10503. serialize(): any;
  10504. /** @hidden */
  10505. _rebuild(): void;
  10506. }
  10507. }
  10508. declare module BABYLON {
  10509. interface ThinEngine {
  10510. /**
  10511. * Creates a raw texture
  10512. * @param data defines the data to store in the texture
  10513. * @param width defines the width of the texture
  10514. * @param height defines the height of the texture
  10515. * @param format defines the format of the data
  10516. * @param generateMipMaps defines if the engine should generate the mip levels
  10517. * @param invertY defines if data must be stored with Y axis inverted
  10518. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10519. * @param compression defines the compression used (null by default)
  10520. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10521. * @returns the raw texture inside an InternalTexture
  10522. */
  10523. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10524. /**
  10525. * Update a raw texture
  10526. * @param texture defines the texture to update
  10527. * @param data defines the data to store in the texture
  10528. * @param format defines the format of the data
  10529. * @param invertY defines if data must be stored with Y axis inverted
  10530. */
  10531. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10532. /**
  10533. * Update a raw texture
  10534. * @param texture defines the texture to update
  10535. * @param data defines the data to store in the texture
  10536. * @param format defines the format of the data
  10537. * @param invertY defines if data must be stored with Y axis inverted
  10538. * @param compression defines the compression used (null by default)
  10539. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10540. */
  10541. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10542. /**
  10543. * Creates a new raw cube texture
  10544. * @param data defines the array of data to use to create each face
  10545. * @param size defines the size of the textures
  10546. * @param format defines the format of the data
  10547. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10548. * @param generateMipMaps defines if the engine should generate the mip levels
  10549. * @param invertY defines if data must be stored with Y axis inverted
  10550. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10551. * @param compression defines the compression used (null by default)
  10552. * @returns the cube texture as an InternalTexture
  10553. */
  10554. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10555. /**
  10556. * Update a raw cube texture
  10557. * @param texture defines the texture to udpdate
  10558. * @param data defines the data to store
  10559. * @param format defines the data format
  10560. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10561. * @param invertY defines if data must be stored with Y axis inverted
  10562. */
  10563. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10564. /**
  10565. * Update a raw cube texture
  10566. * @param texture defines the texture to udpdate
  10567. * @param data defines the data to store
  10568. * @param format defines the data format
  10569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10570. * @param invertY defines if data must be stored with Y axis inverted
  10571. * @param compression defines the compression used (null by default)
  10572. */
  10573. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10574. /**
  10575. * Update a raw cube texture
  10576. * @param texture defines the texture to udpdate
  10577. * @param data defines the data to store
  10578. * @param format defines the data format
  10579. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10580. * @param invertY defines if data must be stored with Y axis inverted
  10581. * @param compression defines the compression used (null by default)
  10582. * @param level defines which level of the texture to update
  10583. */
  10584. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10585. /**
  10586. * Creates a new raw cube texture from a specified url
  10587. * @param url defines the url where the data is located
  10588. * @param scene defines the current scene
  10589. * @param size defines the size of the textures
  10590. * @param format defines the format of the data
  10591. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10592. * @param noMipmap defines if the engine should avoid generating the mip levels
  10593. * @param callback defines a callback used to extract texture data from loaded data
  10594. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10595. * @param onLoad defines a callback called when texture is loaded
  10596. * @param onError defines a callback called if there is an error
  10597. * @returns the cube texture as an InternalTexture
  10598. */
  10599. createRawCubeTextureFromUrl(url: string, scene: 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;
  10600. /**
  10601. * Creates a new raw cube texture from a specified url
  10602. * @param url defines the url where the data is located
  10603. * @param scene defines the current scene
  10604. * @param size defines the size of the textures
  10605. * @param format defines the format of the data
  10606. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10607. * @param noMipmap defines if the engine should avoid generating the mip levels
  10608. * @param callback defines a callback used to extract texture data from loaded data
  10609. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10610. * @param onLoad defines a callback called when texture is loaded
  10611. * @param onError defines a callback called if there is an error
  10612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @returns the cube texture as an InternalTexture
  10615. */
  10616. createRawCubeTextureFromUrl(url: string, scene: 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;
  10617. /**
  10618. * Creates a new raw 3D texture
  10619. * @param data defines the data used to create the texture
  10620. * @param width defines the width of the texture
  10621. * @param height defines the height of the texture
  10622. * @param depth defines the depth of the texture
  10623. * @param format defines the format of the texture
  10624. * @param generateMipMaps defines if the engine must generate mip levels
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10627. * @param compression defines the compressed used (can be null)
  10628. * @param textureType defines the compressed used (can be null)
  10629. * @returns a new raw 3D texture (stored in an InternalTexture)
  10630. */
  10631. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10632. /**
  10633. * Update a raw 3D texture
  10634. * @param texture defines the texture to update
  10635. * @param data defines the data to store
  10636. * @param format defines the data format
  10637. * @param invertY defines if data must be stored with Y axis inverted
  10638. */
  10639. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10640. /**
  10641. * Update a raw 3D texture
  10642. * @param texture defines the texture to update
  10643. * @param data defines the data to store
  10644. * @param format defines the data format
  10645. * @param invertY defines if data must be stored with Y axis inverted
  10646. * @param compression defines the used compression (can be null)
  10647. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10648. */
  10649. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10650. /**
  10651. * Creates a new raw 2D array texture
  10652. * @param data defines the data used to create the texture
  10653. * @param width defines the width of the texture
  10654. * @param height defines the height of the texture
  10655. * @param depth defines the number of layers of the texture
  10656. * @param format defines the format of the texture
  10657. * @param generateMipMaps defines if the engine must generate mip levels
  10658. * @param invertY defines if data must be stored with Y axis inverted
  10659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10660. * @param compression defines the compressed used (can be null)
  10661. * @param textureType defines the compressed used (can be null)
  10662. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10663. */
  10664. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10665. /**
  10666. * Update a raw 2D array texture
  10667. * @param texture defines the texture to update
  10668. * @param data defines the data to store
  10669. * @param format defines the data format
  10670. * @param invertY defines if data must be stored with Y axis inverted
  10671. */
  10672. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10673. /**
  10674. * Update a raw 2D array texture
  10675. * @param texture defines the texture to update
  10676. * @param data defines the data to store
  10677. * @param format defines the data format
  10678. * @param invertY defines if data must be stored with Y axis inverted
  10679. * @param compression defines the used compression (can be null)
  10680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10681. */
  10682. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10683. }
  10684. }
  10685. declare module BABYLON {
  10686. /**
  10687. * Raw texture can help creating a texture directly from an array of data.
  10688. * This can be super useful if you either get the data from an uncompressed source or
  10689. * if you wish to create your texture pixel by pixel.
  10690. */
  10691. export class RawTexture extends Texture {
  10692. /**
  10693. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10694. */
  10695. format: number;
  10696. private _engine;
  10697. /**
  10698. * Instantiates a new RawTexture.
  10699. * Raw texture can help creating a texture directly from an array of data.
  10700. * This can be super useful if you either get the data from an uncompressed source or
  10701. * if you wish to create your texture pixel by pixel.
  10702. * @param data define the array of data to use to create the texture
  10703. * @param width define the width of the texture
  10704. * @param height define the height of the texture
  10705. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10706. * @param scene define the scene the texture belongs to
  10707. * @param generateMipMaps define whether mip maps should be generated or not
  10708. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10709. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10710. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10711. */
  10712. constructor(data: ArrayBufferView, width: number, height: number,
  10713. /**
  10714. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10715. */
  10716. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10717. /**
  10718. * Updates the texture underlying data.
  10719. * @param data Define the new data of the texture
  10720. */
  10721. update(data: ArrayBufferView): void;
  10722. /**
  10723. * Creates a luminance texture from some data.
  10724. * @param data Define the texture data
  10725. * @param width Define the width of the texture
  10726. * @param height Define the height of the texture
  10727. * @param scene Define the scene the texture belongs to
  10728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10731. * @returns the luminance texture
  10732. */
  10733. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10734. /**
  10735. * Creates a luminance alpha texture from some data.
  10736. * @param data Define the texture data
  10737. * @param width Define the width of the texture
  10738. * @param height Define the height of the texture
  10739. * @param scene Define the scene the texture belongs to
  10740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10743. * @returns the luminance alpha texture
  10744. */
  10745. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10746. /**
  10747. * Creates an alpha texture from some data.
  10748. * @param data Define the texture data
  10749. * @param width Define the width of the texture
  10750. * @param height Define the height of the texture
  10751. * @param scene Define the scene the texture belongs to
  10752. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10755. * @returns the alpha texture
  10756. */
  10757. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10758. /**
  10759. * Creates a RGB texture from some data.
  10760. * @param data Define the texture data
  10761. * @param width Define the width of the texture
  10762. * @param height Define the height of the texture
  10763. * @param scene Define the scene the texture belongs to
  10764. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10765. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10766. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10767. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10768. * @returns the RGB alpha texture
  10769. */
  10770. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10771. /**
  10772. * Creates a RGBA texture from some data.
  10773. * @param data Define the texture data
  10774. * @param width Define the width of the texture
  10775. * @param height Define the height of the texture
  10776. * @param scene Define the scene the texture belongs to
  10777. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10778. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10779. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10780. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10781. * @returns the RGBA texture
  10782. */
  10783. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10784. /**
  10785. * Creates a R texture from some data.
  10786. * @param data Define the texture data
  10787. * @param width Define the width of the texture
  10788. * @param height Define the height of the texture
  10789. * @param scene Define the scene the texture belongs to
  10790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10793. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10794. * @returns the R texture
  10795. */
  10796. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10797. }
  10798. }
  10799. declare module BABYLON {
  10800. interface AbstractScene {
  10801. /**
  10802. * The list of procedural textures added to the scene
  10803. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10804. */
  10805. proceduralTextures: Array<ProceduralTexture>;
  10806. }
  10807. /**
  10808. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10809. * in a given scene.
  10810. */
  10811. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10812. /**
  10813. * The component name helpfull to identify the component in the list of scene components.
  10814. */
  10815. readonly name: string;
  10816. /**
  10817. * The scene the component belongs to.
  10818. */
  10819. scene: Scene;
  10820. /**
  10821. * Creates a new instance of the component for the given scene
  10822. * @param scene Defines the scene to register the component in
  10823. */
  10824. constructor(scene: Scene);
  10825. /**
  10826. * Registers the component in a given scene
  10827. */
  10828. register(): void;
  10829. /**
  10830. * Rebuilds the elements related to this component in case of
  10831. * context lost for instance.
  10832. */
  10833. rebuild(): void;
  10834. /**
  10835. * Disposes the component and the associated ressources.
  10836. */
  10837. dispose(): void;
  10838. private _beforeClear;
  10839. }
  10840. }
  10841. declare module BABYLON {
  10842. interface ThinEngine {
  10843. /**
  10844. * Creates a new render target cube texture
  10845. * @param size defines the size of the texture
  10846. * @param options defines the options used to create the texture
  10847. * @returns a new render target cube texture stored in an InternalTexture
  10848. */
  10849. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10850. }
  10851. }
  10852. declare module BABYLON {
  10853. /** @hidden */
  10854. export var proceduralVertexShader: {
  10855. name: string;
  10856. shader: string;
  10857. };
  10858. }
  10859. declare module BABYLON {
  10860. /**
  10861. * 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.
  10862. * This is the base class of any Procedural texture and contains most of the shareable code.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10864. */
  10865. export class ProceduralTexture extends Texture {
  10866. isCube: boolean;
  10867. /**
  10868. * Define if the texture is enabled or not (disabled texture will not render)
  10869. */
  10870. isEnabled: boolean;
  10871. /**
  10872. * Define if the texture must be cleared before rendering (default is true)
  10873. */
  10874. autoClear: boolean;
  10875. /**
  10876. * Callback called when the texture is generated
  10877. */
  10878. onGenerated: () => void;
  10879. /**
  10880. * Event raised when the texture is generated
  10881. */
  10882. onGeneratedObservable: Observable<ProceduralTexture>;
  10883. /** @hidden */
  10884. _generateMipMaps: boolean;
  10885. /** @hidden **/
  10886. _effect: Effect;
  10887. /** @hidden */
  10888. _textures: {
  10889. [key: string]: Texture;
  10890. };
  10891. /** @hidden */
  10892. protected _fallbackTexture: Nullable<Texture>;
  10893. private _size;
  10894. private _currentRefreshId;
  10895. private _frameId;
  10896. private _refreshRate;
  10897. private _vertexBuffers;
  10898. private _indexBuffer;
  10899. private _uniforms;
  10900. private _samplers;
  10901. private _fragment;
  10902. private _floats;
  10903. private _ints;
  10904. private _floatsArrays;
  10905. private _colors3;
  10906. private _colors4;
  10907. private _vectors2;
  10908. private _vectors3;
  10909. private _matrices;
  10910. private _fallbackTextureUsed;
  10911. private _engine;
  10912. private _cachedDefines;
  10913. private _contentUpdateId;
  10914. private _contentData;
  10915. /**
  10916. * Instantiates a new procedural texture.
  10917. * 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.
  10918. * This is the base class of any Procedural texture and contains most of the shareable code.
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10920. * @param name Define the name of the texture
  10921. * @param size Define the size of the texture to create
  10922. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10923. * @param scene Define the scene the texture belongs to
  10924. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10925. * @param generateMipMaps Define if the texture should creates mip maps or not
  10926. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10927. */
  10928. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10929. /**
  10930. * The effect that is created when initializing the post process.
  10931. * @returns The created effect corresponding the the postprocess.
  10932. */
  10933. getEffect(): Effect;
  10934. /**
  10935. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10936. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10937. */
  10938. getContent(): Nullable<ArrayBufferView>;
  10939. private _createIndexBuffer;
  10940. /** @hidden */
  10941. _rebuild(): void;
  10942. /**
  10943. * Resets the texture in order to recreate its associated resources.
  10944. * This can be called in case of context loss
  10945. */
  10946. reset(): void;
  10947. protected _getDefines(): string;
  10948. /**
  10949. * Is the texture ready to be used ? (rendered at least once)
  10950. * @returns true if ready, otherwise, false.
  10951. */
  10952. isReady(): boolean;
  10953. /**
  10954. * Resets the refresh counter of the texture and start bak from scratch.
  10955. * Could be useful to regenerate the texture if it is setup to render only once.
  10956. */
  10957. resetRefreshCounter(): void;
  10958. /**
  10959. * Set the fragment shader to use in order to render the texture.
  10960. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10961. */
  10962. setFragment(fragment: any): void;
  10963. /**
  10964. * Define the refresh rate of the texture or the rendering frequency.
  10965. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10966. */
  10967. get refreshRate(): number;
  10968. set refreshRate(value: number);
  10969. /** @hidden */
  10970. _shouldRender(): boolean;
  10971. /**
  10972. * Get the size the texture is rendering at.
  10973. * @returns the size (texture is always squared)
  10974. */
  10975. getRenderSize(): number;
  10976. /**
  10977. * Resize the texture to new value.
  10978. * @param size Define the new size the texture should have
  10979. * @param generateMipMaps Define whether the new texture should create mip maps
  10980. */
  10981. resize(size: number, generateMipMaps: boolean): void;
  10982. private _checkUniform;
  10983. /**
  10984. * Set a texture in the shader program used to render.
  10985. * @param name Define the name of the uniform samplers as defined in the shader
  10986. * @param texture Define the texture to bind to this sampler
  10987. * @return the texture itself allowing "fluent" like uniform updates
  10988. */
  10989. setTexture(name: string, texture: Texture): ProceduralTexture;
  10990. /**
  10991. * Set a float in the shader.
  10992. * @param name Define the name of the uniform as defined in the shader
  10993. * @param value Define the value to give to the uniform
  10994. * @return the texture itself allowing "fluent" like uniform updates
  10995. */
  10996. setFloat(name: string, value: number): ProceduralTexture;
  10997. /**
  10998. * Set a int in the shader.
  10999. * @param name Define the name of the uniform as defined in the shader
  11000. * @param value Define the value to give to the uniform
  11001. * @return the texture itself allowing "fluent" like uniform updates
  11002. */
  11003. setInt(name: string, value: number): ProceduralTexture;
  11004. /**
  11005. * Set an array of floats in the shader.
  11006. * @param name Define the name of the uniform as defined in the shader
  11007. * @param value Define the value to give to the uniform
  11008. * @return the texture itself allowing "fluent" like uniform updates
  11009. */
  11010. setFloats(name: string, value: number[]): ProceduralTexture;
  11011. /**
  11012. * Set a vec3 in the shader from a Color3.
  11013. * @param name Define the name of the uniform as defined in the shader
  11014. * @param value Define the value to give to the uniform
  11015. * @return the texture itself allowing "fluent" like uniform updates
  11016. */
  11017. setColor3(name: string, value: Color3): ProceduralTexture;
  11018. /**
  11019. * Set a vec4 in the shader from a Color4.
  11020. * @param name Define the name of the uniform as defined in the shader
  11021. * @param value Define the value to give to the uniform
  11022. * @return the texture itself allowing "fluent" like uniform updates
  11023. */
  11024. setColor4(name: string, value: Color4): ProceduralTexture;
  11025. /**
  11026. * Set a vec2 in the shader from a Vector2.
  11027. * @param name Define the name of the uniform as defined in the shader
  11028. * @param value Define the value to give to the uniform
  11029. * @return the texture itself allowing "fluent" like uniform updates
  11030. */
  11031. setVector2(name: string, value: Vector2): ProceduralTexture;
  11032. /**
  11033. * Set a vec3 in the shader from a Vector3.
  11034. * @param name Define the name of the uniform as defined in the shader
  11035. * @param value Define the value to give to the uniform
  11036. * @return the texture itself allowing "fluent" like uniform updates
  11037. */
  11038. setVector3(name: string, value: Vector3): ProceduralTexture;
  11039. /**
  11040. * Set a mat4 in the shader from a MAtrix.
  11041. * @param name Define the name of the uniform as defined in the shader
  11042. * @param value Define the value to give to the uniform
  11043. * @return the texture itself allowing "fluent" like uniform updates
  11044. */
  11045. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11046. /**
  11047. * Render the texture to its associated render target.
  11048. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11049. */
  11050. render(useCameraPostProcess?: boolean): void;
  11051. /**
  11052. * Clone the texture.
  11053. * @returns the cloned texture
  11054. */
  11055. clone(): ProceduralTexture;
  11056. /**
  11057. * Dispose the texture and release its asoociated resources.
  11058. */
  11059. dispose(): void;
  11060. }
  11061. }
  11062. declare module BABYLON {
  11063. /**
  11064. * This represents the base class for particle system in Babylon.
  11065. * 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.
  11066. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11067. * @example https://doc.babylonjs.com/babylon101/particles
  11068. */
  11069. export class BaseParticleSystem {
  11070. /**
  11071. * Source color is added to the destination color without alpha affecting the result
  11072. */
  11073. static BLENDMODE_ONEONE: number;
  11074. /**
  11075. * Blend current color and particle color using particle’s alpha
  11076. */
  11077. static BLENDMODE_STANDARD: number;
  11078. /**
  11079. * Add current color and particle color multiplied by particle’s alpha
  11080. */
  11081. static BLENDMODE_ADD: number;
  11082. /**
  11083. * Multiply current color with particle color
  11084. */
  11085. static BLENDMODE_MULTIPLY: number;
  11086. /**
  11087. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11088. */
  11089. static BLENDMODE_MULTIPLYADD: number;
  11090. /**
  11091. * List of animations used by the particle system.
  11092. */
  11093. animations: Animation[];
  11094. /**
  11095. * Gets or sets the unique id of the particle system
  11096. */
  11097. uniqueId: number;
  11098. /**
  11099. * The id of the Particle system.
  11100. */
  11101. id: string;
  11102. /**
  11103. * The friendly name of the Particle system.
  11104. */
  11105. name: string;
  11106. /**
  11107. * Snippet ID if the particle system was created from the snippet server
  11108. */
  11109. snippetId: string;
  11110. /**
  11111. * The rendering group used by the Particle system to chose when to render.
  11112. */
  11113. renderingGroupId: number;
  11114. /**
  11115. * The emitter represents the Mesh or position we are attaching the particle system to.
  11116. */
  11117. emitter: Nullable<AbstractMesh | Vector3>;
  11118. /**
  11119. * The maximum number of particles to emit per frame
  11120. */
  11121. emitRate: number;
  11122. /**
  11123. * If you want to launch only a few particles at once, that can be done, as well.
  11124. */
  11125. manualEmitCount: number;
  11126. /**
  11127. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11128. */
  11129. updateSpeed: number;
  11130. /**
  11131. * The amount of time the particle system is running (depends of the overall update speed).
  11132. */
  11133. targetStopDuration: number;
  11134. /**
  11135. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11136. */
  11137. disposeOnStop: boolean;
  11138. /**
  11139. * Minimum power of emitting particles.
  11140. */
  11141. minEmitPower: number;
  11142. /**
  11143. * Maximum power of emitting particles.
  11144. */
  11145. maxEmitPower: number;
  11146. /**
  11147. * Minimum life time of emitting particles.
  11148. */
  11149. minLifeTime: number;
  11150. /**
  11151. * Maximum life time of emitting particles.
  11152. */
  11153. maxLifeTime: number;
  11154. /**
  11155. * Minimum Size of emitting particles.
  11156. */
  11157. minSize: number;
  11158. /**
  11159. * Maximum Size of emitting particles.
  11160. */
  11161. maxSize: number;
  11162. /**
  11163. * Minimum scale of emitting particles on X axis.
  11164. */
  11165. minScaleX: number;
  11166. /**
  11167. * Maximum scale of emitting particles on X axis.
  11168. */
  11169. maxScaleX: number;
  11170. /**
  11171. * Minimum scale of emitting particles on Y axis.
  11172. */
  11173. minScaleY: number;
  11174. /**
  11175. * Maximum scale of emitting particles on Y axis.
  11176. */
  11177. maxScaleY: number;
  11178. /**
  11179. * Gets or sets the minimal initial rotation in radians.
  11180. */
  11181. minInitialRotation: number;
  11182. /**
  11183. * Gets or sets the maximal initial rotation in radians.
  11184. */
  11185. maxInitialRotation: number;
  11186. /**
  11187. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11188. */
  11189. minAngularSpeed: number;
  11190. /**
  11191. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11192. */
  11193. maxAngularSpeed: number;
  11194. /**
  11195. * The texture used to render each particle. (this can be a spritesheet)
  11196. */
  11197. particleTexture: Nullable<Texture>;
  11198. /**
  11199. * The layer mask we are rendering the particles through.
  11200. */
  11201. layerMask: number;
  11202. /**
  11203. * This can help using your own shader to render the particle system.
  11204. * The according effect will be created
  11205. */
  11206. customShader: any;
  11207. /**
  11208. * By default particle system starts as soon as they are created. This prevents the
  11209. * automatic start to happen and let you decide when to start emitting particles.
  11210. */
  11211. preventAutoStart: boolean;
  11212. private _noiseTexture;
  11213. /**
  11214. * Gets or sets a texture used to add random noise to particle positions
  11215. */
  11216. get noiseTexture(): Nullable<ProceduralTexture>;
  11217. set noiseTexture(value: Nullable<ProceduralTexture>);
  11218. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11219. noiseStrength: Vector3;
  11220. /**
  11221. * Callback triggered when the particle animation is ending.
  11222. */
  11223. onAnimationEnd: Nullable<() => void>;
  11224. /**
  11225. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11226. */
  11227. blendMode: number;
  11228. /**
  11229. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11230. * to override the particles.
  11231. */
  11232. forceDepthWrite: boolean;
  11233. /** 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 */
  11234. preWarmCycles: number;
  11235. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11236. preWarmStepOffset: number;
  11237. /**
  11238. * 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)
  11239. */
  11240. spriteCellChangeSpeed: number;
  11241. /**
  11242. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11243. */
  11244. startSpriteCellID: number;
  11245. /**
  11246. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11247. */
  11248. endSpriteCellID: number;
  11249. /**
  11250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11251. */
  11252. spriteCellWidth: number;
  11253. /**
  11254. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11255. */
  11256. spriteCellHeight: number;
  11257. /**
  11258. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11259. */
  11260. spriteRandomStartCell: boolean;
  11261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11262. translationPivot: Vector2;
  11263. /** @hidden */
  11264. protected _isAnimationSheetEnabled: boolean;
  11265. /**
  11266. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11267. */
  11268. beginAnimationOnStart: boolean;
  11269. /**
  11270. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11271. */
  11272. beginAnimationFrom: number;
  11273. /**
  11274. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11275. */
  11276. beginAnimationTo: number;
  11277. /**
  11278. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11279. */
  11280. beginAnimationLoop: boolean;
  11281. /**
  11282. * Gets or sets a world offset applied to all particles
  11283. */
  11284. worldOffset: Vector3;
  11285. /**
  11286. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11287. */
  11288. get isAnimationSheetEnabled(): boolean;
  11289. set isAnimationSheetEnabled(value: boolean);
  11290. /**
  11291. * Get hosting scene
  11292. * @returns the scene
  11293. */
  11294. getScene(): Scene;
  11295. /**
  11296. * You can use gravity if you want to give an orientation to your particles.
  11297. */
  11298. gravity: Vector3;
  11299. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11300. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11301. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11302. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11303. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11304. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11305. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11306. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11307. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11308. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11309. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11310. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11311. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11312. /**
  11313. * Defines the delay in milliseconds before starting the system (0 by default)
  11314. */
  11315. startDelay: number;
  11316. /**
  11317. * Gets the current list of drag gradients.
  11318. * You must use addDragGradient and removeDragGradient to udpate this list
  11319. * @returns the list of drag gradients
  11320. */
  11321. getDragGradients(): Nullable<Array<FactorGradient>>;
  11322. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11323. limitVelocityDamping: number;
  11324. /**
  11325. * Gets the current list of limit velocity gradients.
  11326. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11327. * @returns the list of limit velocity gradients
  11328. */
  11329. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11330. /**
  11331. * Gets the current list of color gradients.
  11332. * You must use addColorGradient and removeColorGradient to udpate this list
  11333. * @returns the list of color gradients
  11334. */
  11335. getColorGradients(): Nullable<Array<ColorGradient>>;
  11336. /**
  11337. * Gets the current list of size gradients.
  11338. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11339. * @returns the list of size gradients
  11340. */
  11341. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11342. /**
  11343. * Gets the current list of color remap gradients.
  11344. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11345. * @returns the list of color remap gradients
  11346. */
  11347. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11348. /**
  11349. * Gets the current list of alpha remap gradients.
  11350. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11351. * @returns the list of alpha remap gradients
  11352. */
  11353. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11354. /**
  11355. * Gets the current list of life time gradients.
  11356. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11357. * @returns the list of life time gradients
  11358. */
  11359. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11360. /**
  11361. * Gets the current list of angular speed gradients.
  11362. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11363. * @returns the list of angular speed gradients
  11364. */
  11365. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11366. /**
  11367. * Gets the current list of velocity gradients.
  11368. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11369. * @returns the list of velocity gradients
  11370. */
  11371. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11372. /**
  11373. * Gets the current list of start size gradients.
  11374. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11375. * @returns the list of start size gradients
  11376. */
  11377. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11378. /**
  11379. * Gets the current list of emit rate gradients.
  11380. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11381. * @returns the list of emit rate gradients
  11382. */
  11383. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11384. /**
  11385. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11386. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11387. */
  11388. get direction1(): Vector3;
  11389. set direction1(value: Vector3);
  11390. /**
  11391. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11392. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11393. */
  11394. get direction2(): Vector3;
  11395. set direction2(value: Vector3);
  11396. /**
  11397. * 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.
  11398. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11399. */
  11400. get minEmitBox(): Vector3;
  11401. set minEmitBox(value: Vector3);
  11402. /**
  11403. * 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.
  11404. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11405. */
  11406. get maxEmitBox(): Vector3;
  11407. set maxEmitBox(value: Vector3);
  11408. /**
  11409. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11410. */
  11411. color1: Color4;
  11412. /**
  11413. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11414. */
  11415. color2: Color4;
  11416. /**
  11417. * Color the particle will have at the end of its lifetime
  11418. */
  11419. colorDead: Color4;
  11420. /**
  11421. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11422. */
  11423. textureMask: Color4;
  11424. /**
  11425. * The particle emitter type defines the emitter used by the particle system.
  11426. * It can be for example box, sphere, or cone...
  11427. */
  11428. particleEmitterType: IParticleEmitterType;
  11429. /** @hidden */
  11430. _isSubEmitter: boolean;
  11431. /**
  11432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11434. */
  11435. billboardMode: number;
  11436. protected _isBillboardBased: boolean;
  11437. /**
  11438. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11439. */
  11440. get isBillboardBased(): boolean;
  11441. set isBillboardBased(value: boolean);
  11442. /**
  11443. * The scene the particle system belongs to.
  11444. */
  11445. protected _scene: Scene;
  11446. /**
  11447. * Local cache of defines for image processing.
  11448. */
  11449. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11450. /**
  11451. * Default configuration related to image processing available in the standard Material.
  11452. */
  11453. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11454. /**
  11455. * Gets the image processing configuration used either in this material.
  11456. */
  11457. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11458. /**
  11459. * Sets the Default image processing configuration used either in the this material.
  11460. *
  11461. * If sets to null, the scene one is in use.
  11462. */
  11463. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11464. /**
  11465. * Attaches a new image processing configuration to the Standard Material.
  11466. * @param configuration
  11467. */
  11468. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11469. /** @hidden */
  11470. protected _reset(): void;
  11471. /** @hidden */
  11472. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11473. /**
  11474. * Instantiates a particle system.
  11475. * 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.
  11476. * @param name The name of the particle system
  11477. */
  11478. constructor(name: string);
  11479. /**
  11480. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11481. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11482. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11483. * @returns the emitter
  11484. */
  11485. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11486. /**
  11487. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11488. * @param radius The radius of the hemisphere to emit from
  11489. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11490. * @returns the emitter
  11491. */
  11492. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11493. /**
  11494. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11495. * @param radius The radius of the sphere to emit from
  11496. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11497. * @returns the emitter
  11498. */
  11499. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11500. /**
  11501. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11502. * @param radius The radius of the sphere to emit from
  11503. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11504. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11505. * @returns the emitter
  11506. */
  11507. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11508. /**
  11509. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11510. * @param radius The radius of the emission cylinder
  11511. * @param height The height of the emission cylinder
  11512. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11513. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11514. * @returns the emitter
  11515. */
  11516. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11517. /**
  11518. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11519. * @param radius The radius of the cylinder to emit from
  11520. * @param height The height of the emission cylinder
  11521. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11524. * @returns the emitter
  11525. */
  11526. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11527. /**
  11528. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11529. * @param radius The radius of the cone to emit from
  11530. * @param angle The base angle of the cone
  11531. * @returns the emitter
  11532. */
  11533. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11534. /**
  11535. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11538. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11539. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11540. * @returns the emitter
  11541. */
  11542. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11543. }
  11544. }
  11545. declare module BABYLON {
  11546. /**
  11547. * Type of sub emitter
  11548. */
  11549. export enum SubEmitterType {
  11550. /**
  11551. * Attached to the particle over it's lifetime
  11552. */
  11553. ATTACHED = 0,
  11554. /**
  11555. * Created when the particle dies
  11556. */
  11557. END = 1
  11558. }
  11559. /**
  11560. * Sub emitter class used to emit particles from an existing particle
  11561. */
  11562. export class SubEmitter {
  11563. /**
  11564. * the particle system to be used by the sub emitter
  11565. */
  11566. particleSystem: ParticleSystem;
  11567. /**
  11568. * Type of the submitter (Default: END)
  11569. */
  11570. type: SubEmitterType;
  11571. /**
  11572. * 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)
  11573. * Note: This only is supported when using an emitter of type Mesh
  11574. */
  11575. inheritDirection: boolean;
  11576. /**
  11577. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11578. */
  11579. inheritedVelocityAmount: number;
  11580. /**
  11581. * Creates a sub emitter
  11582. * @param particleSystem the particle system to be used by the sub emitter
  11583. */
  11584. constructor(
  11585. /**
  11586. * the particle system to be used by the sub emitter
  11587. */
  11588. particleSystem: ParticleSystem);
  11589. /**
  11590. * Clones the sub emitter
  11591. * @returns the cloned sub emitter
  11592. */
  11593. clone(): SubEmitter;
  11594. /**
  11595. * Serialize current object to a JSON object
  11596. * @returns the serialized object
  11597. */
  11598. serialize(): any;
  11599. /** @hidden */
  11600. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11601. /**
  11602. * Creates a new SubEmitter from a serialized JSON version
  11603. * @param serializationObject defines the JSON object to read from
  11604. * @param scene defines the hosting scene
  11605. * @param rootUrl defines the rootUrl for data loading
  11606. * @returns a new SubEmitter
  11607. */
  11608. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11609. /** Release associated resources */
  11610. dispose(): void;
  11611. }
  11612. }
  11613. declare module BABYLON {
  11614. /** @hidden */
  11615. export var imageProcessingDeclaration: {
  11616. name: string;
  11617. shader: string;
  11618. };
  11619. }
  11620. declare module BABYLON {
  11621. /** @hidden */
  11622. export var imageProcessingFunctions: {
  11623. name: string;
  11624. shader: string;
  11625. };
  11626. }
  11627. declare module BABYLON {
  11628. /** @hidden */
  11629. export var particlesPixelShader: {
  11630. name: string;
  11631. shader: string;
  11632. };
  11633. }
  11634. declare module BABYLON {
  11635. /** @hidden */
  11636. export var particlesVertexShader: {
  11637. name: string;
  11638. shader: string;
  11639. };
  11640. }
  11641. declare module BABYLON {
  11642. /**
  11643. * This represents a particle system in Babylon.
  11644. * 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.
  11645. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11646. * @example https://doc.babylonjs.com/babylon101/particles
  11647. */
  11648. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11649. /**
  11650. * Billboard mode will only apply to Y axis
  11651. */
  11652. static readonly BILLBOARDMODE_Y: number;
  11653. /**
  11654. * Billboard mode will apply to all axes
  11655. */
  11656. static readonly BILLBOARDMODE_ALL: number;
  11657. /**
  11658. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11659. */
  11660. static readonly BILLBOARDMODE_STRETCHED: number;
  11661. /**
  11662. * This function can be defined to provide custom update for active particles.
  11663. * This function will be called instead of regular update (age, position, color, etc.).
  11664. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11665. */
  11666. updateFunction: (particles: Particle[]) => void;
  11667. private _emitterWorldMatrix;
  11668. /**
  11669. * This function can be defined to specify initial direction for every new particle.
  11670. * It by default use the emitterType defined function
  11671. */
  11672. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11673. /**
  11674. * This function can be defined to specify initial position for every new particle.
  11675. * It by default use the emitterType defined function
  11676. */
  11677. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11678. /**
  11679. * @hidden
  11680. */
  11681. _inheritedVelocityOffset: Vector3;
  11682. /**
  11683. * An event triggered when the system is disposed
  11684. */
  11685. onDisposeObservable: Observable<ParticleSystem>;
  11686. private _onDisposeObserver;
  11687. /**
  11688. * Sets a callback that will be triggered when the system is disposed
  11689. */
  11690. set onDispose(callback: () => void);
  11691. private _particles;
  11692. private _epsilon;
  11693. private _capacity;
  11694. private _stockParticles;
  11695. private _newPartsExcess;
  11696. private _vertexData;
  11697. private _vertexBuffer;
  11698. private _vertexBuffers;
  11699. private _spriteBuffer;
  11700. private _indexBuffer;
  11701. private _effect;
  11702. private _customEffect;
  11703. private _cachedDefines;
  11704. private _scaledColorStep;
  11705. private _colorDiff;
  11706. private _scaledDirection;
  11707. private _scaledGravity;
  11708. private _currentRenderId;
  11709. private _alive;
  11710. private _useInstancing;
  11711. private _started;
  11712. private _stopped;
  11713. private _actualFrame;
  11714. private _scaledUpdateSpeed;
  11715. private _vertexBufferSize;
  11716. /** @hidden */
  11717. _currentEmitRateGradient: Nullable<FactorGradient>;
  11718. /** @hidden */
  11719. _currentEmitRate1: number;
  11720. /** @hidden */
  11721. _currentEmitRate2: number;
  11722. /** @hidden */
  11723. _currentStartSizeGradient: Nullable<FactorGradient>;
  11724. /** @hidden */
  11725. _currentStartSize1: number;
  11726. /** @hidden */
  11727. _currentStartSize2: number;
  11728. private readonly _rawTextureWidth;
  11729. private _rampGradientsTexture;
  11730. private _useRampGradients;
  11731. /** Gets or sets a boolean indicating that ramp gradients must be used
  11732. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11733. */
  11734. get useRampGradients(): boolean;
  11735. set useRampGradients(value: boolean);
  11736. /**
  11737. * 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.
  11738. * 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: [])
  11739. */
  11740. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11741. private _subEmitters;
  11742. /**
  11743. * @hidden
  11744. * If the particle systems emitter should be disposed when the particle system is disposed
  11745. */
  11746. _disposeEmitterOnDispose: boolean;
  11747. /**
  11748. * The current active Sub-systems, this property is used by the root particle system only.
  11749. */
  11750. activeSubSystems: Array<ParticleSystem>;
  11751. /**
  11752. * Specifies if the particles are updated in emitter local space or world space
  11753. */
  11754. isLocal: boolean;
  11755. private _rootParticleSystem;
  11756. /**
  11757. * Gets the current list of active particles
  11758. */
  11759. get particles(): Particle[];
  11760. /**
  11761. * Gets the number of particles active at the same time.
  11762. * @returns The number of active particles.
  11763. */
  11764. getActiveCount(): number;
  11765. /**
  11766. * Returns the string "ParticleSystem"
  11767. * @returns a string containing the class name
  11768. */
  11769. getClassName(): string;
  11770. /**
  11771. * Gets a boolean indicating that the system is stopping
  11772. * @returns true if the system is currently stopping
  11773. */
  11774. isStopping(): boolean;
  11775. /**
  11776. * Instantiates a particle system.
  11777. * 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.
  11778. * @param name The name of the particle system
  11779. * @param capacity The max number of particles alive at the same time
  11780. * @param scene The scene the particle system belongs to
  11781. * @param customEffect a custom effect used to change the way particles are rendered by default
  11782. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11783. * @param epsilon Offset used to render the particles
  11784. */
  11785. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11786. private _addFactorGradient;
  11787. private _removeFactorGradient;
  11788. /**
  11789. * Adds a new life time gradient
  11790. * @param gradient defines the gradient to use (between 0 and 1)
  11791. * @param factor defines the life time factor to affect to the specified gradient
  11792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11793. * @returns the current particle system
  11794. */
  11795. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11796. /**
  11797. * Remove a specific life time gradient
  11798. * @param gradient defines the gradient to remove
  11799. * @returns the current particle system
  11800. */
  11801. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11802. /**
  11803. * Adds a new size gradient
  11804. * @param gradient defines the gradient to use (between 0 and 1)
  11805. * @param factor defines the size factor to affect to the specified gradient
  11806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11807. * @returns the current particle system
  11808. */
  11809. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11810. /**
  11811. * Remove a specific size gradient
  11812. * @param gradient defines the gradient to remove
  11813. * @returns the current particle system
  11814. */
  11815. removeSizeGradient(gradient: number): IParticleSystem;
  11816. /**
  11817. * Adds a new color remap gradient
  11818. * @param gradient defines the gradient to use (between 0 and 1)
  11819. * @param min defines the color remap minimal range
  11820. * @param max defines the color remap maximal range
  11821. * @returns the current particle system
  11822. */
  11823. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11824. /**
  11825. * Remove a specific color remap gradient
  11826. * @param gradient defines the gradient to remove
  11827. * @returns the current particle system
  11828. */
  11829. removeColorRemapGradient(gradient: number): IParticleSystem;
  11830. /**
  11831. * Adds a new alpha remap gradient
  11832. * @param gradient defines the gradient to use (between 0 and 1)
  11833. * @param min defines the alpha remap minimal range
  11834. * @param max defines the alpha remap maximal range
  11835. * @returns the current particle system
  11836. */
  11837. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11838. /**
  11839. * Remove a specific alpha remap gradient
  11840. * @param gradient defines the gradient to remove
  11841. * @returns the current particle system
  11842. */
  11843. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11844. /**
  11845. * Adds a new angular speed gradient
  11846. * @param gradient defines the gradient to use (between 0 and 1)
  11847. * @param factor defines the angular speed to affect to the specified gradient
  11848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11849. * @returns the current particle system
  11850. */
  11851. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11852. /**
  11853. * Remove a specific angular speed gradient
  11854. * @param gradient defines the gradient to remove
  11855. * @returns the current particle system
  11856. */
  11857. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11858. /**
  11859. * Adds a new velocity gradient
  11860. * @param gradient defines the gradient to use (between 0 and 1)
  11861. * @param factor defines the velocity to affect to the specified gradient
  11862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11863. * @returns the current particle system
  11864. */
  11865. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11866. /**
  11867. * Remove a specific velocity gradient
  11868. * @param gradient defines the gradient to remove
  11869. * @returns the current particle system
  11870. */
  11871. removeVelocityGradient(gradient: number): IParticleSystem;
  11872. /**
  11873. * Adds a new limit velocity gradient
  11874. * @param gradient defines the gradient to use (between 0 and 1)
  11875. * @param factor defines the limit velocity value to affect to the specified gradient
  11876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11877. * @returns the current particle system
  11878. */
  11879. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11880. /**
  11881. * Remove a specific limit velocity gradient
  11882. * @param gradient defines the gradient to remove
  11883. * @returns the current particle system
  11884. */
  11885. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11886. /**
  11887. * Adds a new drag gradient
  11888. * @param gradient defines the gradient to use (between 0 and 1)
  11889. * @param factor defines the drag value to affect to the specified gradient
  11890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11891. * @returns the current particle system
  11892. */
  11893. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11894. /**
  11895. * Remove a specific drag gradient
  11896. * @param gradient defines the gradient to remove
  11897. * @returns the current particle system
  11898. */
  11899. removeDragGradient(gradient: number): IParticleSystem;
  11900. /**
  11901. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11902. * @param gradient defines the gradient to use (between 0 and 1)
  11903. * @param factor defines the emit rate value to affect to the specified gradient
  11904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11905. * @returns the current particle system
  11906. */
  11907. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11908. /**
  11909. * Remove a specific emit rate gradient
  11910. * @param gradient defines the gradient to remove
  11911. * @returns the current particle system
  11912. */
  11913. removeEmitRateGradient(gradient: number): IParticleSystem;
  11914. /**
  11915. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11916. * @param gradient defines the gradient to use (between 0 and 1)
  11917. * @param factor defines the start size value to affect to the specified gradient
  11918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11919. * @returns the current particle system
  11920. */
  11921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11922. /**
  11923. * Remove a specific start size gradient
  11924. * @param gradient defines the gradient to remove
  11925. * @returns the current particle system
  11926. */
  11927. removeStartSizeGradient(gradient: number): IParticleSystem;
  11928. private _createRampGradientTexture;
  11929. /**
  11930. * Gets the current list of ramp gradients.
  11931. * You must use addRampGradient and removeRampGradient to udpate this list
  11932. * @returns the list of ramp gradients
  11933. */
  11934. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11935. /** Force the system to rebuild all gradients that need to be resync */
  11936. forceRefreshGradients(): void;
  11937. private _syncRampGradientTexture;
  11938. /**
  11939. * Adds a new ramp gradient used to remap particle colors
  11940. * @param gradient defines the gradient to use (between 0 and 1)
  11941. * @param color defines the color to affect to the specified gradient
  11942. * @returns the current particle system
  11943. */
  11944. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11945. /**
  11946. * Remove a specific ramp gradient
  11947. * @param gradient defines the gradient to remove
  11948. * @returns the current particle system
  11949. */
  11950. removeRampGradient(gradient: number): ParticleSystem;
  11951. /**
  11952. * Adds a new color gradient
  11953. * @param gradient defines the gradient to use (between 0 and 1)
  11954. * @param color1 defines the color to affect to the specified gradient
  11955. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11956. * @returns this particle system
  11957. */
  11958. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11959. /**
  11960. * Remove a specific color gradient
  11961. * @param gradient defines the gradient to remove
  11962. * @returns this particle system
  11963. */
  11964. removeColorGradient(gradient: number): IParticleSystem;
  11965. private _fetchR;
  11966. protected _reset(): void;
  11967. private _resetEffect;
  11968. private _createVertexBuffers;
  11969. private _createIndexBuffer;
  11970. /**
  11971. * Gets the maximum number of particles active at the same time.
  11972. * @returns The max number of active particles.
  11973. */
  11974. getCapacity(): number;
  11975. /**
  11976. * Gets whether there are still active particles in the system.
  11977. * @returns True if it is alive, otherwise false.
  11978. */
  11979. isAlive(): boolean;
  11980. /**
  11981. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11982. * @returns True if it has been started, otherwise false.
  11983. */
  11984. isStarted(): boolean;
  11985. private _prepareSubEmitterInternalArray;
  11986. /**
  11987. * Starts the particle system and begins to emit
  11988. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11989. */
  11990. start(delay?: number): void;
  11991. /**
  11992. * Stops the particle system.
  11993. * @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.
  11994. */
  11995. stop(stopSubEmitters?: boolean): void;
  11996. /**
  11997. * Remove all active particles
  11998. */
  11999. reset(): void;
  12000. /**
  12001. * @hidden (for internal use only)
  12002. */
  12003. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12004. /**
  12005. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12006. * Its lifetime will start back at 0.
  12007. */
  12008. recycleParticle: (particle: Particle) => void;
  12009. private _stopSubEmitters;
  12010. private _createParticle;
  12011. private _removeFromRoot;
  12012. private _emitFromParticle;
  12013. private _update;
  12014. /** @hidden */
  12015. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12016. /** @hidden */
  12017. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12018. /** @hidden */
  12019. private _getEffect;
  12020. /**
  12021. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12022. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12023. */
  12024. animate(preWarmOnly?: boolean): void;
  12025. private _appendParticleVertices;
  12026. /**
  12027. * Rebuilds the particle system.
  12028. */
  12029. rebuild(): void;
  12030. /**
  12031. * Is this system ready to be used/rendered
  12032. * @return true if the system is ready
  12033. */
  12034. isReady(): boolean;
  12035. private _render;
  12036. /**
  12037. * Renders the particle system in its current state.
  12038. * @returns the current number of particles
  12039. */
  12040. render(): number;
  12041. /**
  12042. * Disposes the particle system and free the associated resources
  12043. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12044. */
  12045. dispose(disposeTexture?: boolean): void;
  12046. /**
  12047. * Clones the particle system.
  12048. * @param name The name of the cloned object
  12049. * @param newEmitter The new emitter to use
  12050. * @returns the cloned particle system
  12051. */
  12052. clone(name: string, newEmitter: any): ParticleSystem;
  12053. /**
  12054. * Serializes the particle system to a JSON object
  12055. * @param serializeTexture defines if the texture must be serialized as well
  12056. * @returns the JSON object
  12057. */
  12058. serialize(serializeTexture?: boolean): any;
  12059. /** @hidden */
  12060. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12061. /** @hidden */
  12062. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12063. /**
  12064. * Parses a JSON object to create a particle system.
  12065. * @param parsedParticleSystem The JSON object to parse
  12066. * @param scene The scene to create the particle system in
  12067. * @param rootUrl The root url to use to load external dependencies like texture
  12068. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12069. * @returns the Parsed particle system
  12070. */
  12071. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12072. }
  12073. }
  12074. declare module BABYLON {
  12075. /**
  12076. * A particle represents one of the element emitted by a particle system.
  12077. * This is mainly define by its coordinates, direction, velocity and age.
  12078. */
  12079. export class Particle {
  12080. /**
  12081. * The particle system the particle belongs to.
  12082. */
  12083. particleSystem: ParticleSystem;
  12084. private static _Count;
  12085. /**
  12086. * Unique ID of the particle
  12087. */
  12088. id: number;
  12089. /**
  12090. * The world position of the particle in the scene.
  12091. */
  12092. position: Vector3;
  12093. /**
  12094. * The world direction of the particle in the scene.
  12095. */
  12096. direction: Vector3;
  12097. /**
  12098. * The color of the particle.
  12099. */
  12100. color: Color4;
  12101. /**
  12102. * The color change of the particle per step.
  12103. */
  12104. colorStep: Color4;
  12105. /**
  12106. * Defines how long will the life of the particle be.
  12107. */
  12108. lifeTime: number;
  12109. /**
  12110. * The current age of the particle.
  12111. */
  12112. age: number;
  12113. /**
  12114. * The current size of the particle.
  12115. */
  12116. size: number;
  12117. /**
  12118. * The current scale of the particle.
  12119. */
  12120. scale: Vector2;
  12121. /**
  12122. * The current angle of the particle.
  12123. */
  12124. angle: number;
  12125. /**
  12126. * Defines how fast is the angle changing.
  12127. */
  12128. angularSpeed: number;
  12129. /**
  12130. * Defines the cell index used by the particle to be rendered from a sprite.
  12131. */
  12132. cellIndex: number;
  12133. /**
  12134. * The information required to support color remapping
  12135. */
  12136. remapData: Vector4;
  12137. /** @hidden */
  12138. _randomCellOffset?: number;
  12139. /** @hidden */
  12140. _initialDirection: Nullable<Vector3>;
  12141. /** @hidden */
  12142. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12143. /** @hidden */
  12144. _initialStartSpriteCellID: number;
  12145. /** @hidden */
  12146. _initialEndSpriteCellID: number;
  12147. /** @hidden */
  12148. _currentColorGradient: Nullable<ColorGradient>;
  12149. /** @hidden */
  12150. _currentColor1: Color4;
  12151. /** @hidden */
  12152. _currentColor2: Color4;
  12153. /** @hidden */
  12154. _currentSizeGradient: Nullable<FactorGradient>;
  12155. /** @hidden */
  12156. _currentSize1: number;
  12157. /** @hidden */
  12158. _currentSize2: number;
  12159. /** @hidden */
  12160. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12161. /** @hidden */
  12162. _currentAngularSpeed1: number;
  12163. /** @hidden */
  12164. _currentAngularSpeed2: number;
  12165. /** @hidden */
  12166. _currentVelocityGradient: Nullable<FactorGradient>;
  12167. /** @hidden */
  12168. _currentVelocity1: number;
  12169. /** @hidden */
  12170. _currentVelocity2: number;
  12171. /** @hidden */
  12172. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12173. /** @hidden */
  12174. _currentLimitVelocity1: number;
  12175. /** @hidden */
  12176. _currentLimitVelocity2: number;
  12177. /** @hidden */
  12178. _currentDragGradient: Nullable<FactorGradient>;
  12179. /** @hidden */
  12180. _currentDrag1: number;
  12181. /** @hidden */
  12182. _currentDrag2: number;
  12183. /** @hidden */
  12184. _randomNoiseCoordinates1: Vector3;
  12185. /** @hidden */
  12186. _randomNoiseCoordinates2: Vector3;
  12187. /** @hidden */
  12188. _localPosition?: Vector3;
  12189. /**
  12190. * Creates a new instance Particle
  12191. * @param particleSystem the particle system the particle belongs to
  12192. */
  12193. constructor(
  12194. /**
  12195. * The particle system the particle belongs to.
  12196. */
  12197. particleSystem: ParticleSystem);
  12198. private updateCellInfoFromSystem;
  12199. /**
  12200. * Defines how the sprite cell index is updated for the particle
  12201. */
  12202. updateCellIndex(): void;
  12203. /** @hidden */
  12204. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12205. /** @hidden */
  12206. _inheritParticleInfoToSubEmitters(): void;
  12207. /** @hidden */
  12208. _reset(): void;
  12209. /**
  12210. * Copy the properties of particle to another one.
  12211. * @param other the particle to copy the information to.
  12212. */
  12213. copyTo(other: Particle): void;
  12214. }
  12215. }
  12216. declare module BABYLON {
  12217. /**
  12218. * Particle emitter represents a volume emitting particles.
  12219. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12220. */
  12221. export interface IParticleEmitterType {
  12222. /**
  12223. * Called by the particle System when the direction is computed for the created particle.
  12224. * @param worldMatrix is the world matrix of the particle system
  12225. * @param directionToUpdate is the direction vector to update with the result
  12226. * @param particle is the particle we are computed the direction for
  12227. * @param isLocal defines if the direction should be set in local space
  12228. */
  12229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12230. /**
  12231. * Called by the particle System when the position is computed for the created particle.
  12232. * @param worldMatrix is the world matrix of the particle system
  12233. * @param positionToUpdate is the position vector to update with the result
  12234. * @param particle is the particle we are computed the position for
  12235. * @param isLocal defines if the position should be set in local space
  12236. */
  12237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12238. /**
  12239. * Clones the current emitter and returns a copy of it
  12240. * @returns the new emitter
  12241. */
  12242. clone(): IParticleEmitterType;
  12243. /**
  12244. * Called by the GPUParticleSystem to setup the update shader
  12245. * @param effect defines the update shader
  12246. */
  12247. applyToShader(effect: Effect): void;
  12248. /**
  12249. * Returns a string to use to update the GPU particles update shader
  12250. * @returns the effect defines string
  12251. */
  12252. getEffectDefines(): string;
  12253. /**
  12254. * Returns a string representing the class name
  12255. * @returns a string containing the class name
  12256. */
  12257. getClassName(): string;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /**
  12264. * Parse properties from a JSON object
  12265. * @param serializationObject defines the JSON object
  12266. * @param scene defines the hosting scene
  12267. */
  12268. parse(serializationObject: any, scene: Scene): void;
  12269. }
  12270. }
  12271. declare module BABYLON {
  12272. /**
  12273. * Particle emitter emitting particles from the inside of a box.
  12274. * It emits the particles randomly between 2 given directions.
  12275. */
  12276. export class BoxParticleEmitter implements IParticleEmitterType {
  12277. /**
  12278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12279. */
  12280. direction1: Vector3;
  12281. /**
  12282. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12283. */
  12284. direction2: Vector3;
  12285. /**
  12286. * 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.
  12287. */
  12288. minEmitBox: Vector3;
  12289. /**
  12290. * 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.
  12291. */
  12292. maxEmitBox: Vector3;
  12293. /**
  12294. * Creates a new instance BoxParticleEmitter
  12295. */
  12296. constructor();
  12297. /**
  12298. * Called by the particle System when the direction is computed for the created particle.
  12299. * @param worldMatrix is the world matrix of the particle system
  12300. * @param directionToUpdate is the direction vector to update with the result
  12301. * @param particle is the particle we are computed the direction for
  12302. * @param isLocal defines if the direction should be set in local space
  12303. */
  12304. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12305. /**
  12306. * Called by the particle System when the position is computed for the created particle.
  12307. * @param worldMatrix is the world matrix of the particle system
  12308. * @param positionToUpdate is the position vector to update with the result
  12309. * @param particle is the particle we are computed the position for
  12310. * @param isLocal defines if the position should be set in local space
  12311. */
  12312. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12313. /**
  12314. * Clones the current emitter and returns a copy of it
  12315. * @returns the new emitter
  12316. */
  12317. clone(): BoxParticleEmitter;
  12318. /**
  12319. * Called by the GPUParticleSystem to setup the update shader
  12320. * @param effect defines the update shader
  12321. */
  12322. applyToShader(effect: Effect): void;
  12323. /**
  12324. * Returns a string to use to update the GPU particles update shader
  12325. * @returns a string containng the defines string
  12326. */
  12327. getEffectDefines(): string;
  12328. /**
  12329. * Returns the string "BoxParticleEmitter"
  12330. * @returns a string containing the class name
  12331. */
  12332. getClassName(): string;
  12333. /**
  12334. * Serializes the particle system to a JSON object.
  12335. * @returns the JSON object
  12336. */
  12337. serialize(): any;
  12338. /**
  12339. * Parse properties from a JSON object
  12340. * @param serializationObject defines the JSON object
  12341. */
  12342. parse(serializationObject: any): void;
  12343. }
  12344. }
  12345. declare module BABYLON {
  12346. /**
  12347. * Particle emitter emitting particles from the inside of a cone.
  12348. * It emits the particles alongside the cone volume from the base to the particle.
  12349. * The emission direction might be randomized.
  12350. */
  12351. export class ConeParticleEmitter implements IParticleEmitterType {
  12352. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12353. directionRandomizer: number;
  12354. private _radius;
  12355. private _angle;
  12356. private _height;
  12357. /**
  12358. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12359. */
  12360. radiusRange: number;
  12361. /**
  12362. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12363. */
  12364. heightRange: number;
  12365. /**
  12366. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12367. */
  12368. emitFromSpawnPointOnly: boolean;
  12369. /**
  12370. * Gets or sets the radius of the emission cone
  12371. */
  12372. get radius(): number;
  12373. set radius(value: number);
  12374. /**
  12375. * Gets or sets the angle of the emission cone
  12376. */
  12377. get angle(): number;
  12378. set angle(value: number);
  12379. private _buildHeight;
  12380. /**
  12381. * Creates a new instance ConeParticleEmitter
  12382. * @param radius the radius of the emission cone (1 by default)
  12383. * @param angle the cone base angle (PI by default)
  12384. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12385. */
  12386. constructor(radius?: number, angle?: number,
  12387. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12388. directionRandomizer?: number);
  12389. /**
  12390. * Called by the particle System when the direction is computed for the created particle.
  12391. * @param worldMatrix is the world matrix of the particle system
  12392. * @param directionToUpdate is the direction vector to update with the result
  12393. * @param particle is the particle we are computed the direction for
  12394. * @param isLocal defines if the direction should be set in local space
  12395. */
  12396. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12397. /**
  12398. * Called by the particle System when the position is computed for the created particle.
  12399. * @param worldMatrix is the world matrix of the particle system
  12400. * @param positionToUpdate is the position vector to update with the result
  12401. * @param particle is the particle we are computed the position for
  12402. * @param isLocal defines if the position should be set in local space
  12403. */
  12404. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12405. /**
  12406. * Clones the current emitter and returns a copy of it
  12407. * @returns the new emitter
  12408. */
  12409. clone(): ConeParticleEmitter;
  12410. /**
  12411. * Called by the GPUParticleSystem to setup the update shader
  12412. * @param effect defines the update shader
  12413. */
  12414. applyToShader(effect: Effect): void;
  12415. /**
  12416. * Returns a string to use to update the GPU particles update shader
  12417. * @returns a string containng the defines string
  12418. */
  12419. getEffectDefines(): string;
  12420. /**
  12421. * Returns the string "ConeParticleEmitter"
  12422. * @returns a string containing the class name
  12423. */
  12424. getClassName(): string;
  12425. /**
  12426. * Serializes the particle system to a JSON object.
  12427. * @returns the JSON object
  12428. */
  12429. serialize(): any;
  12430. /**
  12431. * Parse properties from a JSON object
  12432. * @param serializationObject defines the JSON object
  12433. */
  12434. parse(serializationObject: any): void;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Particle emitter emitting particles from the inside of a cylinder.
  12440. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12441. */
  12442. export class CylinderParticleEmitter implements IParticleEmitterType {
  12443. /**
  12444. * The radius of the emission cylinder.
  12445. */
  12446. radius: number;
  12447. /**
  12448. * The height of the emission cylinder.
  12449. */
  12450. height: number;
  12451. /**
  12452. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12453. */
  12454. radiusRange: number;
  12455. /**
  12456. * How much to randomize the particle direction [0-1].
  12457. */
  12458. directionRandomizer: number;
  12459. /**
  12460. * Creates a new instance CylinderParticleEmitter
  12461. * @param radius the radius of the emission cylinder (1 by default)
  12462. * @param height the height of the emission cylinder (1 by default)
  12463. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12464. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12465. */
  12466. constructor(
  12467. /**
  12468. * The radius of the emission cylinder.
  12469. */
  12470. radius?: number,
  12471. /**
  12472. * The height of the emission cylinder.
  12473. */
  12474. height?: number,
  12475. /**
  12476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12477. */
  12478. radiusRange?: number,
  12479. /**
  12480. * How much to randomize the particle direction [0-1].
  12481. */
  12482. directionRandomizer?: number);
  12483. /**
  12484. * Called by the particle System when the direction is computed for the created particle.
  12485. * @param worldMatrix is the world matrix of the particle system
  12486. * @param directionToUpdate is the direction vector to update with the result
  12487. * @param particle is the particle we are computed the direction for
  12488. * @param isLocal defines if the direction should be set in local space
  12489. */
  12490. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12491. /**
  12492. * Called by the particle System when the position is computed for the created particle.
  12493. * @param worldMatrix is the world matrix of the particle system
  12494. * @param positionToUpdate is the position vector to update with the result
  12495. * @param particle is the particle we are computed the position for
  12496. * @param isLocal defines if the position should be set in local space
  12497. */
  12498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12499. /**
  12500. * Clones the current emitter and returns a copy of it
  12501. * @returns the new emitter
  12502. */
  12503. clone(): CylinderParticleEmitter;
  12504. /**
  12505. * Called by the GPUParticleSystem to setup the update shader
  12506. * @param effect defines the update shader
  12507. */
  12508. applyToShader(effect: Effect): void;
  12509. /**
  12510. * Returns a string to use to update the GPU particles update shader
  12511. * @returns a string containng the defines string
  12512. */
  12513. getEffectDefines(): string;
  12514. /**
  12515. * Returns the string "CylinderParticleEmitter"
  12516. * @returns a string containing the class name
  12517. */
  12518. getClassName(): string;
  12519. /**
  12520. * Serializes the particle system to a JSON object.
  12521. * @returns the JSON object
  12522. */
  12523. serialize(): any;
  12524. /**
  12525. * Parse properties from a JSON object
  12526. * @param serializationObject defines the JSON object
  12527. */
  12528. parse(serializationObject: any): void;
  12529. }
  12530. /**
  12531. * Particle emitter emitting particles from the inside of a cylinder.
  12532. * It emits the particles randomly between two vectors.
  12533. */
  12534. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12535. /**
  12536. * The min limit of the emission direction.
  12537. */
  12538. direction1: Vector3;
  12539. /**
  12540. * The max limit of the emission direction.
  12541. */
  12542. direction2: Vector3;
  12543. /**
  12544. * Creates a new instance CylinderDirectedParticleEmitter
  12545. * @param radius the radius of the emission cylinder (1 by default)
  12546. * @param height the height of the emission cylinder (1 by default)
  12547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12548. * @param direction1 the min limit of the emission direction (up vector by default)
  12549. * @param direction2 the max limit of the emission direction (up vector by default)
  12550. */
  12551. constructor(radius?: number, height?: number, radiusRange?: number,
  12552. /**
  12553. * The min limit of the emission direction.
  12554. */
  12555. direction1?: Vector3,
  12556. /**
  12557. * The max limit of the emission direction.
  12558. */
  12559. direction2?: Vector3);
  12560. /**
  12561. * Called by the particle System when the direction is computed for the created particle.
  12562. * @param worldMatrix is the world matrix of the particle system
  12563. * @param directionToUpdate is the direction vector to update with the result
  12564. * @param particle is the particle we are computed the direction for
  12565. */
  12566. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12567. /**
  12568. * Clones the current emitter and returns a copy of it
  12569. * @returns the new emitter
  12570. */
  12571. clone(): CylinderDirectedParticleEmitter;
  12572. /**
  12573. * Called by the GPUParticleSystem to setup the update shader
  12574. * @param effect defines the update shader
  12575. */
  12576. applyToShader(effect: Effect): void;
  12577. /**
  12578. * Returns a string to use to update the GPU particles update shader
  12579. * @returns a string containng the defines string
  12580. */
  12581. getEffectDefines(): string;
  12582. /**
  12583. * Returns the string "CylinderDirectedParticleEmitter"
  12584. * @returns a string containing the class name
  12585. */
  12586. getClassName(): string;
  12587. /**
  12588. * Serializes the particle system to a JSON object.
  12589. * @returns the JSON object
  12590. */
  12591. serialize(): any;
  12592. /**
  12593. * Parse properties from a JSON object
  12594. * @param serializationObject defines the JSON object
  12595. */
  12596. parse(serializationObject: any): void;
  12597. }
  12598. }
  12599. declare module BABYLON {
  12600. /**
  12601. * Particle emitter emitting particles from the inside of a hemisphere.
  12602. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12603. */
  12604. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12605. /**
  12606. * The radius of the emission hemisphere.
  12607. */
  12608. radius: number;
  12609. /**
  12610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12611. */
  12612. radiusRange: number;
  12613. /**
  12614. * How much to randomize the particle direction [0-1].
  12615. */
  12616. directionRandomizer: number;
  12617. /**
  12618. * Creates a new instance HemisphericParticleEmitter
  12619. * @param radius the radius of the emission hemisphere (1 by default)
  12620. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12622. */
  12623. constructor(
  12624. /**
  12625. * The radius of the emission hemisphere.
  12626. */
  12627. radius?: number,
  12628. /**
  12629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12630. */
  12631. radiusRange?: number,
  12632. /**
  12633. * How much to randomize the particle direction [0-1].
  12634. */
  12635. directionRandomizer?: number);
  12636. /**
  12637. * Called by the particle System when the direction is computed for the created particle.
  12638. * @param worldMatrix is the world matrix of the particle system
  12639. * @param directionToUpdate is the direction vector to update with the result
  12640. * @param particle is the particle we are computed the direction for
  12641. * @param isLocal defines if the direction should be set in local space
  12642. */
  12643. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12644. /**
  12645. * Called by the particle System when the position is computed for the created particle.
  12646. * @param worldMatrix is the world matrix of the particle system
  12647. * @param positionToUpdate is the position vector to update with the result
  12648. * @param particle is the particle we are computed the position for
  12649. * @param isLocal defines if the position should be set in local space
  12650. */
  12651. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12652. /**
  12653. * Clones the current emitter and returns a copy of it
  12654. * @returns the new emitter
  12655. */
  12656. clone(): HemisphericParticleEmitter;
  12657. /**
  12658. * Called by the GPUParticleSystem to setup the update shader
  12659. * @param effect defines the update shader
  12660. */
  12661. applyToShader(effect: Effect): void;
  12662. /**
  12663. * Returns a string to use to update the GPU particles update shader
  12664. * @returns a string containng the defines string
  12665. */
  12666. getEffectDefines(): string;
  12667. /**
  12668. * Returns the string "HemisphericParticleEmitter"
  12669. * @returns a string containing the class name
  12670. */
  12671. getClassName(): string;
  12672. /**
  12673. * Serializes the particle system to a JSON object.
  12674. * @returns the JSON object
  12675. */
  12676. serialize(): any;
  12677. /**
  12678. * Parse properties from a JSON object
  12679. * @param serializationObject defines the JSON object
  12680. */
  12681. parse(serializationObject: any): void;
  12682. }
  12683. }
  12684. declare module BABYLON {
  12685. /**
  12686. * Particle emitter emitting particles from a point.
  12687. * It emits the particles randomly between 2 given directions.
  12688. */
  12689. export class PointParticleEmitter implements IParticleEmitterType {
  12690. /**
  12691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12692. */
  12693. direction1: Vector3;
  12694. /**
  12695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12696. */
  12697. direction2: Vector3;
  12698. /**
  12699. * Creates a new instance PointParticleEmitter
  12700. */
  12701. constructor();
  12702. /**
  12703. * Called by the particle System when the direction is computed for the created particle.
  12704. * @param worldMatrix is the world matrix of the particle system
  12705. * @param directionToUpdate is the direction vector to update with the result
  12706. * @param particle is the particle we are computed the direction for
  12707. * @param isLocal defines if the direction should be set in local space
  12708. */
  12709. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12710. /**
  12711. * Called by the particle System when the position is computed for the created particle.
  12712. * @param worldMatrix is the world matrix of the particle system
  12713. * @param positionToUpdate is the position vector to update with the result
  12714. * @param particle is the particle we are computed the position for
  12715. * @param isLocal defines if the position should be set in local space
  12716. */
  12717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12718. /**
  12719. * Clones the current emitter and returns a copy of it
  12720. * @returns the new emitter
  12721. */
  12722. clone(): PointParticleEmitter;
  12723. /**
  12724. * Called by the GPUParticleSystem to setup the update shader
  12725. * @param effect defines the update shader
  12726. */
  12727. applyToShader(effect: Effect): void;
  12728. /**
  12729. * Returns a string to use to update the GPU particles update shader
  12730. * @returns a string containng the defines string
  12731. */
  12732. getEffectDefines(): string;
  12733. /**
  12734. * Returns the string "PointParticleEmitter"
  12735. * @returns a string containing the class name
  12736. */
  12737. getClassName(): string;
  12738. /**
  12739. * Serializes the particle system to a JSON object.
  12740. * @returns the JSON object
  12741. */
  12742. serialize(): any;
  12743. /**
  12744. * Parse properties from a JSON object
  12745. * @param serializationObject defines the JSON object
  12746. */
  12747. parse(serializationObject: any): void;
  12748. }
  12749. }
  12750. declare module BABYLON {
  12751. /**
  12752. * Particle emitter emitting particles from the inside of a sphere.
  12753. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12754. */
  12755. export class SphereParticleEmitter implements IParticleEmitterType {
  12756. /**
  12757. * The radius of the emission sphere.
  12758. */
  12759. radius: number;
  12760. /**
  12761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12762. */
  12763. radiusRange: number;
  12764. /**
  12765. * How much to randomize the particle direction [0-1].
  12766. */
  12767. directionRandomizer: number;
  12768. /**
  12769. * Creates a new instance SphereParticleEmitter
  12770. * @param radius the radius of the emission sphere (1 by default)
  12771. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12772. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12773. */
  12774. constructor(
  12775. /**
  12776. * The radius of the emission sphere.
  12777. */
  12778. radius?: number,
  12779. /**
  12780. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12781. */
  12782. radiusRange?: number,
  12783. /**
  12784. * How much to randomize the particle direction [0-1].
  12785. */
  12786. directionRandomizer?: number);
  12787. /**
  12788. * Called by the particle System when the direction is computed for the created particle.
  12789. * @param worldMatrix is the world matrix of the particle system
  12790. * @param directionToUpdate is the direction vector to update with the result
  12791. * @param particle is the particle we are computed the direction for
  12792. * @param isLocal defines if the direction should be set in local space
  12793. */
  12794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12795. /**
  12796. * Called by the particle System when the position is computed for the created particle.
  12797. * @param worldMatrix is the world matrix of the particle system
  12798. * @param positionToUpdate is the position vector to update with the result
  12799. * @param particle is the particle we are computed the position for
  12800. * @param isLocal defines if the position should be set in local space
  12801. */
  12802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12803. /**
  12804. * Clones the current emitter and returns a copy of it
  12805. * @returns the new emitter
  12806. */
  12807. clone(): SphereParticleEmitter;
  12808. /**
  12809. * Called by the GPUParticleSystem to setup the update shader
  12810. * @param effect defines the update shader
  12811. */
  12812. applyToShader(effect: Effect): void;
  12813. /**
  12814. * Returns a string to use to update the GPU particles update shader
  12815. * @returns a string containng the defines string
  12816. */
  12817. getEffectDefines(): string;
  12818. /**
  12819. * Returns the string "SphereParticleEmitter"
  12820. * @returns a string containing the class name
  12821. */
  12822. getClassName(): string;
  12823. /**
  12824. * Serializes the particle system to a JSON object.
  12825. * @returns the JSON object
  12826. */
  12827. serialize(): any;
  12828. /**
  12829. * Parse properties from a JSON object
  12830. * @param serializationObject defines the JSON object
  12831. */
  12832. parse(serializationObject: any): void;
  12833. }
  12834. /**
  12835. * Particle emitter emitting particles from the inside of a sphere.
  12836. * It emits the particles randomly between two vectors.
  12837. */
  12838. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12839. /**
  12840. * The min limit of the emission direction.
  12841. */
  12842. direction1: Vector3;
  12843. /**
  12844. * The max limit of the emission direction.
  12845. */
  12846. direction2: Vector3;
  12847. /**
  12848. * Creates a new instance SphereDirectedParticleEmitter
  12849. * @param radius the radius of the emission sphere (1 by default)
  12850. * @param direction1 the min limit of the emission direction (up vector by default)
  12851. * @param direction2 the max limit of the emission direction (up vector by default)
  12852. */
  12853. constructor(radius?: number,
  12854. /**
  12855. * The min limit of the emission direction.
  12856. */
  12857. direction1?: Vector3,
  12858. /**
  12859. * The max limit of the emission direction.
  12860. */
  12861. direction2?: Vector3);
  12862. /**
  12863. * Called by the particle System when the direction is computed for the created particle.
  12864. * @param worldMatrix is the world matrix of the particle system
  12865. * @param directionToUpdate is the direction vector to update with the result
  12866. * @param particle is the particle we are computed the direction for
  12867. */
  12868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12869. /**
  12870. * Clones the current emitter and returns a copy of it
  12871. * @returns the new emitter
  12872. */
  12873. clone(): SphereDirectedParticleEmitter;
  12874. /**
  12875. * Called by the GPUParticleSystem to setup the update shader
  12876. * @param effect defines the update shader
  12877. */
  12878. applyToShader(effect: Effect): void;
  12879. /**
  12880. * Returns a string to use to update the GPU particles update shader
  12881. * @returns a string containng the defines string
  12882. */
  12883. getEffectDefines(): string;
  12884. /**
  12885. * Returns the string "SphereDirectedParticleEmitter"
  12886. * @returns a string containing the class name
  12887. */
  12888. getClassName(): string;
  12889. /**
  12890. * Serializes the particle system to a JSON object.
  12891. * @returns the JSON object
  12892. */
  12893. serialize(): any;
  12894. /**
  12895. * Parse properties from a JSON object
  12896. * @param serializationObject defines the JSON object
  12897. */
  12898. parse(serializationObject: any): void;
  12899. }
  12900. }
  12901. declare module BABYLON {
  12902. /**
  12903. * Particle emitter emitting particles from a custom list of positions.
  12904. */
  12905. export class CustomParticleEmitter implements IParticleEmitterType {
  12906. /**
  12907. * Gets or sets the position generator that will create the inital position of each particle.
  12908. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12909. */
  12910. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12911. /**
  12912. * Gets or sets the destination generator that will create the final destination of each particle.
  12913. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12914. */
  12915. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12916. /**
  12917. * Creates a new instance CustomParticleEmitter
  12918. */
  12919. constructor();
  12920. /**
  12921. * Called by the particle System when the direction is computed for the created particle.
  12922. * @param worldMatrix is the world matrix of the particle system
  12923. * @param directionToUpdate is the direction vector to update with the result
  12924. * @param particle is the particle we are computed the direction for
  12925. * @param isLocal defines if the direction should be set in local space
  12926. */
  12927. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12928. /**
  12929. * Called by the particle System when the position is computed for the created particle.
  12930. * @param worldMatrix is the world matrix of the particle system
  12931. * @param positionToUpdate is the position vector to update with the result
  12932. * @param particle is the particle we are computed the position for
  12933. * @param isLocal defines if the position should be set in local space
  12934. */
  12935. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): CustomParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "PointParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. }
  12968. declare module BABYLON {
  12969. /**
  12970. * Particle emitter emitting particles from the inside of a box.
  12971. * It emits the particles randomly between 2 given directions.
  12972. */
  12973. export class MeshParticleEmitter implements IParticleEmitterType {
  12974. private _indices;
  12975. private _positions;
  12976. private _normals;
  12977. private _storedNormal;
  12978. private _mesh;
  12979. /**
  12980. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12981. */
  12982. direction1: Vector3;
  12983. /**
  12984. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12985. */
  12986. direction2: Vector3;
  12987. /**
  12988. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12989. */
  12990. useMeshNormalsForDirection: boolean;
  12991. /** Defines the mesh to use as source */
  12992. get mesh(): Nullable<AbstractMesh>;
  12993. set mesh(value: Nullable<AbstractMesh>);
  12994. /**
  12995. * Creates a new instance MeshParticleEmitter
  12996. * @param mesh defines the mesh to use as source
  12997. */
  12998. constructor(mesh?: Nullable<AbstractMesh>);
  12999. /**
  13000. * Called by the particle System when the direction is computed for the created particle.
  13001. * @param worldMatrix is the world matrix of the particle system
  13002. * @param directionToUpdate is the direction vector to update with the result
  13003. * @param particle is the particle we are computed the direction for
  13004. * @param isLocal defines if the direction should be set in local space
  13005. */
  13006. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13007. /**
  13008. * Called by the particle System when the position is computed for the created particle.
  13009. * @param worldMatrix is the world matrix of the particle system
  13010. * @param positionToUpdate is the position vector to update with the result
  13011. * @param particle is the particle we are computed the position for
  13012. * @param isLocal defines if the position should be set in local space
  13013. */
  13014. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13015. /**
  13016. * Clones the current emitter and returns a copy of it
  13017. * @returns the new emitter
  13018. */
  13019. clone(): MeshParticleEmitter;
  13020. /**
  13021. * Called by the GPUParticleSystem to setup the update shader
  13022. * @param effect defines the update shader
  13023. */
  13024. applyToShader(effect: Effect): void;
  13025. /**
  13026. * Returns a string to use to update the GPU particles update shader
  13027. * @returns a string containng the defines string
  13028. */
  13029. getEffectDefines(): string;
  13030. /**
  13031. * Returns the string "BoxParticleEmitter"
  13032. * @returns a string containing the class name
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Serializes the particle system to a JSON object.
  13037. * @returns the JSON object
  13038. */
  13039. serialize(): any;
  13040. /**
  13041. * Parse properties from a JSON object
  13042. * @param serializationObject defines the JSON object
  13043. * @param scene defines the hosting scene
  13044. */
  13045. parse(serializationObject: any, scene: Scene): void;
  13046. }
  13047. }
  13048. declare module BABYLON {
  13049. /**
  13050. * Interface representing a particle system in Babylon.js.
  13051. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13052. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13053. */
  13054. export interface IParticleSystem {
  13055. /**
  13056. * List of animations used by the particle system.
  13057. */
  13058. animations: Animation[];
  13059. /**
  13060. * The id of the Particle system.
  13061. */
  13062. id: string;
  13063. /**
  13064. * The name of the Particle system.
  13065. */
  13066. name: string;
  13067. /**
  13068. * The emitter represents the Mesh or position we are attaching the particle system to.
  13069. */
  13070. emitter: Nullable<AbstractMesh | Vector3>;
  13071. /**
  13072. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13073. */
  13074. isBillboardBased: boolean;
  13075. /**
  13076. * The rendering group used by the Particle system to chose when to render.
  13077. */
  13078. renderingGroupId: number;
  13079. /**
  13080. * The layer mask we are rendering the particles through.
  13081. */
  13082. layerMask: number;
  13083. /**
  13084. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13085. */
  13086. updateSpeed: number;
  13087. /**
  13088. * The amount of time the particle system is running (depends of the overall update speed).
  13089. */
  13090. targetStopDuration: number;
  13091. /**
  13092. * The texture used to render each particle. (this can be a spritesheet)
  13093. */
  13094. particleTexture: Nullable<Texture>;
  13095. /**
  13096. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13097. */
  13098. blendMode: number;
  13099. /**
  13100. * Minimum life time of emitting particles.
  13101. */
  13102. minLifeTime: number;
  13103. /**
  13104. * Maximum life time of emitting particles.
  13105. */
  13106. maxLifeTime: number;
  13107. /**
  13108. * Minimum Size of emitting particles.
  13109. */
  13110. minSize: number;
  13111. /**
  13112. * Maximum Size of emitting particles.
  13113. */
  13114. maxSize: number;
  13115. /**
  13116. * Minimum scale of emitting particles on X axis.
  13117. */
  13118. minScaleX: number;
  13119. /**
  13120. * Maximum scale of emitting particles on X axis.
  13121. */
  13122. maxScaleX: number;
  13123. /**
  13124. * Minimum scale of emitting particles on Y axis.
  13125. */
  13126. minScaleY: number;
  13127. /**
  13128. * Maximum scale of emitting particles on Y axis.
  13129. */
  13130. maxScaleY: number;
  13131. /**
  13132. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13133. */
  13134. color1: Color4;
  13135. /**
  13136. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13137. */
  13138. color2: Color4;
  13139. /**
  13140. * Color the particle will have at the end of its lifetime.
  13141. */
  13142. colorDead: Color4;
  13143. /**
  13144. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13145. */
  13146. emitRate: number;
  13147. /**
  13148. * You can use gravity if you want to give an orientation to your particles.
  13149. */
  13150. gravity: Vector3;
  13151. /**
  13152. * Minimum power of emitting particles.
  13153. */
  13154. minEmitPower: number;
  13155. /**
  13156. * Maximum power of emitting particles.
  13157. */
  13158. maxEmitPower: number;
  13159. /**
  13160. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13161. */
  13162. minAngularSpeed: number;
  13163. /**
  13164. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13165. */
  13166. maxAngularSpeed: number;
  13167. /**
  13168. * Gets or sets the minimal initial rotation in radians.
  13169. */
  13170. minInitialRotation: number;
  13171. /**
  13172. * Gets or sets the maximal initial rotation in radians.
  13173. */
  13174. maxInitialRotation: number;
  13175. /**
  13176. * The particle emitter type defines the emitter used by the particle system.
  13177. * It can be for example box, sphere, or cone...
  13178. */
  13179. particleEmitterType: Nullable<IParticleEmitterType>;
  13180. /**
  13181. * Defines the delay in milliseconds before starting the system (0 by default)
  13182. */
  13183. startDelay: number;
  13184. /**
  13185. * 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
  13186. */
  13187. preWarmCycles: number;
  13188. /**
  13189. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13190. */
  13191. preWarmStepOffset: number;
  13192. /**
  13193. * 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)
  13194. */
  13195. spriteCellChangeSpeed: number;
  13196. /**
  13197. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13198. */
  13199. startSpriteCellID: number;
  13200. /**
  13201. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13202. */
  13203. endSpriteCellID: number;
  13204. /**
  13205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13206. */
  13207. spriteCellWidth: number;
  13208. /**
  13209. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13210. */
  13211. spriteCellHeight: number;
  13212. /**
  13213. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13214. */
  13215. spriteRandomStartCell: boolean;
  13216. /**
  13217. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13218. */
  13219. isAnimationSheetEnabled: boolean;
  13220. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13221. translationPivot: Vector2;
  13222. /**
  13223. * Gets or sets a texture used to add random noise to particle positions
  13224. */
  13225. noiseTexture: Nullable<BaseTexture>;
  13226. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13227. noiseStrength: Vector3;
  13228. /**
  13229. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13230. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13231. */
  13232. billboardMode: number;
  13233. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13234. limitVelocityDamping: number;
  13235. /**
  13236. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13237. */
  13238. beginAnimationOnStart: boolean;
  13239. /**
  13240. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13241. */
  13242. beginAnimationFrom: number;
  13243. /**
  13244. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13245. */
  13246. beginAnimationTo: number;
  13247. /**
  13248. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13249. */
  13250. beginAnimationLoop: boolean;
  13251. /**
  13252. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13253. */
  13254. disposeOnStop: boolean;
  13255. /**
  13256. * Specifies if the particles are updated in emitter local space or world space
  13257. */
  13258. isLocal: boolean;
  13259. /** Snippet ID if the particle system was created from the snippet server */
  13260. snippetId: string;
  13261. /**
  13262. * Gets the maximum number of particles active at the same time.
  13263. * @returns The max number of active particles.
  13264. */
  13265. getCapacity(): number;
  13266. /**
  13267. * Gets the number of particles active at the same time.
  13268. * @returns The number of active particles.
  13269. */
  13270. getActiveCount(): number;
  13271. /**
  13272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13273. * @returns True if it has been started, otherwise false.
  13274. */
  13275. isStarted(): boolean;
  13276. /**
  13277. * Animates the particle system for this frame.
  13278. */
  13279. animate(): void;
  13280. /**
  13281. * Renders the particle system in its current state.
  13282. * @returns the current number of particles
  13283. */
  13284. render(): number;
  13285. /**
  13286. * Dispose the particle system and frees its associated resources.
  13287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13288. */
  13289. dispose(disposeTexture?: boolean): void;
  13290. /**
  13291. * Clones the particle system.
  13292. * @param name The name of the cloned object
  13293. * @param newEmitter The new emitter to use
  13294. * @returns the cloned particle system
  13295. */
  13296. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13297. /**
  13298. * Serializes the particle system to a JSON object
  13299. * @param serializeTexture defines if the texture must be serialized as well
  13300. * @returns the JSON object
  13301. */
  13302. serialize(serializeTexture: boolean): any;
  13303. /**
  13304. * Rebuild the particle system
  13305. */
  13306. rebuild(): void;
  13307. /** Force the system to rebuild all gradients that need to be resync */
  13308. forceRefreshGradients(): void;
  13309. /**
  13310. * Starts the particle system and begins to emit
  13311. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13312. */
  13313. start(delay?: number): void;
  13314. /**
  13315. * Stops the particle system.
  13316. */
  13317. stop(): void;
  13318. /**
  13319. * Remove all active particles
  13320. */
  13321. reset(): void;
  13322. /**
  13323. * Gets a boolean indicating that the system is stopping
  13324. * @returns true if the system is currently stopping
  13325. */
  13326. isStopping(): boolean;
  13327. /**
  13328. * Is this system ready to be used/rendered
  13329. * @return true if the system is ready
  13330. */
  13331. isReady(): boolean;
  13332. /**
  13333. * Returns the string "ParticleSystem"
  13334. * @returns a string containing the class name
  13335. */
  13336. getClassName(): string;
  13337. /**
  13338. * Adds a new color gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param color1 defines the color to affect to the specified gradient
  13341. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13342. * @returns the current particle system
  13343. */
  13344. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13345. /**
  13346. * Remove a specific color gradient
  13347. * @param gradient defines the gradient to remove
  13348. * @returns the current particle system
  13349. */
  13350. removeColorGradient(gradient: number): IParticleSystem;
  13351. /**
  13352. * Adds a new size gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param factor defines the size factor to affect to the specified gradient
  13355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13356. * @returns the current particle system
  13357. */
  13358. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13359. /**
  13360. * Remove a specific size gradient
  13361. * @param gradient defines the gradient to remove
  13362. * @returns the current particle system
  13363. */
  13364. removeSizeGradient(gradient: number): IParticleSystem;
  13365. /**
  13366. * Gets the current list of color gradients.
  13367. * You must use addColorGradient and removeColorGradient to udpate this list
  13368. * @returns the list of color gradients
  13369. */
  13370. getColorGradients(): Nullable<Array<ColorGradient>>;
  13371. /**
  13372. * Gets the current list of size gradients.
  13373. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13374. * @returns the list of size gradients
  13375. */
  13376. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13377. /**
  13378. * Gets the current list of angular speed gradients.
  13379. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13380. * @returns the list of angular speed gradients
  13381. */
  13382. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13383. /**
  13384. * Adds a new angular speed gradient
  13385. * @param gradient defines the gradient to use (between 0 and 1)
  13386. * @param factor defines the angular speed to affect to the specified gradient
  13387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13388. * @returns the current particle system
  13389. */
  13390. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13391. /**
  13392. * Remove a specific angular speed gradient
  13393. * @param gradient defines the gradient to remove
  13394. * @returns the current particle system
  13395. */
  13396. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13397. /**
  13398. * Gets the current list of velocity gradients.
  13399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13400. * @returns the list of velocity gradients
  13401. */
  13402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13403. /**
  13404. * Adds a new velocity gradient
  13405. * @param gradient defines the gradient to use (between 0 and 1)
  13406. * @param factor defines the velocity to affect to the specified gradient
  13407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13408. * @returns the current particle system
  13409. */
  13410. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13411. /**
  13412. * Remove a specific velocity gradient
  13413. * @param gradient defines the gradient to remove
  13414. * @returns the current particle system
  13415. */
  13416. removeVelocityGradient(gradient: number): IParticleSystem;
  13417. /**
  13418. * Gets the current list of limit velocity gradients.
  13419. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13420. * @returns the list of limit velocity gradients
  13421. */
  13422. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13423. /**
  13424. * Adds a new limit velocity gradient
  13425. * @param gradient defines the gradient to use (between 0 and 1)
  13426. * @param factor defines the limit velocity to affect to the specified gradient
  13427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13428. * @returns the current particle system
  13429. */
  13430. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13431. /**
  13432. * Remove a specific limit velocity gradient
  13433. * @param gradient defines the gradient to remove
  13434. * @returns the current particle system
  13435. */
  13436. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13437. /**
  13438. * Adds a new drag gradient
  13439. * @param gradient defines the gradient to use (between 0 and 1)
  13440. * @param factor defines the drag to affect to the specified gradient
  13441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13442. * @returns the current particle system
  13443. */
  13444. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13445. /**
  13446. * Remove a specific drag gradient
  13447. * @param gradient defines the gradient to remove
  13448. * @returns the current particle system
  13449. */
  13450. removeDragGradient(gradient: number): IParticleSystem;
  13451. /**
  13452. * Gets the current list of drag gradients.
  13453. * You must use addDragGradient and removeDragGradient to udpate this list
  13454. * @returns the list of drag gradients
  13455. */
  13456. getDragGradients(): Nullable<Array<FactorGradient>>;
  13457. /**
  13458. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13459. * @param gradient defines the gradient to use (between 0 and 1)
  13460. * @param factor defines the emit rate to affect to the specified gradient
  13461. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13462. * @returns the current particle system
  13463. */
  13464. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13465. /**
  13466. * Remove a specific emit rate gradient
  13467. * @param gradient defines the gradient to remove
  13468. * @returns the current particle system
  13469. */
  13470. removeEmitRateGradient(gradient: number): IParticleSystem;
  13471. /**
  13472. * Gets the current list of emit rate gradients.
  13473. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13474. * @returns the list of emit rate gradients
  13475. */
  13476. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13477. /**
  13478. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13479. * @param gradient defines the gradient to use (between 0 and 1)
  13480. * @param factor defines the start size to affect to the specified gradient
  13481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13482. * @returns the current particle system
  13483. */
  13484. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13485. /**
  13486. * Remove a specific start size gradient
  13487. * @param gradient defines the gradient to remove
  13488. * @returns the current particle system
  13489. */
  13490. removeStartSizeGradient(gradient: number): IParticleSystem;
  13491. /**
  13492. * Gets the current list of start size gradients.
  13493. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13494. * @returns the list of start size gradients
  13495. */
  13496. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13497. /**
  13498. * Adds a new life time gradient
  13499. * @param gradient defines the gradient to use (between 0 and 1)
  13500. * @param factor defines the life time factor to affect to the specified gradient
  13501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13502. * @returns the current particle system
  13503. */
  13504. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13505. /**
  13506. * Remove a specific life time gradient
  13507. * @param gradient defines the gradient to remove
  13508. * @returns the current particle system
  13509. */
  13510. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13511. /**
  13512. * Gets the current list of life time gradients.
  13513. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13514. * @returns the list of life time gradients
  13515. */
  13516. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13517. /**
  13518. * Gets the current list of color gradients.
  13519. * You must use addColorGradient and removeColorGradient to udpate this list
  13520. * @returns the list of color gradients
  13521. */
  13522. getColorGradients(): Nullable<Array<ColorGradient>>;
  13523. /**
  13524. * Adds a new ramp gradient used to remap particle colors
  13525. * @param gradient defines the gradient to use (between 0 and 1)
  13526. * @param color defines the color to affect to the specified gradient
  13527. * @returns the current particle system
  13528. */
  13529. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13530. /**
  13531. * Gets the current list of ramp gradients.
  13532. * You must use addRampGradient and removeRampGradient to udpate this list
  13533. * @returns the list of ramp gradients
  13534. */
  13535. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13536. /** Gets or sets a boolean indicating that ramp gradients must be used
  13537. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13538. */
  13539. useRampGradients: boolean;
  13540. /**
  13541. * Adds a new color remap gradient
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param min defines the color remap minimal range
  13544. * @param max defines the color remap maximal range
  13545. * @returns the current particle system
  13546. */
  13547. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13548. /**
  13549. * Gets the current list of color remap gradients.
  13550. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13551. * @returns the list of color remap gradients
  13552. */
  13553. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13554. /**
  13555. * Adds a new alpha remap gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param min defines the alpha remap minimal range
  13558. * @param max defines the alpha remap maximal range
  13559. * @returns the current particle system
  13560. */
  13561. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13562. /**
  13563. * Gets the current list of alpha remap gradients.
  13564. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13565. * @returns the list of alpha remap gradients
  13566. */
  13567. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13568. /**
  13569. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13572. * @returns the emitter
  13573. */
  13574. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13575. /**
  13576. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13577. * @param radius The radius of the hemisphere to emit from
  13578. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13579. * @returns the emitter
  13580. */
  13581. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13582. /**
  13583. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13584. * @param radius The radius of the sphere to emit from
  13585. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13586. * @returns the emitter
  13587. */
  13588. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13589. /**
  13590. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13591. * @param radius The radius of the sphere to emit from
  13592. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13593. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13594. * @returns the emitter
  13595. */
  13596. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13597. /**
  13598. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13599. * @param radius The radius of the emission cylinder
  13600. * @param height The height of the emission cylinder
  13601. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13602. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13603. * @returns the emitter
  13604. */
  13605. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13606. /**
  13607. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13608. * @param radius The radius of the cylinder to emit from
  13609. * @param height The height of the emission cylinder
  13610. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13613. * @returns the emitter
  13614. */
  13615. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13616. /**
  13617. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13618. * @param radius The radius of the cone to emit from
  13619. * @param angle The base angle of the cone
  13620. * @returns the emitter
  13621. */
  13622. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13623. /**
  13624. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13627. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13628. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13629. * @returns the emitter
  13630. */
  13631. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13632. /**
  13633. * Get hosting scene
  13634. * @returns the scene
  13635. */
  13636. getScene(): Scene;
  13637. }
  13638. }
  13639. declare module BABYLON {
  13640. /**
  13641. * 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.
  13642. * @see https://doc.babylonjs.com/how_to/transformnode
  13643. */
  13644. export class TransformNode extends Node {
  13645. /**
  13646. * Object will not rotate to face the camera
  13647. */
  13648. static BILLBOARDMODE_NONE: number;
  13649. /**
  13650. * Object will rotate to face the camera but only on the x axis
  13651. */
  13652. static BILLBOARDMODE_X: number;
  13653. /**
  13654. * Object will rotate to face the camera but only on the y axis
  13655. */
  13656. static BILLBOARDMODE_Y: number;
  13657. /**
  13658. * Object will rotate to face the camera but only on the z axis
  13659. */
  13660. static BILLBOARDMODE_Z: number;
  13661. /**
  13662. * Object will rotate to face the camera
  13663. */
  13664. static BILLBOARDMODE_ALL: number;
  13665. /**
  13666. * Object will rotate to face the camera's position instead of orientation
  13667. */
  13668. static BILLBOARDMODE_USE_POSITION: number;
  13669. private _forward;
  13670. private _forwardInverted;
  13671. private _up;
  13672. private _right;
  13673. private _rightInverted;
  13674. private _position;
  13675. private _rotation;
  13676. private _rotationQuaternion;
  13677. protected _scaling: Vector3;
  13678. protected _isDirty: boolean;
  13679. private _transformToBoneReferal;
  13680. private _isAbsoluteSynced;
  13681. private _billboardMode;
  13682. /**
  13683. * Gets or sets the billboard mode. Default is 0.
  13684. *
  13685. * | Value | Type | Description |
  13686. * | --- | --- | --- |
  13687. * | 0 | BILLBOARDMODE_NONE | |
  13688. * | 1 | BILLBOARDMODE_X | |
  13689. * | 2 | BILLBOARDMODE_Y | |
  13690. * | 4 | BILLBOARDMODE_Z | |
  13691. * | 7 | BILLBOARDMODE_ALL | |
  13692. *
  13693. */
  13694. get billboardMode(): number;
  13695. set billboardMode(value: number);
  13696. private _preserveParentRotationForBillboard;
  13697. /**
  13698. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13699. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13700. */
  13701. get preserveParentRotationForBillboard(): boolean;
  13702. set preserveParentRotationForBillboard(value: boolean);
  13703. /**
  13704. * 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
  13705. */
  13706. scalingDeterminant: number;
  13707. private _infiniteDistance;
  13708. /**
  13709. * Gets or sets the distance of the object to max, often used by skybox
  13710. */
  13711. get infiniteDistance(): boolean;
  13712. set infiniteDistance(value: boolean);
  13713. /**
  13714. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13715. * By default the system will update normals to compensate
  13716. */
  13717. ignoreNonUniformScaling: boolean;
  13718. /**
  13719. * 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
  13720. */
  13721. reIntegrateRotationIntoRotationQuaternion: boolean;
  13722. /** @hidden */
  13723. _poseMatrix: Nullable<Matrix>;
  13724. /** @hidden */
  13725. _localMatrix: Matrix;
  13726. private _usePivotMatrix;
  13727. private _absolutePosition;
  13728. private _absoluteScaling;
  13729. private _absoluteRotationQuaternion;
  13730. private _pivotMatrix;
  13731. private _pivotMatrixInverse;
  13732. protected _postMultiplyPivotMatrix: boolean;
  13733. protected _isWorldMatrixFrozen: boolean;
  13734. /** @hidden */
  13735. _indexInSceneTransformNodesArray: number;
  13736. /**
  13737. * An event triggered after the world matrix is updated
  13738. */
  13739. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13740. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13741. /**
  13742. * Gets a string identifying the name of the class
  13743. * @returns "TransformNode" string
  13744. */
  13745. getClassName(): string;
  13746. /**
  13747. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13748. */
  13749. get position(): Vector3;
  13750. set position(newPosition: Vector3);
  13751. /**
  13752. * 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)).
  13753. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13754. */
  13755. get rotation(): Vector3;
  13756. set rotation(newRotation: Vector3);
  13757. /**
  13758. * 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)).
  13759. */
  13760. get scaling(): Vector3;
  13761. set scaling(newScaling: Vector3);
  13762. /**
  13763. * 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).
  13764. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13765. */
  13766. get rotationQuaternion(): Nullable<Quaternion>;
  13767. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13768. /**
  13769. * The forward direction of that transform in world space.
  13770. */
  13771. get forward(): Vector3;
  13772. /**
  13773. * The up direction of that transform in world space.
  13774. */
  13775. get up(): Vector3;
  13776. /**
  13777. * The right direction of that transform in world space.
  13778. */
  13779. get right(): Vector3;
  13780. /**
  13781. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13782. * @param matrix the matrix to copy the pose from
  13783. * @returns this TransformNode.
  13784. */
  13785. updatePoseMatrix(matrix: Matrix): TransformNode;
  13786. /**
  13787. * Returns the mesh Pose matrix.
  13788. * @returns the pose matrix
  13789. */
  13790. getPoseMatrix(): Matrix;
  13791. /** @hidden */
  13792. _isSynchronized(): boolean;
  13793. /** @hidden */
  13794. _initCache(): void;
  13795. /**
  13796. * Flag the transform node as dirty (Forcing it to update everything)
  13797. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13798. * @returns this transform node
  13799. */
  13800. markAsDirty(property: string): TransformNode;
  13801. /**
  13802. * Returns the current mesh absolute position.
  13803. * Returns a Vector3.
  13804. */
  13805. get absolutePosition(): Vector3;
  13806. /**
  13807. * Returns the current mesh absolute scaling.
  13808. * Returns a Vector3.
  13809. */
  13810. get absoluteScaling(): Vector3;
  13811. /**
  13812. * Returns the current mesh absolute rotation.
  13813. * Returns a Quaternion.
  13814. */
  13815. get absoluteRotationQuaternion(): Quaternion;
  13816. /**
  13817. * Sets a new matrix to apply before all other transformation
  13818. * @param matrix defines the transform matrix
  13819. * @returns the current TransformNode
  13820. */
  13821. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13822. /**
  13823. * Sets a new pivot matrix to the current node
  13824. * @param matrix defines the new pivot matrix to use
  13825. * @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
  13826. * @returns the current TransformNode
  13827. */
  13828. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13829. /**
  13830. * Returns the mesh pivot matrix.
  13831. * Default : Identity.
  13832. * @returns the matrix
  13833. */
  13834. getPivotMatrix(): Matrix;
  13835. /**
  13836. * Instantiate (when possible) or clone that node with its hierarchy
  13837. * @param newParent defines the new parent to use for the instance (or clone)
  13838. * @param options defines options to configure how copy is done
  13839. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13840. * @returns an instance (or a clone) of the current node with its hiearchy
  13841. */
  13842. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13843. doNotInstantiate: boolean;
  13844. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13845. /**
  13846. * Prevents the World matrix to be computed any longer
  13847. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13848. * @returns the TransformNode.
  13849. */
  13850. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13851. /**
  13852. * Allows back the World matrix computation.
  13853. * @returns the TransformNode.
  13854. */
  13855. unfreezeWorldMatrix(): this;
  13856. /**
  13857. * True if the World matrix has been frozen.
  13858. */
  13859. get isWorldMatrixFrozen(): boolean;
  13860. /**
  13861. * Retuns the mesh absolute position in the World.
  13862. * @returns a Vector3.
  13863. */
  13864. getAbsolutePosition(): Vector3;
  13865. /**
  13866. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13867. * @param absolutePosition the absolute position to set
  13868. * @returns the TransformNode.
  13869. */
  13870. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13871. /**
  13872. * Sets the mesh position in its local space.
  13873. * @param vector3 the position to set in localspace
  13874. * @returns the TransformNode.
  13875. */
  13876. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13877. /**
  13878. * Returns the mesh position in the local space from the current World matrix values.
  13879. * @returns a new Vector3.
  13880. */
  13881. getPositionExpressedInLocalSpace(): Vector3;
  13882. /**
  13883. * Translates the mesh along the passed Vector3 in its local space.
  13884. * @param vector3 the distance to translate in localspace
  13885. * @returns the TransformNode.
  13886. */
  13887. locallyTranslate(vector3: Vector3): TransformNode;
  13888. private static _lookAtVectorCache;
  13889. /**
  13890. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13891. * @param targetPoint the position (must be in same space as current mesh) to look at
  13892. * @param yawCor optional yaw (y-axis) correction in radians
  13893. * @param pitchCor optional pitch (x-axis) correction in radians
  13894. * @param rollCor optional roll (z-axis) correction in radians
  13895. * @param space the choosen space of the target
  13896. * @returns the TransformNode.
  13897. */
  13898. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13899. /**
  13900. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13901. * This Vector3 is expressed in the World space.
  13902. * @param localAxis axis to rotate
  13903. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13904. */
  13905. getDirection(localAxis: Vector3): Vector3;
  13906. /**
  13907. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13908. * localAxis is expressed in the mesh local space.
  13909. * result is computed in the Wordl space from the mesh World matrix.
  13910. * @param localAxis axis to rotate
  13911. * @param result the resulting transformnode
  13912. * @returns this TransformNode.
  13913. */
  13914. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13915. /**
  13916. * Sets this transform node rotation to the given local axis.
  13917. * @param localAxis the axis in local space
  13918. * @param yawCor optional yaw (y-axis) correction in radians
  13919. * @param pitchCor optional pitch (x-axis) correction in radians
  13920. * @param rollCor optional roll (z-axis) correction in radians
  13921. * @returns this TransformNode
  13922. */
  13923. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13924. /**
  13925. * Sets a new pivot point to the current node
  13926. * @param point defines the new pivot point to use
  13927. * @param space defines if the point is in world or local space (local by default)
  13928. * @returns the current TransformNode
  13929. */
  13930. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13931. /**
  13932. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13933. * @returns the pivot point
  13934. */
  13935. getPivotPoint(): Vector3;
  13936. /**
  13937. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13938. * @param result the vector3 to store the result
  13939. * @returns this TransformNode.
  13940. */
  13941. getPivotPointToRef(result: Vector3): TransformNode;
  13942. /**
  13943. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13944. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13945. */
  13946. getAbsolutePivotPoint(): Vector3;
  13947. /**
  13948. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13949. * @param result vector3 to store the result
  13950. * @returns this TransformNode.
  13951. */
  13952. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13953. /**
  13954. * Defines the passed node as the parent of the current node.
  13955. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13956. * @see https://doc.babylonjs.com/how_to/parenting
  13957. * @param node the node ot set as the parent
  13958. * @returns this TransformNode.
  13959. */
  13960. setParent(node: Nullable<Node>): TransformNode;
  13961. private _nonUniformScaling;
  13962. /**
  13963. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13964. */
  13965. get nonUniformScaling(): boolean;
  13966. /** @hidden */
  13967. _updateNonUniformScalingState(value: boolean): boolean;
  13968. /**
  13969. * Attach the current TransformNode to another TransformNode associated with a bone
  13970. * @param bone Bone affecting the TransformNode
  13971. * @param affectedTransformNode TransformNode associated with the bone
  13972. * @returns this object
  13973. */
  13974. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13975. /**
  13976. * Detach the transform node if its associated with a bone
  13977. * @returns this object
  13978. */
  13979. detachFromBone(): TransformNode;
  13980. private static _rotationAxisCache;
  13981. /**
  13982. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13983. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13984. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13985. * The passed axis is also normalized.
  13986. * @param axis the axis to rotate around
  13987. * @param amount the amount to rotate in radians
  13988. * @param space Space to rotate in (Default: local)
  13989. * @returns the TransformNode.
  13990. */
  13991. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13992. /**
  13993. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13994. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13995. * The passed axis is also normalized. .
  13996. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13997. * @param point the point to rotate around
  13998. * @param axis the axis to rotate around
  13999. * @param amount the amount to rotate in radians
  14000. * @returns the TransformNode
  14001. */
  14002. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14003. /**
  14004. * Translates the mesh along the axis vector for the passed distance in the given space.
  14005. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14006. * @param axis the axis to translate in
  14007. * @param distance the distance to translate
  14008. * @param space Space to rotate in (Default: local)
  14009. * @returns the TransformNode.
  14010. */
  14011. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14012. /**
  14013. * Adds a rotation step to the mesh current rotation.
  14014. * x, y, z are Euler angles expressed in radians.
  14015. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14016. * This means this rotation is made in the mesh local space only.
  14017. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14018. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14019. * ```javascript
  14020. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14021. * ```
  14022. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14023. * 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.
  14024. * @param x Rotation to add
  14025. * @param y Rotation to add
  14026. * @param z Rotation to add
  14027. * @returns the TransformNode.
  14028. */
  14029. addRotation(x: number, y: number, z: number): TransformNode;
  14030. /**
  14031. * @hidden
  14032. */
  14033. protected _getEffectiveParent(): Nullable<Node>;
  14034. /**
  14035. * Computes the world matrix of the node
  14036. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14037. * @returns the world matrix
  14038. */
  14039. computeWorldMatrix(force?: boolean): Matrix;
  14040. /**
  14041. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14042. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14043. */
  14044. resetLocalMatrix(independentOfChildren?: boolean): void;
  14045. protected _afterComputeWorldMatrix(): void;
  14046. /**
  14047. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14048. * @param func callback function to add
  14049. *
  14050. * @returns the TransformNode.
  14051. */
  14052. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14053. /**
  14054. * Removes a registered callback function.
  14055. * @param func callback function to remove
  14056. * @returns the TransformNode.
  14057. */
  14058. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14059. /**
  14060. * Gets the position of the current mesh in camera space
  14061. * @param camera defines the camera to use
  14062. * @returns a position
  14063. */
  14064. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14065. /**
  14066. * Returns the distance from the mesh to the active camera
  14067. * @param camera defines the camera to use
  14068. * @returns the distance
  14069. */
  14070. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14071. /**
  14072. * Clone the current transform node
  14073. * @param name Name of the new clone
  14074. * @param newParent New parent for the clone
  14075. * @param doNotCloneChildren Do not clone children hierarchy
  14076. * @returns the new transform node
  14077. */
  14078. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14079. /**
  14080. * Serializes the objects information.
  14081. * @param currentSerializationObject defines the object to serialize in
  14082. * @returns the serialized object
  14083. */
  14084. serialize(currentSerializationObject?: any): any;
  14085. /**
  14086. * Returns a new TransformNode object parsed from the source provided.
  14087. * @param parsedTransformNode is the source.
  14088. * @param scene the scne the object belongs to
  14089. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14090. * @returns a new TransformNode object parsed from the source provided.
  14091. */
  14092. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14093. /**
  14094. * Get all child-transformNodes of this node
  14095. * @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
  14096. * @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
  14097. * @returns an array of TransformNode
  14098. */
  14099. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14100. /**
  14101. * Releases resources associated with this transform node.
  14102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14104. */
  14105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14106. /**
  14107. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14108. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14109. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14110. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14111. * @returns the current mesh
  14112. */
  14113. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14114. private _syncAbsoluteScalingAndRotation;
  14115. }
  14116. }
  14117. declare module BABYLON {
  14118. /**
  14119. * Class used to override all child animations of a given target
  14120. */
  14121. export class AnimationPropertiesOverride {
  14122. /**
  14123. * Gets or sets a value indicating if animation blending must be used
  14124. */
  14125. enableBlending: boolean;
  14126. /**
  14127. * Gets or sets the blending speed to use when enableBlending is true
  14128. */
  14129. blendingSpeed: number;
  14130. /**
  14131. * Gets or sets the default loop mode to use
  14132. */
  14133. loopMode: number;
  14134. }
  14135. }
  14136. declare module BABYLON {
  14137. /**
  14138. * Class used to store bone information
  14139. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14140. */
  14141. export class Bone extends Node {
  14142. /**
  14143. * defines the bone name
  14144. */
  14145. name: string;
  14146. private static _tmpVecs;
  14147. private static _tmpQuat;
  14148. private static _tmpMats;
  14149. /**
  14150. * Gets the list of child bones
  14151. */
  14152. children: Bone[];
  14153. /** Gets the animations associated with this bone */
  14154. animations: Animation[];
  14155. /**
  14156. * Gets or sets bone length
  14157. */
  14158. length: number;
  14159. /**
  14160. * @hidden Internal only
  14161. * Set this value to map this bone to a different index in the transform matrices
  14162. * Set this value to -1 to exclude the bone from the transform matrices
  14163. */
  14164. _index: Nullable<number>;
  14165. private _skeleton;
  14166. private _localMatrix;
  14167. private _restPose;
  14168. private _baseMatrix;
  14169. private _absoluteTransform;
  14170. private _invertedAbsoluteTransform;
  14171. private _parent;
  14172. private _scalingDeterminant;
  14173. private _worldTransform;
  14174. private _localScaling;
  14175. private _localRotation;
  14176. private _localPosition;
  14177. private _needToDecompose;
  14178. private _needToCompose;
  14179. /** @hidden */
  14180. _linkedTransformNode: Nullable<TransformNode>;
  14181. /** @hidden */
  14182. _waitingTransformNodeId: Nullable<string>;
  14183. /** @hidden */
  14184. get _matrix(): Matrix;
  14185. /** @hidden */
  14186. set _matrix(value: Matrix);
  14187. /**
  14188. * Create a new bone
  14189. * @param name defines the bone name
  14190. * @param skeleton defines the parent skeleton
  14191. * @param parentBone defines the parent (can be null if the bone is the root)
  14192. * @param localMatrix defines the local matrix
  14193. * @param restPose defines the rest pose matrix
  14194. * @param baseMatrix defines the base matrix
  14195. * @param index defines index of the bone in the hiearchy
  14196. */
  14197. constructor(
  14198. /**
  14199. * defines the bone name
  14200. */
  14201. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14202. /**
  14203. * Gets the current object class name.
  14204. * @return the class name
  14205. */
  14206. getClassName(): string;
  14207. /**
  14208. * Gets the parent skeleton
  14209. * @returns a skeleton
  14210. */
  14211. getSkeleton(): Skeleton;
  14212. /**
  14213. * Gets parent bone
  14214. * @returns a bone or null if the bone is the root of the bone hierarchy
  14215. */
  14216. getParent(): Nullable<Bone>;
  14217. /**
  14218. * Returns an array containing the root bones
  14219. * @returns an array containing the root bones
  14220. */
  14221. getChildren(): Array<Bone>;
  14222. /**
  14223. * Gets the node index in matrix array generated for rendering
  14224. * @returns the node index
  14225. */
  14226. getIndex(): number;
  14227. /**
  14228. * Sets the parent bone
  14229. * @param parent defines the parent (can be null if the bone is the root)
  14230. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14231. */
  14232. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14233. /**
  14234. * Gets the local matrix
  14235. * @returns a matrix
  14236. */
  14237. getLocalMatrix(): Matrix;
  14238. /**
  14239. * Gets the base matrix (initial matrix which remains unchanged)
  14240. * @returns a matrix
  14241. */
  14242. getBaseMatrix(): Matrix;
  14243. /**
  14244. * Gets the rest pose matrix
  14245. * @returns a matrix
  14246. */
  14247. getRestPose(): Matrix;
  14248. /**
  14249. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14250. */
  14251. getWorldMatrix(): Matrix;
  14252. /**
  14253. * Sets the local matrix to rest pose matrix
  14254. */
  14255. returnToRest(): void;
  14256. /**
  14257. * Gets the inverse of the absolute transform matrix.
  14258. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14259. * @returns a matrix
  14260. */
  14261. getInvertedAbsoluteTransform(): Matrix;
  14262. /**
  14263. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14264. * @returns a matrix
  14265. */
  14266. getAbsoluteTransform(): Matrix;
  14267. /**
  14268. * Links with the given transform node.
  14269. * The local matrix of this bone is copied from the transform node every frame.
  14270. * @param transformNode defines the transform node to link to
  14271. */
  14272. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14273. /**
  14274. * Gets the node used to drive the bone's transformation
  14275. * @returns a transform node or null
  14276. */
  14277. getTransformNode(): Nullable<TransformNode>;
  14278. /** Gets or sets current position (in local space) */
  14279. get position(): Vector3;
  14280. set position(newPosition: Vector3);
  14281. /** Gets or sets current rotation (in local space) */
  14282. get rotation(): Vector3;
  14283. set rotation(newRotation: Vector3);
  14284. /** Gets or sets current rotation quaternion (in local space) */
  14285. get rotationQuaternion(): Quaternion;
  14286. set rotationQuaternion(newRotation: Quaternion);
  14287. /** Gets or sets current scaling (in local space) */
  14288. get scaling(): Vector3;
  14289. set scaling(newScaling: Vector3);
  14290. /**
  14291. * Gets the animation properties override
  14292. */
  14293. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14294. private _decompose;
  14295. private _compose;
  14296. /**
  14297. * Update the base and local matrices
  14298. * @param matrix defines the new base or local matrix
  14299. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14300. * @param updateLocalMatrix defines if the local matrix should be updated
  14301. */
  14302. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14303. /** @hidden */
  14304. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14305. /**
  14306. * Flag the bone as dirty (Forcing it to update everything)
  14307. */
  14308. markAsDirty(): void;
  14309. /** @hidden */
  14310. _markAsDirtyAndCompose(): void;
  14311. private _markAsDirtyAndDecompose;
  14312. /**
  14313. * Translate the bone in local or world space
  14314. * @param vec The amount to translate the bone
  14315. * @param space The space that the translation is in
  14316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14317. */
  14318. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14319. /**
  14320. * Set the postion of the bone in local or world space
  14321. * @param position The position to set the bone
  14322. * @param space The space that the position is in
  14323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14324. */
  14325. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14326. /**
  14327. * Set the absolute position of the bone (world space)
  14328. * @param position The position to set the bone
  14329. * @param mesh The mesh that this bone is attached to
  14330. */
  14331. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14332. /**
  14333. * Scale the bone on the x, y and z axes (in local space)
  14334. * @param x The amount to scale the bone on the x axis
  14335. * @param y The amount to scale the bone on the y axis
  14336. * @param z The amount to scale the bone on the z axis
  14337. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14338. */
  14339. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14340. /**
  14341. * Set the bone scaling in local space
  14342. * @param scale defines the scaling vector
  14343. */
  14344. setScale(scale: Vector3): void;
  14345. /**
  14346. * Gets the current scaling in local space
  14347. * @returns the current scaling vector
  14348. */
  14349. getScale(): Vector3;
  14350. /**
  14351. * Gets the current scaling in local space and stores it in a target vector
  14352. * @param result defines the target vector
  14353. */
  14354. getScaleToRef(result: Vector3): void;
  14355. /**
  14356. * Set the yaw, pitch, and roll of the bone in local or world space
  14357. * @param yaw The rotation of the bone on the y axis
  14358. * @param pitch The rotation of the bone on the x axis
  14359. * @param roll The rotation of the bone on the z axis
  14360. * @param space The space that the axes of rotation are in
  14361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14362. */
  14363. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14364. /**
  14365. * Add a rotation to the bone on an axis in local or world space
  14366. * @param axis The axis to rotate the bone on
  14367. * @param amount The amount to rotate the bone
  14368. * @param space The space that the axis is in
  14369. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14370. */
  14371. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14372. /**
  14373. * Set the rotation of the bone to a particular axis angle in local or world space
  14374. * @param axis The axis to rotate the bone on
  14375. * @param angle The angle that the bone should be rotated to
  14376. * @param space The space that the axis is in
  14377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14378. */
  14379. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14380. /**
  14381. * Set the euler rotation of the bone in local of world space
  14382. * @param rotation The euler rotation that the bone should be set to
  14383. * @param space The space that the rotation is in
  14384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14385. */
  14386. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14387. /**
  14388. * Set the quaternion rotation of the bone in local of world space
  14389. * @param quat The quaternion rotation that the bone should be set to
  14390. * @param space The space that the rotation is in
  14391. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14392. */
  14393. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14394. /**
  14395. * Set the rotation matrix of the bone in local of world space
  14396. * @param rotMat The rotation matrix that the bone should be set to
  14397. * @param space The space that the rotation is in
  14398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14399. */
  14400. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14401. private _rotateWithMatrix;
  14402. private _getNegativeRotationToRef;
  14403. /**
  14404. * Get the position of the bone in local or world space
  14405. * @param space The space that the returned position is in
  14406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14407. * @returns The position of the bone
  14408. */
  14409. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14410. /**
  14411. * Copy the position of the bone to a vector3 in local or world space
  14412. * @param space The space that the returned position is in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. * @param result The vector3 to copy the position to
  14415. */
  14416. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14417. /**
  14418. * Get the absolute position of the bone (world space)
  14419. * @param mesh The mesh that this bone is attached to
  14420. * @returns The absolute position of the bone
  14421. */
  14422. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14423. /**
  14424. * Copy the absolute position of the bone (world space) to the result param
  14425. * @param mesh The mesh that this bone is attached to
  14426. * @param result The vector3 to copy the absolute position to
  14427. */
  14428. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14429. /**
  14430. * Compute the absolute transforms of this bone and its children
  14431. */
  14432. computeAbsoluteTransforms(): void;
  14433. /**
  14434. * Get the world direction from an axis that is in the local space of the bone
  14435. * @param localAxis The local direction that is used to compute the world direction
  14436. * @param mesh The mesh that this bone is attached to
  14437. * @returns The world direction
  14438. */
  14439. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14440. /**
  14441. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14442. * @param localAxis The local direction that is used to compute the world direction
  14443. * @param mesh The mesh that this bone is attached to
  14444. * @param result The vector3 that the world direction will be copied to
  14445. */
  14446. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14447. /**
  14448. * Get the euler rotation of the bone in local or world space
  14449. * @param space The space that the rotation should be in
  14450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14451. * @returns The euler rotation
  14452. */
  14453. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14454. /**
  14455. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14456. * @param space The space that the rotation should be in
  14457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14458. * @param result The vector3 that the rotation should be copied to
  14459. */
  14460. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14461. /**
  14462. * Get the quaternion rotation of the bone in either local or world space
  14463. * @param space The space that the rotation should be in
  14464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14465. * @returns The quaternion rotation
  14466. */
  14467. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14468. /**
  14469. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14470. * @param space The space that the rotation should be in
  14471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14472. * @param result The quaternion that the rotation should be copied to
  14473. */
  14474. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14475. /**
  14476. * Get the rotation matrix of the bone in local or world space
  14477. * @param space The space that the rotation should be in
  14478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14479. * @returns The rotation matrix
  14480. */
  14481. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14482. /**
  14483. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14484. * @param space The space that the rotation should be in
  14485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14486. * @param result The quaternion that the rotation should be copied to
  14487. */
  14488. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14489. /**
  14490. * Get the world position of a point that is in the local space of the bone
  14491. * @param position The local position
  14492. * @param mesh The mesh that this bone is attached to
  14493. * @returns The world position
  14494. */
  14495. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14496. /**
  14497. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14498. * @param position The local position
  14499. * @param mesh The mesh that this bone is attached to
  14500. * @param result The vector3 that the world position should be copied to
  14501. */
  14502. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14503. /**
  14504. * Get the local position of a point that is in world space
  14505. * @param position The world position
  14506. * @param mesh The mesh that this bone is attached to
  14507. * @returns The local position
  14508. */
  14509. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14510. /**
  14511. * Get the local position of a point that is in world space and copy it to the result param
  14512. * @param position The world position
  14513. * @param mesh The mesh that this bone is attached to
  14514. * @param result The vector3 that the local position should be copied to
  14515. */
  14516. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14517. }
  14518. }
  14519. declare module BABYLON {
  14520. /**
  14521. * Defines a runtime animation
  14522. */
  14523. export class RuntimeAnimation {
  14524. private _events;
  14525. /**
  14526. * The current frame of the runtime animation
  14527. */
  14528. private _currentFrame;
  14529. /**
  14530. * The animation used by the runtime animation
  14531. */
  14532. private _animation;
  14533. /**
  14534. * The target of the runtime animation
  14535. */
  14536. private _target;
  14537. /**
  14538. * The initiating animatable
  14539. */
  14540. private _host;
  14541. /**
  14542. * The original value of the runtime animation
  14543. */
  14544. private _originalValue;
  14545. /**
  14546. * The original blend value of the runtime animation
  14547. */
  14548. private _originalBlendValue;
  14549. /**
  14550. * The offsets cache of the runtime animation
  14551. */
  14552. private _offsetsCache;
  14553. /**
  14554. * The high limits cache of the runtime animation
  14555. */
  14556. private _highLimitsCache;
  14557. /**
  14558. * Specifies if the runtime animation has been stopped
  14559. */
  14560. private _stopped;
  14561. /**
  14562. * The blending factor of the runtime animation
  14563. */
  14564. private _blendingFactor;
  14565. /**
  14566. * The BabylonJS scene
  14567. */
  14568. private _scene;
  14569. /**
  14570. * The current value of the runtime animation
  14571. */
  14572. private _currentValue;
  14573. /** @hidden */
  14574. _animationState: _IAnimationState;
  14575. /**
  14576. * The active target of the runtime animation
  14577. */
  14578. private _activeTargets;
  14579. private _currentActiveTarget;
  14580. private _directTarget;
  14581. /**
  14582. * The target path of the runtime animation
  14583. */
  14584. private _targetPath;
  14585. /**
  14586. * The weight of the runtime animation
  14587. */
  14588. private _weight;
  14589. /**
  14590. * The ratio offset of the runtime animation
  14591. */
  14592. private _ratioOffset;
  14593. /**
  14594. * The previous delay of the runtime animation
  14595. */
  14596. private _previousDelay;
  14597. /**
  14598. * The previous ratio of the runtime animation
  14599. */
  14600. private _previousRatio;
  14601. private _enableBlending;
  14602. private _keys;
  14603. private _minFrame;
  14604. private _maxFrame;
  14605. private _minValue;
  14606. private _maxValue;
  14607. private _targetIsArray;
  14608. /**
  14609. * Gets the current frame of the runtime animation
  14610. */
  14611. get currentFrame(): number;
  14612. /**
  14613. * Gets the weight of the runtime animation
  14614. */
  14615. get weight(): number;
  14616. /**
  14617. * Gets the current value of the runtime animation
  14618. */
  14619. get currentValue(): any;
  14620. /**
  14621. * Gets the target path of the runtime animation
  14622. */
  14623. get targetPath(): string;
  14624. /**
  14625. * Gets the actual target of the runtime animation
  14626. */
  14627. get target(): any;
  14628. /**
  14629. * Gets the additive state of the runtime animation
  14630. */
  14631. get isAdditive(): boolean;
  14632. /** @hidden */
  14633. _onLoop: () => void;
  14634. /**
  14635. * Create a new RuntimeAnimation object
  14636. * @param target defines the target of the animation
  14637. * @param animation defines the source animation object
  14638. * @param scene defines the hosting scene
  14639. * @param host defines the initiating Animatable
  14640. */
  14641. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14642. private _preparePath;
  14643. /**
  14644. * Gets the animation from the runtime animation
  14645. */
  14646. get animation(): Animation;
  14647. /**
  14648. * Resets the runtime animation to the beginning
  14649. * @param restoreOriginal defines whether to restore the target property to the original value
  14650. */
  14651. reset(restoreOriginal?: boolean): void;
  14652. /**
  14653. * Specifies if the runtime animation is stopped
  14654. * @returns Boolean specifying if the runtime animation is stopped
  14655. */
  14656. isStopped(): boolean;
  14657. /**
  14658. * Disposes of the runtime animation
  14659. */
  14660. dispose(): void;
  14661. /**
  14662. * Apply the interpolated value to the target
  14663. * @param currentValue defines the value computed by the animation
  14664. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14665. */
  14666. setValue(currentValue: any, weight: number): void;
  14667. private _getOriginalValues;
  14668. private _setValue;
  14669. /**
  14670. * Gets the loop pmode of the runtime animation
  14671. * @returns Loop Mode
  14672. */
  14673. private _getCorrectLoopMode;
  14674. /**
  14675. * Move the current animation to a given frame
  14676. * @param frame defines the frame to move to
  14677. */
  14678. goToFrame(frame: number): void;
  14679. /**
  14680. * @hidden Internal use only
  14681. */
  14682. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14683. /**
  14684. * Execute the current animation
  14685. * @param delay defines the delay to add to the current frame
  14686. * @param from defines the lower bound of the animation range
  14687. * @param to defines the upper bound of the animation range
  14688. * @param loop defines if the current animation must loop
  14689. * @param speedRatio defines the current speed ratio
  14690. * @param weight defines the weight of the animation (default is -1 so no weight)
  14691. * @param onLoop optional callback called when animation loops
  14692. * @returns a boolean indicating if the animation is running
  14693. */
  14694. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14695. }
  14696. }
  14697. declare module BABYLON {
  14698. /**
  14699. * Class used to store an actual running animation
  14700. */
  14701. export class Animatable {
  14702. /** defines the target object */
  14703. target: any;
  14704. /** defines the starting frame number (default is 0) */
  14705. fromFrame: number;
  14706. /** defines the ending frame number (default is 100) */
  14707. toFrame: number;
  14708. /** defines if the animation must loop (default is false) */
  14709. loopAnimation: boolean;
  14710. /** defines a callback to call when animation ends if it is not looping */
  14711. onAnimationEnd?: (() => void) | null | undefined;
  14712. /** defines a callback to call when animation loops */
  14713. onAnimationLoop?: (() => void) | null | undefined;
  14714. /** defines whether the animation should be evaluated additively */
  14715. isAdditive: boolean;
  14716. private _localDelayOffset;
  14717. private _pausedDelay;
  14718. private _runtimeAnimations;
  14719. private _paused;
  14720. private _scene;
  14721. private _speedRatio;
  14722. private _weight;
  14723. private _syncRoot;
  14724. /**
  14725. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14726. * This will only apply for non looping animation (default is true)
  14727. */
  14728. disposeOnEnd: boolean;
  14729. /**
  14730. * Gets a boolean indicating if the animation has started
  14731. */
  14732. animationStarted: boolean;
  14733. /**
  14734. * Observer raised when the animation ends
  14735. */
  14736. onAnimationEndObservable: Observable<Animatable>;
  14737. /**
  14738. * Observer raised when the animation loops
  14739. */
  14740. onAnimationLoopObservable: Observable<Animatable>;
  14741. /**
  14742. * Gets the root Animatable used to synchronize and normalize animations
  14743. */
  14744. get syncRoot(): Nullable<Animatable>;
  14745. /**
  14746. * Gets the current frame of the first RuntimeAnimation
  14747. * Used to synchronize Animatables
  14748. */
  14749. get masterFrame(): number;
  14750. /**
  14751. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14752. */
  14753. get weight(): number;
  14754. set weight(value: number);
  14755. /**
  14756. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14757. */
  14758. get speedRatio(): number;
  14759. set speedRatio(value: number);
  14760. /**
  14761. * Creates a new Animatable
  14762. * @param scene defines the hosting scene
  14763. * @param target defines the target object
  14764. * @param fromFrame defines the starting frame number (default is 0)
  14765. * @param toFrame defines the ending frame number (default is 100)
  14766. * @param loopAnimation defines if the animation must loop (default is false)
  14767. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14768. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14769. * @param animations defines a group of animation to add to the new Animatable
  14770. * @param onAnimationLoop defines a callback to call when animation loops
  14771. * @param isAdditive defines whether the animation should be evaluated additively
  14772. */
  14773. constructor(scene: Scene,
  14774. /** defines the target object */
  14775. target: any,
  14776. /** defines the starting frame number (default is 0) */
  14777. fromFrame?: number,
  14778. /** defines the ending frame number (default is 100) */
  14779. toFrame?: number,
  14780. /** defines if the animation must loop (default is false) */
  14781. loopAnimation?: boolean, speedRatio?: number,
  14782. /** defines a callback to call when animation ends if it is not looping */
  14783. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14784. /** defines a callback to call when animation loops */
  14785. onAnimationLoop?: (() => void) | null | undefined,
  14786. /** defines whether the animation should be evaluated additively */
  14787. isAdditive?: boolean);
  14788. /**
  14789. * Synchronize and normalize current Animatable with a source Animatable
  14790. * This is useful when using animation weights and when animations are not of the same length
  14791. * @param root defines the root Animatable to synchronize with
  14792. * @returns the current Animatable
  14793. */
  14794. syncWith(root: Animatable): Animatable;
  14795. /**
  14796. * Gets the list of runtime animations
  14797. * @returns an array of RuntimeAnimation
  14798. */
  14799. getAnimations(): RuntimeAnimation[];
  14800. /**
  14801. * Adds more animations to the current animatable
  14802. * @param target defines the target of the animations
  14803. * @param animations defines the new animations to add
  14804. */
  14805. appendAnimations(target: any, animations: Animation[]): void;
  14806. /**
  14807. * Gets the source animation for a specific property
  14808. * @param property defines the propertyu to look for
  14809. * @returns null or the source animation for the given property
  14810. */
  14811. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14812. /**
  14813. * Gets the runtime animation for a specific property
  14814. * @param property defines the propertyu to look for
  14815. * @returns null or the runtime animation for the given property
  14816. */
  14817. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14818. /**
  14819. * Resets the animatable to its original state
  14820. */
  14821. reset(): void;
  14822. /**
  14823. * Allows the animatable to blend with current running animations
  14824. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14825. * @param blendingSpeed defines the blending speed to use
  14826. */
  14827. enableBlending(blendingSpeed: number): void;
  14828. /**
  14829. * Disable animation blending
  14830. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14831. */
  14832. disableBlending(): void;
  14833. /**
  14834. * Jump directly to a given frame
  14835. * @param frame defines the frame to jump to
  14836. */
  14837. goToFrame(frame: number): void;
  14838. /**
  14839. * Pause the animation
  14840. */
  14841. pause(): void;
  14842. /**
  14843. * Restart the animation
  14844. */
  14845. restart(): void;
  14846. private _raiseOnAnimationEnd;
  14847. /**
  14848. * Stop and delete the current animation
  14849. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14850. * @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)
  14851. */
  14852. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14853. /**
  14854. * Wait asynchronously for the animation to end
  14855. * @returns a promise which will be fullfilled when the animation ends
  14856. */
  14857. waitAsync(): Promise<Animatable>;
  14858. /** @hidden */
  14859. _animate(delay: number): boolean;
  14860. }
  14861. interface Scene {
  14862. /** @hidden */
  14863. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14864. /** @hidden */
  14865. _processLateAnimationBindingsForMatrices(holder: {
  14866. totalWeight: number;
  14867. totalAdditiveWeight: number;
  14868. animations: RuntimeAnimation[];
  14869. additiveAnimations: RuntimeAnimation[];
  14870. originalValue: Matrix;
  14871. }): any;
  14872. /** @hidden */
  14873. _processLateAnimationBindingsForQuaternions(holder: {
  14874. totalWeight: number;
  14875. totalAdditiveWeight: number;
  14876. animations: RuntimeAnimation[];
  14877. additiveAnimations: RuntimeAnimation[];
  14878. originalValue: Quaternion;
  14879. }, refQuaternion: Quaternion): Quaternion;
  14880. /** @hidden */
  14881. _processLateAnimationBindings(): void;
  14882. /**
  14883. * Will start the animation sequence of a given target
  14884. * @param target defines the target
  14885. * @param from defines from which frame should animation start
  14886. * @param to defines until which frame should animation run.
  14887. * @param weight defines the weight to apply to the animation (1.0 by default)
  14888. * @param loop defines if the animation loops
  14889. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14890. * @param onAnimationEnd defines the function to be executed when the animation ends
  14891. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14892. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14893. * @param onAnimationLoop defines the callback to call when an animation loops
  14894. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14895. * @returns the animatable object created for this animation
  14896. */
  14897. 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;
  14898. /**
  14899. * Will start the animation sequence of a given target
  14900. * @param target defines the target
  14901. * @param from defines from which frame should animation start
  14902. * @param to defines until which frame should animation run.
  14903. * @param loop defines if the animation loops
  14904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14905. * @param onAnimationEnd defines the function to be executed when the animation ends
  14906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14908. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14909. * @param onAnimationLoop defines the callback to call when an animation loops
  14910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14911. * @returns the animatable object created for this animation
  14912. */
  14913. 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;
  14914. /**
  14915. * Will start the animation sequence of a given target and its hierarchy
  14916. * @param target defines the target
  14917. * @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.
  14918. * @param from defines from which frame should animation start
  14919. * @param to defines until which frame should animation run.
  14920. * @param loop defines if the animation loops
  14921. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14922. * @param onAnimationEnd defines the function to be executed when the animation ends
  14923. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14924. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14925. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14926. * @param onAnimationLoop defines the callback to call when an animation loops
  14927. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14928. * @returns the list of created animatables
  14929. */
  14930. 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[];
  14931. /**
  14932. * Begin a new animation on a given node
  14933. * @param target defines the target where the animation will take place
  14934. * @param animations defines the list of animations to start
  14935. * @param from defines the initial value
  14936. * @param to defines the final value
  14937. * @param loop defines if you want animation to loop (off by default)
  14938. * @param speedRatio defines the speed ratio to apply to all animations
  14939. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14940. * @param onAnimationLoop defines the callback to call when an animation loops
  14941. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14942. * @returns the list of created animatables
  14943. */
  14944. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14945. /**
  14946. * Begin a new animation on a given node and its hierarchy
  14947. * @param target defines the root node where the animation will take place
  14948. * @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.
  14949. * @param animations defines the list of animations to start
  14950. * @param from defines the initial value
  14951. * @param to defines the final value
  14952. * @param loop defines if you want animation to loop (off by default)
  14953. * @param speedRatio defines the speed ratio to apply to all animations
  14954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14955. * @param onAnimationLoop defines the callback to call when an animation loops
  14956. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14957. * @returns the list of animatables created for all nodes
  14958. */
  14959. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14960. /**
  14961. * Gets the animatable associated with a specific target
  14962. * @param target defines the target of the animatable
  14963. * @returns the required animatable if found
  14964. */
  14965. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14966. /**
  14967. * Gets all animatables associated with a given target
  14968. * @param target defines the target to look animatables for
  14969. * @returns an array of Animatables
  14970. */
  14971. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14972. /**
  14973. * Stops and removes all animations that have been applied to the scene
  14974. */
  14975. stopAllAnimations(): void;
  14976. /**
  14977. * Gets the current delta time used by animation engine
  14978. */
  14979. deltaTime: number;
  14980. }
  14981. interface Bone {
  14982. /**
  14983. * Copy an animation range from another bone
  14984. * @param source defines the source bone
  14985. * @param rangeName defines the range name to copy
  14986. * @param frameOffset defines the frame offset
  14987. * @param rescaleAsRequired defines if rescaling must be applied if required
  14988. * @param skelDimensionsRatio defines the scaling ratio
  14989. * @returns true if operation was successful
  14990. */
  14991. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14992. }
  14993. }
  14994. declare module BABYLON {
  14995. /**
  14996. * Class used to handle skinning animations
  14997. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14998. */
  14999. export class Skeleton implements IAnimatable {
  15000. /** defines the skeleton name */
  15001. name: string;
  15002. /** defines the skeleton Id */
  15003. id: string;
  15004. /**
  15005. * Defines the list of child bones
  15006. */
  15007. bones: Bone[];
  15008. /**
  15009. * Defines an estimate of the dimension of the skeleton at rest
  15010. */
  15011. dimensionsAtRest: Vector3;
  15012. /**
  15013. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15014. */
  15015. needInitialSkinMatrix: boolean;
  15016. /**
  15017. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15018. */
  15019. overrideMesh: Nullable<AbstractMesh>;
  15020. /**
  15021. * Gets the list of animations attached to this skeleton
  15022. */
  15023. animations: Array<Animation>;
  15024. private _scene;
  15025. private _isDirty;
  15026. private _transformMatrices;
  15027. private _transformMatrixTexture;
  15028. private _meshesWithPoseMatrix;
  15029. private _animatables;
  15030. private _identity;
  15031. private _synchronizedWithMesh;
  15032. private _ranges;
  15033. private _lastAbsoluteTransformsUpdateId;
  15034. private _canUseTextureForBones;
  15035. private _uniqueId;
  15036. /** @hidden */
  15037. _numBonesWithLinkedTransformNode: number;
  15038. /** @hidden */
  15039. _hasWaitingData: Nullable<boolean>;
  15040. /**
  15041. * Specifies if the skeleton should be serialized
  15042. */
  15043. doNotSerialize: boolean;
  15044. private _useTextureToStoreBoneMatrices;
  15045. /**
  15046. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15047. * Please note that this option is not available if the hardware does not support it
  15048. */
  15049. get useTextureToStoreBoneMatrices(): boolean;
  15050. set useTextureToStoreBoneMatrices(value: boolean);
  15051. private _animationPropertiesOverride;
  15052. /**
  15053. * Gets or sets the animation properties override
  15054. */
  15055. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15056. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15057. /**
  15058. * List of inspectable custom properties (used by the Inspector)
  15059. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15060. */
  15061. inspectableCustomProperties: IInspectable[];
  15062. /**
  15063. * An observable triggered before computing the skeleton's matrices
  15064. */
  15065. onBeforeComputeObservable: Observable<Skeleton>;
  15066. /**
  15067. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15068. */
  15069. get isUsingTextureForMatrices(): boolean;
  15070. /**
  15071. * Gets the unique ID of this skeleton
  15072. */
  15073. get uniqueId(): number;
  15074. /**
  15075. * Creates a new skeleton
  15076. * @param name defines the skeleton name
  15077. * @param id defines the skeleton Id
  15078. * @param scene defines the hosting scene
  15079. */
  15080. constructor(
  15081. /** defines the skeleton name */
  15082. name: string,
  15083. /** defines the skeleton Id */
  15084. id: string, scene: Scene);
  15085. /**
  15086. * Gets the current object class name.
  15087. * @return the class name
  15088. */
  15089. getClassName(): string;
  15090. /**
  15091. * Returns an array containing the root bones
  15092. * @returns an array containing the root bones
  15093. */
  15094. getChildren(): Array<Bone>;
  15095. /**
  15096. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15097. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15098. * @returns a Float32Array containing matrices data
  15099. */
  15100. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15101. /**
  15102. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15103. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15104. * @returns a raw texture containing the data
  15105. */
  15106. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15107. /**
  15108. * Gets the current hosting scene
  15109. * @returns a scene object
  15110. */
  15111. getScene(): Scene;
  15112. /**
  15113. * Gets a string representing the current skeleton data
  15114. * @param fullDetails defines a boolean indicating if we want a verbose version
  15115. * @returns a string representing the current skeleton data
  15116. */
  15117. toString(fullDetails?: boolean): string;
  15118. /**
  15119. * Get bone's index searching by name
  15120. * @param name defines bone's name to search for
  15121. * @return the indice of the bone. Returns -1 if not found
  15122. */
  15123. getBoneIndexByName(name: string): number;
  15124. /**
  15125. * Creater a new animation range
  15126. * @param name defines the name of the range
  15127. * @param from defines the start key
  15128. * @param to defines the end key
  15129. */
  15130. createAnimationRange(name: string, from: number, to: number): void;
  15131. /**
  15132. * Delete a specific animation range
  15133. * @param name defines the name of the range
  15134. * @param deleteFrames defines if frames must be removed as well
  15135. */
  15136. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15137. /**
  15138. * Gets a specific animation range
  15139. * @param name defines the name of the range to look for
  15140. * @returns the requested animation range or null if not found
  15141. */
  15142. getAnimationRange(name: string): Nullable<AnimationRange>;
  15143. /**
  15144. * Gets the list of all animation ranges defined on this skeleton
  15145. * @returns an array
  15146. */
  15147. getAnimationRanges(): Nullable<AnimationRange>[];
  15148. /**
  15149. * Copy animation range from a source skeleton.
  15150. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15151. * @param source defines the source skeleton
  15152. * @param name defines the name of the range to copy
  15153. * @param rescaleAsRequired defines if rescaling must be applied if required
  15154. * @returns true if operation was successful
  15155. */
  15156. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15157. /**
  15158. * Forces the skeleton to go to rest pose
  15159. */
  15160. returnToRest(): void;
  15161. private _getHighestAnimationFrame;
  15162. /**
  15163. * Begin a specific animation range
  15164. * @param name defines the name of the range to start
  15165. * @param loop defines if looping must be turned on (false by default)
  15166. * @param speedRatio defines the speed ratio to apply (1 by default)
  15167. * @param onAnimationEnd defines a callback which will be called when animation will end
  15168. * @returns a new animatable
  15169. */
  15170. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15171. /**
  15172. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15173. * @param skeleton defines the Skeleton containing the animation range to convert
  15174. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15175. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15176. * @returns the original skeleton
  15177. */
  15178. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15179. /** @hidden */
  15180. _markAsDirty(): void;
  15181. /** @hidden */
  15182. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15183. /** @hidden */
  15184. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15185. private _computeTransformMatrices;
  15186. /**
  15187. * Build all resources required to render a skeleton
  15188. */
  15189. prepare(): void;
  15190. /**
  15191. * Gets the list of animatables currently running for this skeleton
  15192. * @returns an array of animatables
  15193. */
  15194. getAnimatables(): IAnimatable[];
  15195. /**
  15196. * Clone the current skeleton
  15197. * @param name defines the name of the new skeleton
  15198. * @param id defines the id of the new skeleton
  15199. * @returns the new skeleton
  15200. */
  15201. clone(name: string, id?: string): Skeleton;
  15202. /**
  15203. * Enable animation blending for this skeleton
  15204. * @param blendingSpeed defines the blending speed to apply
  15205. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15206. */
  15207. enableBlending(blendingSpeed?: number): void;
  15208. /**
  15209. * Releases all resources associated with the current skeleton
  15210. */
  15211. dispose(): void;
  15212. /**
  15213. * Serialize the skeleton in a JSON object
  15214. * @returns a JSON object
  15215. */
  15216. serialize(): any;
  15217. /**
  15218. * Creates a new skeleton from serialized data
  15219. * @param parsedSkeleton defines the serialized data
  15220. * @param scene defines the hosting scene
  15221. * @returns a new skeleton
  15222. */
  15223. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15224. /**
  15225. * Compute all node absolute transforms
  15226. * @param forceUpdate defines if computation must be done even if cache is up to date
  15227. */
  15228. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15229. /**
  15230. * Gets the root pose matrix
  15231. * @returns a matrix
  15232. */
  15233. getPoseMatrix(): Nullable<Matrix>;
  15234. /**
  15235. * Sorts bones per internal index
  15236. */
  15237. sortBones(): void;
  15238. private _sortBones;
  15239. }
  15240. }
  15241. declare module BABYLON {
  15242. /**
  15243. * Creates an instance based on a source mesh.
  15244. */
  15245. export class InstancedMesh extends AbstractMesh {
  15246. private _sourceMesh;
  15247. private _currentLOD;
  15248. /** @hidden */
  15249. _indexInSourceMeshInstanceArray: number;
  15250. constructor(name: string, source: Mesh);
  15251. /**
  15252. * Returns the string "InstancedMesh".
  15253. */
  15254. getClassName(): string;
  15255. /** Gets the list of lights affecting that mesh */
  15256. get lightSources(): Light[];
  15257. _resyncLightSources(): void;
  15258. _resyncLightSource(light: Light): void;
  15259. _removeLightSource(light: Light, dispose: boolean): void;
  15260. /**
  15261. * If the source mesh receives shadows
  15262. */
  15263. get receiveShadows(): boolean;
  15264. /**
  15265. * The material of the source mesh
  15266. */
  15267. get material(): Nullable<Material>;
  15268. /**
  15269. * Visibility of the source mesh
  15270. */
  15271. get visibility(): number;
  15272. /**
  15273. * Skeleton of the source mesh
  15274. */
  15275. get skeleton(): Nullable<Skeleton>;
  15276. /**
  15277. * Rendering ground id of the source mesh
  15278. */
  15279. get renderingGroupId(): number;
  15280. set renderingGroupId(value: number);
  15281. /**
  15282. * Returns the total number of vertices (integer).
  15283. */
  15284. getTotalVertices(): number;
  15285. /**
  15286. * Returns a positive integer : the total number of indices in this mesh geometry.
  15287. * @returns the numner of indices or zero if the mesh has no geometry.
  15288. */
  15289. getTotalIndices(): number;
  15290. /**
  15291. * The source mesh of the instance
  15292. */
  15293. get sourceMesh(): Mesh;
  15294. /**
  15295. * Is this node ready to be used/rendered
  15296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15297. * @return {boolean} is it ready
  15298. */
  15299. isReady(completeCheck?: boolean): boolean;
  15300. /**
  15301. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15302. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15303. * @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.
  15304. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15305. */
  15306. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15307. /**
  15308. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15309. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15310. * The `data` are either a numeric array either a Float32Array.
  15311. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15312. * 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).
  15313. * Note that a new underlying VertexBuffer object is created each call.
  15314. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15315. *
  15316. * Possible `kind` values :
  15317. * - VertexBuffer.PositionKind
  15318. * - VertexBuffer.UVKind
  15319. * - VertexBuffer.UV2Kind
  15320. * - VertexBuffer.UV3Kind
  15321. * - VertexBuffer.UV4Kind
  15322. * - VertexBuffer.UV5Kind
  15323. * - VertexBuffer.UV6Kind
  15324. * - VertexBuffer.ColorKind
  15325. * - VertexBuffer.MatricesIndicesKind
  15326. * - VertexBuffer.MatricesIndicesExtraKind
  15327. * - VertexBuffer.MatricesWeightsKind
  15328. * - VertexBuffer.MatricesWeightsExtraKind
  15329. *
  15330. * Returns the Mesh.
  15331. */
  15332. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15333. /**
  15334. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15335. * If the mesh has no geometry, it is simply returned as it is.
  15336. * The `data` are either a numeric array either a Float32Array.
  15337. * No new underlying VertexBuffer object is created.
  15338. * 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.
  15339. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15340. *
  15341. * Possible `kind` values :
  15342. * - VertexBuffer.PositionKind
  15343. * - VertexBuffer.UVKind
  15344. * - VertexBuffer.UV2Kind
  15345. * - VertexBuffer.UV3Kind
  15346. * - VertexBuffer.UV4Kind
  15347. * - VertexBuffer.UV5Kind
  15348. * - VertexBuffer.UV6Kind
  15349. * - VertexBuffer.ColorKind
  15350. * - VertexBuffer.MatricesIndicesKind
  15351. * - VertexBuffer.MatricesIndicesExtraKind
  15352. * - VertexBuffer.MatricesWeightsKind
  15353. * - VertexBuffer.MatricesWeightsExtraKind
  15354. *
  15355. * Returns the Mesh.
  15356. */
  15357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15358. /**
  15359. * Sets the mesh indices.
  15360. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15361. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15362. * This method creates a new index buffer each call.
  15363. * Returns the Mesh.
  15364. */
  15365. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15366. /**
  15367. * Boolean : True if the mesh owns the requested kind of data.
  15368. */
  15369. isVerticesDataPresent(kind: string): boolean;
  15370. /**
  15371. * Returns an array of indices (IndicesArray).
  15372. */
  15373. getIndices(): Nullable<IndicesArray>;
  15374. get _positions(): Nullable<Vector3[]>;
  15375. /**
  15376. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15377. * This means the mesh underlying bounding box and sphere are recomputed.
  15378. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15379. * @returns the current mesh
  15380. */
  15381. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15382. /** @hidden */
  15383. _preActivate(): InstancedMesh;
  15384. /** @hidden */
  15385. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15386. /** @hidden */
  15387. _postActivate(): void;
  15388. getWorldMatrix(): Matrix;
  15389. get isAnInstance(): boolean;
  15390. /**
  15391. * Returns the current associated LOD AbstractMesh.
  15392. */
  15393. getLOD(camera: Camera): AbstractMesh;
  15394. /** @hidden */
  15395. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15396. /** @hidden */
  15397. _syncSubMeshes(): InstancedMesh;
  15398. /** @hidden */
  15399. _generatePointsArray(): boolean;
  15400. /**
  15401. * Creates a new InstancedMesh from the current mesh.
  15402. * - name (string) : the cloned mesh name
  15403. * - newParent (optional Node) : the optional Node to parent the clone to.
  15404. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15405. *
  15406. * Returns the clone.
  15407. */
  15408. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15409. /**
  15410. * Disposes the InstancedMesh.
  15411. * Returns nothing.
  15412. */
  15413. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15414. }
  15415. interface Mesh {
  15416. /**
  15417. * Register a custom buffer that will be instanced
  15418. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15419. * @param kind defines the buffer kind
  15420. * @param stride defines the stride in floats
  15421. */
  15422. registerInstancedBuffer(kind: string, stride: number): void;
  15423. /** @hidden */
  15424. _userInstancedBuffersStorage: {
  15425. data: {
  15426. [key: string]: Float32Array;
  15427. };
  15428. sizes: {
  15429. [key: string]: number;
  15430. };
  15431. vertexBuffers: {
  15432. [key: string]: Nullable<VertexBuffer>;
  15433. };
  15434. strides: {
  15435. [key: string]: number;
  15436. };
  15437. };
  15438. }
  15439. interface AbstractMesh {
  15440. /**
  15441. * Object used to store instanced buffers defined by user
  15442. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15443. */
  15444. instancedBuffers: {
  15445. [key: string]: any;
  15446. };
  15447. }
  15448. }
  15449. declare module BABYLON {
  15450. /**
  15451. * Defines the options associated with the creation of a shader material.
  15452. */
  15453. export interface IShaderMaterialOptions {
  15454. /**
  15455. * Does the material work in alpha blend mode
  15456. */
  15457. needAlphaBlending: boolean;
  15458. /**
  15459. * Does the material work in alpha test mode
  15460. */
  15461. needAlphaTesting: boolean;
  15462. /**
  15463. * The list of attribute names used in the shader
  15464. */
  15465. attributes: string[];
  15466. /**
  15467. * The list of unifrom names used in the shader
  15468. */
  15469. uniforms: string[];
  15470. /**
  15471. * The list of UBO names used in the shader
  15472. */
  15473. uniformBuffers: string[];
  15474. /**
  15475. * The list of sampler names used in the shader
  15476. */
  15477. samplers: string[];
  15478. /**
  15479. * The list of defines used in the shader
  15480. */
  15481. defines: string[];
  15482. }
  15483. /**
  15484. * 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.
  15485. *
  15486. * This returned material effects how the mesh will look based on the code in the shaders.
  15487. *
  15488. * @see http://doc.babylonjs.com/how_to/shader_material
  15489. */
  15490. export class ShaderMaterial extends Material {
  15491. private _shaderPath;
  15492. private _options;
  15493. private _textures;
  15494. private _textureArrays;
  15495. private _floats;
  15496. private _ints;
  15497. private _floatsArrays;
  15498. private _colors3;
  15499. private _colors3Arrays;
  15500. private _colors4;
  15501. private _colors4Arrays;
  15502. private _vectors2;
  15503. private _vectors3;
  15504. private _vectors4;
  15505. private _matrices;
  15506. private _matrixArrays;
  15507. private _matrices3x3;
  15508. private _matrices2x2;
  15509. private _vectors2Arrays;
  15510. private _vectors3Arrays;
  15511. private _vectors4Arrays;
  15512. private _cachedWorldViewMatrix;
  15513. private _cachedWorldViewProjectionMatrix;
  15514. private _renderId;
  15515. private _multiview;
  15516. private _cachedDefines;
  15517. /**
  15518. * Instantiate a new shader material.
  15519. * 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.
  15520. * This returned material effects how the mesh will look based on the code in the shaders.
  15521. * @see http://doc.babylonjs.com/how_to/shader_material
  15522. * @param name Define the name of the material in the scene
  15523. * @param scene Define the scene the material belongs to
  15524. * @param shaderPath Defines the route to the shader code in one of three ways:
  15525. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15526. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15527. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15528. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15529. * @param options Define the options used to create the shader
  15530. */
  15531. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15532. /**
  15533. * Gets the shader path used to define the shader code
  15534. * It can be modified to trigger a new compilation
  15535. */
  15536. get shaderPath(): any;
  15537. /**
  15538. * Sets the shader path used to define the shader code
  15539. * It can be modified to trigger a new compilation
  15540. */
  15541. set shaderPath(shaderPath: any);
  15542. /**
  15543. * Gets the options used to compile the shader.
  15544. * They can be modified to trigger a new compilation
  15545. */
  15546. get options(): IShaderMaterialOptions;
  15547. /**
  15548. * Gets the current class name of the material e.g. "ShaderMaterial"
  15549. * Mainly use in serialization.
  15550. * @returns the class name
  15551. */
  15552. getClassName(): string;
  15553. /**
  15554. * Specifies if the material will require alpha blending
  15555. * @returns a boolean specifying if alpha blending is needed
  15556. */
  15557. needAlphaBlending(): boolean;
  15558. /**
  15559. * Specifies if this material should be rendered in alpha test mode
  15560. * @returns a boolean specifying if an alpha test is needed.
  15561. */
  15562. needAlphaTesting(): boolean;
  15563. private _checkUniform;
  15564. /**
  15565. * Set a texture in the shader.
  15566. * @param name Define the name of the uniform samplers as defined in the shader
  15567. * @param texture Define the texture to bind to this sampler
  15568. * @return the material itself allowing "fluent" like uniform updates
  15569. */
  15570. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15571. /**
  15572. * Set a texture array in the shader.
  15573. * @param name Define the name of the uniform sampler array as defined in the shader
  15574. * @param textures Define the list of textures to bind to this sampler
  15575. * @return the material itself allowing "fluent" like uniform updates
  15576. */
  15577. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15578. /**
  15579. * Set a float in the shader.
  15580. * @param name Define the name of the uniform as defined in the shader
  15581. * @param value Define the value to give to the uniform
  15582. * @return the material itself allowing "fluent" like uniform updates
  15583. */
  15584. setFloat(name: string, value: number): ShaderMaterial;
  15585. /**
  15586. * Set a int in the shader.
  15587. * @param name Define the name of the uniform as defined in the shader
  15588. * @param value Define the value to give to the uniform
  15589. * @return the material itself allowing "fluent" like uniform updates
  15590. */
  15591. setInt(name: string, value: number): ShaderMaterial;
  15592. /**
  15593. * Set an array of floats in the shader.
  15594. * @param name Define the name of the uniform as defined in the shader
  15595. * @param value Define the value to give to the uniform
  15596. * @return the material itself allowing "fluent" like uniform updates
  15597. */
  15598. setFloats(name: string, value: number[]): ShaderMaterial;
  15599. /**
  15600. * Set a vec3 in the shader from a Color3.
  15601. * @param name Define the name of the uniform as defined in the shader
  15602. * @param value Define the value to give to the uniform
  15603. * @return the material itself allowing "fluent" like uniform updates
  15604. */
  15605. setColor3(name: string, value: Color3): ShaderMaterial;
  15606. /**
  15607. * Set a vec3 array in the shader from a Color3 array.
  15608. * @param name Define the name of the uniform as defined in the shader
  15609. * @param value Define the value to give to the uniform
  15610. * @return the material itself allowing "fluent" like uniform updates
  15611. */
  15612. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15613. /**
  15614. * Set a vec4 in the shader from a Color4.
  15615. * @param name Define the name of the uniform as defined in the shader
  15616. * @param value Define the value to give to the uniform
  15617. * @return the material itself allowing "fluent" like uniform updates
  15618. */
  15619. setColor4(name: string, value: Color4): ShaderMaterial;
  15620. /**
  15621. * Set a vec4 array in the shader from a Color4 array.
  15622. * @param name Define the name of the uniform as defined in the shader
  15623. * @param value Define the value to give to the uniform
  15624. * @return the material itself allowing "fluent" like uniform updates
  15625. */
  15626. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15627. /**
  15628. * Set a vec2 in the shader from a Vector2.
  15629. * @param name Define the name of the uniform as defined in the shader
  15630. * @param value Define the value to give to the uniform
  15631. * @return the material itself allowing "fluent" like uniform updates
  15632. */
  15633. setVector2(name: string, value: Vector2): ShaderMaterial;
  15634. /**
  15635. * Set a vec3 in the shader from a Vector3.
  15636. * @param name Define the name of the uniform as defined in the shader
  15637. * @param value Define the value to give to the uniform
  15638. * @return the material itself allowing "fluent" like uniform updates
  15639. */
  15640. setVector3(name: string, value: Vector3): ShaderMaterial;
  15641. /**
  15642. * Set a vec4 in the shader from a Vector4.
  15643. * @param name Define the name of the uniform as defined in the shader
  15644. * @param value Define the value to give to the uniform
  15645. * @return the material itself allowing "fluent" like uniform updates
  15646. */
  15647. setVector4(name: string, value: Vector4): ShaderMaterial;
  15648. /**
  15649. * Set a mat4 in the shader from a Matrix.
  15650. * @param name Define the name of the uniform as defined in the shader
  15651. * @param value Define the value to give to the uniform
  15652. * @return the material itself allowing "fluent" like uniform updates
  15653. */
  15654. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15655. /**
  15656. * Set a float32Array in the shader from a matrix array.
  15657. * @param name Define the name of the uniform as defined in the shader
  15658. * @param value Define the value to give to the uniform
  15659. * @return the material itself allowing "fluent" like uniform updates
  15660. */
  15661. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15662. /**
  15663. * Set a mat3 in the shader from a Float32Array.
  15664. * @param name Define the name of the uniform as defined in the shader
  15665. * @param value Define the value to give to the uniform
  15666. * @return the material itself allowing "fluent" like uniform updates
  15667. */
  15668. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15669. /**
  15670. * Set a mat2 in the shader from a Float32Array.
  15671. * @param name Define the name of the uniform as defined in the shader
  15672. * @param value Define the value to give to the uniform
  15673. * @return the material itself allowing "fluent" like uniform updates
  15674. */
  15675. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15676. /**
  15677. * Set a vec2 array in the shader from a number array.
  15678. * @param name Define the name of the uniform as defined in the shader
  15679. * @param value Define the value to give to the uniform
  15680. * @return the material itself allowing "fluent" like uniform updates
  15681. */
  15682. setArray2(name: string, value: number[]): ShaderMaterial;
  15683. /**
  15684. * Set a vec3 array in the shader from a number array.
  15685. * @param name Define the name of the uniform as defined in the shader
  15686. * @param value Define the value to give to the uniform
  15687. * @return the material itself allowing "fluent" like uniform updates
  15688. */
  15689. setArray3(name: string, value: number[]): ShaderMaterial;
  15690. /**
  15691. * Set a vec4 array in the shader from a number array.
  15692. * @param name Define the name of the uniform as defined in the shader
  15693. * @param value Define the value to give to the uniform
  15694. * @return the material itself allowing "fluent" like uniform updates
  15695. */
  15696. setArray4(name: string, value: number[]): ShaderMaterial;
  15697. private _checkCache;
  15698. /**
  15699. * Specifies that the submesh is ready to be used
  15700. * @param mesh defines the mesh to check
  15701. * @param subMesh defines which submesh to check
  15702. * @param useInstances specifies that instances should be used
  15703. * @returns a boolean indicating that the submesh is ready or not
  15704. */
  15705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15706. /**
  15707. * Checks if the material is ready to render the requested mesh
  15708. * @param mesh Define the mesh to render
  15709. * @param useInstances Define whether or not the material is used with instances
  15710. * @returns true if ready, otherwise false
  15711. */
  15712. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15713. /**
  15714. * Binds the world matrix to the material
  15715. * @param world defines the world transformation matrix
  15716. * @param effectOverride - If provided, use this effect instead of internal effect
  15717. */
  15718. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15719. /**
  15720. * Binds the submesh to this material by preparing the effect and shader to draw
  15721. * @param world defines the world transformation matrix
  15722. * @param mesh defines the mesh containing the submesh
  15723. * @param subMesh defines the submesh to bind the material to
  15724. */
  15725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15726. /**
  15727. * Binds the material to the mesh
  15728. * @param world defines the world transformation matrix
  15729. * @param mesh defines the mesh to bind the material to
  15730. * @param effectOverride - If provided, use this effect instead of internal effect
  15731. */
  15732. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15733. protected _afterBind(mesh?: Mesh): void;
  15734. /**
  15735. * Gets the active textures from the material
  15736. * @returns an array of textures
  15737. */
  15738. getActiveTextures(): BaseTexture[];
  15739. /**
  15740. * Specifies if the material uses a texture
  15741. * @param texture defines the texture to check against the material
  15742. * @returns a boolean specifying if the material uses the texture
  15743. */
  15744. hasTexture(texture: BaseTexture): boolean;
  15745. /**
  15746. * Makes a duplicate of the material, and gives it a new name
  15747. * @param name defines the new name for the duplicated material
  15748. * @returns the cloned material
  15749. */
  15750. clone(name: string): ShaderMaterial;
  15751. /**
  15752. * Disposes the material
  15753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15755. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15756. */
  15757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15758. /**
  15759. * Serializes this material in a JSON representation
  15760. * @returns the serialized material object
  15761. */
  15762. serialize(): any;
  15763. /**
  15764. * Creates a shader material from parsed shader material data
  15765. * @param source defines the JSON represnetation of the material
  15766. * @param scene defines the hosting scene
  15767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15768. * @returns a new material
  15769. */
  15770. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15771. }
  15772. }
  15773. declare module BABYLON {
  15774. /** @hidden */
  15775. export var colorPixelShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module BABYLON {
  15781. /** @hidden */
  15782. export var colorVertexShader: {
  15783. name: string;
  15784. shader: string;
  15785. };
  15786. }
  15787. declare module BABYLON {
  15788. /**
  15789. * Line mesh
  15790. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15791. */
  15792. export class LinesMesh extends Mesh {
  15793. /**
  15794. * If vertex color should be applied to the mesh
  15795. */
  15796. readonly useVertexColor?: boolean | undefined;
  15797. /**
  15798. * If vertex alpha should be applied to the mesh
  15799. */
  15800. readonly useVertexAlpha?: boolean | undefined;
  15801. /**
  15802. * Color of the line (Default: White)
  15803. */
  15804. color: Color3;
  15805. /**
  15806. * Alpha of the line (Default: 1)
  15807. */
  15808. alpha: number;
  15809. /**
  15810. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15811. * This margin is expressed in world space coordinates, so its value may vary.
  15812. * Default value is 0.1
  15813. */
  15814. intersectionThreshold: number;
  15815. private _colorShader;
  15816. private color4;
  15817. /**
  15818. * Creates a new LinesMesh
  15819. * @param name defines the name
  15820. * @param scene defines the hosting scene
  15821. * @param parent defines the parent mesh if any
  15822. * @param source defines the optional source LinesMesh used to clone data from
  15823. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15824. * When false, achieved by calling a clone(), also passing False.
  15825. * This will make creation of children, recursive.
  15826. * @param useVertexColor defines if this LinesMesh supports vertex color
  15827. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15828. */
  15829. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15830. /**
  15831. * If vertex color should be applied to the mesh
  15832. */
  15833. useVertexColor?: boolean | undefined,
  15834. /**
  15835. * If vertex alpha should be applied to the mesh
  15836. */
  15837. useVertexAlpha?: boolean | undefined);
  15838. private _addClipPlaneDefine;
  15839. private _removeClipPlaneDefine;
  15840. isReady(): boolean;
  15841. /**
  15842. * Returns the string "LineMesh"
  15843. */
  15844. getClassName(): string;
  15845. /**
  15846. * @hidden
  15847. */
  15848. get material(): Material;
  15849. /**
  15850. * @hidden
  15851. */
  15852. set material(value: Material);
  15853. /**
  15854. * @hidden
  15855. */
  15856. get checkCollisions(): boolean;
  15857. /** @hidden */
  15858. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15859. /** @hidden */
  15860. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15861. /**
  15862. * Disposes of the line mesh
  15863. * @param doNotRecurse If children should be disposed
  15864. */
  15865. dispose(doNotRecurse?: boolean): void;
  15866. /**
  15867. * Returns a new LineMesh object cloned from the current one.
  15868. */
  15869. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15870. /**
  15871. * Creates a new InstancedLinesMesh object from the mesh model.
  15872. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15873. * @param name defines the name of the new instance
  15874. * @returns a new InstancedLinesMesh
  15875. */
  15876. createInstance(name: string): InstancedLinesMesh;
  15877. }
  15878. /**
  15879. * Creates an instance based on a source LinesMesh
  15880. */
  15881. export class InstancedLinesMesh extends InstancedMesh {
  15882. /**
  15883. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15884. * This margin is expressed in world space coordinates, so its value may vary.
  15885. * Initilized with the intersectionThreshold value of the source LinesMesh
  15886. */
  15887. intersectionThreshold: number;
  15888. constructor(name: string, source: LinesMesh);
  15889. /**
  15890. * Returns the string "InstancedLinesMesh".
  15891. */
  15892. getClassName(): string;
  15893. }
  15894. }
  15895. declare module BABYLON {
  15896. /** @hidden */
  15897. export var linePixelShader: {
  15898. name: string;
  15899. shader: string;
  15900. };
  15901. }
  15902. declare module BABYLON {
  15903. /** @hidden */
  15904. export var lineVertexShader: {
  15905. name: string;
  15906. shader: string;
  15907. };
  15908. }
  15909. declare module BABYLON {
  15910. interface AbstractMesh {
  15911. /**
  15912. * Gets the edgesRenderer associated with the mesh
  15913. */
  15914. edgesRenderer: Nullable<EdgesRenderer>;
  15915. }
  15916. interface LinesMesh {
  15917. /**
  15918. * Enables the edge rendering mode on the mesh.
  15919. * This mode makes the mesh edges visible
  15920. * @param epsilon defines the maximal distance between two angles to detect a face
  15921. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15922. * @returns the currentAbstractMesh
  15923. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15924. */
  15925. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15926. }
  15927. interface InstancedLinesMesh {
  15928. /**
  15929. * Enables the edge rendering mode on the mesh.
  15930. * This mode makes the mesh edges visible
  15931. * @param epsilon defines the maximal distance between two angles to detect a face
  15932. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15933. * @returns the current InstancedLinesMesh
  15934. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15935. */
  15936. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15937. }
  15938. /**
  15939. * Defines the minimum contract an Edges renderer should follow.
  15940. */
  15941. export interface IEdgesRenderer extends IDisposable {
  15942. /**
  15943. * Gets or sets a boolean indicating if the edgesRenderer is active
  15944. */
  15945. isEnabled: boolean;
  15946. /**
  15947. * Renders the edges of the attached mesh,
  15948. */
  15949. render(): void;
  15950. /**
  15951. * Checks wether or not the edges renderer is ready to render.
  15952. * @return true if ready, otherwise false.
  15953. */
  15954. isReady(): boolean;
  15955. }
  15956. /**
  15957. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15958. */
  15959. export class EdgesRenderer implements IEdgesRenderer {
  15960. /**
  15961. * Define the size of the edges with an orthographic camera
  15962. */
  15963. edgesWidthScalerForOrthographic: number;
  15964. /**
  15965. * Define the size of the edges with a perspective camera
  15966. */
  15967. edgesWidthScalerForPerspective: number;
  15968. protected _source: AbstractMesh;
  15969. protected _linesPositions: number[];
  15970. protected _linesNormals: number[];
  15971. protected _linesIndices: number[];
  15972. protected _epsilon: number;
  15973. protected _indicesCount: number;
  15974. protected _lineShader: ShaderMaterial;
  15975. protected _ib: DataBuffer;
  15976. protected _buffers: {
  15977. [key: string]: Nullable<VertexBuffer>;
  15978. };
  15979. protected _checkVerticesInsteadOfIndices: boolean;
  15980. private _meshRebuildObserver;
  15981. private _meshDisposeObserver;
  15982. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15983. isEnabled: boolean;
  15984. /**
  15985. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15986. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15987. * @param source Mesh used to create edges
  15988. * @param epsilon sum of angles in adjacency to check for edge
  15989. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15990. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15991. */
  15992. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15993. protected _prepareRessources(): void;
  15994. /** @hidden */
  15995. _rebuild(): void;
  15996. /**
  15997. * Releases the required resources for the edges renderer
  15998. */
  15999. dispose(): void;
  16000. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16001. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16002. /**
  16003. * Checks if the pair of p0 and p1 is en edge
  16004. * @param faceIndex
  16005. * @param edge
  16006. * @param faceNormals
  16007. * @param p0
  16008. * @param p1
  16009. * @private
  16010. */
  16011. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16012. /**
  16013. * push line into the position, normal and index buffer
  16014. * @protected
  16015. */
  16016. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16017. /**
  16018. * Generates lines edges from adjacencjes
  16019. * @private
  16020. */
  16021. _generateEdgesLines(): void;
  16022. /**
  16023. * Checks wether or not the edges renderer is ready to render.
  16024. * @return true if ready, otherwise false.
  16025. */
  16026. isReady(): boolean;
  16027. /**
  16028. * Renders the edges of the attached mesh,
  16029. */
  16030. render(): void;
  16031. }
  16032. /**
  16033. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16034. */
  16035. export class LineEdgesRenderer extends EdgesRenderer {
  16036. /**
  16037. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16038. * @param source LineMesh used to generate edges
  16039. * @param epsilon not important (specified angle for edge detection)
  16040. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16041. */
  16042. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16043. /**
  16044. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16045. */
  16046. _generateEdgesLines(): void;
  16047. }
  16048. }
  16049. declare module BABYLON {
  16050. /**
  16051. * This represents the object necessary to create a rendering group.
  16052. * This is exclusively used and created by the rendering manager.
  16053. * To modify the behavior, you use the available helpers in your scene or meshes.
  16054. * @hidden
  16055. */
  16056. export class RenderingGroup {
  16057. index: number;
  16058. private static _zeroVector;
  16059. private _scene;
  16060. private _opaqueSubMeshes;
  16061. private _transparentSubMeshes;
  16062. private _alphaTestSubMeshes;
  16063. private _depthOnlySubMeshes;
  16064. private _particleSystems;
  16065. private _spriteManagers;
  16066. private _opaqueSortCompareFn;
  16067. private _alphaTestSortCompareFn;
  16068. private _transparentSortCompareFn;
  16069. private _renderOpaque;
  16070. private _renderAlphaTest;
  16071. private _renderTransparent;
  16072. /** @hidden */
  16073. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16074. onBeforeTransparentRendering: () => void;
  16075. /**
  16076. * Set the opaque sort comparison function.
  16077. * If null the sub meshes will be render in the order they were created
  16078. */
  16079. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16080. /**
  16081. * Set the alpha test sort comparison function.
  16082. * If null the sub meshes will be render in the order they were created
  16083. */
  16084. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16085. /**
  16086. * Set the transparent sort comparison function.
  16087. * If null the sub meshes will be render in the order they were created
  16088. */
  16089. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16090. /**
  16091. * Creates a new rendering group.
  16092. * @param index The rendering group index
  16093. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16094. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16095. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16096. */
  16097. 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>);
  16098. /**
  16099. * Render all the sub meshes contained in the group.
  16100. * @param customRenderFunction Used to override the default render behaviour of the group.
  16101. * @returns true if rendered some submeshes.
  16102. */
  16103. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16104. /**
  16105. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16106. * @param subMeshes The submeshes to render
  16107. */
  16108. private renderOpaqueSorted;
  16109. /**
  16110. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16111. * @param subMeshes The submeshes to render
  16112. */
  16113. private renderAlphaTestSorted;
  16114. /**
  16115. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16116. * @param subMeshes The submeshes to render
  16117. */
  16118. private renderTransparentSorted;
  16119. /**
  16120. * Renders the submeshes in a specified order.
  16121. * @param subMeshes The submeshes to sort before render
  16122. * @param sortCompareFn The comparison function use to sort
  16123. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16124. * @param transparent Specifies to activate blending if true
  16125. */
  16126. private static renderSorted;
  16127. /**
  16128. * Renders the submeshes in the order they were dispatched (no sort applied).
  16129. * @param subMeshes The submeshes to render
  16130. */
  16131. private static renderUnsorted;
  16132. /**
  16133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16134. * are rendered back to front if in the same alpha index.
  16135. *
  16136. * @param a The first submesh
  16137. * @param b The second submesh
  16138. * @returns The result of the comparison
  16139. */
  16140. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16141. /**
  16142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16143. * are rendered back to front.
  16144. *
  16145. * @param a The first submesh
  16146. * @param b The second submesh
  16147. * @returns The result of the comparison
  16148. */
  16149. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16150. /**
  16151. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16152. * are rendered front to back (prevent overdraw).
  16153. *
  16154. * @param a The first submesh
  16155. * @param b The second submesh
  16156. * @returns The result of the comparison
  16157. */
  16158. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16159. /**
  16160. * Resets the different lists of submeshes to prepare a new frame.
  16161. */
  16162. prepare(): void;
  16163. dispose(): void;
  16164. /**
  16165. * Inserts the submesh in its correct queue depending on its material.
  16166. * @param subMesh The submesh to dispatch
  16167. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16168. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16169. */
  16170. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16171. dispatchSprites(spriteManager: ISpriteManager): void;
  16172. dispatchParticles(particleSystem: IParticleSystem): void;
  16173. private _renderParticles;
  16174. private _renderSprites;
  16175. }
  16176. }
  16177. declare module BABYLON {
  16178. /**
  16179. * Interface describing the different options available in the rendering manager
  16180. * regarding Auto Clear between groups.
  16181. */
  16182. export interface IRenderingManagerAutoClearSetup {
  16183. /**
  16184. * Defines whether or not autoclear is enable.
  16185. */
  16186. autoClear: boolean;
  16187. /**
  16188. * Defines whether or not to autoclear the depth buffer.
  16189. */
  16190. depth: boolean;
  16191. /**
  16192. * Defines whether or not to autoclear the stencil buffer.
  16193. */
  16194. stencil: boolean;
  16195. }
  16196. /**
  16197. * This class is used by the onRenderingGroupObservable
  16198. */
  16199. export class RenderingGroupInfo {
  16200. /**
  16201. * The Scene that being rendered
  16202. */
  16203. scene: Scene;
  16204. /**
  16205. * The camera currently used for the rendering pass
  16206. */
  16207. camera: Nullable<Camera>;
  16208. /**
  16209. * The ID of the renderingGroup being processed
  16210. */
  16211. renderingGroupId: number;
  16212. }
  16213. /**
  16214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16215. * It is enable to manage the different groups as well as the different necessary sort functions.
  16216. * This should not be used directly aside of the few static configurations
  16217. */
  16218. export class RenderingManager {
  16219. /**
  16220. * The max id used for rendering groups (not included)
  16221. */
  16222. static MAX_RENDERINGGROUPS: number;
  16223. /**
  16224. * The min id used for rendering groups (included)
  16225. */
  16226. static MIN_RENDERINGGROUPS: number;
  16227. /**
  16228. * Used to globally prevent autoclearing scenes.
  16229. */
  16230. static AUTOCLEAR: boolean;
  16231. /**
  16232. * @hidden
  16233. */
  16234. _useSceneAutoClearSetup: boolean;
  16235. private _scene;
  16236. private _renderingGroups;
  16237. private _depthStencilBufferAlreadyCleaned;
  16238. private _autoClearDepthStencil;
  16239. private _customOpaqueSortCompareFn;
  16240. private _customAlphaTestSortCompareFn;
  16241. private _customTransparentSortCompareFn;
  16242. private _renderingGroupInfo;
  16243. /**
  16244. * Instantiates a new rendering group for a particular scene
  16245. * @param scene Defines the scene the groups belongs to
  16246. */
  16247. constructor(scene: Scene);
  16248. private _clearDepthStencilBuffer;
  16249. /**
  16250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16251. * @hidden
  16252. */
  16253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16254. /**
  16255. * Resets the different information of the group to prepare a new frame
  16256. * @hidden
  16257. */
  16258. reset(): void;
  16259. /**
  16260. * Dispose and release the group and its associated resources.
  16261. * @hidden
  16262. */
  16263. dispose(): void;
  16264. /**
  16265. * Clear the info related to rendering groups preventing retention points during dispose.
  16266. */
  16267. freeRenderingGroups(): void;
  16268. private _prepareRenderingGroup;
  16269. /**
  16270. * Add a sprite manager to the rendering manager in order to render it this frame.
  16271. * @param spriteManager Define the sprite manager to render
  16272. */
  16273. dispatchSprites(spriteManager: ISpriteManager): void;
  16274. /**
  16275. * Add a particle system to the rendering manager in order to render it this frame.
  16276. * @param particleSystem Define the particle system to render
  16277. */
  16278. dispatchParticles(particleSystem: IParticleSystem): void;
  16279. /**
  16280. * Add a submesh to the manager in order to render it this frame
  16281. * @param subMesh The submesh to dispatch
  16282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16284. */
  16285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16286. /**
  16287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16288. * This allowed control for front to back rendering or reversly depending of the special needs.
  16289. *
  16290. * @param renderingGroupId The rendering group id corresponding to its index
  16291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16294. */
  16295. 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;
  16296. /**
  16297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16298. *
  16299. * @param renderingGroupId The rendering group id corresponding to its index
  16300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16303. */
  16304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16305. /**
  16306. * Gets the current auto clear configuration for one rendering group of the rendering
  16307. * manager.
  16308. * @param index the rendering group index to get the information for
  16309. * @returns The auto clear setup for the requested rendering group
  16310. */
  16311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16312. }
  16313. }
  16314. declare module BABYLON {
  16315. /**
  16316. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16317. */
  16318. export interface ICustomShaderOptions {
  16319. /**
  16320. * Gets or sets the custom shader name to use
  16321. */
  16322. shaderName: string;
  16323. /**
  16324. * The list of attribute names used in the shader
  16325. */
  16326. attributes?: string[];
  16327. /**
  16328. * The list of unifrom names used in the shader
  16329. */
  16330. uniforms?: string[];
  16331. /**
  16332. * The list of sampler names used in the shader
  16333. */
  16334. samplers?: string[];
  16335. /**
  16336. * The list of defines used in the shader
  16337. */
  16338. defines?: string[];
  16339. }
  16340. /**
  16341. * Interface to implement to create a shadow generator compatible with BJS.
  16342. */
  16343. export interface IShadowGenerator {
  16344. /**
  16345. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16346. * @returns The render target texture if present otherwise, null
  16347. */
  16348. getShadowMap(): Nullable<RenderTargetTexture>;
  16349. /**
  16350. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16351. * @param subMesh The submesh we want to render in the shadow map
  16352. * @param useInstances Defines wether will draw in the map using instances
  16353. * @returns true if ready otherwise, false
  16354. */
  16355. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16356. /**
  16357. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16358. * @param defines Defines of the material we want to update
  16359. * @param lightIndex Index of the light in the enabled light list of the material
  16360. */
  16361. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16362. /**
  16363. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16364. * defined in the generator but impacting the effect).
  16365. * It implies the unifroms available on the materials are the standard BJS ones.
  16366. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16367. * @param effect The effect we are binfing the information for
  16368. */
  16369. bindShadowLight(lightIndex: string, effect: Effect): void;
  16370. /**
  16371. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16372. * (eq to shadow prjection matrix * light transform matrix)
  16373. * @returns The transform matrix used to create the shadow map
  16374. */
  16375. getTransformMatrix(): Matrix;
  16376. /**
  16377. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16378. * Cube and 2D textures for instance.
  16379. */
  16380. recreateShadowMap(): void;
  16381. /**
  16382. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16383. * @param onCompiled Callback triggered at the and of the effects compilation
  16384. * @param options Sets of optional options forcing the compilation with different modes
  16385. */
  16386. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16387. useInstances: boolean;
  16388. }>): void;
  16389. /**
  16390. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16391. * @param options Sets of optional options forcing the compilation with different modes
  16392. * @returns A promise that resolves when the compilation completes
  16393. */
  16394. forceCompilationAsync(options?: Partial<{
  16395. useInstances: boolean;
  16396. }>): Promise<void>;
  16397. /**
  16398. * Serializes the shadow generator setup to a json object.
  16399. * @returns The serialized JSON object
  16400. */
  16401. serialize(): any;
  16402. /**
  16403. * Disposes the Shadow map and related Textures and effects.
  16404. */
  16405. dispose(): void;
  16406. }
  16407. /**
  16408. * Default implementation IShadowGenerator.
  16409. * This is the main object responsible of generating shadows in the framework.
  16410. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16411. */
  16412. export class ShadowGenerator implements IShadowGenerator {
  16413. /**
  16414. * Name of the shadow generator class
  16415. */
  16416. static CLASSNAME: string;
  16417. /**
  16418. * Shadow generator mode None: no filtering applied.
  16419. */
  16420. static readonly FILTER_NONE: number;
  16421. /**
  16422. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16423. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16424. */
  16425. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16426. /**
  16427. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16428. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16429. */
  16430. static readonly FILTER_POISSONSAMPLING: number;
  16431. /**
  16432. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16433. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16434. */
  16435. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16436. /**
  16437. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16438. * edge artifacts on steep falloff.
  16439. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16440. */
  16441. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16442. /**
  16443. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16444. * edge artifacts on steep falloff.
  16445. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16446. */
  16447. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16448. /**
  16449. * Shadow generator mode PCF: Percentage Closer Filtering
  16450. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16451. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16452. */
  16453. static readonly FILTER_PCF: number;
  16454. /**
  16455. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16456. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16457. * Contact Hardening
  16458. */
  16459. static readonly FILTER_PCSS: number;
  16460. /**
  16461. * Reserved for PCF and PCSS
  16462. * Highest Quality.
  16463. *
  16464. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16465. *
  16466. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16467. */
  16468. static readonly QUALITY_HIGH: number;
  16469. /**
  16470. * Reserved for PCF and PCSS
  16471. * Good tradeoff for quality/perf cross devices
  16472. *
  16473. * Execute PCF on a 3*3 kernel.
  16474. *
  16475. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16476. */
  16477. static readonly QUALITY_MEDIUM: number;
  16478. /**
  16479. * Reserved for PCF and PCSS
  16480. * The lowest quality but the fastest.
  16481. *
  16482. * Execute PCF on a 1*1 kernel.
  16483. *
  16484. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16485. */
  16486. static readonly QUALITY_LOW: number;
  16487. /** Gets or sets the custom shader name to use */
  16488. customShaderOptions: ICustomShaderOptions;
  16489. /**
  16490. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16491. */
  16492. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16493. /**
  16494. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16495. */
  16496. onAfterShadowMapRenderObservable: Observable<Effect>;
  16497. /**
  16498. * Observable triggered before a mesh is rendered in the shadow map.
  16499. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16500. */
  16501. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16502. /**
  16503. * Observable triggered after a mesh is rendered in the shadow map.
  16504. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16505. */
  16506. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16507. protected _bias: number;
  16508. /**
  16509. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16510. */
  16511. get bias(): number;
  16512. /**
  16513. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16514. */
  16515. set bias(bias: number);
  16516. protected _normalBias: number;
  16517. /**
  16518. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16519. */
  16520. get normalBias(): number;
  16521. /**
  16522. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16523. */
  16524. set normalBias(normalBias: number);
  16525. protected _blurBoxOffset: number;
  16526. /**
  16527. * Gets the blur box offset: offset applied during the blur pass.
  16528. * Only useful if useKernelBlur = false
  16529. */
  16530. get blurBoxOffset(): number;
  16531. /**
  16532. * Sets the blur box offset: offset applied during the blur pass.
  16533. * Only useful if useKernelBlur = false
  16534. */
  16535. set blurBoxOffset(value: number);
  16536. protected _blurScale: number;
  16537. /**
  16538. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16539. * 2 means half of the size.
  16540. */
  16541. get blurScale(): number;
  16542. /**
  16543. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16544. * 2 means half of the size.
  16545. */
  16546. set blurScale(value: number);
  16547. protected _blurKernel: number;
  16548. /**
  16549. * Gets the blur kernel: kernel size of the blur pass.
  16550. * Only useful if useKernelBlur = true
  16551. */
  16552. get blurKernel(): number;
  16553. /**
  16554. * Sets the blur kernel: kernel size of the blur pass.
  16555. * Only useful if useKernelBlur = true
  16556. */
  16557. set blurKernel(value: number);
  16558. protected _useKernelBlur: boolean;
  16559. /**
  16560. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16561. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16562. */
  16563. get useKernelBlur(): boolean;
  16564. /**
  16565. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16566. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16567. */
  16568. set useKernelBlur(value: boolean);
  16569. protected _depthScale: number;
  16570. /**
  16571. * Gets the depth scale used in ESM mode.
  16572. */
  16573. get depthScale(): number;
  16574. /**
  16575. * Sets the depth scale used in ESM mode.
  16576. * This can override the scale stored on the light.
  16577. */
  16578. set depthScale(value: number);
  16579. protected _validateFilter(filter: number): number;
  16580. protected _filter: number;
  16581. /**
  16582. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16583. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16584. */
  16585. get filter(): number;
  16586. /**
  16587. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16588. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16589. */
  16590. set filter(value: number);
  16591. /**
  16592. * Gets if the current filter is set to Poisson Sampling.
  16593. */
  16594. get usePoissonSampling(): boolean;
  16595. /**
  16596. * Sets the current filter to Poisson Sampling.
  16597. */
  16598. set usePoissonSampling(value: boolean);
  16599. /**
  16600. * Gets if the current filter is set to ESM.
  16601. */
  16602. get useExponentialShadowMap(): boolean;
  16603. /**
  16604. * Sets the current filter is to ESM.
  16605. */
  16606. set useExponentialShadowMap(value: boolean);
  16607. /**
  16608. * Gets if the current filter is set to filtered ESM.
  16609. */
  16610. get useBlurExponentialShadowMap(): boolean;
  16611. /**
  16612. * Gets if the current filter is set to filtered ESM.
  16613. */
  16614. set useBlurExponentialShadowMap(value: boolean);
  16615. /**
  16616. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16617. * exponential to prevent steep falloff artifacts).
  16618. */
  16619. get useCloseExponentialShadowMap(): boolean;
  16620. /**
  16621. * Sets the current filter to "close ESM" (using the inverse of the
  16622. * exponential to prevent steep falloff artifacts).
  16623. */
  16624. set useCloseExponentialShadowMap(value: boolean);
  16625. /**
  16626. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16627. * exponential to prevent steep falloff artifacts).
  16628. */
  16629. get useBlurCloseExponentialShadowMap(): boolean;
  16630. /**
  16631. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16632. * exponential to prevent steep falloff artifacts).
  16633. */
  16634. set useBlurCloseExponentialShadowMap(value: boolean);
  16635. /**
  16636. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16637. */
  16638. get usePercentageCloserFiltering(): boolean;
  16639. /**
  16640. * Sets the current filter to "PCF" (percentage closer filtering).
  16641. */
  16642. set usePercentageCloserFiltering(value: boolean);
  16643. protected _filteringQuality: number;
  16644. /**
  16645. * Gets the PCF or PCSS Quality.
  16646. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16647. */
  16648. get filteringQuality(): number;
  16649. /**
  16650. * Sets the PCF or PCSS Quality.
  16651. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16652. */
  16653. set filteringQuality(filteringQuality: number);
  16654. /**
  16655. * Gets if the current filter is set to "PCSS" (contact hardening).
  16656. */
  16657. get useContactHardeningShadow(): boolean;
  16658. /**
  16659. * Sets the current filter to "PCSS" (contact hardening).
  16660. */
  16661. set useContactHardeningShadow(value: boolean);
  16662. protected _contactHardeningLightSizeUVRatio: number;
  16663. /**
  16664. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16665. * Using a ratio helps keeping shape stability independently of the map size.
  16666. *
  16667. * It does not account for the light projection as it was having too much
  16668. * instability during the light setup or during light position changes.
  16669. *
  16670. * Only valid if useContactHardeningShadow is true.
  16671. */
  16672. get contactHardeningLightSizeUVRatio(): number;
  16673. /**
  16674. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16675. * Using a ratio helps keeping shape stability independently of the map size.
  16676. *
  16677. * It does not account for the light projection as it was having too much
  16678. * instability during the light setup or during light position changes.
  16679. *
  16680. * Only valid if useContactHardeningShadow is true.
  16681. */
  16682. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16683. protected _darkness: number;
  16684. /** Gets or sets the actual darkness of a shadow */
  16685. get darkness(): number;
  16686. set darkness(value: number);
  16687. /**
  16688. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16689. * 0 means strongest and 1 would means no shadow.
  16690. * @returns the darkness.
  16691. */
  16692. getDarkness(): number;
  16693. /**
  16694. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16695. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16696. * @returns the shadow generator allowing fluent coding.
  16697. */
  16698. setDarkness(darkness: number): ShadowGenerator;
  16699. protected _transparencyShadow: boolean;
  16700. /** Gets or sets the ability to have transparent shadow */
  16701. get transparencyShadow(): boolean;
  16702. set transparencyShadow(value: boolean);
  16703. /**
  16704. * Sets the ability to have transparent shadow (boolean).
  16705. * @param transparent True if transparent else False
  16706. * @returns the shadow generator allowing fluent coding
  16707. */
  16708. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16709. protected _shadowMap: Nullable<RenderTargetTexture>;
  16710. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16711. /**
  16712. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16713. * @returns The render target texture if present otherwise, null
  16714. */
  16715. getShadowMap(): Nullable<RenderTargetTexture>;
  16716. /**
  16717. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16718. * @returns The render target texture if the shadow map is present otherwise, null
  16719. */
  16720. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16721. /**
  16722. * Gets the class name of that object
  16723. * @returns "ShadowGenerator"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16728. * @param mesh Mesh to add
  16729. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16730. * @returns the Shadow Generator itself
  16731. */
  16732. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16733. /**
  16734. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16735. * @param mesh Mesh to remove
  16736. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16737. * @returns the Shadow Generator itself
  16738. */
  16739. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16740. /**
  16741. * Controls the extent to which the shadows fade out at the edge of the frustum
  16742. */
  16743. frustumEdgeFalloff: number;
  16744. protected _light: IShadowLight;
  16745. /**
  16746. * Returns the associated light object.
  16747. * @returns the light generating the shadow
  16748. */
  16749. getLight(): IShadowLight;
  16750. /**
  16751. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16752. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16753. * It might on the other hand introduce peter panning.
  16754. */
  16755. forceBackFacesOnly: boolean;
  16756. protected _scene: Scene;
  16757. protected _lightDirection: Vector3;
  16758. protected _effect: Effect;
  16759. protected _viewMatrix: Matrix;
  16760. protected _projectionMatrix: Matrix;
  16761. protected _transformMatrix: Matrix;
  16762. protected _cachedPosition: Vector3;
  16763. protected _cachedDirection: Vector3;
  16764. protected _cachedDefines: string;
  16765. protected _currentRenderID: number;
  16766. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16767. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16768. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16769. protected _blurPostProcesses: PostProcess[];
  16770. protected _mapSize: number;
  16771. protected _currentFaceIndex: number;
  16772. protected _currentFaceIndexCache: number;
  16773. protected _textureType: number;
  16774. protected _defaultTextureMatrix: Matrix;
  16775. protected _storedUniqueId: Nullable<number>;
  16776. /** @hidden */
  16777. static _SceneComponentInitialization: (scene: Scene) => void;
  16778. /**
  16779. * Creates a ShadowGenerator object.
  16780. * A ShadowGenerator is the required tool to use the shadows.
  16781. * Each light casting shadows needs to use its own ShadowGenerator.
  16782. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16783. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16784. * @param light The light object generating the shadows.
  16785. * @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.
  16786. */
  16787. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16788. protected _initializeGenerator(): void;
  16789. protected _createTargetRenderTexture(): void;
  16790. protected _initializeShadowMap(): void;
  16791. protected _initializeBlurRTTAndPostProcesses(): void;
  16792. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16793. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any): void;
  16794. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16795. protected _applyFilterValues(): void;
  16796. /**
  16797. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16798. * @param onCompiled Callback triggered at the and of the effects compilation
  16799. * @param options Sets of optional options forcing the compilation with different modes
  16800. */
  16801. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16802. useInstances: boolean;
  16803. }>): void;
  16804. /**
  16805. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16806. * @param options Sets of optional options forcing the compilation with different modes
  16807. * @returns A promise that resolves when the compilation completes
  16808. */
  16809. forceCompilationAsync(options?: Partial<{
  16810. useInstances: boolean;
  16811. }>): Promise<void>;
  16812. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16813. private _prepareShadowDefines;
  16814. /**
  16815. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16816. * @param subMesh The submesh we want to render in the shadow map
  16817. * @param useInstances Defines wether will draw in the map using instances
  16818. * @returns true if ready otherwise, false
  16819. */
  16820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16821. /**
  16822. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16823. * @param defines Defines of the material we want to update
  16824. * @param lightIndex Index of the light in the enabled light list of the material
  16825. */
  16826. prepareDefines(defines: any, lightIndex: number): void;
  16827. /**
  16828. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16829. * defined in the generator but impacting the effect).
  16830. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16831. * @param effect The effect we are binfing the information for
  16832. */
  16833. bindShadowLight(lightIndex: string, effect: Effect): void;
  16834. /**
  16835. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16836. * (eq to shadow prjection matrix * light transform matrix)
  16837. * @returns The transform matrix used to create the shadow map
  16838. */
  16839. getTransformMatrix(): Matrix;
  16840. /**
  16841. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16842. * Cube and 2D textures for instance.
  16843. */
  16844. recreateShadowMap(): void;
  16845. protected _disposeBlurPostProcesses(): void;
  16846. protected _disposeRTTandPostProcesses(): void;
  16847. /**
  16848. * Disposes the ShadowGenerator.
  16849. * Returns nothing.
  16850. */
  16851. dispose(): void;
  16852. /**
  16853. * Serializes the shadow generator setup to a json object.
  16854. * @returns The serialized JSON object
  16855. */
  16856. serialize(): any;
  16857. /**
  16858. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16859. * @param parsedShadowGenerator The JSON object to parse
  16860. * @param scene The scene to create the shadow map for
  16861. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16862. * @returns The parsed shadow generator
  16863. */
  16864. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16865. }
  16866. }
  16867. declare module BABYLON {
  16868. /**
  16869. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16870. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16871. * 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.
  16872. */
  16873. export abstract class Light extends Node {
  16874. /**
  16875. * Falloff Default: light is falling off following the material specification:
  16876. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16877. */
  16878. static readonly FALLOFF_DEFAULT: number;
  16879. /**
  16880. * Falloff Physical: light is falling off following the inverse squared distance law.
  16881. */
  16882. static readonly FALLOFF_PHYSICAL: number;
  16883. /**
  16884. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16885. * to enhance interoperability with other engines.
  16886. */
  16887. static readonly FALLOFF_GLTF: number;
  16888. /**
  16889. * Falloff Standard: light is falling off like in the standard material
  16890. * to enhance interoperability with other materials.
  16891. */
  16892. static readonly FALLOFF_STANDARD: number;
  16893. /**
  16894. * If every light affecting the material is in this lightmapMode,
  16895. * material.lightmapTexture adds or multiplies
  16896. * (depends on material.useLightmapAsShadowmap)
  16897. * after every other light calculations.
  16898. */
  16899. static readonly LIGHTMAP_DEFAULT: number;
  16900. /**
  16901. * material.lightmapTexture as only diffuse lighting from this light
  16902. * adds only specular lighting from this light
  16903. * adds dynamic shadows
  16904. */
  16905. static readonly LIGHTMAP_SPECULAR: number;
  16906. /**
  16907. * material.lightmapTexture as only lighting
  16908. * no light calculation from this light
  16909. * only adds dynamic shadows from this light
  16910. */
  16911. static readonly LIGHTMAP_SHADOWSONLY: number;
  16912. /**
  16913. * Each light type uses the default quantity according to its type:
  16914. * point/spot lights use luminous intensity
  16915. * directional lights use illuminance
  16916. */
  16917. static readonly INTENSITYMODE_AUTOMATIC: number;
  16918. /**
  16919. * lumen (lm)
  16920. */
  16921. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16922. /**
  16923. * candela (lm/sr)
  16924. */
  16925. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16926. /**
  16927. * lux (lm/m^2)
  16928. */
  16929. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16930. /**
  16931. * nit (cd/m^2)
  16932. */
  16933. static readonly INTENSITYMODE_LUMINANCE: number;
  16934. /**
  16935. * Light type const id of the point light.
  16936. */
  16937. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16938. /**
  16939. * Light type const id of the directional light.
  16940. */
  16941. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16942. /**
  16943. * Light type const id of the spot light.
  16944. */
  16945. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16946. /**
  16947. * Light type const id of the hemispheric light.
  16948. */
  16949. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16950. /**
  16951. * Diffuse gives the basic color to an object.
  16952. */
  16953. diffuse: Color3;
  16954. /**
  16955. * Specular produces a highlight color on an object.
  16956. * Note: This is note affecting PBR materials.
  16957. */
  16958. specular: Color3;
  16959. /**
  16960. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16961. * falling off base on range or angle.
  16962. * This can be set to any values in Light.FALLOFF_x.
  16963. *
  16964. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16965. * other types of materials.
  16966. */
  16967. falloffType: number;
  16968. /**
  16969. * Strength of the light.
  16970. * Note: By default it is define in the framework own unit.
  16971. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16972. */
  16973. intensity: number;
  16974. private _range;
  16975. protected _inverseSquaredRange: number;
  16976. /**
  16977. * Defines how far from the source the light is impacting in scene units.
  16978. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16979. */
  16980. get range(): number;
  16981. /**
  16982. * Defines how far from the source the light is impacting in scene units.
  16983. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16984. */
  16985. set range(value: number);
  16986. /**
  16987. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16988. * of light.
  16989. */
  16990. private _photometricScale;
  16991. private _intensityMode;
  16992. /**
  16993. * Gets the photometric scale used to interpret the intensity.
  16994. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16995. */
  16996. get intensityMode(): number;
  16997. /**
  16998. * Sets the photometric scale used to interpret the intensity.
  16999. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17000. */
  17001. set intensityMode(value: number);
  17002. private _radius;
  17003. /**
  17004. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17005. */
  17006. get radius(): number;
  17007. /**
  17008. * sets the light radius used by PBR Materials to simulate soft area lights.
  17009. */
  17010. set radius(value: number);
  17011. private _renderPriority;
  17012. /**
  17013. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17014. * exceeding the number allowed of the materials.
  17015. */
  17016. renderPriority: number;
  17017. private _shadowEnabled;
  17018. /**
  17019. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17020. * the current shadow generator.
  17021. */
  17022. get shadowEnabled(): boolean;
  17023. /**
  17024. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17025. * the current shadow generator.
  17026. */
  17027. set shadowEnabled(value: boolean);
  17028. private _includedOnlyMeshes;
  17029. /**
  17030. * Gets the only meshes impacted by this light.
  17031. */
  17032. get includedOnlyMeshes(): AbstractMesh[];
  17033. /**
  17034. * Sets the only meshes impacted by this light.
  17035. */
  17036. set includedOnlyMeshes(value: AbstractMesh[]);
  17037. private _excludedMeshes;
  17038. /**
  17039. * Gets the meshes not impacted by this light.
  17040. */
  17041. get excludedMeshes(): AbstractMesh[];
  17042. /**
  17043. * Sets the meshes not impacted by this light.
  17044. */
  17045. set excludedMeshes(value: AbstractMesh[]);
  17046. private _excludeWithLayerMask;
  17047. /**
  17048. * Gets the layer id use to find what meshes are not impacted by the light.
  17049. * Inactive if 0
  17050. */
  17051. get excludeWithLayerMask(): number;
  17052. /**
  17053. * Sets the layer id use to find what meshes are not impacted by the light.
  17054. * Inactive if 0
  17055. */
  17056. set excludeWithLayerMask(value: number);
  17057. private _includeOnlyWithLayerMask;
  17058. /**
  17059. * Gets the layer id use to find what meshes are impacted by the light.
  17060. * Inactive if 0
  17061. */
  17062. get includeOnlyWithLayerMask(): number;
  17063. /**
  17064. * Sets the layer id use to find what meshes are impacted by the light.
  17065. * Inactive if 0
  17066. */
  17067. set includeOnlyWithLayerMask(value: number);
  17068. private _lightmapMode;
  17069. /**
  17070. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17071. */
  17072. get lightmapMode(): number;
  17073. /**
  17074. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17075. */
  17076. set lightmapMode(value: number);
  17077. /**
  17078. * Shadow generator associted to the light.
  17079. * @hidden Internal use only.
  17080. */
  17081. _shadowGenerator: Nullable<IShadowGenerator>;
  17082. /**
  17083. * @hidden Internal use only.
  17084. */
  17085. _excludedMeshesIds: string[];
  17086. /**
  17087. * @hidden Internal use only.
  17088. */
  17089. _includedOnlyMeshesIds: string[];
  17090. /**
  17091. * The current light unifom buffer.
  17092. * @hidden Internal use only.
  17093. */
  17094. _uniformBuffer: UniformBuffer;
  17095. /** @hidden */
  17096. _renderId: number;
  17097. /**
  17098. * Creates a Light object in the scene.
  17099. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17100. * @param name The firendly name of the light
  17101. * @param scene The scene the light belongs too
  17102. */
  17103. constructor(name: string, scene: Scene);
  17104. protected abstract _buildUniformLayout(): void;
  17105. /**
  17106. * Sets the passed Effect "effect" with the Light information.
  17107. * @param effect The effect to update
  17108. * @param lightIndex The index of the light in the effect to update
  17109. * @returns The light
  17110. */
  17111. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17112. /**
  17113. * Sets the passed Effect "effect" with the Light textures.
  17114. * @param effect The effect to update
  17115. * @param lightIndex The index of the light in the effect to update
  17116. * @returns The light
  17117. */
  17118. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17119. /**
  17120. * Binds the lights information from the scene to the effect for the given mesh.
  17121. * @param lightIndex Light index
  17122. * @param scene The scene where the light belongs to
  17123. * @param effect The effect we are binding the data to
  17124. * @param useSpecular Defines if specular is supported
  17125. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17126. */
  17127. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17128. /**
  17129. * Sets the passed Effect "effect" with the Light information.
  17130. * @param effect The effect to update
  17131. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17132. * @returns The light
  17133. */
  17134. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17135. /**
  17136. * Returns the string "Light".
  17137. * @returns the class name
  17138. */
  17139. getClassName(): string;
  17140. /** @hidden */
  17141. readonly _isLight: boolean;
  17142. /**
  17143. * Converts the light information to a readable string for debug purpose.
  17144. * @param fullDetails Supports for multiple levels of logging within scene loading
  17145. * @returns the human readable light info
  17146. */
  17147. toString(fullDetails?: boolean): string;
  17148. /** @hidden */
  17149. protected _syncParentEnabledState(): void;
  17150. /**
  17151. * Set the enabled state of this node.
  17152. * @param value - the new enabled state
  17153. */
  17154. setEnabled(value: boolean): void;
  17155. /**
  17156. * Returns the Light associated shadow generator if any.
  17157. * @return the associated shadow generator.
  17158. */
  17159. getShadowGenerator(): Nullable<IShadowGenerator>;
  17160. /**
  17161. * Returns a Vector3, the absolute light position in the World.
  17162. * @returns the world space position of the light
  17163. */
  17164. getAbsolutePosition(): Vector3;
  17165. /**
  17166. * Specifies if the light will affect the passed mesh.
  17167. * @param mesh The mesh to test against the light
  17168. * @return true the mesh is affected otherwise, false.
  17169. */
  17170. canAffectMesh(mesh: AbstractMesh): boolean;
  17171. /**
  17172. * Sort function to order lights for rendering.
  17173. * @param a First Light object to compare to second.
  17174. * @param b Second Light object to compare first.
  17175. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17176. */
  17177. static CompareLightsPriority(a: Light, b: Light): number;
  17178. /**
  17179. * Releases resources associated with this node.
  17180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17182. */
  17183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17184. /**
  17185. * Returns the light type ID (integer).
  17186. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17187. */
  17188. getTypeID(): number;
  17189. /**
  17190. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17191. * @returns the scaled intensity in intensity mode unit
  17192. */
  17193. getScaledIntensity(): number;
  17194. /**
  17195. * Returns a new Light object, named "name", from the current one.
  17196. * @param name The name of the cloned light
  17197. * @returns the new created light
  17198. */
  17199. clone(name: string): Nullable<Light>;
  17200. /**
  17201. * Serializes the current light into a Serialization object.
  17202. * @returns the serialized object.
  17203. */
  17204. serialize(): any;
  17205. /**
  17206. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17207. * This new light is named "name" and added to the passed scene.
  17208. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17209. * @param name The friendly name of the light
  17210. * @param scene The scene the new light will belong to
  17211. * @returns the constructor function
  17212. */
  17213. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17214. /**
  17215. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17216. * @param parsedLight The JSON representation of the light
  17217. * @param scene The scene to create the parsed light in
  17218. * @returns the created light after parsing
  17219. */
  17220. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17221. private _hookArrayForExcluded;
  17222. private _hookArrayForIncludedOnly;
  17223. private _resyncMeshes;
  17224. /**
  17225. * Forces the meshes to update their light related information in their rendering used effects
  17226. * @hidden Internal Use Only
  17227. */
  17228. _markMeshesAsLightDirty(): void;
  17229. /**
  17230. * Recomputes the cached photometric scale if needed.
  17231. */
  17232. private _computePhotometricScale;
  17233. /**
  17234. * Returns the Photometric Scale according to the light type and intensity mode.
  17235. */
  17236. private _getPhotometricScale;
  17237. /**
  17238. * Reorder the light in the scene according to their defined priority.
  17239. * @hidden Internal Use Only
  17240. */
  17241. _reorderLightsInScene(): void;
  17242. /**
  17243. * Prepares the list of defines specific to the light type.
  17244. * @param defines the list of defines
  17245. * @param lightIndex defines the index of the light for the effect
  17246. */
  17247. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17248. }
  17249. }
  17250. declare module BABYLON {
  17251. /**
  17252. * Interface used to define Action
  17253. */
  17254. export interface IAction {
  17255. /**
  17256. * Trigger for the action
  17257. */
  17258. trigger: number;
  17259. /** Options of the trigger */
  17260. triggerOptions: any;
  17261. /**
  17262. * Gets the trigger parameters
  17263. * @returns the trigger parameters
  17264. */
  17265. getTriggerParameter(): any;
  17266. /**
  17267. * Internal only - executes current action event
  17268. * @hidden
  17269. */
  17270. _executeCurrent(evt?: ActionEvent): void;
  17271. /**
  17272. * Serialize placeholder for child classes
  17273. * @param parent of child
  17274. * @returns the serialized object
  17275. */
  17276. serialize(parent: any): any;
  17277. /**
  17278. * Internal only
  17279. * @hidden
  17280. */
  17281. _prepare(): void;
  17282. /**
  17283. * Internal only - manager for action
  17284. * @hidden
  17285. */
  17286. _actionManager: AbstractActionManager;
  17287. /**
  17288. * Adds action to chain of actions, may be a DoNothingAction
  17289. * @param action defines the next action to execute
  17290. * @returns The action passed in
  17291. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17292. */
  17293. then(action: IAction): IAction;
  17294. }
  17295. /**
  17296. * The action to be carried out following a trigger
  17297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17298. */
  17299. export class Action implements IAction {
  17300. /** the trigger, with or without parameters, for the action */
  17301. triggerOptions: any;
  17302. /**
  17303. * Trigger for the action
  17304. */
  17305. trigger: number;
  17306. /**
  17307. * Internal only - manager for action
  17308. * @hidden
  17309. */
  17310. _actionManager: ActionManager;
  17311. private _nextActiveAction;
  17312. private _child;
  17313. private _condition?;
  17314. private _triggerParameter;
  17315. /**
  17316. * An event triggered prior to action being executed.
  17317. */
  17318. onBeforeExecuteObservable: Observable<Action>;
  17319. /**
  17320. * Creates a new Action
  17321. * @param triggerOptions the trigger, with or without parameters, for the action
  17322. * @param condition an optional determinant of action
  17323. */
  17324. constructor(
  17325. /** the trigger, with or without parameters, for the action */
  17326. triggerOptions: any, condition?: Condition);
  17327. /**
  17328. * Internal only
  17329. * @hidden
  17330. */
  17331. _prepare(): void;
  17332. /**
  17333. * Gets the trigger parameters
  17334. * @returns the trigger parameters
  17335. */
  17336. getTriggerParameter(): any;
  17337. /**
  17338. * Internal only - executes current action event
  17339. * @hidden
  17340. */
  17341. _executeCurrent(evt?: ActionEvent): void;
  17342. /**
  17343. * Execute placeholder for child classes
  17344. * @param evt optional action event
  17345. */
  17346. execute(evt?: ActionEvent): void;
  17347. /**
  17348. * Skips to next active action
  17349. */
  17350. skipToNextActiveAction(): void;
  17351. /**
  17352. * Adds action to chain of actions, may be a DoNothingAction
  17353. * @param action defines the next action to execute
  17354. * @returns The action passed in
  17355. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17356. */
  17357. then(action: Action): Action;
  17358. /**
  17359. * Internal only
  17360. * @hidden
  17361. */
  17362. _getProperty(propertyPath: string): string;
  17363. /**
  17364. * Internal only
  17365. * @hidden
  17366. */
  17367. _getEffectiveTarget(target: any, propertyPath: string): any;
  17368. /**
  17369. * Serialize placeholder for child classes
  17370. * @param parent of child
  17371. * @returns the serialized object
  17372. */
  17373. serialize(parent: any): any;
  17374. /**
  17375. * Internal only called by serialize
  17376. * @hidden
  17377. */
  17378. protected _serialize(serializedAction: any, parent?: any): any;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. static _SerializeValueAsString: (value: any) => string;
  17384. /**
  17385. * Internal only
  17386. * @hidden
  17387. */
  17388. static _GetTargetProperty: (target: Node | Scene) => {
  17389. name: string;
  17390. targetType: string;
  17391. value: string;
  17392. };
  17393. }
  17394. }
  17395. declare module BABYLON {
  17396. /**
  17397. * A Condition applied to an Action
  17398. */
  17399. export class Condition {
  17400. /**
  17401. * Internal only - manager for action
  17402. * @hidden
  17403. */
  17404. _actionManager: ActionManager;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. _evaluationId: number;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. _currentResult: boolean;
  17415. /**
  17416. * Creates a new Condition
  17417. * @param actionManager the manager of the action the condition is applied to
  17418. */
  17419. constructor(actionManager: ActionManager);
  17420. /**
  17421. * Check if the current condition is valid
  17422. * @returns a boolean
  17423. */
  17424. isValid(): boolean;
  17425. /**
  17426. * Internal only
  17427. * @hidden
  17428. */
  17429. _getProperty(propertyPath: string): string;
  17430. /**
  17431. * Internal only
  17432. * @hidden
  17433. */
  17434. _getEffectiveTarget(target: any, propertyPath: string): any;
  17435. /**
  17436. * Serialize placeholder for child classes
  17437. * @returns the serialized object
  17438. */
  17439. serialize(): any;
  17440. /**
  17441. * Internal only
  17442. * @hidden
  17443. */
  17444. protected _serialize(serializedCondition: any): any;
  17445. }
  17446. /**
  17447. * Defines specific conditional operators as extensions of Condition
  17448. */
  17449. export class ValueCondition extends Condition {
  17450. /** path to specify the property of the target the conditional operator uses */
  17451. propertyPath: string;
  17452. /** the value compared by the conditional operator against the current value of the property */
  17453. value: any;
  17454. /** the conditional operator, default ValueCondition.IsEqual */
  17455. operator: number;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. private static _IsEqual;
  17461. /**
  17462. * Internal only
  17463. * @hidden
  17464. */
  17465. private static _IsDifferent;
  17466. /**
  17467. * Internal only
  17468. * @hidden
  17469. */
  17470. private static _IsGreater;
  17471. /**
  17472. * Internal only
  17473. * @hidden
  17474. */
  17475. private static _IsLesser;
  17476. /**
  17477. * returns the number for IsEqual
  17478. */
  17479. static get IsEqual(): number;
  17480. /**
  17481. * Returns the number for IsDifferent
  17482. */
  17483. static get IsDifferent(): number;
  17484. /**
  17485. * Returns the number for IsGreater
  17486. */
  17487. static get IsGreater(): number;
  17488. /**
  17489. * Returns the number for IsLesser
  17490. */
  17491. static get IsLesser(): number;
  17492. /**
  17493. * Internal only The action manager for the condition
  17494. * @hidden
  17495. */
  17496. _actionManager: ActionManager;
  17497. /**
  17498. * Internal only
  17499. * @hidden
  17500. */
  17501. private _target;
  17502. /**
  17503. * Internal only
  17504. * @hidden
  17505. */
  17506. private _effectiveTarget;
  17507. /**
  17508. * Internal only
  17509. * @hidden
  17510. */
  17511. private _property;
  17512. /**
  17513. * Creates a new ValueCondition
  17514. * @param actionManager manager for the action the condition applies to
  17515. * @param target for the action
  17516. * @param propertyPath path to specify the property of the target the conditional operator uses
  17517. * @param value the value compared by the conditional operator against the current value of the property
  17518. * @param operator the conditional operator, default ValueCondition.IsEqual
  17519. */
  17520. constructor(actionManager: ActionManager, target: any,
  17521. /** path to specify the property of the target the conditional operator uses */
  17522. propertyPath: string,
  17523. /** the value compared by the conditional operator against the current value of the property */
  17524. value: any,
  17525. /** the conditional operator, default ValueCondition.IsEqual */
  17526. operator?: number);
  17527. /**
  17528. * Compares the given value with the property value for the specified conditional operator
  17529. * @returns the result of the comparison
  17530. */
  17531. isValid(): boolean;
  17532. /**
  17533. * Serialize the ValueCondition into a JSON compatible object
  17534. * @returns serialization object
  17535. */
  17536. serialize(): any;
  17537. /**
  17538. * Gets the name of the conditional operator for the ValueCondition
  17539. * @param operator the conditional operator
  17540. * @returns the name
  17541. */
  17542. static GetOperatorName(operator: number): string;
  17543. }
  17544. /**
  17545. * Defines a predicate condition as an extension of Condition
  17546. */
  17547. export class PredicateCondition extends Condition {
  17548. /** defines the predicate function used to validate the condition */
  17549. predicate: () => boolean;
  17550. /**
  17551. * Internal only - manager for action
  17552. * @hidden
  17553. */
  17554. _actionManager: ActionManager;
  17555. /**
  17556. * Creates a new PredicateCondition
  17557. * @param actionManager manager for the action the condition applies to
  17558. * @param predicate defines the predicate function used to validate the condition
  17559. */
  17560. constructor(actionManager: ActionManager,
  17561. /** defines the predicate function used to validate the condition */
  17562. predicate: () => boolean);
  17563. /**
  17564. * @returns the validity of the predicate condition
  17565. */
  17566. isValid(): boolean;
  17567. }
  17568. /**
  17569. * Defines a state condition as an extension of Condition
  17570. */
  17571. export class StateCondition extends Condition {
  17572. /** Value to compare with target state */
  17573. value: string;
  17574. /**
  17575. * Internal only - manager for action
  17576. * @hidden
  17577. */
  17578. _actionManager: ActionManager;
  17579. /**
  17580. * Internal only
  17581. * @hidden
  17582. */
  17583. private _target;
  17584. /**
  17585. * Creates a new StateCondition
  17586. * @param actionManager manager for the action the condition applies to
  17587. * @param target of the condition
  17588. * @param value to compare with target state
  17589. */
  17590. constructor(actionManager: ActionManager, target: any,
  17591. /** Value to compare with target state */
  17592. value: string);
  17593. /**
  17594. * Gets a boolean indicating if the current condition is met
  17595. * @returns the validity of the state
  17596. */
  17597. isValid(): boolean;
  17598. /**
  17599. * Serialize the StateCondition into a JSON compatible object
  17600. * @returns serialization object
  17601. */
  17602. serialize(): any;
  17603. }
  17604. }
  17605. declare module BABYLON {
  17606. /**
  17607. * This defines an action responsible to toggle a boolean once triggered.
  17608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17609. */
  17610. export class SwitchBooleanAction extends Action {
  17611. /**
  17612. * The path to the boolean property in the target object
  17613. */
  17614. propertyPath: string;
  17615. private _target;
  17616. private _effectiveTarget;
  17617. private _property;
  17618. /**
  17619. * Instantiate the action
  17620. * @param triggerOptions defines the trigger options
  17621. * @param target defines the object containing the boolean
  17622. * @param propertyPath defines the path to the boolean property in the target object
  17623. * @param condition defines the trigger related conditions
  17624. */
  17625. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17626. /** @hidden */
  17627. _prepare(): void;
  17628. /**
  17629. * Execute the action toggle the boolean value.
  17630. */
  17631. execute(): void;
  17632. /**
  17633. * Serializes the actions and its related information.
  17634. * @param parent defines the object to serialize in
  17635. * @returns the serialized object
  17636. */
  17637. serialize(parent: any): any;
  17638. }
  17639. /**
  17640. * This defines an action responsible to set a the state field of the target
  17641. * to a desired value once triggered.
  17642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17643. */
  17644. export class SetStateAction extends Action {
  17645. /**
  17646. * The value to store in the state field.
  17647. */
  17648. value: string;
  17649. private _target;
  17650. /**
  17651. * Instantiate the action
  17652. * @param triggerOptions defines the trigger options
  17653. * @param target defines the object containing the state property
  17654. * @param value defines the value to store in the state field
  17655. * @param condition defines the trigger related conditions
  17656. */
  17657. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17658. /**
  17659. * Execute the action and store the value on the target state property.
  17660. */
  17661. execute(): void;
  17662. /**
  17663. * Serializes the actions and its related information.
  17664. * @param parent defines the object to serialize in
  17665. * @returns the serialized object
  17666. */
  17667. serialize(parent: any): any;
  17668. }
  17669. /**
  17670. * This defines an action responsible to set a property of the target
  17671. * to a desired value once triggered.
  17672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17673. */
  17674. export class SetValueAction extends Action {
  17675. /**
  17676. * The path of the property to set in the target.
  17677. */
  17678. propertyPath: string;
  17679. /**
  17680. * The value to set in the property
  17681. */
  17682. value: any;
  17683. private _target;
  17684. private _effectiveTarget;
  17685. private _property;
  17686. /**
  17687. * Instantiate the action
  17688. * @param triggerOptions defines the trigger options
  17689. * @param target defines the object containing the property
  17690. * @param propertyPath defines the path of the property to set in the target
  17691. * @param value defines the value to set in the property
  17692. * @param condition defines the trigger related conditions
  17693. */
  17694. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17695. /** @hidden */
  17696. _prepare(): void;
  17697. /**
  17698. * Execute the action and set the targetted property to the desired value.
  17699. */
  17700. execute(): void;
  17701. /**
  17702. * Serializes the actions and its related information.
  17703. * @param parent defines the object to serialize in
  17704. * @returns the serialized object
  17705. */
  17706. serialize(parent: any): any;
  17707. }
  17708. /**
  17709. * This defines an action responsible to increment the target value
  17710. * to a desired value once triggered.
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17712. */
  17713. export class IncrementValueAction extends Action {
  17714. /**
  17715. * The path of the property to increment in the target.
  17716. */
  17717. propertyPath: string;
  17718. /**
  17719. * The value we should increment the property by.
  17720. */
  17721. value: any;
  17722. private _target;
  17723. private _effectiveTarget;
  17724. private _property;
  17725. /**
  17726. * Instantiate the action
  17727. * @param triggerOptions defines the trigger options
  17728. * @param target defines the object containing the property
  17729. * @param propertyPath defines the path of the property to increment in the target
  17730. * @param value defines the value value we should increment the property by
  17731. * @param condition defines the trigger related conditions
  17732. */
  17733. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17734. /** @hidden */
  17735. _prepare(): void;
  17736. /**
  17737. * Execute the action and increment the target of the value amount.
  17738. */
  17739. execute(): void;
  17740. /**
  17741. * Serializes the actions and its related information.
  17742. * @param parent defines the object to serialize in
  17743. * @returns the serialized object
  17744. */
  17745. serialize(parent: any): any;
  17746. }
  17747. /**
  17748. * This defines an action responsible to start an animation once triggered.
  17749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17750. */
  17751. export class PlayAnimationAction extends Action {
  17752. /**
  17753. * Where the animation should start (animation frame)
  17754. */
  17755. from: number;
  17756. /**
  17757. * Where the animation should stop (animation frame)
  17758. */
  17759. to: number;
  17760. /**
  17761. * Define if the animation should loop or stop after the first play.
  17762. */
  17763. loop?: boolean;
  17764. private _target;
  17765. /**
  17766. * Instantiate the action
  17767. * @param triggerOptions defines the trigger options
  17768. * @param target defines the target animation or animation name
  17769. * @param from defines from where the animation should start (animation frame)
  17770. * @param end defines where the animation should stop (animation frame)
  17771. * @param loop defines if the animation should loop or stop after the first play
  17772. * @param condition defines the trigger related conditions
  17773. */
  17774. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17775. /** @hidden */
  17776. _prepare(): void;
  17777. /**
  17778. * Execute the action and play the animation.
  17779. */
  17780. execute(): void;
  17781. /**
  17782. * Serializes the actions and its related information.
  17783. * @param parent defines the object to serialize in
  17784. * @returns the serialized object
  17785. */
  17786. serialize(parent: any): any;
  17787. }
  17788. /**
  17789. * This defines an action responsible to stop an animation once triggered.
  17790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17791. */
  17792. export class StopAnimationAction extends Action {
  17793. private _target;
  17794. /**
  17795. * Instantiate the action
  17796. * @param triggerOptions defines the trigger options
  17797. * @param target defines the target animation or animation name
  17798. * @param condition defines the trigger related conditions
  17799. */
  17800. constructor(triggerOptions: any, target: any, condition?: Condition);
  17801. /** @hidden */
  17802. _prepare(): void;
  17803. /**
  17804. * Execute the action and stop the animation.
  17805. */
  17806. execute(): void;
  17807. /**
  17808. * Serializes the actions and its related information.
  17809. * @param parent defines the object to serialize in
  17810. * @returns the serialized object
  17811. */
  17812. serialize(parent: any): any;
  17813. }
  17814. /**
  17815. * This defines an action responsible that does nothing once triggered.
  17816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17817. */
  17818. export class DoNothingAction extends Action {
  17819. /**
  17820. * Instantiate the action
  17821. * @param triggerOptions defines the trigger options
  17822. * @param condition defines the trigger related conditions
  17823. */
  17824. constructor(triggerOptions?: any, condition?: Condition);
  17825. /**
  17826. * Execute the action and do nothing.
  17827. */
  17828. execute(): void;
  17829. /**
  17830. * Serializes the actions and its related information.
  17831. * @param parent defines the object to serialize in
  17832. * @returns the serialized object
  17833. */
  17834. serialize(parent: any): any;
  17835. }
  17836. /**
  17837. * This defines an action responsible to trigger several actions once triggered.
  17838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17839. */
  17840. export class CombineAction extends Action {
  17841. /**
  17842. * The list of aggregated animations to run.
  17843. */
  17844. children: Action[];
  17845. /**
  17846. * Instantiate the action
  17847. * @param triggerOptions defines the trigger options
  17848. * @param children defines the list of aggregated animations to run
  17849. * @param condition defines the trigger related conditions
  17850. */
  17851. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17852. /** @hidden */
  17853. _prepare(): void;
  17854. /**
  17855. * Execute the action and executes all the aggregated actions.
  17856. */
  17857. execute(evt: ActionEvent): void;
  17858. /**
  17859. * Serializes the actions and its related information.
  17860. * @param parent defines the object to serialize in
  17861. * @returns the serialized object
  17862. */
  17863. serialize(parent: any): any;
  17864. }
  17865. /**
  17866. * This defines an action responsible to run code (external event) once triggered.
  17867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17868. */
  17869. export class ExecuteCodeAction extends Action {
  17870. /**
  17871. * The callback function to run.
  17872. */
  17873. func: (evt: ActionEvent) => void;
  17874. /**
  17875. * Instantiate the action
  17876. * @param triggerOptions defines the trigger options
  17877. * @param func defines the callback function to run
  17878. * @param condition defines the trigger related conditions
  17879. */
  17880. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17881. /**
  17882. * Execute the action and run the attached code.
  17883. */
  17884. execute(evt: ActionEvent): void;
  17885. }
  17886. /**
  17887. * This defines an action responsible to set the parent property of the target once triggered.
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17889. */
  17890. export class SetParentAction extends Action {
  17891. private _parent;
  17892. private _target;
  17893. /**
  17894. * Instantiate the action
  17895. * @param triggerOptions defines the trigger options
  17896. * @param target defines the target containing the parent property
  17897. * @param parent defines from where the animation should start (animation frame)
  17898. * @param condition defines the trigger related conditions
  17899. */
  17900. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17901. /** @hidden */
  17902. _prepare(): void;
  17903. /**
  17904. * Execute the action and set the parent property.
  17905. */
  17906. execute(): void;
  17907. /**
  17908. * Serializes the actions and its related information.
  17909. * @param parent defines the object to serialize in
  17910. * @returns the serialized object
  17911. */
  17912. serialize(parent: any): any;
  17913. }
  17914. }
  17915. declare module BABYLON {
  17916. /**
  17917. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17918. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17920. */
  17921. export class ActionManager extends AbstractActionManager {
  17922. /**
  17923. * Nothing
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly NothingTrigger: number;
  17927. /**
  17928. * On pick
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnPickTrigger: number;
  17932. /**
  17933. * On left pick
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnLeftPickTrigger: number;
  17937. /**
  17938. * On right pick
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnRightPickTrigger: number;
  17942. /**
  17943. * On center pick
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnCenterPickTrigger: number;
  17947. /**
  17948. * On pick down
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17950. */
  17951. static readonly OnPickDownTrigger: number;
  17952. /**
  17953. * On double pick
  17954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17955. */
  17956. static readonly OnDoublePickTrigger: number;
  17957. /**
  17958. * On pick up
  17959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17960. */
  17961. static readonly OnPickUpTrigger: number;
  17962. /**
  17963. * On pick out.
  17964. * This trigger will only be raised if you also declared a OnPickDown
  17965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17966. */
  17967. static readonly OnPickOutTrigger: number;
  17968. /**
  17969. * On long press
  17970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17971. */
  17972. static readonly OnLongPressTrigger: number;
  17973. /**
  17974. * On pointer over
  17975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17976. */
  17977. static readonly OnPointerOverTrigger: number;
  17978. /**
  17979. * On pointer out
  17980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17981. */
  17982. static readonly OnPointerOutTrigger: number;
  17983. /**
  17984. * On every frame
  17985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17986. */
  17987. static readonly OnEveryFrameTrigger: number;
  17988. /**
  17989. * On intersection enter
  17990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17991. */
  17992. static readonly OnIntersectionEnterTrigger: number;
  17993. /**
  17994. * On intersection exit
  17995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17996. */
  17997. static readonly OnIntersectionExitTrigger: number;
  17998. /**
  17999. * On key down
  18000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18001. */
  18002. static readonly OnKeyDownTrigger: number;
  18003. /**
  18004. * On key up
  18005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18006. */
  18007. static readonly OnKeyUpTrigger: number;
  18008. private _scene;
  18009. /**
  18010. * Creates a new action manager
  18011. * @param scene defines the hosting scene
  18012. */
  18013. constructor(scene: Scene);
  18014. /**
  18015. * Releases all associated resources
  18016. */
  18017. dispose(): void;
  18018. /**
  18019. * Gets hosting scene
  18020. * @returns the hosting scene
  18021. */
  18022. getScene(): Scene;
  18023. /**
  18024. * Does this action manager handles actions of any of the given triggers
  18025. * @param triggers defines the triggers to be tested
  18026. * @return a boolean indicating whether one (or more) of the triggers is handled
  18027. */
  18028. hasSpecificTriggers(triggers: number[]): boolean;
  18029. /**
  18030. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18031. * speed.
  18032. * @param triggerA defines the trigger to be tested
  18033. * @param triggerB defines the trigger to be tested
  18034. * @return a boolean indicating whether one (or more) of the triggers is handled
  18035. */
  18036. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18037. /**
  18038. * Does this action manager handles actions of a given trigger
  18039. * @param trigger defines the trigger to be tested
  18040. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18041. * @return whether the trigger is handled
  18042. */
  18043. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18044. /**
  18045. * Does this action manager has pointer triggers
  18046. */
  18047. get hasPointerTriggers(): boolean;
  18048. /**
  18049. * Does this action manager has pick triggers
  18050. */
  18051. get hasPickTriggers(): boolean;
  18052. /**
  18053. * Registers an action to this action manager
  18054. * @param action defines the action to be registered
  18055. * @return the action amended (prepared) after registration
  18056. */
  18057. registerAction(action: IAction): Nullable<IAction>;
  18058. /**
  18059. * Unregisters an action to this action manager
  18060. * @param action defines the action to be unregistered
  18061. * @return a boolean indicating whether the action has been unregistered
  18062. */
  18063. unregisterAction(action: IAction): Boolean;
  18064. /**
  18065. * Process a specific trigger
  18066. * @param trigger defines the trigger to process
  18067. * @param evt defines the event details to be processed
  18068. */
  18069. processTrigger(trigger: number, evt?: IActionEvent): void;
  18070. /** @hidden */
  18071. _getEffectiveTarget(target: any, propertyPath: string): any;
  18072. /** @hidden */
  18073. _getProperty(propertyPath: string): string;
  18074. /**
  18075. * Serialize this manager to a JSON object
  18076. * @param name defines the property name to store this manager
  18077. * @returns a JSON representation of this manager
  18078. */
  18079. serialize(name: string): any;
  18080. /**
  18081. * Creates a new ActionManager from a JSON data
  18082. * @param parsedActions defines the JSON data to read from
  18083. * @param object defines the hosting mesh
  18084. * @param scene defines the hosting scene
  18085. */
  18086. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18087. /**
  18088. * Get a trigger name by index
  18089. * @param trigger defines the trigger index
  18090. * @returns a trigger name
  18091. */
  18092. static GetTriggerName(trigger: number): string;
  18093. }
  18094. }
  18095. declare module BABYLON {
  18096. /**
  18097. * Class used to represent a sprite
  18098. * @see http://doc.babylonjs.com/babylon101/sprites
  18099. */
  18100. export class Sprite {
  18101. /** defines the name */
  18102. name: string;
  18103. /** Gets or sets the current world position */
  18104. position: Vector3;
  18105. /** Gets or sets the main color */
  18106. color: Color4;
  18107. /** Gets or sets the width */
  18108. width: number;
  18109. /** Gets or sets the height */
  18110. height: number;
  18111. /** Gets or sets rotation angle */
  18112. angle: number;
  18113. /** Gets or sets the cell index in the sprite sheet */
  18114. cellIndex: number;
  18115. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18116. cellRef: string;
  18117. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18118. invertU: number;
  18119. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18120. invertV: number;
  18121. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18122. disposeWhenFinishedAnimating: boolean;
  18123. /** Gets the list of attached animations */
  18124. animations: Animation[];
  18125. /** Gets or sets a boolean indicating if the sprite can be picked */
  18126. isPickable: boolean;
  18127. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18128. useAlphaForPicking: boolean;
  18129. /** @hidden */
  18130. _xOffset: number;
  18131. /** @hidden */
  18132. _yOffset: number;
  18133. /** @hidden */
  18134. _xSize: number;
  18135. /** @hidden */
  18136. _ySize: number;
  18137. /**
  18138. * Gets or sets the associated action manager
  18139. */
  18140. actionManager: Nullable<ActionManager>;
  18141. private _animationStarted;
  18142. private _loopAnimation;
  18143. private _fromIndex;
  18144. private _toIndex;
  18145. private _delay;
  18146. private _direction;
  18147. private _manager;
  18148. private _time;
  18149. private _onAnimationEnd;
  18150. /**
  18151. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18152. */
  18153. isVisible: boolean;
  18154. /**
  18155. * Gets or sets the sprite size
  18156. */
  18157. get size(): number;
  18158. set size(value: number);
  18159. /**
  18160. * Creates a new Sprite
  18161. * @param name defines the name
  18162. * @param manager defines the manager
  18163. */
  18164. constructor(
  18165. /** defines the name */
  18166. name: string, manager: ISpriteManager);
  18167. /**
  18168. * Starts an animation
  18169. * @param from defines the initial key
  18170. * @param to defines the end key
  18171. * @param loop defines if the animation must loop
  18172. * @param delay defines the start delay (in ms)
  18173. * @param onAnimationEnd defines a callback to call when animation ends
  18174. */
  18175. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18176. /** Stops current animation (if any) */
  18177. stopAnimation(): void;
  18178. /** @hidden */
  18179. _animate(deltaTime: number): void;
  18180. /** Release associated resources */
  18181. dispose(): void;
  18182. }
  18183. }
  18184. declare module BABYLON {
  18185. /**
  18186. * Information about the result of picking within a scene
  18187. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18188. */
  18189. export class PickingInfo {
  18190. /** @hidden */
  18191. _pickingUnavailable: boolean;
  18192. /**
  18193. * If the pick collided with an object
  18194. */
  18195. hit: boolean;
  18196. /**
  18197. * Distance away where the pick collided
  18198. */
  18199. distance: number;
  18200. /**
  18201. * The location of pick collision
  18202. */
  18203. pickedPoint: Nullable<Vector3>;
  18204. /**
  18205. * The mesh corresponding the the pick collision
  18206. */
  18207. pickedMesh: Nullable<AbstractMesh>;
  18208. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18209. bu: number;
  18210. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18211. bv: number;
  18212. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18213. faceId: number;
  18214. /** Id of the the submesh that was picked */
  18215. subMeshId: number;
  18216. /** If a sprite was picked, this will be the sprite the pick collided with */
  18217. pickedSprite: Nullable<Sprite>;
  18218. /**
  18219. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18220. */
  18221. originMesh: Nullable<AbstractMesh>;
  18222. /**
  18223. * The ray that was used to perform the picking.
  18224. */
  18225. ray: Nullable<Ray>;
  18226. /**
  18227. * Gets the normal correspodning to the face the pick collided with
  18228. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18229. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18230. * @returns The normal correspodning to the face the pick collided with
  18231. */
  18232. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18233. /**
  18234. * Gets the texture coordinates of where the pick occured
  18235. * @returns the vector containing the coordnates of the texture
  18236. */
  18237. getTextureCoordinates(): Nullable<Vector2>;
  18238. }
  18239. }
  18240. declare module BABYLON {
  18241. /**
  18242. * Gather the list of pointer event types as constants.
  18243. */
  18244. export class PointerEventTypes {
  18245. /**
  18246. * 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.
  18247. */
  18248. static readonly POINTERDOWN: number;
  18249. /**
  18250. * The pointerup event is fired when a pointer is no longer active.
  18251. */
  18252. static readonly POINTERUP: number;
  18253. /**
  18254. * The pointermove event is fired when a pointer changes coordinates.
  18255. */
  18256. static readonly POINTERMOVE: number;
  18257. /**
  18258. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18259. */
  18260. static readonly POINTERWHEEL: number;
  18261. /**
  18262. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18263. */
  18264. static readonly POINTERPICK: number;
  18265. /**
  18266. * The pointertap event is fired when a the object has been touched and released without drag.
  18267. */
  18268. static readonly POINTERTAP: number;
  18269. /**
  18270. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18271. */
  18272. static readonly POINTERDOUBLETAP: number;
  18273. }
  18274. /**
  18275. * Base class of pointer info types.
  18276. */
  18277. export class PointerInfoBase {
  18278. /**
  18279. * Defines the type of event (PointerEventTypes)
  18280. */
  18281. type: number;
  18282. /**
  18283. * Defines the related dom event
  18284. */
  18285. event: PointerEvent | MouseWheelEvent;
  18286. /**
  18287. * Instantiates the base class of pointers info.
  18288. * @param type Defines the type of event (PointerEventTypes)
  18289. * @param event Defines the related dom event
  18290. */
  18291. constructor(
  18292. /**
  18293. * Defines the type of event (PointerEventTypes)
  18294. */
  18295. type: number,
  18296. /**
  18297. * Defines the related dom event
  18298. */
  18299. event: PointerEvent | MouseWheelEvent);
  18300. }
  18301. /**
  18302. * This class is used to store pointer related info for the onPrePointerObservable event.
  18303. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18304. */
  18305. export class PointerInfoPre extends PointerInfoBase {
  18306. /**
  18307. * Ray from a pointer if availible (eg. 6dof controller)
  18308. */
  18309. ray: Nullable<Ray>;
  18310. /**
  18311. * Defines the local position of the pointer on the canvas.
  18312. */
  18313. localPosition: Vector2;
  18314. /**
  18315. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18316. */
  18317. skipOnPointerObservable: boolean;
  18318. /**
  18319. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18320. * @param type Defines the type of event (PointerEventTypes)
  18321. * @param event Defines the related dom event
  18322. * @param localX Defines the local x coordinates of the pointer when the event occured
  18323. * @param localY Defines the local y coordinates of the pointer when the event occured
  18324. */
  18325. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18326. }
  18327. /**
  18328. * This type contains all the data related to a pointer event in Babylon.js.
  18329. * 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.
  18330. */
  18331. export class PointerInfo extends PointerInfoBase {
  18332. /**
  18333. * Defines the picking info associated to the info (if any)\
  18334. */
  18335. pickInfo: Nullable<PickingInfo>;
  18336. /**
  18337. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18338. * @param type Defines the type of event (PointerEventTypes)
  18339. * @param event Defines the related dom event
  18340. * @param pickInfo Defines the picking info associated to the info (if any)\
  18341. */
  18342. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18343. /**
  18344. * Defines the picking info associated to the info (if any)\
  18345. */
  18346. pickInfo: Nullable<PickingInfo>);
  18347. }
  18348. /**
  18349. * Data relating to a touch event on the screen.
  18350. */
  18351. export interface PointerTouch {
  18352. /**
  18353. * X coordinate of touch.
  18354. */
  18355. x: number;
  18356. /**
  18357. * Y coordinate of touch.
  18358. */
  18359. y: number;
  18360. /**
  18361. * Id of touch. Unique for each finger.
  18362. */
  18363. pointerId: number;
  18364. /**
  18365. * Event type passed from DOM.
  18366. */
  18367. type: any;
  18368. }
  18369. }
  18370. declare module BABYLON {
  18371. /**
  18372. * Manage the mouse inputs to control the movement of a free camera.
  18373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18374. */
  18375. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18376. /**
  18377. * Define if touch is enabled in the mouse input
  18378. */
  18379. touchEnabled: boolean;
  18380. /**
  18381. * Defines the camera the input is attached to.
  18382. */
  18383. camera: FreeCamera;
  18384. /**
  18385. * Defines the buttons associated with the input to handle camera move.
  18386. */
  18387. buttons: number[];
  18388. /**
  18389. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18390. */
  18391. angularSensibility: number;
  18392. private _pointerInput;
  18393. private _onMouseMove;
  18394. private _observer;
  18395. private previousPosition;
  18396. /**
  18397. * Observable for when a pointer move event occurs containing the move offset
  18398. */
  18399. onPointerMovedObservable: Observable<{
  18400. offsetX: number;
  18401. offsetY: number;
  18402. }>;
  18403. /**
  18404. * @hidden
  18405. * If the camera should be rotated automatically based on pointer movement
  18406. */
  18407. _allowCameraRotation: boolean;
  18408. /**
  18409. * Manage the mouse inputs to control the movement of a free camera.
  18410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18411. * @param touchEnabled Defines if touch is enabled or not
  18412. */
  18413. constructor(
  18414. /**
  18415. * Define if touch is enabled in the mouse input
  18416. */
  18417. touchEnabled?: boolean);
  18418. /**
  18419. * Attach the input controls to a specific dom element to get the input from.
  18420. * @param element Defines the element the controls should be listened from
  18421. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18422. */
  18423. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18424. /**
  18425. * Called on JS contextmenu event.
  18426. * Override this method to provide functionality.
  18427. */
  18428. protected onContextMenu(evt: PointerEvent): void;
  18429. /**
  18430. * Detach the current controls from the specified dom element.
  18431. * @param element Defines the element to stop listening the inputs from
  18432. */
  18433. detachControl(element: Nullable<HTMLElement>): void;
  18434. /**
  18435. * Gets the class name of the current intput.
  18436. * @returns the class name
  18437. */
  18438. getClassName(): string;
  18439. /**
  18440. * Get the friendly name associated with the input class.
  18441. * @returns the input friendly name
  18442. */
  18443. getSimpleName(): string;
  18444. }
  18445. }
  18446. declare module BABYLON {
  18447. /**
  18448. * Manage the touch inputs to control the movement of a free camera.
  18449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18450. */
  18451. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18452. /**
  18453. * Defines the camera the input is attached to.
  18454. */
  18455. camera: FreeCamera;
  18456. /**
  18457. * Defines the touch sensibility for rotation.
  18458. * The higher the faster.
  18459. */
  18460. touchAngularSensibility: number;
  18461. /**
  18462. * Defines the touch sensibility for move.
  18463. * The higher the faster.
  18464. */
  18465. touchMoveSensibility: number;
  18466. private _offsetX;
  18467. private _offsetY;
  18468. private _pointerPressed;
  18469. private _pointerInput;
  18470. private _observer;
  18471. private _onLostFocus;
  18472. /**
  18473. * Attach the input controls to a specific dom element to get the input from.
  18474. * @param element Defines the element the controls should be listened from
  18475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18476. */
  18477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18478. /**
  18479. * Detach the current controls from the specified dom element.
  18480. * @param element Defines the element to stop listening the inputs from
  18481. */
  18482. detachControl(element: Nullable<HTMLElement>): void;
  18483. /**
  18484. * Update the current camera state depending on the inputs that have been used this frame.
  18485. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18486. */
  18487. checkInputs(): void;
  18488. /**
  18489. * Gets the class name of the current intput.
  18490. * @returns the class name
  18491. */
  18492. getClassName(): string;
  18493. /**
  18494. * Get the friendly name associated with the input class.
  18495. * @returns the input friendly name
  18496. */
  18497. getSimpleName(): string;
  18498. }
  18499. }
  18500. declare module BABYLON {
  18501. /**
  18502. * Default Inputs manager for the FreeCamera.
  18503. * It groups all the default supported inputs for ease of use.
  18504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18505. */
  18506. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18507. /**
  18508. * @hidden
  18509. */
  18510. _mouseInput: Nullable<FreeCameraMouseInput>;
  18511. /**
  18512. * Instantiates a new FreeCameraInputsManager.
  18513. * @param camera Defines the camera the inputs belong to
  18514. */
  18515. constructor(camera: FreeCamera);
  18516. /**
  18517. * Add keyboard input support to the input manager.
  18518. * @returns the current input manager
  18519. */
  18520. addKeyboard(): FreeCameraInputsManager;
  18521. /**
  18522. * Add mouse input support to the input manager.
  18523. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18524. * @returns the current input manager
  18525. */
  18526. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18527. /**
  18528. * Removes the mouse input support from the manager
  18529. * @returns the current input manager
  18530. */
  18531. removeMouse(): FreeCameraInputsManager;
  18532. /**
  18533. * Add touch input support to the input manager.
  18534. * @returns the current input manager
  18535. */
  18536. addTouch(): FreeCameraInputsManager;
  18537. /**
  18538. * Remove all attached input methods from a camera
  18539. */
  18540. clear(): void;
  18541. }
  18542. }
  18543. declare module BABYLON {
  18544. /**
  18545. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18546. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18547. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18548. */
  18549. export class FreeCamera extends TargetCamera {
  18550. /**
  18551. * Define the collision ellipsoid of the camera.
  18552. * This is helpful to simulate a camera body like the player body around the camera
  18553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18554. */
  18555. ellipsoid: Vector3;
  18556. /**
  18557. * Define an offset for the position of the ellipsoid around the camera.
  18558. * This can be helpful to determine the center of the body near the gravity center of the body
  18559. * instead of its head.
  18560. */
  18561. ellipsoidOffset: Vector3;
  18562. /**
  18563. * Enable or disable collisions of the camera with the rest of the scene objects.
  18564. */
  18565. checkCollisions: boolean;
  18566. /**
  18567. * Enable or disable gravity on the camera.
  18568. */
  18569. applyGravity: boolean;
  18570. /**
  18571. * Define the input manager associated to the camera.
  18572. */
  18573. inputs: FreeCameraInputsManager;
  18574. /**
  18575. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18576. * Higher values reduce sensitivity.
  18577. */
  18578. get angularSensibility(): number;
  18579. /**
  18580. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18581. * Higher values reduce sensitivity.
  18582. */
  18583. set angularSensibility(value: number);
  18584. /**
  18585. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18586. */
  18587. get keysUp(): number[];
  18588. set keysUp(value: number[]);
  18589. /**
  18590. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18591. */
  18592. get keysUpward(): number[];
  18593. set keysUpward(value: number[]);
  18594. /**
  18595. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18596. */
  18597. get keysDown(): number[];
  18598. set keysDown(value: number[]);
  18599. /**
  18600. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18601. */
  18602. get keysDownward(): number[];
  18603. set keysDownward(value: number[]);
  18604. /**
  18605. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18606. */
  18607. get keysLeft(): number[];
  18608. set keysLeft(value: number[]);
  18609. /**
  18610. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18611. */
  18612. get keysRight(): number[];
  18613. set keysRight(value: number[]);
  18614. /**
  18615. * Event raised when the camera collide with a mesh in the scene.
  18616. */
  18617. onCollide: (collidedMesh: AbstractMesh) => void;
  18618. private _collider;
  18619. private _needMoveForGravity;
  18620. private _oldPosition;
  18621. private _diffPosition;
  18622. private _newPosition;
  18623. /** @hidden */
  18624. _localDirection: Vector3;
  18625. /** @hidden */
  18626. _transformedDirection: Vector3;
  18627. /**
  18628. * Instantiates a Free Camera.
  18629. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18630. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18631. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18632. * @param name Define the name of the camera in the scene
  18633. * @param position Define the start position of the camera in the scene
  18634. * @param scene Define the scene the camera belongs to
  18635. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18636. */
  18637. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18638. /**
  18639. * Attached controls to the current camera.
  18640. * @param element Defines the element the controls should be listened from
  18641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18642. */
  18643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18644. /**
  18645. * Detach the current controls from the camera.
  18646. * The camera will stop reacting to inputs.
  18647. * @param element Defines the element to stop listening the inputs from
  18648. */
  18649. detachControl(element: HTMLElement): void;
  18650. private _collisionMask;
  18651. /**
  18652. * Define a collision mask to limit the list of object the camera can collide with
  18653. */
  18654. get collisionMask(): number;
  18655. set collisionMask(mask: number);
  18656. /** @hidden */
  18657. _collideWithWorld(displacement: Vector3): void;
  18658. private _onCollisionPositionChange;
  18659. /** @hidden */
  18660. _checkInputs(): void;
  18661. /** @hidden */
  18662. _decideIfNeedsToMove(): boolean;
  18663. /** @hidden */
  18664. _updatePosition(): void;
  18665. /**
  18666. * Destroy the camera and release the current resources hold by it.
  18667. */
  18668. dispose(): void;
  18669. /**
  18670. * Gets the current object class name.
  18671. * @return the class name
  18672. */
  18673. getClassName(): string;
  18674. }
  18675. }
  18676. declare module BABYLON {
  18677. /**
  18678. * Represents a gamepad control stick position
  18679. */
  18680. export class StickValues {
  18681. /**
  18682. * The x component of the control stick
  18683. */
  18684. x: number;
  18685. /**
  18686. * The y component of the control stick
  18687. */
  18688. y: number;
  18689. /**
  18690. * Initializes the gamepad x and y control stick values
  18691. * @param x The x component of the gamepad control stick value
  18692. * @param y The y component of the gamepad control stick value
  18693. */
  18694. constructor(
  18695. /**
  18696. * The x component of the control stick
  18697. */
  18698. x: number,
  18699. /**
  18700. * The y component of the control stick
  18701. */
  18702. y: number);
  18703. }
  18704. /**
  18705. * An interface which manages callbacks for gamepad button changes
  18706. */
  18707. export interface GamepadButtonChanges {
  18708. /**
  18709. * Called when a gamepad has been changed
  18710. */
  18711. changed: boolean;
  18712. /**
  18713. * Called when a gamepad press event has been triggered
  18714. */
  18715. pressChanged: boolean;
  18716. /**
  18717. * Called when a touch event has been triggered
  18718. */
  18719. touchChanged: boolean;
  18720. /**
  18721. * Called when a value has changed
  18722. */
  18723. valueChanged: boolean;
  18724. }
  18725. /**
  18726. * Represents a gamepad
  18727. */
  18728. export class Gamepad {
  18729. /**
  18730. * The id of the gamepad
  18731. */
  18732. id: string;
  18733. /**
  18734. * The index of the gamepad
  18735. */
  18736. index: number;
  18737. /**
  18738. * The browser gamepad
  18739. */
  18740. browserGamepad: any;
  18741. /**
  18742. * Specifies what type of gamepad this represents
  18743. */
  18744. type: number;
  18745. private _leftStick;
  18746. private _rightStick;
  18747. /** @hidden */
  18748. _isConnected: boolean;
  18749. private _leftStickAxisX;
  18750. private _leftStickAxisY;
  18751. private _rightStickAxisX;
  18752. private _rightStickAxisY;
  18753. /**
  18754. * Triggered when the left control stick has been changed
  18755. */
  18756. private _onleftstickchanged;
  18757. /**
  18758. * Triggered when the right control stick has been changed
  18759. */
  18760. private _onrightstickchanged;
  18761. /**
  18762. * Represents a gamepad controller
  18763. */
  18764. static GAMEPAD: number;
  18765. /**
  18766. * Represents a generic controller
  18767. */
  18768. static GENERIC: number;
  18769. /**
  18770. * Represents an XBox controller
  18771. */
  18772. static XBOX: number;
  18773. /**
  18774. * Represents a pose-enabled controller
  18775. */
  18776. static POSE_ENABLED: number;
  18777. /**
  18778. * Represents an Dual Shock controller
  18779. */
  18780. static DUALSHOCK: number;
  18781. /**
  18782. * Specifies whether the left control stick should be Y-inverted
  18783. */
  18784. protected _invertLeftStickY: boolean;
  18785. /**
  18786. * Specifies if the gamepad has been connected
  18787. */
  18788. get isConnected(): boolean;
  18789. /**
  18790. * Initializes the gamepad
  18791. * @param id The id of the gamepad
  18792. * @param index The index of the gamepad
  18793. * @param browserGamepad The browser gamepad
  18794. * @param leftStickX The x component of the left joystick
  18795. * @param leftStickY The y component of the left joystick
  18796. * @param rightStickX The x component of the right joystick
  18797. * @param rightStickY The y component of the right joystick
  18798. */
  18799. constructor(
  18800. /**
  18801. * The id of the gamepad
  18802. */
  18803. id: string,
  18804. /**
  18805. * The index of the gamepad
  18806. */
  18807. index: number,
  18808. /**
  18809. * The browser gamepad
  18810. */
  18811. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18812. /**
  18813. * Callback triggered when the left joystick has changed
  18814. * @param callback
  18815. */
  18816. onleftstickchanged(callback: (values: StickValues) => void): void;
  18817. /**
  18818. * Callback triggered when the right joystick has changed
  18819. * @param callback
  18820. */
  18821. onrightstickchanged(callback: (values: StickValues) => void): void;
  18822. /**
  18823. * Gets the left joystick
  18824. */
  18825. get leftStick(): StickValues;
  18826. /**
  18827. * Sets the left joystick values
  18828. */
  18829. set leftStick(newValues: StickValues);
  18830. /**
  18831. * Gets the right joystick
  18832. */
  18833. get rightStick(): StickValues;
  18834. /**
  18835. * Sets the right joystick value
  18836. */
  18837. set rightStick(newValues: StickValues);
  18838. /**
  18839. * Updates the gamepad joystick positions
  18840. */
  18841. update(): void;
  18842. /**
  18843. * Disposes the gamepad
  18844. */
  18845. dispose(): void;
  18846. }
  18847. /**
  18848. * Represents a generic gamepad
  18849. */
  18850. export class GenericPad extends Gamepad {
  18851. private _buttons;
  18852. private _onbuttondown;
  18853. private _onbuttonup;
  18854. /**
  18855. * Observable triggered when a button has been pressed
  18856. */
  18857. onButtonDownObservable: Observable<number>;
  18858. /**
  18859. * Observable triggered when a button has been released
  18860. */
  18861. onButtonUpObservable: Observable<number>;
  18862. /**
  18863. * Callback triggered when a button has been pressed
  18864. * @param callback Called when a button has been pressed
  18865. */
  18866. onbuttondown(callback: (buttonPressed: number) => void): void;
  18867. /**
  18868. * Callback triggered when a button has been released
  18869. * @param callback Called when a button has been released
  18870. */
  18871. onbuttonup(callback: (buttonReleased: number) => void): void;
  18872. /**
  18873. * Initializes the generic gamepad
  18874. * @param id The id of the generic gamepad
  18875. * @param index The index of the generic gamepad
  18876. * @param browserGamepad The browser gamepad
  18877. */
  18878. constructor(id: string, index: number, browserGamepad: any);
  18879. private _setButtonValue;
  18880. /**
  18881. * Updates the generic gamepad
  18882. */
  18883. update(): void;
  18884. /**
  18885. * Disposes the generic gamepad
  18886. */
  18887. dispose(): void;
  18888. }
  18889. }
  18890. declare module BABYLON {
  18891. /**
  18892. * Defines the types of pose enabled controllers that are supported
  18893. */
  18894. export enum PoseEnabledControllerType {
  18895. /**
  18896. * HTC Vive
  18897. */
  18898. VIVE = 0,
  18899. /**
  18900. * Oculus Rift
  18901. */
  18902. OCULUS = 1,
  18903. /**
  18904. * Windows mixed reality
  18905. */
  18906. WINDOWS = 2,
  18907. /**
  18908. * Samsung gear VR
  18909. */
  18910. GEAR_VR = 3,
  18911. /**
  18912. * Google Daydream
  18913. */
  18914. DAYDREAM = 4,
  18915. /**
  18916. * Generic
  18917. */
  18918. GENERIC = 5
  18919. }
  18920. /**
  18921. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18922. */
  18923. export interface MutableGamepadButton {
  18924. /**
  18925. * Value of the button/trigger
  18926. */
  18927. value: number;
  18928. /**
  18929. * If the button/trigger is currently touched
  18930. */
  18931. touched: boolean;
  18932. /**
  18933. * If the button/trigger is currently pressed
  18934. */
  18935. pressed: boolean;
  18936. }
  18937. /**
  18938. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18939. * @hidden
  18940. */
  18941. export interface ExtendedGamepadButton extends GamepadButton {
  18942. /**
  18943. * If the button/trigger is currently pressed
  18944. */
  18945. readonly pressed: boolean;
  18946. /**
  18947. * If the button/trigger is currently touched
  18948. */
  18949. readonly touched: boolean;
  18950. /**
  18951. * Value of the button/trigger
  18952. */
  18953. readonly value: number;
  18954. }
  18955. /** @hidden */
  18956. export interface _GamePadFactory {
  18957. /**
  18958. * Returns whether or not the current gamepad can be created for this type of controller.
  18959. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18960. * @returns true if it can be created, otherwise false
  18961. */
  18962. canCreate(gamepadInfo: any): boolean;
  18963. /**
  18964. * Creates a new instance of the Gamepad.
  18965. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18966. * @returns the new gamepad instance
  18967. */
  18968. create(gamepadInfo: any): Gamepad;
  18969. }
  18970. /**
  18971. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18972. */
  18973. export class PoseEnabledControllerHelper {
  18974. /** @hidden */
  18975. static _ControllerFactories: _GamePadFactory[];
  18976. /** @hidden */
  18977. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18978. /**
  18979. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18980. * @param vrGamepad the gamepad to initialized
  18981. * @returns a vr controller of the type the gamepad identified as
  18982. */
  18983. static InitiateController(vrGamepad: any): Gamepad;
  18984. }
  18985. /**
  18986. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18987. */
  18988. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18989. /**
  18990. * If the controller is used in a webXR session
  18991. */
  18992. isXR: boolean;
  18993. private _deviceRoomPosition;
  18994. private _deviceRoomRotationQuaternion;
  18995. /**
  18996. * The device position in babylon space
  18997. */
  18998. devicePosition: Vector3;
  18999. /**
  19000. * The device rotation in babylon space
  19001. */
  19002. deviceRotationQuaternion: Quaternion;
  19003. /**
  19004. * The scale factor of the device in babylon space
  19005. */
  19006. deviceScaleFactor: number;
  19007. /**
  19008. * (Likely devicePosition should be used instead) The device position in its room space
  19009. */
  19010. position: Vector3;
  19011. /**
  19012. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19013. */
  19014. rotationQuaternion: Quaternion;
  19015. /**
  19016. * The type of controller (Eg. Windows mixed reality)
  19017. */
  19018. controllerType: PoseEnabledControllerType;
  19019. protected _calculatedPosition: Vector3;
  19020. private _calculatedRotation;
  19021. /**
  19022. * The raw pose from the device
  19023. */
  19024. rawPose: DevicePose;
  19025. private _trackPosition;
  19026. private _maxRotationDistFromHeadset;
  19027. private _draggedRoomRotation;
  19028. /**
  19029. * @hidden
  19030. */
  19031. _disableTrackPosition(fixedPosition: Vector3): void;
  19032. /**
  19033. * Internal, the mesh attached to the controller
  19034. * @hidden
  19035. */
  19036. _mesh: Nullable<AbstractMesh>;
  19037. private _poseControlledCamera;
  19038. private _leftHandSystemQuaternion;
  19039. /**
  19040. * Internal, matrix used to convert room space to babylon space
  19041. * @hidden
  19042. */
  19043. _deviceToWorld: Matrix;
  19044. /**
  19045. * Node to be used when casting a ray from the controller
  19046. * @hidden
  19047. */
  19048. _pointingPoseNode: Nullable<TransformNode>;
  19049. /**
  19050. * Name of the child mesh that can be used to cast a ray from the controller
  19051. */
  19052. static readonly POINTING_POSE: string;
  19053. /**
  19054. * Creates a new PoseEnabledController from a gamepad
  19055. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19056. */
  19057. constructor(browserGamepad: any);
  19058. private _workingMatrix;
  19059. /**
  19060. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19061. */
  19062. update(): void;
  19063. /**
  19064. * Updates only the pose device and mesh without doing any button event checking
  19065. */
  19066. protected _updatePoseAndMesh(): void;
  19067. /**
  19068. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19069. * @param poseData raw pose fromthe device
  19070. */
  19071. updateFromDevice(poseData: DevicePose): void;
  19072. /**
  19073. * @hidden
  19074. */
  19075. _meshAttachedObservable: Observable<AbstractMesh>;
  19076. /**
  19077. * Attaches a mesh to the controller
  19078. * @param mesh the mesh to be attached
  19079. */
  19080. attachToMesh(mesh: AbstractMesh): void;
  19081. /**
  19082. * Attaches the controllers mesh to a camera
  19083. * @param camera the camera the mesh should be attached to
  19084. */
  19085. attachToPoseControlledCamera(camera: TargetCamera): void;
  19086. /**
  19087. * Disposes of the controller
  19088. */
  19089. dispose(): void;
  19090. /**
  19091. * The mesh that is attached to the controller
  19092. */
  19093. get mesh(): Nullable<AbstractMesh>;
  19094. /**
  19095. * Gets the ray of the controller in the direction the controller is pointing
  19096. * @param length the length the resulting ray should be
  19097. * @returns a ray in the direction the controller is pointing
  19098. */
  19099. getForwardRay(length?: number): Ray;
  19100. }
  19101. }
  19102. declare module BABYLON {
  19103. /**
  19104. * Defines the WebVRController object that represents controllers tracked in 3D space
  19105. */
  19106. export abstract class WebVRController extends PoseEnabledController {
  19107. /**
  19108. * Internal, the default controller model for the controller
  19109. */
  19110. protected _defaultModel: Nullable<AbstractMesh>;
  19111. /**
  19112. * Fired when the trigger state has changed
  19113. */
  19114. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19115. /**
  19116. * Fired when the main button state has changed
  19117. */
  19118. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19119. /**
  19120. * Fired when the secondary button state has changed
  19121. */
  19122. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19123. /**
  19124. * Fired when the pad state has changed
  19125. */
  19126. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19127. /**
  19128. * Fired when controllers stick values have changed
  19129. */
  19130. onPadValuesChangedObservable: Observable<StickValues>;
  19131. /**
  19132. * Array of button availible on the controller
  19133. */
  19134. protected _buttons: Array<MutableGamepadButton>;
  19135. private _onButtonStateChange;
  19136. /**
  19137. * Fired when a controller button's state has changed
  19138. * @param callback the callback containing the button that was modified
  19139. */
  19140. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19141. /**
  19142. * X and Y axis corresponding to the controllers joystick
  19143. */
  19144. pad: StickValues;
  19145. /**
  19146. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19147. */
  19148. hand: string;
  19149. /**
  19150. * The default controller model for the controller
  19151. */
  19152. get defaultModel(): Nullable<AbstractMesh>;
  19153. /**
  19154. * Creates a new WebVRController from a gamepad
  19155. * @param vrGamepad the gamepad that the WebVRController should be created from
  19156. */
  19157. constructor(vrGamepad: any);
  19158. /**
  19159. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19160. */
  19161. update(): void;
  19162. /**
  19163. * Function to be called when a button is modified
  19164. */
  19165. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19166. /**
  19167. * Loads a mesh and attaches it to the controller
  19168. * @param scene the scene the mesh should be added to
  19169. * @param meshLoaded callback for when the mesh has been loaded
  19170. */
  19171. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19172. private _setButtonValue;
  19173. private _changes;
  19174. private _checkChanges;
  19175. /**
  19176. * Disposes of th webVRCOntroller
  19177. */
  19178. dispose(): void;
  19179. }
  19180. }
  19181. declare module BABYLON {
  19182. /**
  19183. * The HemisphericLight simulates the ambient environment light,
  19184. * so the passed direction is the light reflection direction, not the incoming direction.
  19185. */
  19186. export class HemisphericLight extends Light {
  19187. /**
  19188. * The groundColor is the light in the opposite direction to the one specified during creation.
  19189. * 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.
  19190. */
  19191. groundColor: Color3;
  19192. /**
  19193. * The light reflection direction, not the incoming direction.
  19194. */
  19195. direction: Vector3;
  19196. /**
  19197. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19198. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19199. * The HemisphericLight can't cast shadows.
  19200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19201. * @param name The friendly name of the light
  19202. * @param direction The direction of the light reflection
  19203. * @param scene The scene the light belongs to
  19204. */
  19205. constructor(name: string, direction: Vector3, scene: Scene);
  19206. protected _buildUniformLayout(): void;
  19207. /**
  19208. * Returns the string "HemisphericLight".
  19209. * @return The class name
  19210. */
  19211. getClassName(): string;
  19212. /**
  19213. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19214. * Returns the updated direction.
  19215. * @param target The target the direction should point to
  19216. * @return The computed direction
  19217. */
  19218. setDirectionToTarget(target: Vector3): Vector3;
  19219. /**
  19220. * Returns the shadow generator associated to the light.
  19221. * @returns Always null for hemispheric lights because it does not support shadows.
  19222. */
  19223. getShadowGenerator(): Nullable<IShadowGenerator>;
  19224. /**
  19225. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19226. * @param effect The effect to update
  19227. * @param lightIndex The index of the light in the effect to update
  19228. * @returns The hemispheric light
  19229. */
  19230. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19231. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19232. /**
  19233. * Computes the world matrix of the node
  19234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19235. * @param useWasUpdatedFlag defines a reserved property
  19236. * @returns the world matrix
  19237. */
  19238. computeWorldMatrix(): Matrix;
  19239. /**
  19240. * Returns the integer 3.
  19241. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19242. */
  19243. getTypeID(): number;
  19244. /**
  19245. * Prepares the list of defines specific to the light type.
  19246. * @param defines the list of defines
  19247. * @param lightIndex defines the index of the light for the effect
  19248. */
  19249. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19250. }
  19251. }
  19252. declare module BABYLON {
  19253. /** @hidden */
  19254. export var vrMultiviewToSingleviewPixelShader: {
  19255. name: string;
  19256. shader: string;
  19257. };
  19258. }
  19259. declare module BABYLON {
  19260. /**
  19261. * Renders to multiple views with a single draw call
  19262. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19263. */
  19264. export class MultiviewRenderTarget extends RenderTargetTexture {
  19265. /**
  19266. * Creates a multiview render target
  19267. * @param scene scene used with the render target
  19268. * @param size the size of the render target (used for each view)
  19269. */
  19270. constructor(scene: Scene, size?: number | {
  19271. width: number;
  19272. height: number;
  19273. } | {
  19274. ratio: number;
  19275. });
  19276. /**
  19277. * @hidden
  19278. * @param faceIndex the face index, if its a cube texture
  19279. */
  19280. _bindFrameBuffer(faceIndex?: number): void;
  19281. /**
  19282. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19283. * @returns the view count
  19284. */
  19285. getViewCount(): number;
  19286. }
  19287. }
  19288. declare module BABYLON {
  19289. /**
  19290. * Represents a camera frustum
  19291. */
  19292. export class Frustum {
  19293. /**
  19294. * Gets the planes representing the frustum
  19295. * @param transform matrix to be applied to the returned planes
  19296. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19297. */
  19298. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19299. /**
  19300. * Gets the near frustum plane transformed by the transform matrix
  19301. * @param transform transformation matrix to be applied to the resulting frustum plane
  19302. * @param frustumPlane the resuling frustum plane
  19303. */
  19304. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19305. /**
  19306. * Gets the far frustum plane transformed by the transform matrix
  19307. * @param transform transformation matrix to be applied to the resulting frustum plane
  19308. * @param frustumPlane the resuling frustum plane
  19309. */
  19310. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19311. /**
  19312. * Gets the left frustum plane transformed by the transform matrix
  19313. * @param transform transformation matrix to be applied to the resulting frustum plane
  19314. * @param frustumPlane the resuling frustum plane
  19315. */
  19316. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19317. /**
  19318. * Gets the right frustum plane transformed by the transform matrix
  19319. * @param transform transformation matrix to be applied to the resulting frustum plane
  19320. * @param frustumPlane the resuling frustum plane
  19321. */
  19322. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19323. /**
  19324. * Gets the top frustum plane transformed by the transform matrix
  19325. * @param transform transformation matrix to be applied to the resulting frustum plane
  19326. * @param frustumPlane the resuling frustum plane
  19327. */
  19328. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19329. /**
  19330. * Gets the bottom frustum plane transformed by the transform matrix
  19331. * @param transform transformation matrix to be applied to the resulting frustum plane
  19332. * @param frustumPlane the resuling frustum plane
  19333. */
  19334. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19335. /**
  19336. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19337. * @param transform transformation matrix to be applied to the resulting frustum planes
  19338. * @param frustumPlanes the resuling frustum planes
  19339. */
  19340. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19341. }
  19342. }
  19343. declare module BABYLON {
  19344. interface Engine {
  19345. /**
  19346. * Creates a new multiview render target
  19347. * @param width defines the width of the texture
  19348. * @param height defines the height of the texture
  19349. * @returns the created multiview texture
  19350. */
  19351. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19352. /**
  19353. * Binds a multiview framebuffer to be drawn to
  19354. * @param multiviewTexture texture to bind
  19355. */
  19356. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19357. }
  19358. interface Camera {
  19359. /**
  19360. * @hidden
  19361. * 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)
  19362. */
  19363. _useMultiviewToSingleView: boolean;
  19364. /**
  19365. * @hidden
  19366. * 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)
  19367. */
  19368. _multiviewTexture: Nullable<RenderTargetTexture>;
  19369. /**
  19370. * @hidden
  19371. * ensures the multiview texture of the camera exists and has the specified width/height
  19372. * @param width height to set on the multiview texture
  19373. * @param height width to set on the multiview texture
  19374. */
  19375. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19376. }
  19377. interface Scene {
  19378. /** @hidden */
  19379. _transformMatrixR: Matrix;
  19380. /** @hidden */
  19381. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19382. /** @hidden */
  19383. _createMultiviewUbo(): void;
  19384. /** @hidden */
  19385. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19386. /** @hidden */
  19387. _renderMultiviewToSingleView(camera: Camera): void;
  19388. }
  19389. }
  19390. declare module BABYLON {
  19391. /**
  19392. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19393. * This will not be used for webXR as it supports displaying texture arrays directly
  19394. */
  19395. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19396. /**
  19397. * Initializes a VRMultiviewToSingleview
  19398. * @param name name of the post process
  19399. * @param camera camera to be applied to
  19400. * @param scaleFactor scaling factor to the size of the output texture
  19401. */
  19402. constructor(name: string, camera: Camera, scaleFactor: number);
  19403. }
  19404. }
  19405. declare module BABYLON {
  19406. /**
  19407. * Interface used to define additional presentation attributes
  19408. */
  19409. export interface IVRPresentationAttributes {
  19410. /**
  19411. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19412. */
  19413. highRefreshRate: boolean;
  19414. /**
  19415. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19416. */
  19417. foveationLevel: number;
  19418. }
  19419. interface Engine {
  19420. /** @hidden */
  19421. _vrDisplay: any;
  19422. /** @hidden */
  19423. _vrSupported: boolean;
  19424. /** @hidden */
  19425. _oldSize: Size;
  19426. /** @hidden */
  19427. _oldHardwareScaleFactor: number;
  19428. /** @hidden */
  19429. _vrExclusivePointerMode: boolean;
  19430. /** @hidden */
  19431. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19432. /** @hidden */
  19433. _onVRDisplayPointerRestricted: () => void;
  19434. /** @hidden */
  19435. _onVRDisplayPointerUnrestricted: () => void;
  19436. /** @hidden */
  19437. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19438. /** @hidden */
  19439. _onVrDisplayDisconnect: Nullable<() => void>;
  19440. /** @hidden */
  19441. _onVrDisplayPresentChange: Nullable<() => void>;
  19442. /**
  19443. * Observable signaled when VR display mode changes
  19444. */
  19445. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19446. /**
  19447. * Observable signaled when VR request present is complete
  19448. */
  19449. onVRRequestPresentComplete: Observable<boolean>;
  19450. /**
  19451. * Observable signaled when VR request present starts
  19452. */
  19453. onVRRequestPresentStart: Observable<Engine>;
  19454. /**
  19455. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19456. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19457. */
  19458. isInVRExclusivePointerMode: boolean;
  19459. /**
  19460. * Gets a boolean indicating if a webVR device was detected
  19461. * @returns true if a webVR device was detected
  19462. */
  19463. isVRDevicePresent(): boolean;
  19464. /**
  19465. * Gets the current webVR device
  19466. * @returns the current webVR device (or null)
  19467. */
  19468. getVRDevice(): any;
  19469. /**
  19470. * Initializes a webVR display and starts listening to display change events
  19471. * The onVRDisplayChangedObservable will be notified upon these changes
  19472. * @returns A promise containing a VRDisplay and if vr is supported
  19473. */
  19474. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19475. /** @hidden */
  19476. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19477. /**
  19478. * Gets or sets the presentation attributes used to configure VR rendering
  19479. */
  19480. vrPresentationAttributes?: IVRPresentationAttributes;
  19481. /**
  19482. * Call this function to switch to webVR mode
  19483. * Will do nothing if webVR is not supported or if there is no webVR device
  19484. * @param options the webvr options provided to the camera. mainly used for multiview
  19485. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19486. */
  19487. enableVR(options: WebVROptions): void;
  19488. /** @hidden */
  19489. _onVRFullScreenTriggered(): void;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. /**
  19494. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19495. * IMPORTANT!! The data is right-hand data.
  19496. * @export
  19497. * @interface DevicePose
  19498. */
  19499. export interface DevicePose {
  19500. /**
  19501. * The position of the device, values in array are [x,y,z].
  19502. */
  19503. readonly position: Nullable<Float32Array>;
  19504. /**
  19505. * The linearVelocity of the device, values in array are [x,y,z].
  19506. */
  19507. readonly linearVelocity: Nullable<Float32Array>;
  19508. /**
  19509. * The linearAcceleration of the device, values in array are [x,y,z].
  19510. */
  19511. readonly linearAcceleration: Nullable<Float32Array>;
  19512. /**
  19513. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19514. */
  19515. readonly orientation: Nullable<Float32Array>;
  19516. /**
  19517. * The angularVelocity of the device, values in array are [x,y,z].
  19518. */
  19519. readonly angularVelocity: Nullable<Float32Array>;
  19520. /**
  19521. * The angularAcceleration of the device, values in array are [x,y,z].
  19522. */
  19523. readonly angularAcceleration: Nullable<Float32Array>;
  19524. }
  19525. /**
  19526. * Interface representing a pose controlled object in Babylon.
  19527. * A pose controlled object has both regular pose values as well as pose values
  19528. * from an external device such as a VR head mounted display
  19529. */
  19530. export interface PoseControlled {
  19531. /**
  19532. * The position of the object in babylon space.
  19533. */
  19534. position: Vector3;
  19535. /**
  19536. * The rotation quaternion of the object in babylon space.
  19537. */
  19538. rotationQuaternion: Quaternion;
  19539. /**
  19540. * The position of the device in babylon space.
  19541. */
  19542. devicePosition?: Vector3;
  19543. /**
  19544. * The rotation quaternion of the device in babylon space.
  19545. */
  19546. deviceRotationQuaternion: Quaternion;
  19547. /**
  19548. * The raw pose coming from the device.
  19549. */
  19550. rawPose: Nullable<DevicePose>;
  19551. /**
  19552. * The scale of the device to be used when translating from device space to babylon space.
  19553. */
  19554. deviceScaleFactor: number;
  19555. /**
  19556. * Updates the poseControlled values based on the input device pose.
  19557. * @param poseData the pose data to update the object with
  19558. */
  19559. updateFromDevice(poseData: DevicePose): void;
  19560. }
  19561. /**
  19562. * Set of options to customize the webVRCamera
  19563. */
  19564. export interface WebVROptions {
  19565. /**
  19566. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19567. */
  19568. trackPosition?: boolean;
  19569. /**
  19570. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19571. */
  19572. positionScale?: number;
  19573. /**
  19574. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19575. */
  19576. displayName?: string;
  19577. /**
  19578. * Should the native controller meshes be initialized. (default: true)
  19579. */
  19580. controllerMeshes?: boolean;
  19581. /**
  19582. * Creating a default HemiLight only on controllers. (default: true)
  19583. */
  19584. defaultLightingOnControllers?: boolean;
  19585. /**
  19586. * If you don't want to use the default VR button of the helper. (default: false)
  19587. */
  19588. useCustomVRButton?: boolean;
  19589. /**
  19590. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19591. */
  19592. customVRButton?: HTMLButtonElement;
  19593. /**
  19594. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19595. */
  19596. rayLength?: number;
  19597. /**
  19598. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19599. */
  19600. defaultHeight?: number;
  19601. /**
  19602. * If multiview should be used if availible (default: false)
  19603. */
  19604. useMultiview?: boolean;
  19605. }
  19606. /**
  19607. * This represents a WebVR camera.
  19608. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19609. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19610. */
  19611. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19612. private webVROptions;
  19613. /**
  19614. * @hidden
  19615. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19616. */
  19617. _vrDevice: any;
  19618. /**
  19619. * The rawPose of the vrDevice.
  19620. */
  19621. rawPose: Nullable<DevicePose>;
  19622. private _onVREnabled;
  19623. private _specsVersion;
  19624. private _attached;
  19625. private _frameData;
  19626. protected _descendants: Array<Node>;
  19627. private _deviceRoomPosition;
  19628. /** @hidden */
  19629. _deviceRoomRotationQuaternion: Quaternion;
  19630. private _standingMatrix;
  19631. /**
  19632. * Represents device position in babylon space.
  19633. */
  19634. devicePosition: Vector3;
  19635. /**
  19636. * Represents device rotation in babylon space.
  19637. */
  19638. deviceRotationQuaternion: Quaternion;
  19639. /**
  19640. * The scale of the device to be used when translating from device space to babylon space.
  19641. */
  19642. deviceScaleFactor: number;
  19643. private _deviceToWorld;
  19644. private _worldToDevice;
  19645. /**
  19646. * References to the webVR controllers for the vrDevice.
  19647. */
  19648. controllers: Array<WebVRController>;
  19649. /**
  19650. * Emits an event when a controller is attached.
  19651. */
  19652. onControllersAttachedObservable: Observable<WebVRController[]>;
  19653. /**
  19654. * Emits an event when a controller's mesh has been loaded;
  19655. */
  19656. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19657. /**
  19658. * Emits an event when the HMD's pose has been updated.
  19659. */
  19660. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19661. private _poseSet;
  19662. /**
  19663. * If the rig cameras be used as parent instead of this camera.
  19664. */
  19665. rigParenting: boolean;
  19666. private _lightOnControllers;
  19667. private _defaultHeight?;
  19668. /**
  19669. * Instantiates a WebVRFreeCamera.
  19670. * @param name The name of the WebVRFreeCamera
  19671. * @param position The starting anchor position for the camera
  19672. * @param scene The scene the camera belongs to
  19673. * @param webVROptions a set of customizable options for the webVRCamera
  19674. */
  19675. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19676. /**
  19677. * Gets the device distance from the ground in meters.
  19678. * @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.
  19679. */
  19680. deviceDistanceToRoomGround(): number;
  19681. /**
  19682. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19683. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19684. */
  19685. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19686. /**
  19687. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19688. * @returns A promise with a boolean set to if the standing matrix is supported.
  19689. */
  19690. useStandingMatrixAsync(): Promise<boolean>;
  19691. /**
  19692. * Disposes the camera
  19693. */
  19694. dispose(): void;
  19695. /**
  19696. * Gets a vrController by name.
  19697. * @param name The name of the controller to retreive
  19698. * @returns the controller matching the name specified or null if not found
  19699. */
  19700. getControllerByName(name: string): Nullable<WebVRController>;
  19701. private _leftController;
  19702. /**
  19703. * The controller corresponding to the users left hand.
  19704. */
  19705. get leftController(): Nullable<WebVRController>;
  19706. private _rightController;
  19707. /**
  19708. * The controller corresponding to the users right hand.
  19709. */
  19710. get rightController(): Nullable<WebVRController>;
  19711. /**
  19712. * Casts a ray forward from the vrCamera's gaze.
  19713. * @param length Length of the ray (default: 100)
  19714. * @returns the ray corresponding to the gaze
  19715. */
  19716. getForwardRay(length?: number): Ray;
  19717. /**
  19718. * @hidden
  19719. * Updates the camera based on device's frame data
  19720. */
  19721. _checkInputs(): void;
  19722. /**
  19723. * Updates the poseControlled values based on the input device pose.
  19724. * @param poseData Pose coming from the device
  19725. */
  19726. updateFromDevice(poseData: DevicePose): void;
  19727. private _htmlElementAttached;
  19728. private _detachIfAttached;
  19729. /**
  19730. * WebVR's attach control will start broadcasting frames to the device.
  19731. * Note that in certain browsers (chrome for example) this function must be called
  19732. * within a user-interaction callback. Example:
  19733. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19734. *
  19735. * @param element html element to attach the vrDevice to
  19736. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19737. */
  19738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19739. /**
  19740. * Detaches the camera from the html element and disables VR
  19741. *
  19742. * @param element html element to detach from
  19743. */
  19744. detachControl(element: HTMLElement): void;
  19745. /**
  19746. * @returns the name of this class
  19747. */
  19748. getClassName(): string;
  19749. /**
  19750. * Calls resetPose on the vrDisplay
  19751. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19752. */
  19753. resetToCurrentRotation(): void;
  19754. /**
  19755. * @hidden
  19756. * Updates the rig cameras (left and right eye)
  19757. */
  19758. _updateRigCameras(): void;
  19759. private _workingVector;
  19760. private _oneVector;
  19761. private _workingMatrix;
  19762. private updateCacheCalled;
  19763. private _correctPositionIfNotTrackPosition;
  19764. /**
  19765. * @hidden
  19766. * Updates the cached values of the camera
  19767. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19768. */
  19769. _updateCache(ignoreParentClass?: boolean): void;
  19770. /**
  19771. * @hidden
  19772. * Get current device position in babylon world
  19773. */
  19774. _computeDevicePosition(): void;
  19775. /**
  19776. * Updates the current device position and rotation in the babylon world
  19777. */
  19778. update(): void;
  19779. /**
  19780. * @hidden
  19781. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19782. * @returns an identity matrix
  19783. */
  19784. _getViewMatrix(): Matrix;
  19785. private _tmpMatrix;
  19786. /**
  19787. * This function is called by the two RIG cameras.
  19788. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19789. * @hidden
  19790. */
  19791. _getWebVRViewMatrix(): Matrix;
  19792. /** @hidden */
  19793. _getWebVRProjectionMatrix(): Matrix;
  19794. private _onGamepadConnectedObserver;
  19795. private _onGamepadDisconnectedObserver;
  19796. private _updateCacheWhenTrackingDisabledObserver;
  19797. /**
  19798. * Initializes the controllers and their meshes
  19799. */
  19800. initControllers(): void;
  19801. }
  19802. }
  19803. declare module BABYLON {
  19804. /**
  19805. * Size options for a post process
  19806. */
  19807. export type PostProcessOptions = {
  19808. width: number;
  19809. height: number;
  19810. };
  19811. /**
  19812. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19813. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19814. */
  19815. export class PostProcess {
  19816. /** Name of the PostProcess. */
  19817. name: string;
  19818. /**
  19819. * Gets or sets the unique id of the post process
  19820. */
  19821. uniqueId: number;
  19822. /**
  19823. * Width of the texture to apply the post process on
  19824. */
  19825. width: number;
  19826. /**
  19827. * Height of the texture to apply the post process on
  19828. */
  19829. height: number;
  19830. /**
  19831. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19832. * @hidden
  19833. */
  19834. _outputTexture: Nullable<InternalTexture>;
  19835. /**
  19836. * Sampling mode used by the shader
  19837. * See https://doc.babylonjs.com/classes/3.1/texture
  19838. */
  19839. renderTargetSamplingMode: number;
  19840. /**
  19841. * Clear color to use when screen clearing
  19842. */
  19843. clearColor: Color4;
  19844. /**
  19845. * If the buffer needs to be cleared before applying the post process. (default: true)
  19846. * Should be set to false if shader will overwrite all previous pixels.
  19847. */
  19848. autoClear: boolean;
  19849. /**
  19850. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19851. */
  19852. alphaMode: number;
  19853. /**
  19854. * Sets the setAlphaBlendConstants of the babylon engine
  19855. */
  19856. alphaConstants: Color4;
  19857. /**
  19858. * Animations to be used for the post processing
  19859. */
  19860. animations: Animation[];
  19861. /**
  19862. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19863. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19864. */
  19865. enablePixelPerfectMode: boolean;
  19866. /**
  19867. * Force the postprocess to be applied without taking in account viewport
  19868. */
  19869. forceFullscreenViewport: boolean;
  19870. /**
  19871. * List of inspectable custom properties (used by the Inspector)
  19872. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19873. */
  19874. inspectableCustomProperties: IInspectable[];
  19875. /**
  19876. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19877. *
  19878. * | Value | Type | Description |
  19879. * | ----- | ----------------------------------- | ----------- |
  19880. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19881. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19882. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19883. *
  19884. */
  19885. scaleMode: number;
  19886. /**
  19887. * Force textures to be a power of two (default: false)
  19888. */
  19889. alwaysForcePOT: boolean;
  19890. private _samples;
  19891. /**
  19892. * Number of sample textures (default: 1)
  19893. */
  19894. get samples(): number;
  19895. set samples(n: number);
  19896. /**
  19897. * Modify the scale of the post process to be the same as the viewport (default: false)
  19898. */
  19899. adaptScaleToCurrentViewport: boolean;
  19900. private _camera;
  19901. private _scene;
  19902. private _engine;
  19903. private _options;
  19904. private _reusable;
  19905. private _textureType;
  19906. private _textureFormat;
  19907. /**
  19908. * Smart array of input and output textures for the post process.
  19909. * @hidden
  19910. */
  19911. _textures: SmartArray<InternalTexture>;
  19912. /**
  19913. * The index in _textures that corresponds to the output texture.
  19914. * @hidden
  19915. */
  19916. _currentRenderTextureInd: number;
  19917. private _effect;
  19918. private _samplers;
  19919. private _fragmentUrl;
  19920. private _vertexUrl;
  19921. private _parameters;
  19922. private _scaleRatio;
  19923. protected _indexParameters: any;
  19924. private _shareOutputWithPostProcess;
  19925. private _texelSize;
  19926. private _forcedOutputTexture;
  19927. /**
  19928. * Returns the fragment url or shader name used in the post process.
  19929. * @returns the fragment url or name in the shader store.
  19930. */
  19931. getEffectName(): string;
  19932. /**
  19933. * An event triggered when the postprocess is activated.
  19934. */
  19935. onActivateObservable: Observable<Camera>;
  19936. private _onActivateObserver;
  19937. /**
  19938. * A function that is added to the onActivateObservable
  19939. */
  19940. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19941. /**
  19942. * An event triggered when the postprocess changes its size.
  19943. */
  19944. onSizeChangedObservable: Observable<PostProcess>;
  19945. private _onSizeChangedObserver;
  19946. /**
  19947. * A function that is added to the onSizeChangedObservable
  19948. */
  19949. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19950. /**
  19951. * An event triggered when the postprocess applies its effect.
  19952. */
  19953. onApplyObservable: Observable<Effect>;
  19954. private _onApplyObserver;
  19955. /**
  19956. * A function that is added to the onApplyObservable
  19957. */
  19958. set onApply(callback: (effect: Effect) => void);
  19959. /**
  19960. * An event triggered before rendering the postprocess
  19961. */
  19962. onBeforeRenderObservable: Observable<Effect>;
  19963. private _onBeforeRenderObserver;
  19964. /**
  19965. * A function that is added to the onBeforeRenderObservable
  19966. */
  19967. set onBeforeRender(callback: (effect: Effect) => void);
  19968. /**
  19969. * An event triggered after rendering the postprocess
  19970. */
  19971. onAfterRenderObservable: Observable<Effect>;
  19972. private _onAfterRenderObserver;
  19973. /**
  19974. * A function that is added to the onAfterRenderObservable
  19975. */
  19976. set onAfterRender(callback: (efect: Effect) => void);
  19977. /**
  19978. * 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
  19979. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19980. */
  19981. get inputTexture(): InternalTexture;
  19982. set inputTexture(value: InternalTexture);
  19983. /**
  19984. * Gets the camera which post process is applied to.
  19985. * @returns The camera the post process is applied to.
  19986. */
  19987. getCamera(): Camera;
  19988. /**
  19989. * Gets the texel size of the postprocess.
  19990. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19991. */
  19992. get texelSize(): Vector2;
  19993. /**
  19994. * Creates a new instance PostProcess
  19995. * @param name The name of the PostProcess.
  19996. * @param fragmentUrl The url of the fragment shader to be used.
  19997. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19998. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19999. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20000. * @param camera The camera to apply the render pass to.
  20001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20002. * @param engine The engine which the post process will be applied. (default: current engine)
  20003. * @param reusable If the post process can be reused on the same frame. (default: false)
  20004. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20005. * @param textureType Type of textures used when performing the post process. (default: 0)
  20006. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20007. * @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
  20008. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20009. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20010. */
  20011. constructor(
  20012. /** Name of the PostProcess. */
  20013. 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);
  20014. /**
  20015. * Gets a string idenfifying the name of the class
  20016. * @returns "PostProcess" string
  20017. */
  20018. getClassName(): string;
  20019. /**
  20020. * Gets the engine which this post process belongs to.
  20021. * @returns The engine the post process was enabled with.
  20022. */
  20023. getEngine(): Engine;
  20024. /**
  20025. * The effect that is created when initializing the post process.
  20026. * @returns The created effect corresponding the the postprocess.
  20027. */
  20028. getEffect(): Effect;
  20029. /**
  20030. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20031. * @param postProcess The post process to share the output with.
  20032. * @returns This post process.
  20033. */
  20034. shareOutputWith(postProcess: PostProcess): PostProcess;
  20035. /**
  20036. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20037. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20038. */
  20039. useOwnOutput(): void;
  20040. /**
  20041. * Updates the effect with the current post process compile time values and recompiles the shader.
  20042. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20043. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20044. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20045. * @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
  20046. * @param onCompiled Called when the shader has been compiled.
  20047. * @param onError Called if there is an error when compiling a shader.
  20048. */
  20049. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20050. /**
  20051. * The post process is reusable if it can be used multiple times within one frame.
  20052. * @returns If the post process is reusable
  20053. */
  20054. isReusable(): boolean;
  20055. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20056. markTextureDirty(): void;
  20057. /**
  20058. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20059. * 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.
  20060. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20061. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20062. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20063. * @returns The target texture that was bound to be written to.
  20064. */
  20065. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20066. /**
  20067. * If the post process is supported.
  20068. */
  20069. get isSupported(): boolean;
  20070. /**
  20071. * The aspect ratio of the output texture.
  20072. */
  20073. get aspectRatio(): number;
  20074. /**
  20075. * Get a value indicating if the post-process is ready to be used
  20076. * @returns true if the post-process is ready (shader is compiled)
  20077. */
  20078. isReady(): boolean;
  20079. /**
  20080. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20081. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20082. */
  20083. apply(): Nullable<Effect>;
  20084. private _disposeTextures;
  20085. /**
  20086. * Disposes the post process.
  20087. * @param camera The camera to dispose the post process on.
  20088. */
  20089. dispose(camera?: Camera): void;
  20090. }
  20091. }
  20092. declare module BABYLON {
  20093. /** @hidden */
  20094. export var kernelBlurVaryingDeclaration: {
  20095. name: string;
  20096. shader: string;
  20097. };
  20098. }
  20099. declare module BABYLON {
  20100. /** @hidden */
  20101. export var kernelBlurFragment: {
  20102. name: string;
  20103. shader: string;
  20104. };
  20105. }
  20106. declare module BABYLON {
  20107. /** @hidden */
  20108. export var kernelBlurFragment2: {
  20109. name: string;
  20110. shader: string;
  20111. };
  20112. }
  20113. declare module BABYLON {
  20114. /** @hidden */
  20115. export var kernelBlurPixelShader: {
  20116. name: string;
  20117. shader: string;
  20118. };
  20119. }
  20120. declare module BABYLON {
  20121. /** @hidden */
  20122. export var kernelBlurVertex: {
  20123. name: string;
  20124. shader: string;
  20125. };
  20126. }
  20127. declare module BABYLON {
  20128. /** @hidden */
  20129. export var kernelBlurVertexShader: {
  20130. name: string;
  20131. shader: string;
  20132. };
  20133. }
  20134. declare module BABYLON {
  20135. /**
  20136. * The Blur Post Process which blurs an image based on a kernel and direction.
  20137. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20138. */
  20139. export class BlurPostProcess extends PostProcess {
  20140. /** The direction in which to blur the image. */
  20141. direction: Vector2;
  20142. private blockCompilation;
  20143. protected _kernel: number;
  20144. protected _idealKernel: number;
  20145. protected _packedFloat: boolean;
  20146. private _staticDefines;
  20147. /**
  20148. * Sets the length in pixels of the blur sample region
  20149. */
  20150. set kernel(v: number);
  20151. /**
  20152. * Gets the length in pixels of the blur sample region
  20153. */
  20154. get kernel(): number;
  20155. /**
  20156. * Sets wether or not the blur needs to unpack/repack floats
  20157. */
  20158. set packedFloat(v: boolean);
  20159. /**
  20160. * Gets wether or not the blur is unpacking/repacking floats
  20161. */
  20162. get packedFloat(): boolean;
  20163. /**
  20164. * Creates a new instance BlurPostProcess
  20165. * @param name The name of the effect.
  20166. * @param direction The direction in which to blur the image.
  20167. * @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.
  20168. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20169. * @param camera The camera to apply the render pass to.
  20170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20171. * @param engine The engine which the post process will be applied. (default: current engine)
  20172. * @param reusable If the post process can be reused on the same frame. (default: false)
  20173. * @param textureType Type of textures used when performing the post process. (default: 0)
  20174. * @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)
  20175. */
  20176. constructor(name: string,
  20177. /** The direction in which to blur the image. */
  20178. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20179. /**
  20180. * Updates the effect with the current post process compile time values and recompiles the shader.
  20181. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20182. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20183. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20184. * @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
  20185. * @param onCompiled Called when the shader has been compiled.
  20186. * @param onError Called if there is an error when compiling a shader.
  20187. */
  20188. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20189. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20190. /**
  20191. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20192. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20193. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20194. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20195. * The gaps between physical kernels are compensated for in the weighting of the samples
  20196. * @param idealKernel Ideal blur kernel.
  20197. * @return Nearest best kernel.
  20198. */
  20199. protected _nearestBestKernel(idealKernel: number): number;
  20200. /**
  20201. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20202. * @param x The point on the Gaussian distribution to sample.
  20203. * @return the value of the Gaussian function at x.
  20204. */
  20205. protected _gaussianWeight(x: number): number;
  20206. /**
  20207. * Generates a string that can be used as a floating point number in GLSL.
  20208. * @param x Value to print.
  20209. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20210. * @return GLSL float string.
  20211. */
  20212. protected _glslFloat(x: number, decimalFigures?: number): string;
  20213. }
  20214. }
  20215. declare module BABYLON {
  20216. /**
  20217. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20218. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20219. * You can then easily use it as a reflectionTexture on a flat surface.
  20220. * In case the surface is not a plane, please consider relying on reflection probes.
  20221. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20222. */
  20223. export class MirrorTexture extends RenderTargetTexture {
  20224. private scene;
  20225. /**
  20226. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20227. * 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.
  20228. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20229. */
  20230. mirrorPlane: Plane;
  20231. /**
  20232. * Define the blur ratio used to blur the reflection if needed.
  20233. */
  20234. set blurRatio(value: number);
  20235. get blurRatio(): number;
  20236. /**
  20237. * Define the adaptive blur kernel used to blur the reflection if needed.
  20238. * This will autocompute the closest best match for the `blurKernel`
  20239. */
  20240. set adaptiveBlurKernel(value: number);
  20241. /**
  20242. * Define the blur kernel used to blur the reflection if needed.
  20243. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20244. */
  20245. set blurKernel(value: number);
  20246. /**
  20247. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20248. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20249. */
  20250. set blurKernelX(value: number);
  20251. get blurKernelX(): number;
  20252. /**
  20253. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20254. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20255. */
  20256. set blurKernelY(value: number);
  20257. get blurKernelY(): number;
  20258. private _autoComputeBlurKernel;
  20259. protected _onRatioRescale(): void;
  20260. private _updateGammaSpace;
  20261. private _imageProcessingConfigChangeObserver;
  20262. private _transformMatrix;
  20263. private _mirrorMatrix;
  20264. private _savedViewMatrix;
  20265. private _blurX;
  20266. private _blurY;
  20267. private _adaptiveBlurKernel;
  20268. private _blurKernelX;
  20269. private _blurKernelY;
  20270. private _blurRatio;
  20271. /**
  20272. * Instantiates a Mirror Texture.
  20273. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20274. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20275. * You can then easily use it as a reflectionTexture on a flat surface.
  20276. * In case the surface is not a plane, please consider relying on reflection probes.
  20277. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20278. * @param name
  20279. * @param size
  20280. * @param scene
  20281. * @param generateMipMaps
  20282. * @param type
  20283. * @param samplingMode
  20284. * @param generateDepthBuffer
  20285. */
  20286. constructor(name: string, size: number | {
  20287. width: number;
  20288. height: number;
  20289. } | {
  20290. ratio: number;
  20291. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20292. private _preparePostProcesses;
  20293. /**
  20294. * Clone the mirror texture.
  20295. * @returns the cloned texture
  20296. */
  20297. clone(): MirrorTexture;
  20298. /**
  20299. * Serialize the texture to a JSON representation you could use in Parse later on
  20300. * @returns the serialized JSON representation
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Dispose the texture and release its associated resources.
  20305. */
  20306. dispose(): void;
  20307. }
  20308. }
  20309. declare module BABYLON {
  20310. /**
  20311. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20312. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20313. */
  20314. export class Texture extends BaseTexture {
  20315. /**
  20316. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20317. */
  20318. static SerializeBuffers: boolean;
  20319. /** @hidden */
  20320. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20321. /** @hidden */
  20322. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20323. /** @hidden */
  20324. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20325. /** nearest is mag = nearest and min = nearest and mip = linear */
  20326. static readonly NEAREST_SAMPLINGMODE: number;
  20327. /** nearest is mag = nearest and min = nearest and mip = linear */
  20328. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20329. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20330. static readonly BILINEAR_SAMPLINGMODE: number;
  20331. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20332. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20333. /** Trilinear is mag = linear and min = linear and mip = linear */
  20334. static readonly TRILINEAR_SAMPLINGMODE: number;
  20335. /** Trilinear is mag = linear and min = linear and mip = linear */
  20336. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20337. /** mag = nearest and min = nearest and mip = nearest */
  20338. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20339. /** mag = nearest and min = linear and mip = nearest */
  20340. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20341. /** mag = nearest and min = linear and mip = linear */
  20342. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20343. /** mag = nearest and min = linear and mip = none */
  20344. static readonly NEAREST_LINEAR: number;
  20345. /** mag = nearest and min = nearest and mip = none */
  20346. static readonly NEAREST_NEAREST: number;
  20347. /** mag = linear and min = nearest and mip = nearest */
  20348. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20349. /** mag = linear and min = nearest and mip = linear */
  20350. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20351. /** mag = linear and min = linear and mip = none */
  20352. static readonly LINEAR_LINEAR: number;
  20353. /** mag = linear and min = nearest and mip = none */
  20354. static readonly LINEAR_NEAREST: number;
  20355. /** Explicit coordinates mode */
  20356. static readonly EXPLICIT_MODE: number;
  20357. /** Spherical coordinates mode */
  20358. static readonly SPHERICAL_MODE: number;
  20359. /** Planar coordinates mode */
  20360. static readonly PLANAR_MODE: number;
  20361. /** Cubic coordinates mode */
  20362. static readonly CUBIC_MODE: number;
  20363. /** Projection coordinates mode */
  20364. static readonly PROJECTION_MODE: number;
  20365. /** Inverse Cubic coordinates mode */
  20366. static readonly SKYBOX_MODE: number;
  20367. /** Inverse Cubic coordinates mode */
  20368. static readonly INVCUBIC_MODE: number;
  20369. /** Equirectangular coordinates mode */
  20370. static readonly EQUIRECTANGULAR_MODE: number;
  20371. /** Equirectangular Fixed coordinates mode */
  20372. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20373. /** Equirectangular Fixed Mirrored coordinates mode */
  20374. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20375. /** Texture is not repeating outside of 0..1 UVs */
  20376. static readonly CLAMP_ADDRESSMODE: number;
  20377. /** Texture is repeating outside of 0..1 UVs */
  20378. static readonly WRAP_ADDRESSMODE: number;
  20379. /** Texture is repeating and mirrored */
  20380. static readonly MIRROR_ADDRESSMODE: number;
  20381. /**
  20382. * 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
  20383. */
  20384. static UseSerializedUrlIfAny: boolean;
  20385. /**
  20386. * Define the url of the texture.
  20387. */
  20388. url: Nullable<string>;
  20389. /**
  20390. * Define an offset on the texture to offset the u coordinates of the UVs
  20391. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20392. */
  20393. uOffset: number;
  20394. /**
  20395. * Define an offset on the texture to offset the v coordinates of the UVs
  20396. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20397. */
  20398. vOffset: number;
  20399. /**
  20400. * Define an offset on the texture to scale the u coordinates of the UVs
  20401. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20402. */
  20403. uScale: number;
  20404. /**
  20405. * Define an offset on the texture to scale the v coordinates of the UVs
  20406. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20407. */
  20408. vScale: number;
  20409. /**
  20410. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20411. * @see http://doc.babylonjs.com/how_to/more_materials
  20412. */
  20413. uAng: number;
  20414. /**
  20415. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20416. * @see http://doc.babylonjs.com/how_to/more_materials
  20417. */
  20418. vAng: number;
  20419. /**
  20420. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20421. * @see http://doc.babylonjs.com/how_to/more_materials
  20422. */
  20423. wAng: number;
  20424. /**
  20425. * Defines the center of rotation (U)
  20426. */
  20427. uRotationCenter: number;
  20428. /**
  20429. * Defines the center of rotation (V)
  20430. */
  20431. vRotationCenter: number;
  20432. /**
  20433. * Defines the center of rotation (W)
  20434. */
  20435. wRotationCenter: number;
  20436. /**
  20437. * Are mip maps generated for this texture or not.
  20438. */
  20439. get noMipmap(): boolean;
  20440. /**
  20441. * List of inspectable custom properties (used by the Inspector)
  20442. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20443. */
  20444. inspectableCustomProperties: Nullable<IInspectable[]>;
  20445. private _noMipmap;
  20446. /** @hidden */
  20447. _invertY: boolean;
  20448. private _rowGenerationMatrix;
  20449. private _cachedTextureMatrix;
  20450. private _projectionModeMatrix;
  20451. private _t0;
  20452. private _t1;
  20453. private _t2;
  20454. private _cachedUOffset;
  20455. private _cachedVOffset;
  20456. private _cachedUScale;
  20457. private _cachedVScale;
  20458. private _cachedUAng;
  20459. private _cachedVAng;
  20460. private _cachedWAng;
  20461. private _cachedProjectionMatrixId;
  20462. private _cachedCoordinatesMode;
  20463. /** @hidden */
  20464. protected _initialSamplingMode: number;
  20465. /** @hidden */
  20466. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20467. private _deleteBuffer;
  20468. protected _format: Nullable<number>;
  20469. private _delayedOnLoad;
  20470. private _delayedOnError;
  20471. private _mimeType?;
  20472. /**
  20473. * Observable triggered once the texture has been loaded.
  20474. */
  20475. onLoadObservable: Observable<Texture>;
  20476. protected _isBlocking: boolean;
  20477. /**
  20478. * Is the texture preventing material to render while loading.
  20479. * If false, a default texture will be used instead of the loading one during the preparation step.
  20480. */
  20481. set isBlocking(value: boolean);
  20482. get isBlocking(): boolean;
  20483. /**
  20484. * Get the current sampling mode associated with the texture.
  20485. */
  20486. get samplingMode(): number;
  20487. /**
  20488. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20489. */
  20490. get invertY(): boolean;
  20491. /**
  20492. * Instantiates a new texture.
  20493. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20494. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20495. * @param url defines the url of the picture to load as a texture
  20496. * @param scene defines the scene or engine the texture will belong to
  20497. * @param noMipmap defines if the texture will require mip maps or not
  20498. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20499. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20500. * @param onLoad defines a callback triggered when the texture has been loaded
  20501. * @param onError defines a callback triggered when an error occurred during the loading session
  20502. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20503. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20504. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20505. * @param mimeType defines an optional mime type information
  20506. */
  20507. 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);
  20508. /**
  20509. * Update the url (and optional buffer) of this texture if url was null during construction.
  20510. * @param url the url of the texture
  20511. * @param buffer the buffer of the texture (defaults to null)
  20512. * @param onLoad callback called when the texture is loaded (defaults to null)
  20513. */
  20514. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20515. /**
  20516. * Finish the loading sequence of a texture flagged as delayed load.
  20517. * @hidden
  20518. */
  20519. delayLoad(): void;
  20520. private _prepareRowForTextureGeneration;
  20521. /**
  20522. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20523. * @returns the transform matrix of the texture.
  20524. */
  20525. getTextureMatrix(uBase?: number): Matrix;
  20526. /**
  20527. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20528. * @returns The reflection texture transform
  20529. */
  20530. getReflectionTextureMatrix(): Matrix;
  20531. /**
  20532. * Clones the texture.
  20533. * @returns the cloned texture
  20534. */
  20535. clone(): Texture;
  20536. /**
  20537. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20538. * @returns The JSON representation of the texture
  20539. */
  20540. serialize(): any;
  20541. /**
  20542. * Get the current class name of the texture useful for serialization or dynamic coding.
  20543. * @returns "Texture"
  20544. */
  20545. getClassName(): string;
  20546. /**
  20547. * Dispose the texture and release its associated resources.
  20548. */
  20549. dispose(): void;
  20550. /**
  20551. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20552. * @param parsedTexture Define the JSON representation of the texture
  20553. * @param scene Define the scene the parsed texture should be instantiated in
  20554. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20555. * @returns The parsed texture if successful
  20556. */
  20557. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20558. /**
  20559. * Creates a texture from its base 64 representation.
  20560. * @param data Define the base64 payload without the data: prefix
  20561. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20562. * @param scene Define the scene the texture should belong to
  20563. * @param noMipmap Forces the texture to not create mip map information if true
  20564. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20565. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20566. * @param onLoad define a callback triggered when the texture has been loaded
  20567. * @param onError define a callback triggered when an error occurred during the loading session
  20568. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20569. * @returns the created texture
  20570. */
  20571. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20572. /**
  20573. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20574. * @param data Define the base64 payload without the data: prefix
  20575. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20576. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20577. * @param scene Define the scene the texture should belong to
  20578. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20579. * @param noMipmap Forces the texture to not create mip map information if true
  20580. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20581. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20582. * @param onLoad define a callback triggered when the texture has been loaded
  20583. * @param onError define a callback triggered when an error occurred during the loading session
  20584. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20585. * @returns the created texture
  20586. */
  20587. 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;
  20588. }
  20589. }
  20590. declare module BABYLON {
  20591. /**
  20592. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20594. */
  20595. export class PostProcessManager {
  20596. private _scene;
  20597. private _indexBuffer;
  20598. private _vertexBuffers;
  20599. /**
  20600. * Creates a new instance PostProcess
  20601. * @param scene The scene that the post process is associated with.
  20602. */
  20603. constructor(scene: Scene);
  20604. private _prepareBuffers;
  20605. private _buildIndexBuffer;
  20606. /**
  20607. * Rebuilds the vertex buffers of the manager.
  20608. * @hidden
  20609. */
  20610. _rebuild(): void;
  20611. /**
  20612. * Prepares a frame to be run through a post process.
  20613. * @param sourceTexture The input texture to the post procesess. (default: null)
  20614. * @param postProcesses An array of post processes to be run. (default: null)
  20615. * @returns True if the post processes were able to be run.
  20616. * @hidden
  20617. */
  20618. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20619. /**
  20620. * Manually render a set of post processes to a texture.
  20621. * @param postProcesses An array of post processes to be run.
  20622. * @param targetTexture The target texture to render to.
  20623. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20624. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20625. * @param lodLevel defines which lod of the texture to render to
  20626. */
  20627. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20628. /**
  20629. * Finalize the result of the output of the postprocesses.
  20630. * @param doNotPresent If true the result will not be displayed to the screen.
  20631. * @param targetTexture The target texture to render to.
  20632. * @param faceIndex The index of the face to bind the target texture to.
  20633. * @param postProcesses The array of post processes to render.
  20634. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20635. * @hidden
  20636. */
  20637. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20638. /**
  20639. * Disposes of the post process manager.
  20640. */
  20641. dispose(): void;
  20642. }
  20643. }
  20644. declare module BABYLON {
  20645. /**
  20646. * This Helps creating a texture that will be created from a camera in your scene.
  20647. * It is basically a dynamic texture that could be used to create special effects for instance.
  20648. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20649. */
  20650. export class RenderTargetTexture extends Texture {
  20651. isCube: boolean;
  20652. /**
  20653. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20654. */
  20655. static readonly REFRESHRATE_RENDER_ONCE: number;
  20656. /**
  20657. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20658. */
  20659. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20660. /**
  20661. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20662. * the central point of your effect and can save a lot of performances.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20665. /**
  20666. * Use this predicate to dynamically define the list of mesh you want to render.
  20667. * If set, the renderList property will be overwritten.
  20668. */
  20669. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20670. private _renderList;
  20671. /**
  20672. * Use this list to define the list of mesh you want to render.
  20673. */
  20674. get renderList(): Nullable<Array<AbstractMesh>>;
  20675. set renderList(value: Nullable<Array<AbstractMesh>>);
  20676. /**
  20677. * Use this function to overload the renderList array at rendering time.
  20678. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20679. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20680. * the cube (if the RTT is a cube, else layerOrFace=0).
  20681. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20682. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20683. * hold dummy elements!
  20684. */
  20685. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20686. private _hookArray;
  20687. /**
  20688. * Define if particles should be rendered in your texture.
  20689. */
  20690. renderParticles: boolean;
  20691. /**
  20692. * Define if sprites should be rendered in your texture.
  20693. */
  20694. renderSprites: boolean;
  20695. /**
  20696. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20697. */
  20698. coordinatesMode: number;
  20699. /**
  20700. * Define the camera used to render the texture.
  20701. */
  20702. activeCamera: Nullable<Camera>;
  20703. /**
  20704. * Override the mesh isReady function with your own one.
  20705. */
  20706. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20707. /**
  20708. * Override the render function of the texture with your own one.
  20709. */
  20710. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20711. /**
  20712. * Define if camera post processes should be use while rendering the texture.
  20713. */
  20714. useCameraPostProcesses: boolean;
  20715. /**
  20716. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20717. */
  20718. ignoreCameraViewport: boolean;
  20719. private _postProcessManager;
  20720. private _postProcesses;
  20721. private _resizeObserver;
  20722. /**
  20723. * An event triggered when the texture is unbind.
  20724. */
  20725. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20726. /**
  20727. * An event triggered when the texture is unbind.
  20728. */
  20729. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20730. private _onAfterUnbindObserver;
  20731. /**
  20732. * Set a after unbind callback in the texture.
  20733. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20734. */
  20735. set onAfterUnbind(callback: () => void);
  20736. /**
  20737. * An event triggered before rendering the texture
  20738. */
  20739. onBeforeRenderObservable: Observable<number>;
  20740. private _onBeforeRenderObserver;
  20741. /**
  20742. * Set a before render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20744. */
  20745. set onBeforeRender(callback: (faceIndex: number) => void);
  20746. /**
  20747. * An event triggered after rendering the texture
  20748. */
  20749. onAfterRenderObservable: Observable<number>;
  20750. private _onAfterRenderObserver;
  20751. /**
  20752. * Set a after render callback in the texture.
  20753. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20754. */
  20755. set onAfterRender(callback: (faceIndex: number) => void);
  20756. /**
  20757. * An event triggered after the texture clear
  20758. */
  20759. onClearObservable: Observable<Engine>;
  20760. private _onClearObserver;
  20761. /**
  20762. * Set a clear callback in the texture.
  20763. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20764. */
  20765. set onClear(callback: (Engine: Engine) => void);
  20766. /**
  20767. * An event triggered when the texture is resized.
  20768. */
  20769. onResizeObservable: Observable<RenderTargetTexture>;
  20770. /**
  20771. * Define the clear color of the Render Target if it should be different from the scene.
  20772. */
  20773. clearColor: Color4;
  20774. protected _size: number | {
  20775. width: number;
  20776. height: number;
  20777. layers?: number;
  20778. };
  20779. protected _initialSizeParameter: number | {
  20780. width: number;
  20781. height: number;
  20782. } | {
  20783. ratio: number;
  20784. };
  20785. protected _sizeRatio: Nullable<number>;
  20786. /** @hidden */
  20787. _generateMipMaps: boolean;
  20788. protected _renderingManager: RenderingManager;
  20789. /** @hidden */
  20790. _waitingRenderList: string[];
  20791. protected _doNotChangeAspectRatio: boolean;
  20792. protected _currentRefreshId: number;
  20793. protected _refreshRate: number;
  20794. protected _textureMatrix: Matrix;
  20795. protected _samples: number;
  20796. protected _renderTargetOptions: RenderTargetCreationOptions;
  20797. /**
  20798. * Gets render target creation options that were used.
  20799. */
  20800. get renderTargetOptions(): RenderTargetCreationOptions;
  20801. protected _engine: Engine;
  20802. protected _onRatioRescale(): void;
  20803. /**
  20804. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20805. * It must define where the camera used to render the texture is set
  20806. */
  20807. boundingBoxPosition: Vector3;
  20808. private _boundingBoxSize;
  20809. /**
  20810. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20811. * When defined, the cubemap will switch to local mode
  20812. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20813. * @example https://www.babylonjs-playground.com/#RNASML
  20814. */
  20815. set boundingBoxSize(value: Vector3);
  20816. get boundingBoxSize(): Vector3;
  20817. /**
  20818. * In case the RTT has been created with a depth texture, get the associated
  20819. * depth texture.
  20820. * Otherwise, return null.
  20821. */
  20822. get depthStencilTexture(): Nullable<InternalTexture>;
  20823. /**
  20824. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20825. * or used a shadow, depth texture...
  20826. * @param name The friendly name of the texture
  20827. * @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)
  20828. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20829. * @param generateMipMaps True if mip maps need to be generated after render.
  20830. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20831. * @param type The type of the buffer in the RTT (int, half float, float...)
  20832. * @param isCube True if a cube texture needs to be created
  20833. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20834. * @param generateDepthBuffer True to generate a depth buffer
  20835. * @param generateStencilBuffer True to generate a stencil buffer
  20836. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20837. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20838. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20839. */
  20840. constructor(name: string, size: number | {
  20841. width: number;
  20842. height: number;
  20843. layers?: number;
  20844. } | {
  20845. ratio: number;
  20846. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20847. /**
  20848. * Creates a depth stencil texture.
  20849. * This is only available in WebGL 2 or with the depth texture extension available.
  20850. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20851. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20852. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20853. */
  20854. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20855. private _processSizeParameter;
  20856. /**
  20857. * Define the number of samples to use in case of MSAA.
  20858. * It defaults to one meaning no MSAA has been enabled.
  20859. */
  20860. get samples(): number;
  20861. set samples(value: number);
  20862. /**
  20863. * Resets the refresh counter of the texture and start bak from scratch.
  20864. * Could be useful to regenerate the texture if it is setup to render only once.
  20865. */
  20866. resetRefreshCounter(): void;
  20867. /**
  20868. * Define the refresh rate of the texture or the rendering frequency.
  20869. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20870. */
  20871. get refreshRate(): number;
  20872. set refreshRate(value: number);
  20873. /**
  20874. * Adds a post process to the render target rendering passes.
  20875. * @param postProcess define the post process to add
  20876. */
  20877. addPostProcess(postProcess: PostProcess): void;
  20878. /**
  20879. * Clear all the post processes attached to the render target
  20880. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20881. */
  20882. clearPostProcesses(dispose?: boolean): void;
  20883. /**
  20884. * Remove one of the post process from the list of attached post processes to the texture
  20885. * @param postProcess define the post process to remove from the list
  20886. */
  20887. removePostProcess(postProcess: PostProcess): void;
  20888. /** @hidden */
  20889. _shouldRender(): boolean;
  20890. /**
  20891. * Gets the actual render size of the texture.
  20892. * @returns the width of the render size
  20893. */
  20894. getRenderSize(): number;
  20895. /**
  20896. * Gets the actual render width of the texture.
  20897. * @returns the width of the render size
  20898. */
  20899. getRenderWidth(): number;
  20900. /**
  20901. * Gets the actual render height of the texture.
  20902. * @returns the height of the render size
  20903. */
  20904. getRenderHeight(): number;
  20905. /**
  20906. * Gets the actual number of layers of the texture.
  20907. * @returns the number of layers
  20908. */
  20909. getRenderLayers(): number;
  20910. /**
  20911. * Get if the texture can be rescaled or not.
  20912. */
  20913. get canRescale(): boolean;
  20914. /**
  20915. * Resize the texture using a ratio.
  20916. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20917. */
  20918. scale(ratio: number): void;
  20919. /**
  20920. * Get the texture reflection matrix used to rotate/transform the reflection.
  20921. * @returns the reflection matrix
  20922. */
  20923. getReflectionTextureMatrix(): Matrix;
  20924. /**
  20925. * Resize the texture to a new desired size.
  20926. * Be carrefull as it will recreate all the data in the new texture.
  20927. * @param size Define the new size. It can be:
  20928. * - a number for squared texture,
  20929. * - an object containing { width: number, height: number }
  20930. * - or an object containing a ratio { ratio: number }
  20931. */
  20932. resize(size: number | {
  20933. width: number;
  20934. height: number;
  20935. } | {
  20936. ratio: number;
  20937. }): void;
  20938. private _defaultRenderListPrepared;
  20939. /**
  20940. * Renders all the objects from the render list into the texture.
  20941. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20942. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20943. */
  20944. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20945. private _bestReflectionRenderTargetDimension;
  20946. private _prepareRenderingManager;
  20947. /**
  20948. * @hidden
  20949. * @param faceIndex face index to bind to if this is a cubetexture
  20950. * @param layer defines the index of the texture to bind in the array
  20951. */
  20952. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20953. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20954. private renderToTarget;
  20955. /**
  20956. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20957. * This allowed control for front to back rendering or reversly depending of the special needs.
  20958. *
  20959. * @param renderingGroupId The rendering group id corresponding to its index
  20960. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20961. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20962. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20963. */
  20964. 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;
  20965. /**
  20966. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20967. *
  20968. * @param renderingGroupId The rendering group id corresponding to its index
  20969. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20970. */
  20971. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20972. /**
  20973. * Clones the texture.
  20974. * @returns the cloned texture
  20975. */
  20976. clone(): RenderTargetTexture;
  20977. /**
  20978. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20979. * @returns The JSON representation of the texture
  20980. */
  20981. serialize(): any;
  20982. /**
  20983. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20984. */
  20985. disposeFramebufferObjects(): void;
  20986. /**
  20987. * Dispose the texture and release its associated resources.
  20988. */
  20989. dispose(): void;
  20990. /** @hidden */
  20991. _rebuild(): void;
  20992. /**
  20993. * Clear the info related to rendering groups preventing retention point in material dispose.
  20994. */
  20995. freeRenderingGroups(): void;
  20996. /**
  20997. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20998. * @returns the view count
  20999. */
  21000. getViewCount(): number;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /**
  21005. * Class used to manipulate GUIDs
  21006. */
  21007. export class GUID {
  21008. /**
  21009. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21010. * Be aware Math.random() could cause collisions, but:
  21011. * "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"
  21012. * @returns a pseudo random id
  21013. */
  21014. static RandomId(): string;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Options to be used when creating a shadow depth material
  21020. */
  21021. export interface IIOptionShadowDepthMaterial {
  21022. /** Variables in the vertex shader code that need to have their names remapped.
  21023. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21024. * "var_name" should be either: worldPos or vNormalW
  21025. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21026. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21027. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21028. */
  21029. remappedVariables?: string[];
  21030. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21031. standalone?: boolean;
  21032. }
  21033. /**
  21034. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21035. */
  21036. export class ShadowDepthWrapper {
  21037. private _scene;
  21038. private _options?;
  21039. private _baseMaterial;
  21040. private _onEffectCreatedObserver;
  21041. private _subMeshToEffect;
  21042. private _subMeshToDepthEffect;
  21043. private _meshes;
  21044. /** @hidden */
  21045. _matriceNames: any;
  21046. /** Gets the standalone status of the wrapper */
  21047. get standalone(): boolean;
  21048. /** Gets the base material the wrapper is built upon */
  21049. get baseMaterial(): Material;
  21050. /**
  21051. * Instantiate a new shadow depth wrapper.
  21052. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21053. * generate the shadow depth map. For more information, please refer to the documentation:
  21054. * https://doc.babylonjs.com/babylon101/shadows
  21055. * @param baseMaterial Material to wrap
  21056. * @param scene Define the scene the material belongs to
  21057. * @param options Options used to create the wrapper
  21058. */
  21059. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21060. /**
  21061. * Gets the effect to use to generate the depth map
  21062. * @param subMesh subMesh to get the effect for
  21063. * @param shadowGenerator shadow generator to get the effect for
  21064. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21065. */
  21066. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21067. /**
  21068. * Specifies that the submesh is ready to be used for depth rendering
  21069. * @param subMesh submesh to check
  21070. * @param defines the list of defines to take into account when checking the effect
  21071. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21072. * @param useInstances specifies that instances should be used
  21073. * @returns a boolean indicating that the submesh is ready or not
  21074. */
  21075. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21076. /**
  21077. * Disposes the resources
  21078. */
  21079. dispose(): void;
  21080. private _makeEffect;
  21081. }
  21082. }
  21083. declare module BABYLON {
  21084. /**
  21085. * Options for compiling materials.
  21086. */
  21087. export interface IMaterialCompilationOptions {
  21088. /**
  21089. * Defines whether clip planes are enabled.
  21090. */
  21091. clipPlane: boolean;
  21092. /**
  21093. * Defines whether instances are enabled.
  21094. */
  21095. useInstances: boolean;
  21096. }
  21097. /**
  21098. * Base class for the main features of a material in Babylon.js
  21099. */
  21100. export class Material implements IAnimatable {
  21101. /**
  21102. * Returns the triangle fill mode
  21103. */
  21104. static readonly TriangleFillMode: number;
  21105. /**
  21106. * Returns the wireframe mode
  21107. */
  21108. static readonly WireFrameFillMode: number;
  21109. /**
  21110. * Returns the point fill mode
  21111. */
  21112. static readonly PointFillMode: number;
  21113. /**
  21114. * Returns the point list draw mode
  21115. */
  21116. static readonly PointListDrawMode: number;
  21117. /**
  21118. * Returns the line list draw mode
  21119. */
  21120. static readonly LineListDrawMode: number;
  21121. /**
  21122. * Returns the line loop draw mode
  21123. */
  21124. static readonly LineLoopDrawMode: number;
  21125. /**
  21126. * Returns the line strip draw mode
  21127. */
  21128. static readonly LineStripDrawMode: number;
  21129. /**
  21130. * Returns the triangle strip draw mode
  21131. */
  21132. static readonly TriangleStripDrawMode: number;
  21133. /**
  21134. * Returns the triangle fan draw mode
  21135. */
  21136. static readonly TriangleFanDrawMode: number;
  21137. /**
  21138. * Stores the clock-wise side orientation
  21139. */
  21140. static readonly ClockWiseSideOrientation: number;
  21141. /**
  21142. * Stores the counter clock-wise side orientation
  21143. */
  21144. static readonly CounterClockWiseSideOrientation: number;
  21145. /**
  21146. * The dirty texture flag value
  21147. */
  21148. static readonly TextureDirtyFlag: number;
  21149. /**
  21150. * The dirty light flag value
  21151. */
  21152. static readonly LightDirtyFlag: number;
  21153. /**
  21154. * The dirty fresnel flag value
  21155. */
  21156. static readonly FresnelDirtyFlag: number;
  21157. /**
  21158. * The dirty attribute flag value
  21159. */
  21160. static readonly AttributesDirtyFlag: number;
  21161. /**
  21162. * The dirty misc flag value
  21163. */
  21164. static readonly MiscDirtyFlag: number;
  21165. /**
  21166. * The all dirty flag value
  21167. */
  21168. static readonly AllDirtyFlag: number;
  21169. /**
  21170. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21171. */
  21172. static readonly MATERIAL_OPAQUE: number;
  21173. /**
  21174. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21175. */
  21176. static readonly MATERIAL_ALPHATEST: number;
  21177. /**
  21178. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21179. */
  21180. static readonly MATERIAL_ALPHABLEND: number;
  21181. /**
  21182. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21183. * They are also discarded below the alpha cutoff threshold to improve performances.
  21184. */
  21185. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21186. /**
  21187. * Custom callback helping to override the default shader used in the material.
  21188. */
  21189. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21190. /**
  21191. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21192. */
  21193. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21194. /**
  21195. * The ID of the material
  21196. */
  21197. id: string;
  21198. /**
  21199. * Gets or sets the unique id of the material
  21200. */
  21201. uniqueId: number;
  21202. /**
  21203. * The name of the material
  21204. */
  21205. name: string;
  21206. /**
  21207. * Gets or sets user defined metadata
  21208. */
  21209. metadata: any;
  21210. /**
  21211. * For internal use only. Please do not use.
  21212. */
  21213. reservedDataStore: any;
  21214. /**
  21215. * Specifies if the ready state should be checked on each call
  21216. */
  21217. checkReadyOnEveryCall: boolean;
  21218. /**
  21219. * Specifies if the ready state should be checked once
  21220. */
  21221. checkReadyOnlyOnce: boolean;
  21222. /**
  21223. * The state of the material
  21224. */
  21225. state: string;
  21226. /**
  21227. * The alpha value of the material
  21228. */
  21229. protected _alpha: number;
  21230. /**
  21231. * List of inspectable custom properties (used by the Inspector)
  21232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21233. */
  21234. inspectableCustomProperties: IInspectable[];
  21235. /**
  21236. * Sets the alpha value of the material
  21237. */
  21238. set alpha(value: number);
  21239. /**
  21240. * Gets the alpha value of the material
  21241. */
  21242. get alpha(): number;
  21243. /**
  21244. * Specifies if back face culling is enabled
  21245. */
  21246. protected _backFaceCulling: boolean;
  21247. /**
  21248. * Sets the back-face culling state
  21249. */
  21250. set backFaceCulling(value: boolean);
  21251. /**
  21252. * Gets the back-face culling state
  21253. */
  21254. get backFaceCulling(): boolean;
  21255. /**
  21256. * Stores the value for side orientation
  21257. */
  21258. sideOrientation: number;
  21259. /**
  21260. * Callback triggered when the material is compiled
  21261. */
  21262. onCompiled: Nullable<(effect: Effect) => void>;
  21263. /**
  21264. * Callback triggered when an error occurs
  21265. */
  21266. onError: Nullable<(effect: Effect, errors: string) => void>;
  21267. /**
  21268. * Callback triggered to get the render target textures
  21269. */
  21270. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21271. /**
  21272. * Gets a boolean indicating that current material needs to register RTT
  21273. */
  21274. get hasRenderTargetTextures(): boolean;
  21275. /**
  21276. * Specifies if the material should be serialized
  21277. */
  21278. doNotSerialize: boolean;
  21279. /**
  21280. * @hidden
  21281. */
  21282. _storeEffectOnSubMeshes: boolean;
  21283. /**
  21284. * Stores the animations for the material
  21285. */
  21286. animations: Nullable<Array<Animation>>;
  21287. /**
  21288. * An event triggered when the material is disposed
  21289. */
  21290. onDisposeObservable: Observable<Material>;
  21291. /**
  21292. * An observer which watches for dispose events
  21293. */
  21294. private _onDisposeObserver;
  21295. private _onUnBindObservable;
  21296. /**
  21297. * Called during a dispose event
  21298. */
  21299. set onDispose(callback: () => void);
  21300. private _onBindObservable;
  21301. /**
  21302. * An event triggered when the material is bound
  21303. */
  21304. get onBindObservable(): Observable<AbstractMesh>;
  21305. /**
  21306. * An observer which watches for bind events
  21307. */
  21308. private _onBindObserver;
  21309. /**
  21310. * Called during a bind event
  21311. */
  21312. set onBind(callback: (Mesh: AbstractMesh) => void);
  21313. /**
  21314. * An event triggered when the material is unbound
  21315. */
  21316. get onUnBindObservable(): Observable<Material>;
  21317. protected _onEffectCreatedObservable: Nullable<Observable<{
  21318. effect: Effect;
  21319. subMesh: Nullable<SubMesh>;
  21320. }>>;
  21321. /**
  21322. * An event triggered when the effect is (re)created
  21323. */
  21324. get onEffectCreatedObservable(): Observable<{
  21325. effect: Effect;
  21326. subMesh: Nullable<SubMesh>;
  21327. }>;
  21328. /**
  21329. * Stores the value of the alpha mode
  21330. */
  21331. private _alphaMode;
  21332. /**
  21333. * Sets the value of the alpha mode.
  21334. *
  21335. * | Value | Type | Description |
  21336. * | --- | --- | --- |
  21337. * | 0 | ALPHA_DISABLE | |
  21338. * | 1 | ALPHA_ADD | |
  21339. * | 2 | ALPHA_COMBINE | |
  21340. * | 3 | ALPHA_SUBTRACT | |
  21341. * | 4 | ALPHA_MULTIPLY | |
  21342. * | 5 | ALPHA_MAXIMIZED | |
  21343. * | 6 | ALPHA_ONEONE | |
  21344. * | 7 | ALPHA_PREMULTIPLIED | |
  21345. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21346. * | 9 | ALPHA_INTERPOLATE | |
  21347. * | 10 | ALPHA_SCREENMODE | |
  21348. *
  21349. */
  21350. set alphaMode(value: number);
  21351. /**
  21352. * Gets the value of the alpha mode
  21353. */
  21354. get alphaMode(): number;
  21355. /**
  21356. * Stores the state of the need depth pre-pass value
  21357. */
  21358. private _needDepthPrePass;
  21359. /**
  21360. * Sets the need depth pre-pass value
  21361. */
  21362. set needDepthPrePass(value: boolean);
  21363. /**
  21364. * Gets the depth pre-pass value
  21365. */
  21366. get needDepthPrePass(): boolean;
  21367. /**
  21368. * Specifies if depth writing should be disabled
  21369. */
  21370. disableDepthWrite: boolean;
  21371. /**
  21372. * Specifies if depth writing should be forced
  21373. */
  21374. forceDepthWrite: boolean;
  21375. /**
  21376. * Specifies the depth function that should be used. 0 means the default engine function
  21377. */
  21378. depthFunction: number;
  21379. /**
  21380. * Specifies if there should be a separate pass for culling
  21381. */
  21382. separateCullingPass: boolean;
  21383. /**
  21384. * Stores the state specifing if fog should be enabled
  21385. */
  21386. private _fogEnabled;
  21387. /**
  21388. * Sets the state for enabling fog
  21389. */
  21390. set fogEnabled(value: boolean);
  21391. /**
  21392. * Gets the value of the fog enabled state
  21393. */
  21394. get fogEnabled(): boolean;
  21395. /**
  21396. * Stores the size of points
  21397. */
  21398. pointSize: number;
  21399. /**
  21400. * Stores the z offset value
  21401. */
  21402. zOffset: number;
  21403. /**
  21404. * Gets a value specifying if wireframe mode is enabled
  21405. */
  21406. get wireframe(): boolean;
  21407. /**
  21408. * Sets the state of wireframe mode
  21409. */
  21410. set wireframe(value: boolean);
  21411. /**
  21412. * Gets the value specifying if point clouds are enabled
  21413. */
  21414. get pointsCloud(): boolean;
  21415. /**
  21416. * Sets the state of point cloud mode
  21417. */
  21418. set pointsCloud(value: boolean);
  21419. /**
  21420. * Gets the material fill mode
  21421. */
  21422. get fillMode(): number;
  21423. /**
  21424. * Sets the material fill mode
  21425. */
  21426. set fillMode(value: number);
  21427. /**
  21428. * @hidden
  21429. * Stores the effects for the material
  21430. */
  21431. _effect: Nullable<Effect>;
  21432. /**
  21433. * Specifies if uniform buffers should be used
  21434. */
  21435. private _useUBO;
  21436. /**
  21437. * Stores a reference to the scene
  21438. */
  21439. private _scene;
  21440. /**
  21441. * Stores the fill mode state
  21442. */
  21443. private _fillMode;
  21444. /**
  21445. * Specifies if the depth write state should be cached
  21446. */
  21447. private _cachedDepthWriteState;
  21448. /**
  21449. * Specifies if the depth function state should be cached
  21450. */
  21451. private _cachedDepthFunctionState;
  21452. /**
  21453. * Stores the uniform buffer
  21454. */
  21455. protected _uniformBuffer: UniformBuffer;
  21456. /** @hidden */
  21457. _indexInSceneMaterialArray: number;
  21458. /** @hidden */
  21459. meshMap: Nullable<{
  21460. [id: string]: AbstractMesh | undefined;
  21461. }>;
  21462. /**
  21463. * Creates a material instance
  21464. * @param name defines the name of the material
  21465. * @param scene defines the scene to reference
  21466. * @param doNotAdd specifies if the material should be added to the scene
  21467. */
  21468. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21469. /**
  21470. * Returns a string representation of the current material
  21471. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21472. * @returns a string with material information
  21473. */
  21474. toString(fullDetails?: boolean): string;
  21475. /**
  21476. * Gets the class name of the material
  21477. * @returns a string with the class name of the material
  21478. */
  21479. getClassName(): string;
  21480. /**
  21481. * Specifies if updates for the material been locked
  21482. */
  21483. get isFrozen(): boolean;
  21484. /**
  21485. * Locks updates for the material
  21486. */
  21487. freeze(): void;
  21488. /**
  21489. * Unlocks updates for the material
  21490. */
  21491. unfreeze(): void;
  21492. /**
  21493. * Specifies if the material is ready to be used
  21494. * @param mesh defines the mesh to check
  21495. * @param useInstances specifies if instances should be used
  21496. * @returns a boolean indicating if the material is ready to be used
  21497. */
  21498. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21499. /**
  21500. * Specifies that the submesh is ready to be used
  21501. * @param mesh defines the mesh to check
  21502. * @param subMesh defines which submesh to check
  21503. * @param useInstances specifies that instances should be used
  21504. * @returns a boolean indicating that the submesh is ready or not
  21505. */
  21506. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21507. /**
  21508. * Returns the material effect
  21509. * @returns the effect associated with the material
  21510. */
  21511. getEffect(): Nullable<Effect>;
  21512. /**
  21513. * Returns the current scene
  21514. * @returns a Scene
  21515. */
  21516. getScene(): Scene;
  21517. /**
  21518. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21519. */
  21520. protected _forceAlphaTest: boolean;
  21521. /**
  21522. * The transparency mode of the material.
  21523. */
  21524. protected _transparencyMode: Nullable<number>;
  21525. /**
  21526. * Gets the current transparency mode.
  21527. */
  21528. get transparencyMode(): Nullable<number>;
  21529. /**
  21530. * Sets the transparency mode of the material.
  21531. *
  21532. * | Value | Type | Description |
  21533. * | ----- | ----------------------------------- | ----------- |
  21534. * | 0 | OPAQUE | |
  21535. * | 1 | ALPHATEST | |
  21536. * | 2 | ALPHABLEND | |
  21537. * | 3 | ALPHATESTANDBLEND | |
  21538. *
  21539. */
  21540. set transparencyMode(value: Nullable<number>);
  21541. /**
  21542. * Returns true if alpha blending should be disabled.
  21543. */
  21544. protected get _disableAlphaBlending(): boolean;
  21545. /**
  21546. * Specifies whether or not this material should be rendered in alpha blend mode.
  21547. * @returns a boolean specifying if alpha blending is needed
  21548. */
  21549. needAlphaBlending(): boolean;
  21550. /**
  21551. * Specifies if the mesh will require alpha blending
  21552. * @param mesh defines the mesh to check
  21553. * @returns a boolean specifying if alpha blending is needed for the mesh
  21554. */
  21555. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21556. /**
  21557. * Specifies whether or not this material should be rendered in alpha test mode.
  21558. * @returns a boolean specifying if an alpha test is needed.
  21559. */
  21560. needAlphaTesting(): boolean;
  21561. /**
  21562. * Specifies if material alpha testing should be turned on for the mesh
  21563. * @param mesh defines the mesh to check
  21564. */
  21565. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21566. /**
  21567. * Gets the texture used for the alpha test
  21568. * @returns the texture to use for alpha testing
  21569. */
  21570. getAlphaTestTexture(): Nullable<BaseTexture>;
  21571. /**
  21572. * Marks the material to indicate that it needs to be re-calculated
  21573. */
  21574. markDirty(): void;
  21575. /** @hidden */
  21576. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21577. /**
  21578. * Binds the material to the mesh
  21579. * @param world defines the world transformation matrix
  21580. * @param mesh defines the mesh to bind the material to
  21581. */
  21582. bind(world: Matrix, mesh?: Mesh): void;
  21583. /**
  21584. * Binds the submesh to the material
  21585. * @param world defines the world transformation matrix
  21586. * @param mesh defines the mesh containing the submesh
  21587. * @param subMesh defines the submesh to bind the material to
  21588. */
  21589. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21590. /**
  21591. * Binds the world matrix to the material
  21592. * @param world defines the world transformation matrix
  21593. */
  21594. bindOnlyWorldMatrix(world: Matrix): void;
  21595. /**
  21596. * Binds the scene's uniform buffer to the effect.
  21597. * @param effect defines the effect to bind to the scene uniform buffer
  21598. * @param sceneUbo defines the uniform buffer storing scene data
  21599. */
  21600. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21601. /**
  21602. * Binds the view matrix to the effect
  21603. * @param effect defines the effect to bind the view matrix to
  21604. */
  21605. bindView(effect: Effect): void;
  21606. /**
  21607. * Binds the view projection matrix to the effect
  21608. * @param effect defines the effect to bind the view projection matrix to
  21609. */
  21610. bindViewProjection(effect: Effect): void;
  21611. /**
  21612. * Processes to execute after binding the material to a mesh
  21613. * @param mesh defines the rendered mesh
  21614. */
  21615. protected _afterBind(mesh?: Mesh): void;
  21616. /**
  21617. * Unbinds the material from the mesh
  21618. */
  21619. unbind(): void;
  21620. /**
  21621. * Gets the active textures from the material
  21622. * @returns an array of textures
  21623. */
  21624. getActiveTextures(): BaseTexture[];
  21625. /**
  21626. * Specifies if the material uses a texture
  21627. * @param texture defines the texture to check against the material
  21628. * @returns a boolean specifying if the material uses the texture
  21629. */
  21630. hasTexture(texture: BaseTexture): boolean;
  21631. /**
  21632. * Makes a duplicate of the material, and gives it a new name
  21633. * @param name defines the new name for the duplicated material
  21634. * @returns the cloned material
  21635. */
  21636. clone(name: string): Nullable<Material>;
  21637. /**
  21638. * Gets the meshes bound to the material
  21639. * @returns an array of meshes bound to the material
  21640. */
  21641. getBindedMeshes(): AbstractMesh[];
  21642. /**
  21643. * Force shader compilation
  21644. * @param mesh defines the mesh associated with this material
  21645. * @param onCompiled defines a function to execute once the material is compiled
  21646. * @param options defines the options to configure the compilation
  21647. * @param onError defines a function to execute if the material fails compiling
  21648. */
  21649. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21650. /**
  21651. * Force shader compilation
  21652. * @param mesh defines the mesh that will use this material
  21653. * @param options defines additional options for compiling the shaders
  21654. * @returns a promise that resolves when the compilation completes
  21655. */
  21656. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21657. private static readonly _AllDirtyCallBack;
  21658. private static readonly _ImageProcessingDirtyCallBack;
  21659. private static readonly _TextureDirtyCallBack;
  21660. private static readonly _FresnelDirtyCallBack;
  21661. private static readonly _MiscDirtyCallBack;
  21662. private static readonly _LightsDirtyCallBack;
  21663. private static readonly _AttributeDirtyCallBack;
  21664. private static _FresnelAndMiscDirtyCallBack;
  21665. private static _TextureAndMiscDirtyCallBack;
  21666. private static readonly _DirtyCallbackArray;
  21667. private static readonly _RunDirtyCallBacks;
  21668. /**
  21669. * Marks a define in the material to indicate that it needs to be re-computed
  21670. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21671. */
  21672. markAsDirty(flag: number): void;
  21673. /**
  21674. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21675. * @param func defines a function which checks material defines against the submeshes
  21676. */
  21677. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21678. /**
  21679. * Indicates that we need to re-calculated for all submeshes
  21680. */
  21681. protected _markAllSubMeshesAsAllDirty(): void;
  21682. /**
  21683. * Indicates that image processing needs to be re-calculated for all submeshes
  21684. */
  21685. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21686. /**
  21687. * Indicates that textures need to be re-calculated for all submeshes
  21688. */
  21689. protected _markAllSubMeshesAsTexturesDirty(): void;
  21690. /**
  21691. * Indicates that fresnel needs to be re-calculated for all submeshes
  21692. */
  21693. protected _markAllSubMeshesAsFresnelDirty(): void;
  21694. /**
  21695. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21696. */
  21697. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21698. /**
  21699. * Indicates that lights need to be re-calculated for all submeshes
  21700. */
  21701. protected _markAllSubMeshesAsLightsDirty(): void;
  21702. /**
  21703. * Indicates that attributes need to be re-calculated for all submeshes
  21704. */
  21705. protected _markAllSubMeshesAsAttributesDirty(): void;
  21706. /**
  21707. * Indicates that misc needs to be re-calculated for all submeshes
  21708. */
  21709. protected _markAllSubMeshesAsMiscDirty(): void;
  21710. /**
  21711. * Indicates that textures and misc need to be re-calculated for all submeshes
  21712. */
  21713. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21714. /**
  21715. * Disposes the material
  21716. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21717. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21718. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21719. */
  21720. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21721. /** @hidden */
  21722. private releaseVertexArrayObject;
  21723. /**
  21724. * Serializes this material
  21725. * @returns the serialized material object
  21726. */
  21727. serialize(): any;
  21728. /**
  21729. * Creates a material from parsed material data
  21730. * @param parsedMaterial defines parsed material data
  21731. * @param scene defines the hosting scene
  21732. * @param rootUrl defines the root URL to use to load textures
  21733. * @returns a new material
  21734. */
  21735. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21736. }
  21737. }
  21738. declare module BABYLON {
  21739. /**
  21740. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21741. * separate meshes. This can be use to improve performances.
  21742. * @see http://doc.babylonjs.com/how_to/multi_materials
  21743. */
  21744. export class MultiMaterial extends Material {
  21745. private _subMaterials;
  21746. /**
  21747. * Gets or Sets the list of Materials used within the multi material.
  21748. * They need to be ordered according to the submeshes order in the associated mesh
  21749. */
  21750. get subMaterials(): Nullable<Material>[];
  21751. set subMaterials(value: Nullable<Material>[]);
  21752. /**
  21753. * Function used to align with Node.getChildren()
  21754. * @returns the list of Materials used within the multi material
  21755. */
  21756. getChildren(): Nullable<Material>[];
  21757. /**
  21758. * Instantiates a new Multi Material
  21759. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21760. * separate meshes. This can be use to improve performances.
  21761. * @see http://doc.babylonjs.com/how_to/multi_materials
  21762. * @param name Define the name in the scene
  21763. * @param scene Define the scene the material belongs to
  21764. */
  21765. constructor(name: string, scene: Scene);
  21766. private _hookArray;
  21767. /**
  21768. * Get one of the submaterial by its index in the submaterials array
  21769. * @param index The index to look the sub material at
  21770. * @returns The Material if the index has been defined
  21771. */
  21772. getSubMaterial(index: number): Nullable<Material>;
  21773. /**
  21774. * Get the list of active textures for the whole sub materials list.
  21775. * @returns All the textures that will be used during the rendering
  21776. */
  21777. getActiveTextures(): BaseTexture[];
  21778. /**
  21779. * Gets the current class name of the material e.g. "MultiMaterial"
  21780. * Mainly use in serialization.
  21781. * @returns the class name
  21782. */
  21783. getClassName(): string;
  21784. /**
  21785. * Checks if the material is ready to render the requested sub mesh
  21786. * @param mesh Define the mesh the submesh belongs to
  21787. * @param subMesh Define the sub mesh to look readyness for
  21788. * @param useInstances Define whether or not the material is used with instances
  21789. * @returns true if ready, otherwise false
  21790. */
  21791. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21792. /**
  21793. * Clones the current material and its related sub materials
  21794. * @param name Define the name of the newly cloned material
  21795. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21796. * @returns the cloned material
  21797. */
  21798. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21799. /**
  21800. * Serializes the materials into a JSON representation.
  21801. * @returns the JSON representation
  21802. */
  21803. serialize(): any;
  21804. /**
  21805. * Dispose the material and release its associated resources
  21806. * @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)
  21807. * @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)
  21808. * @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)
  21809. */
  21810. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21811. /**
  21812. * Creates a MultiMaterial from parsed MultiMaterial data.
  21813. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21814. * @param scene defines the hosting scene
  21815. * @returns a new MultiMaterial
  21816. */
  21817. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21818. }
  21819. }
  21820. declare module BABYLON {
  21821. /**
  21822. * Base class for submeshes
  21823. */
  21824. export class BaseSubMesh {
  21825. /** @hidden */
  21826. _materialDefines: Nullable<MaterialDefines>;
  21827. /** @hidden */
  21828. _materialEffect: Nullable<Effect>;
  21829. /** @hidden */
  21830. _effectOverride: Nullable<Effect>;
  21831. /**
  21832. * Gets material defines used by the effect associated to the sub mesh
  21833. */
  21834. get materialDefines(): Nullable<MaterialDefines>;
  21835. /**
  21836. * Sets material defines used by the effect associated to the sub mesh
  21837. */
  21838. set materialDefines(defines: Nullable<MaterialDefines>);
  21839. /**
  21840. * Gets associated effect
  21841. */
  21842. get effect(): Nullable<Effect>;
  21843. /**
  21844. * Sets associated effect (effect used to render this submesh)
  21845. * @param effect defines the effect to associate with
  21846. * @param defines defines the set of defines used to compile this effect
  21847. */
  21848. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21849. }
  21850. /**
  21851. * Defines a subdivision inside a mesh
  21852. */
  21853. export class SubMesh extends BaseSubMesh implements ICullable {
  21854. /** the material index to use */
  21855. materialIndex: number;
  21856. /** vertex index start */
  21857. verticesStart: number;
  21858. /** vertices count */
  21859. verticesCount: number;
  21860. /** index start */
  21861. indexStart: number;
  21862. /** indices count */
  21863. indexCount: number;
  21864. /** @hidden */
  21865. _linesIndexCount: number;
  21866. private _mesh;
  21867. private _renderingMesh;
  21868. private _boundingInfo;
  21869. private _linesIndexBuffer;
  21870. /** @hidden */
  21871. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21872. /** @hidden */
  21873. _trianglePlanes: Plane[];
  21874. /** @hidden */
  21875. _lastColliderTransformMatrix: Nullable<Matrix>;
  21876. /** @hidden */
  21877. _renderId: number;
  21878. /** @hidden */
  21879. _alphaIndex: number;
  21880. /** @hidden */
  21881. _distanceToCamera: number;
  21882. /** @hidden */
  21883. _id: number;
  21884. private _currentMaterial;
  21885. /**
  21886. * Add a new submesh to a mesh
  21887. * @param materialIndex defines the material index to use
  21888. * @param verticesStart defines vertex index start
  21889. * @param verticesCount defines vertices count
  21890. * @param indexStart defines index start
  21891. * @param indexCount defines indices count
  21892. * @param mesh defines the parent mesh
  21893. * @param renderingMesh defines an optional rendering mesh
  21894. * @param createBoundingBox defines if bounding box should be created for this submesh
  21895. * @returns the new submesh
  21896. */
  21897. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21898. /**
  21899. * Creates a new submesh
  21900. * @param materialIndex defines the material index to use
  21901. * @param verticesStart defines vertex index start
  21902. * @param verticesCount defines vertices count
  21903. * @param indexStart defines index start
  21904. * @param indexCount defines indices count
  21905. * @param mesh defines the parent mesh
  21906. * @param renderingMesh defines an optional rendering mesh
  21907. * @param createBoundingBox defines if bounding box should be created for this submesh
  21908. */
  21909. constructor(
  21910. /** the material index to use */
  21911. materialIndex: number,
  21912. /** vertex index start */
  21913. verticesStart: number,
  21914. /** vertices count */
  21915. verticesCount: number,
  21916. /** index start */
  21917. indexStart: number,
  21918. /** indices count */
  21919. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21920. /**
  21921. * Returns true if this submesh covers the entire parent mesh
  21922. * @ignorenaming
  21923. */
  21924. get IsGlobal(): boolean;
  21925. /**
  21926. * Returns the submesh BoudingInfo object
  21927. * @returns current bounding info (or mesh's one if the submesh is global)
  21928. */
  21929. getBoundingInfo(): BoundingInfo;
  21930. /**
  21931. * Sets the submesh BoundingInfo
  21932. * @param boundingInfo defines the new bounding info to use
  21933. * @returns the SubMesh
  21934. */
  21935. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21936. /**
  21937. * Returns the mesh of the current submesh
  21938. * @return the parent mesh
  21939. */
  21940. getMesh(): AbstractMesh;
  21941. /**
  21942. * Returns the rendering mesh of the submesh
  21943. * @returns the rendering mesh (could be different from parent mesh)
  21944. */
  21945. getRenderingMesh(): Mesh;
  21946. /**
  21947. * Returns the submesh material
  21948. * @returns null or the current material
  21949. */
  21950. getMaterial(): Nullable<Material>;
  21951. /**
  21952. * Sets a new updated BoundingInfo object to the submesh
  21953. * @param data defines an optional position array to use to determine the bounding info
  21954. * @returns the SubMesh
  21955. */
  21956. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21957. /** @hidden */
  21958. _checkCollision(collider: Collider): boolean;
  21959. /**
  21960. * Updates the submesh BoundingInfo
  21961. * @param world defines the world matrix to use to update the bounding info
  21962. * @returns the submesh
  21963. */
  21964. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21965. /**
  21966. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21967. * @param frustumPlanes defines the frustum planes
  21968. * @returns true if the submesh is intersecting with the frustum
  21969. */
  21970. isInFrustum(frustumPlanes: Plane[]): boolean;
  21971. /**
  21972. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21973. * @param frustumPlanes defines the frustum planes
  21974. * @returns true if the submesh is inside the frustum
  21975. */
  21976. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21977. /**
  21978. * Renders the submesh
  21979. * @param enableAlphaMode defines if alpha needs to be used
  21980. * @returns the submesh
  21981. */
  21982. render(enableAlphaMode: boolean): SubMesh;
  21983. /**
  21984. * @hidden
  21985. */
  21986. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21987. /**
  21988. * Checks if the submesh intersects with a ray
  21989. * @param ray defines the ray to test
  21990. * @returns true is the passed ray intersects the submesh bounding box
  21991. */
  21992. canIntersects(ray: Ray): boolean;
  21993. /**
  21994. * Intersects current submesh with a ray
  21995. * @param ray defines the ray to test
  21996. * @param positions defines mesh's positions array
  21997. * @param indices defines mesh's indices array
  21998. * @param fastCheck defines if only bounding info should be used
  21999. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22000. * @returns intersection info or null if no intersection
  22001. */
  22002. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22003. /** @hidden */
  22004. private _intersectLines;
  22005. /** @hidden */
  22006. private _intersectUnIndexedLines;
  22007. /** @hidden */
  22008. private _intersectTriangles;
  22009. /** @hidden */
  22010. private _intersectUnIndexedTriangles;
  22011. /** @hidden */
  22012. _rebuild(): void;
  22013. /**
  22014. * Creates a new submesh from the passed mesh
  22015. * @param newMesh defines the new hosting mesh
  22016. * @param newRenderingMesh defines an optional rendering mesh
  22017. * @returns the new submesh
  22018. */
  22019. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22020. /**
  22021. * Release associated resources
  22022. */
  22023. dispose(): void;
  22024. /**
  22025. * Gets the class name
  22026. * @returns the string "SubMesh".
  22027. */
  22028. getClassName(): string;
  22029. /**
  22030. * Creates a new submesh from indices data
  22031. * @param materialIndex the index of the main mesh material
  22032. * @param startIndex the index where to start the copy in the mesh indices array
  22033. * @param indexCount the number of indices to copy then from the startIndex
  22034. * @param mesh the main mesh to create the submesh from
  22035. * @param renderingMesh the optional rendering mesh
  22036. * @returns a new submesh
  22037. */
  22038. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22039. }
  22040. }
  22041. declare module BABYLON {
  22042. /**
  22043. * Class used to represent data loading progression
  22044. */
  22045. export class SceneLoaderFlags {
  22046. private static _ForceFullSceneLoadingForIncremental;
  22047. private static _ShowLoadingScreen;
  22048. private static _CleanBoneMatrixWeights;
  22049. private static _loggingLevel;
  22050. /**
  22051. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22052. */
  22053. static get ForceFullSceneLoadingForIncremental(): boolean;
  22054. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22055. /**
  22056. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22057. */
  22058. static get ShowLoadingScreen(): boolean;
  22059. static set ShowLoadingScreen(value: boolean);
  22060. /**
  22061. * Defines the current logging level (while loading the scene)
  22062. * @ignorenaming
  22063. */
  22064. static get loggingLevel(): number;
  22065. static set loggingLevel(value: number);
  22066. /**
  22067. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22068. */
  22069. static get CleanBoneMatrixWeights(): boolean;
  22070. static set CleanBoneMatrixWeights(value: boolean);
  22071. }
  22072. }
  22073. declare module BABYLON {
  22074. /**
  22075. * Class used to store geometry data (vertex buffers + index buffer)
  22076. */
  22077. export class Geometry implements IGetSetVerticesData {
  22078. /**
  22079. * Gets or sets the ID of the geometry
  22080. */
  22081. id: string;
  22082. /**
  22083. * Gets or sets the unique ID of the geometry
  22084. */
  22085. uniqueId: number;
  22086. /**
  22087. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22088. */
  22089. delayLoadState: number;
  22090. /**
  22091. * Gets the file containing the data to load when running in delay load state
  22092. */
  22093. delayLoadingFile: Nullable<string>;
  22094. /**
  22095. * Callback called when the geometry is updated
  22096. */
  22097. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22098. private _scene;
  22099. private _engine;
  22100. private _meshes;
  22101. private _totalVertices;
  22102. /** @hidden */
  22103. _indices: IndicesArray;
  22104. /** @hidden */
  22105. _vertexBuffers: {
  22106. [key: string]: VertexBuffer;
  22107. };
  22108. private _isDisposed;
  22109. private _extend;
  22110. private _boundingBias;
  22111. /** @hidden */
  22112. _delayInfo: Array<string>;
  22113. private _indexBuffer;
  22114. private _indexBufferIsUpdatable;
  22115. /** @hidden */
  22116. _boundingInfo: Nullable<BoundingInfo>;
  22117. /** @hidden */
  22118. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22119. /** @hidden */
  22120. _softwareSkinningFrameId: number;
  22121. private _vertexArrayObjects;
  22122. private _updatable;
  22123. /** @hidden */
  22124. _positions: Nullable<Vector3[]>;
  22125. /**
  22126. * 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
  22127. */
  22128. get boundingBias(): Vector2;
  22129. /**
  22130. * 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
  22131. */
  22132. set boundingBias(value: Vector2);
  22133. /**
  22134. * Static function used to attach a new empty geometry to a mesh
  22135. * @param mesh defines the mesh to attach the geometry to
  22136. * @returns the new Geometry
  22137. */
  22138. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22139. /** Get the list of meshes using this geometry */
  22140. get meshes(): Mesh[];
  22141. /**
  22142. * Creates a new geometry
  22143. * @param id defines the unique ID
  22144. * @param scene defines the hosting scene
  22145. * @param vertexData defines the VertexData used to get geometry data
  22146. * @param updatable defines if geometry must be updatable (false by default)
  22147. * @param mesh defines the mesh that will be associated with the geometry
  22148. */
  22149. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22150. /**
  22151. * Gets the current extend of the geometry
  22152. */
  22153. get extend(): {
  22154. minimum: Vector3;
  22155. maximum: Vector3;
  22156. };
  22157. /**
  22158. * Gets the hosting scene
  22159. * @returns the hosting Scene
  22160. */
  22161. getScene(): Scene;
  22162. /**
  22163. * Gets the hosting engine
  22164. * @returns the hosting Engine
  22165. */
  22166. getEngine(): Engine;
  22167. /**
  22168. * Defines if the geometry is ready to use
  22169. * @returns true if the geometry is ready to be used
  22170. */
  22171. isReady(): boolean;
  22172. /**
  22173. * Gets a value indicating that the geometry should not be serialized
  22174. */
  22175. get doNotSerialize(): boolean;
  22176. /** @hidden */
  22177. _rebuild(): void;
  22178. /**
  22179. * Affects all geometry data in one call
  22180. * @param vertexData defines the geometry data
  22181. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22182. */
  22183. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22184. /**
  22185. * Set specific vertex data
  22186. * @param kind defines the data kind (Position, normal, etc...)
  22187. * @param data defines the vertex data to use
  22188. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22189. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22190. */
  22191. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22192. /**
  22193. * Removes a specific vertex data
  22194. * @param kind defines the data kind (Position, normal, etc...)
  22195. */
  22196. removeVerticesData(kind: string): void;
  22197. /**
  22198. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22199. * @param buffer defines the vertex buffer to use
  22200. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22201. */
  22202. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22203. /**
  22204. * Update a specific vertex buffer
  22205. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22206. * It will do nothing if the buffer is not updatable
  22207. * @param kind defines the data kind (Position, normal, etc...)
  22208. * @param data defines the data to use
  22209. * @param offset defines the offset in the target buffer where to store the data
  22210. * @param useBytes set to true if the offset is in bytes
  22211. */
  22212. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22213. /**
  22214. * Update a specific vertex buffer
  22215. * This function will create a new buffer if the current one is not updatable
  22216. * @param kind defines the data kind (Position, normal, etc...)
  22217. * @param data defines the data to use
  22218. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22219. */
  22220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22221. private _updateBoundingInfo;
  22222. /** @hidden */
  22223. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22224. /**
  22225. * Gets total number of vertices
  22226. * @returns the total number of vertices
  22227. */
  22228. getTotalVertices(): number;
  22229. /**
  22230. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22231. * @param kind defines the data kind (Position, normal, etc...)
  22232. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22234. * @returns a float array containing vertex data
  22235. */
  22236. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22237. /**
  22238. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22239. * @param kind defines the data kind (Position, normal, etc...)
  22240. * @returns true if the vertex buffer with the specified kind is updatable
  22241. */
  22242. isVertexBufferUpdatable(kind: string): boolean;
  22243. /**
  22244. * Gets a specific vertex buffer
  22245. * @param kind defines the data kind (Position, normal, etc...)
  22246. * @returns a VertexBuffer
  22247. */
  22248. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22249. /**
  22250. * Returns all vertex buffers
  22251. * @return an object holding all vertex buffers indexed by kind
  22252. */
  22253. getVertexBuffers(): Nullable<{
  22254. [key: string]: VertexBuffer;
  22255. }>;
  22256. /**
  22257. * Gets a boolean indicating if specific vertex buffer is present
  22258. * @param kind defines the data kind (Position, normal, etc...)
  22259. * @returns true if data is present
  22260. */
  22261. isVerticesDataPresent(kind: string): boolean;
  22262. /**
  22263. * Gets a list of all attached data kinds (Position, normal, etc...)
  22264. * @returns a list of string containing all kinds
  22265. */
  22266. getVerticesDataKinds(): string[];
  22267. /**
  22268. * Update index buffer
  22269. * @param indices defines the indices to store in the index buffer
  22270. * @param offset defines the offset in the target buffer where to store the data
  22271. * @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)
  22272. */
  22273. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22274. /**
  22275. * Creates a new index buffer
  22276. * @param indices defines the indices to store in the index buffer
  22277. * @param totalVertices defines the total number of vertices (could be null)
  22278. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22279. */
  22280. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22281. /**
  22282. * Return the total number of indices
  22283. * @returns the total number of indices
  22284. */
  22285. getTotalIndices(): number;
  22286. /**
  22287. * Gets the index buffer array
  22288. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22289. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22290. * @returns the index buffer array
  22291. */
  22292. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22293. /**
  22294. * Gets the index buffer
  22295. * @return the index buffer
  22296. */
  22297. getIndexBuffer(): Nullable<DataBuffer>;
  22298. /** @hidden */
  22299. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22300. /**
  22301. * Release the associated resources for a specific mesh
  22302. * @param mesh defines the source mesh
  22303. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22304. */
  22305. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22306. /**
  22307. * Apply current geometry to a given mesh
  22308. * @param mesh defines the mesh to apply geometry to
  22309. */
  22310. applyToMesh(mesh: Mesh): void;
  22311. private _updateExtend;
  22312. private _applyToMesh;
  22313. private notifyUpdate;
  22314. /**
  22315. * Load the geometry if it was flagged as delay loaded
  22316. * @param scene defines the hosting scene
  22317. * @param onLoaded defines a callback called when the geometry is loaded
  22318. */
  22319. load(scene: Scene, onLoaded?: () => void): void;
  22320. private _queueLoad;
  22321. /**
  22322. * Invert the geometry to move from a right handed system to a left handed one.
  22323. */
  22324. toLeftHanded(): void;
  22325. /** @hidden */
  22326. _resetPointsArrayCache(): void;
  22327. /** @hidden */
  22328. _generatePointsArray(): boolean;
  22329. /**
  22330. * Gets a value indicating if the geometry is disposed
  22331. * @returns true if the geometry was disposed
  22332. */
  22333. isDisposed(): boolean;
  22334. private _disposeVertexArrayObjects;
  22335. /**
  22336. * Free all associated resources
  22337. */
  22338. dispose(): void;
  22339. /**
  22340. * Clone the current geometry into a new geometry
  22341. * @param id defines the unique ID of the new geometry
  22342. * @returns a new geometry object
  22343. */
  22344. copy(id: string): Geometry;
  22345. /**
  22346. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22347. * @return a JSON representation of the current geometry data (without the vertices data)
  22348. */
  22349. serialize(): any;
  22350. private toNumberArray;
  22351. /**
  22352. * Serialize all vertices data into a JSON oject
  22353. * @returns a JSON representation of the current geometry data
  22354. */
  22355. serializeVerticeData(): any;
  22356. /**
  22357. * Extracts a clone of a mesh geometry
  22358. * @param mesh defines the source mesh
  22359. * @param id defines the unique ID of the new geometry object
  22360. * @returns the new geometry object
  22361. */
  22362. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22363. /**
  22364. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22365. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22366. * Be aware Math.random() could cause collisions, but:
  22367. * "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"
  22368. * @returns a string containing a new GUID
  22369. */
  22370. static RandomId(): string;
  22371. /** @hidden */
  22372. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22373. private static _CleanMatricesWeights;
  22374. /**
  22375. * Create a new geometry from persisted data (Using .babylon file format)
  22376. * @param parsedVertexData defines the persisted data
  22377. * @param scene defines the hosting scene
  22378. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22379. * @returns the new geometry object
  22380. */
  22381. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22382. }
  22383. }
  22384. declare module BABYLON {
  22385. /**
  22386. * Define an interface for all classes that will get and set the data on vertices
  22387. */
  22388. export interface IGetSetVerticesData {
  22389. /**
  22390. * Gets a boolean indicating if specific vertex data is present
  22391. * @param kind defines the vertex data kind to use
  22392. * @returns true is data kind is present
  22393. */
  22394. isVerticesDataPresent(kind: string): boolean;
  22395. /**
  22396. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22397. * @param kind defines the data kind (Position, normal, etc...)
  22398. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22399. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22400. * @returns a float array containing vertex data
  22401. */
  22402. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22403. /**
  22404. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22405. * @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.
  22406. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22407. * @returns the indices array or an empty array if the mesh has no geometry
  22408. */
  22409. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22410. /**
  22411. * Set specific vertex data
  22412. * @param kind defines the data kind (Position, normal, etc...)
  22413. * @param data defines the vertex data to use
  22414. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22415. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22416. */
  22417. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22418. /**
  22419. * Update a specific associated vertex buffer
  22420. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22421. * - VertexBuffer.PositionKind
  22422. * - VertexBuffer.UVKind
  22423. * - VertexBuffer.UV2Kind
  22424. * - VertexBuffer.UV3Kind
  22425. * - VertexBuffer.UV4Kind
  22426. * - VertexBuffer.UV5Kind
  22427. * - VertexBuffer.UV6Kind
  22428. * - VertexBuffer.ColorKind
  22429. * - VertexBuffer.MatricesIndicesKind
  22430. * - VertexBuffer.MatricesIndicesExtraKind
  22431. * - VertexBuffer.MatricesWeightsKind
  22432. * - VertexBuffer.MatricesWeightsExtraKind
  22433. * @param data defines the data source
  22434. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22435. * @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)
  22436. */
  22437. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22438. /**
  22439. * Creates a new index buffer
  22440. * @param indices defines the indices to store in the index buffer
  22441. * @param totalVertices defines the total number of vertices (could be null)
  22442. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22443. */
  22444. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22445. }
  22446. /**
  22447. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22448. */
  22449. export class VertexData {
  22450. /**
  22451. * Mesh side orientation : usually the external or front surface
  22452. */
  22453. static readonly FRONTSIDE: number;
  22454. /**
  22455. * Mesh side orientation : usually the internal or back surface
  22456. */
  22457. static readonly BACKSIDE: number;
  22458. /**
  22459. * Mesh side orientation : both internal and external or front and back surfaces
  22460. */
  22461. static readonly DOUBLESIDE: number;
  22462. /**
  22463. * Mesh side orientation : by default, `FRONTSIDE`
  22464. */
  22465. static readonly DEFAULTSIDE: number;
  22466. /**
  22467. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22468. */
  22469. positions: Nullable<FloatArray>;
  22470. /**
  22471. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22472. */
  22473. normals: Nullable<FloatArray>;
  22474. /**
  22475. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22476. */
  22477. tangents: Nullable<FloatArray>;
  22478. /**
  22479. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22480. */
  22481. uvs: Nullable<FloatArray>;
  22482. /**
  22483. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22484. */
  22485. uvs2: Nullable<FloatArray>;
  22486. /**
  22487. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22488. */
  22489. uvs3: Nullable<FloatArray>;
  22490. /**
  22491. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22492. */
  22493. uvs4: Nullable<FloatArray>;
  22494. /**
  22495. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22496. */
  22497. uvs5: Nullable<FloatArray>;
  22498. /**
  22499. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22500. */
  22501. uvs6: Nullable<FloatArray>;
  22502. /**
  22503. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22504. */
  22505. colors: Nullable<FloatArray>;
  22506. /**
  22507. * 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).
  22508. */
  22509. matricesIndices: Nullable<FloatArray>;
  22510. /**
  22511. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22512. */
  22513. matricesWeights: Nullable<FloatArray>;
  22514. /**
  22515. * An array extending the number of possible indices
  22516. */
  22517. matricesIndicesExtra: Nullable<FloatArray>;
  22518. /**
  22519. * An array extending the number of possible weights when the number of indices is extended
  22520. */
  22521. matricesWeightsExtra: Nullable<FloatArray>;
  22522. /**
  22523. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22524. */
  22525. indices: Nullable<IndicesArray>;
  22526. /**
  22527. * Uses the passed data array to set the set the values for the specified kind of data
  22528. * @param data a linear array of floating numbers
  22529. * @param kind the type of data that is being set, eg positions, colors etc
  22530. */
  22531. set(data: FloatArray, kind: string): void;
  22532. /**
  22533. * Associates the vertexData to the passed Mesh.
  22534. * Sets it as updatable or not (default `false`)
  22535. * @param mesh the mesh the vertexData is applied to
  22536. * @param updatable when used and having the value true allows new data to update the vertexData
  22537. * @returns the VertexData
  22538. */
  22539. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22540. /**
  22541. * Associates the vertexData to the passed Geometry.
  22542. * Sets it as updatable or not (default `false`)
  22543. * @param geometry the geometry the vertexData is applied to
  22544. * @param updatable when used and having the value true allows new data to update the vertexData
  22545. * @returns VertexData
  22546. */
  22547. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22548. /**
  22549. * Updates the associated mesh
  22550. * @param mesh the mesh to be updated
  22551. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22552. * @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
  22553. * @returns VertexData
  22554. */
  22555. updateMesh(mesh: Mesh): VertexData;
  22556. /**
  22557. * Updates the associated geometry
  22558. * @param geometry the geometry to be updated
  22559. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22560. * @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
  22561. * @returns VertexData.
  22562. */
  22563. updateGeometry(geometry: Geometry): VertexData;
  22564. private _applyTo;
  22565. private _update;
  22566. /**
  22567. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22568. * @param matrix the transforming matrix
  22569. * @returns the VertexData
  22570. */
  22571. transform(matrix: Matrix): VertexData;
  22572. /**
  22573. * Merges the passed VertexData into the current one
  22574. * @param other the VertexData to be merged into the current one
  22575. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22576. * @returns the modified VertexData
  22577. */
  22578. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22579. private _mergeElement;
  22580. private _validate;
  22581. /**
  22582. * Serializes the VertexData
  22583. * @returns a serialized object
  22584. */
  22585. serialize(): any;
  22586. /**
  22587. * Extracts the vertexData from a mesh
  22588. * @param mesh the mesh from which to extract the VertexData
  22589. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22590. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22591. * @returns the object VertexData associated to the passed mesh
  22592. */
  22593. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22594. /**
  22595. * Extracts the vertexData from the geometry
  22596. * @param geometry the geometry from which to extract the VertexData
  22597. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22598. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22599. * @returns the object VertexData associated to the passed mesh
  22600. */
  22601. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22602. private static _ExtractFrom;
  22603. /**
  22604. * Creates the VertexData for a Ribbon
  22605. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22606. * * pathArray array of paths, each of which an array of successive Vector3
  22607. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22608. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22609. * * 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
  22610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22611. * * 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)
  22612. * * 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)
  22613. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22614. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22615. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22616. * @returns the VertexData of the ribbon
  22617. */
  22618. static CreateRibbon(options: {
  22619. pathArray: Vector3[][];
  22620. closeArray?: boolean;
  22621. closePath?: boolean;
  22622. offset?: number;
  22623. sideOrientation?: number;
  22624. frontUVs?: Vector4;
  22625. backUVs?: Vector4;
  22626. invertUV?: boolean;
  22627. uvs?: Vector2[];
  22628. colors?: Color4[];
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a box
  22632. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22633. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22634. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22635. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22636. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22637. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22638. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22639. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22640. * * 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)
  22641. * * 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)
  22642. * @returns the VertexData of the box
  22643. */
  22644. static CreateBox(options: {
  22645. size?: number;
  22646. width?: number;
  22647. height?: number;
  22648. depth?: number;
  22649. faceUV?: Vector4[];
  22650. faceColors?: Color4[];
  22651. sideOrientation?: number;
  22652. frontUVs?: Vector4;
  22653. backUVs?: Vector4;
  22654. }): VertexData;
  22655. /**
  22656. * Creates the VertexData for a tiled box
  22657. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22658. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22659. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22660. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22662. * @returns the VertexData of the box
  22663. */
  22664. static CreateTiledBox(options: {
  22665. pattern?: number;
  22666. width?: number;
  22667. height?: number;
  22668. depth?: number;
  22669. tileSize?: number;
  22670. tileWidth?: number;
  22671. tileHeight?: number;
  22672. alignHorizontal?: number;
  22673. alignVertical?: number;
  22674. faceUV?: Vector4[];
  22675. faceColors?: Color4[];
  22676. sideOrientation?: number;
  22677. }): VertexData;
  22678. /**
  22679. * Creates the VertexData for a tiled plane
  22680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22681. * * pattern a limited pattern arrangement depending on the number
  22682. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22683. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22684. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22686. * * 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)
  22687. * * 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)
  22688. * @returns the VertexData of the tiled plane
  22689. */
  22690. static CreateTiledPlane(options: {
  22691. pattern?: number;
  22692. tileSize?: number;
  22693. tileWidth?: number;
  22694. tileHeight?: number;
  22695. size?: number;
  22696. width?: number;
  22697. height?: number;
  22698. alignHorizontal?: number;
  22699. alignVertical?: number;
  22700. sideOrientation?: number;
  22701. frontUVs?: Vector4;
  22702. backUVs?: Vector4;
  22703. }): VertexData;
  22704. /**
  22705. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22706. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22707. * * segments sets the number of horizontal strips optional, default 32
  22708. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22709. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22710. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22711. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22712. * * 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
  22713. * * 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
  22714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22715. * * 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)
  22716. * * 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)
  22717. * @returns the VertexData of the ellipsoid
  22718. */
  22719. static CreateSphere(options: {
  22720. segments?: number;
  22721. diameter?: number;
  22722. diameterX?: number;
  22723. diameterY?: number;
  22724. diameterZ?: number;
  22725. arc?: number;
  22726. slice?: number;
  22727. sideOrientation?: number;
  22728. frontUVs?: Vector4;
  22729. backUVs?: Vector4;
  22730. }): VertexData;
  22731. /**
  22732. * Creates the VertexData for a cylinder, cone or prism
  22733. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22734. * * height sets the height (y direction) of the cylinder, optional, default 2
  22735. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22736. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22737. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22738. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22739. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22740. * * 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
  22741. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22742. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22743. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22744. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22745. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22746. * * 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)
  22747. * * 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)
  22748. * @returns the VertexData of the cylinder, cone or prism
  22749. */
  22750. static CreateCylinder(options: {
  22751. height?: number;
  22752. diameterTop?: number;
  22753. diameterBottom?: number;
  22754. diameter?: number;
  22755. tessellation?: number;
  22756. subdivisions?: number;
  22757. arc?: number;
  22758. faceColors?: Color4[];
  22759. faceUV?: Vector4[];
  22760. hasRings?: boolean;
  22761. enclose?: boolean;
  22762. sideOrientation?: number;
  22763. frontUVs?: Vector4;
  22764. backUVs?: Vector4;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a torus
  22768. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22769. * * diameter the diameter of the torus, optional default 1
  22770. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22771. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the torus
  22776. */
  22777. static CreateTorus(options: {
  22778. diameter?: number;
  22779. thickness?: number;
  22780. tessellation?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the LineSystem
  22787. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22788. * - lines an array of lines, each line being an array of successive Vector3
  22789. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22790. * @returns the VertexData of the LineSystem
  22791. */
  22792. static CreateLineSystem(options: {
  22793. lines: Vector3[][];
  22794. colors?: Nullable<Color4[][]>;
  22795. }): VertexData;
  22796. /**
  22797. * Create the VertexData for a DashedLines
  22798. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22799. * - points an array successive Vector3
  22800. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22801. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22802. * - dashNb the intended total number of dashes, optional, default 200
  22803. * @returns the VertexData for the DashedLines
  22804. */
  22805. static CreateDashedLines(options: {
  22806. points: Vector3[];
  22807. dashSize?: number;
  22808. gapSize?: number;
  22809. dashNb?: number;
  22810. }): VertexData;
  22811. /**
  22812. * Creates the VertexData for a Ground
  22813. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22814. * - width the width (x direction) of the ground, optional, default 1
  22815. * - height the height (z direction) of the ground, optional, default 1
  22816. * - subdivisions the number of subdivisions per side, optional, default 1
  22817. * @returns the VertexData of the Ground
  22818. */
  22819. static CreateGround(options: {
  22820. width?: number;
  22821. height?: number;
  22822. subdivisions?: number;
  22823. subdivisionsX?: number;
  22824. subdivisionsY?: number;
  22825. }): VertexData;
  22826. /**
  22827. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22828. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22829. * * xmin the ground minimum X coordinate, optional, default -1
  22830. * * zmin the ground minimum Z coordinate, optional, default -1
  22831. * * xmax the ground maximum X coordinate, optional, default 1
  22832. * * zmax the ground maximum Z coordinate, optional, default 1
  22833. * * 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}
  22834. * * 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}
  22835. * @returns the VertexData of the TiledGround
  22836. */
  22837. static CreateTiledGround(options: {
  22838. xmin: number;
  22839. zmin: number;
  22840. xmax: number;
  22841. zmax: number;
  22842. subdivisions?: {
  22843. w: number;
  22844. h: number;
  22845. };
  22846. precision?: {
  22847. w: number;
  22848. h: number;
  22849. };
  22850. }): VertexData;
  22851. /**
  22852. * Creates the VertexData of the Ground designed from a heightmap
  22853. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22854. * * width the width (x direction) of the ground
  22855. * * height the height (z direction) of the ground
  22856. * * subdivisions the number of subdivisions per side
  22857. * * minHeight the minimum altitude on the ground, optional, default 0
  22858. * * maxHeight the maximum altitude on the ground, optional default 1
  22859. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22860. * * buffer the array holding the image color data
  22861. * * bufferWidth the width of image
  22862. * * bufferHeight the height of image
  22863. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22864. * @returns the VertexData of the Ground designed from a heightmap
  22865. */
  22866. static CreateGroundFromHeightMap(options: {
  22867. width: number;
  22868. height: number;
  22869. subdivisions: number;
  22870. minHeight: number;
  22871. maxHeight: number;
  22872. colorFilter: Color3;
  22873. buffer: Uint8Array;
  22874. bufferWidth: number;
  22875. bufferHeight: number;
  22876. alphaFilter: number;
  22877. }): VertexData;
  22878. /**
  22879. * Creates the VertexData for a Plane
  22880. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22881. * * size sets the width and height of the plane to the value of size, optional default 1
  22882. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22883. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the box
  22888. */
  22889. static CreatePlane(options: {
  22890. size?: number;
  22891. width?: number;
  22892. height?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. }): VertexData;
  22897. /**
  22898. * Creates the VertexData of the Disc or regular Polygon
  22899. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22900. * * radius the radius of the disc, optional default 0.5
  22901. * * tessellation the number of polygon sides, optional, default 64
  22902. * * 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
  22903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22904. * * 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)
  22905. * * 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)
  22906. * @returns the VertexData of the box
  22907. */
  22908. static CreateDisc(options: {
  22909. radius?: number;
  22910. tessellation?: number;
  22911. arc?: number;
  22912. sideOrientation?: number;
  22913. frontUVs?: Vector4;
  22914. backUVs?: Vector4;
  22915. }): VertexData;
  22916. /**
  22917. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22918. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22919. * @param polygon a mesh built from polygonTriangulation.build()
  22920. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22921. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22922. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22923. * @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)
  22924. * @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)
  22925. * @returns the VertexData of the Polygon
  22926. */
  22927. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22928. /**
  22929. * Creates the VertexData of the IcoSphere
  22930. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22931. * * radius the radius of the IcoSphere, optional default 1
  22932. * * radiusX allows stretching in the x direction, optional, default radius
  22933. * * radiusY allows stretching in the y direction, optional, default radius
  22934. * * radiusZ allows stretching in the z direction, optional, default radius
  22935. * * flat when true creates a flat shaded mesh, optional, default true
  22936. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22938. * * 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)
  22939. * * 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)
  22940. * @returns the VertexData of the IcoSphere
  22941. */
  22942. static CreateIcoSphere(options: {
  22943. radius?: number;
  22944. radiusX?: number;
  22945. radiusY?: number;
  22946. radiusZ?: number;
  22947. flat?: boolean;
  22948. subdivisions?: number;
  22949. sideOrientation?: number;
  22950. frontUVs?: Vector4;
  22951. backUVs?: Vector4;
  22952. }): VertexData;
  22953. /**
  22954. * Creates the VertexData for a Polyhedron
  22955. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22956. * * type provided types are:
  22957. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22958. * * 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)
  22959. * * size the size of the IcoSphere, optional default 1
  22960. * * sizeX allows stretching in the x direction, optional, default size
  22961. * * sizeY allows stretching in the y direction, optional, default size
  22962. * * sizeZ allows stretching in the z direction, optional, default size
  22963. * * 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
  22964. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22965. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22966. * * flat when true creates a flat shaded mesh, optional, default true
  22967. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22968. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22969. * * 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)
  22970. * * 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)
  22971. * @returns the VertexData of the Polyhedron
  22972. */
  22973. static CreatePolyhedron(options: {
  22974. type?: number;
  22975. size?: number;
  22976. sizeX?: number;
  22977. sizeY?: number;
  22978. sizeZ?: number;
  22979. custom?: any;
  22980. faceUV?: Vector4[];
  22981. faceColors?: Color4[];
  22982. flat?: boolean;
  22983. sideOrientation?: number;
  22984. frontUVs?: Vector4;
  22985. backUVs?: Vector4;
  22986. }): VertexData;
  22987. /**
  22988. * Creates the VertexData for a TorusKnot
  22989. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22990. * * radius the radius of the torus knot, optional, default 2
  22991. * * tube the thickness of the tube, optional, default 0.5
  22992. * * radialSegments the number of sides on each tube segments, optional, default 32
  22993. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22994. * * p the number of windings around the z axis, optional, default 2
  22995. * * q the number of windings around the x axis, optional, default 3
  22996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22997. * * 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)
  22998. * * 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)
  22999. * @returns the VertexData of the Torus Knot
  23000. */
  23001. static CreateTorusKnot(options: {
  23002. radius?: number;
  23003. tube?: number;
  23004. radialSegments?: number;
  23005. tubularSegments?: number;
  23006. p?: number;
  23007. q?: number;
  23008. sideOrientation?: number;
  23009. frontUVs?: Vector4;
  23010. backUVs?: Vector4;
  23011. }): VertexData;
  23012. /**
  23013. * Compute normals for given positions and indices
  23014. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23015. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23016. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23017. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23018. * * facetNormals : optional array of facet normals (vector3)
  23019. * * facetPositions : optional array of facet positions (vector3)
  23020. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23021. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23022. * * bInfo : optional bounding info, required for facetPartitioning computation
  23023. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23024. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23025. * * useRightHandedSystem: optional boolean to for right handed system computation
  23026. * * depthSort : optional boolean to enable the facet depth sort computation
  23027. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23028. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23029. */
  23030. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23031. facetNormals?: any;
  23032. facetPositions?: any;
  23033. facetPartitioning?: any;
  23034. ratio?: number;
  23035. bInfo?: any;
  23036. bbSize?: Vector3;
  23037. subDiv?: any;
  23038. useRightHandedSystem?: boolean;
  23039. depthSort?: boolean;
  23040. distanceTo?: Vector3;
  23041. depthSortedFacets?: any;
  23042. }): void;
  23043. /** @hidden */
  23044. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23045. /**
  23046. * Applies VertexData created from the imported parameters to the geometry
  23047. * @param parsedVertexData the parsed data from an imported file
  23048. * @param geometry the geometry to apply the VertexData to
  23049. */
  23050. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23051. }
  23052. }
  23053. declare module BABYLON {
  23054. /**
  23055. * Defines a target to use with MorphTargetManager
  23056. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23057. */
  23058. export class MorphTarget implements IAnimatable {
  23059. /** defines the name of the target */
  23060. name: string;
  23061. /**
  23062. * Gets or sets the list of animations
  23063. */
  23064. animations: Animation[];
  23065. private _scene;
  23066. private _positions;
  23067. private _normals;
  23068. private _tangents;
  23069. private _uvs;
  23070. private _influence;
  23071. private _uniqueId;
  23072. /**
  23073. * Observable raised when the influence changes
  23074. */
  23075. onInfluenceChanged: Observable<boolean>;
  23076. /** @hidden */
  23077. _onDataLayoutChanged: Observable<void>;
  23078. /**
  23079. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23080. */
  23081. get influence(): number;
  23082. set influence(influence: number);
  23083. /**
  23084. * Gets or sets the id of the morph Target
  23085. */
  23086. id: string;
  23087. private _animationPropertiesOverride;
  23088. /**
  23089. * Gets or sets the animation properties override
  23090. */
  23091. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23092. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23093. /**
  23094. * Creates a new MorphTarget
  23095. * @param name defines the name of the target
  23096. * @param influence defines the influence to use
  23097. * @param scene defines the scene the morphtarget belongs to
  23098. */
  23099. constructor(
  23100. /** defines the name of the target */
  23101. name: string, influence?: number, scene?: Nullable<Scene>);
  23102. /**
  23103. * Gets the unique ID of this manager
  23104. */
  23105. get uniqueId(): number;
  23106. /**
  23107. * Gets a boolean defining if the target contains position data
  23108. */
  23109. get hasPositions(): boolean;
  23110. /**
  23111. * Gets a boolean defining if the target contains normal data
  23112. */
  23113. get hasNormals(): boolean;
  23114. /**
  23115. * Gets a boolean defining if the target contains tangent data
  23116. */
  23117. get hasTangents(): boolean;
  23118. /**
  23119. * Gets a boolean defining if the target contains texture coordinates data
  23120. */
  23121. get hasUVs(): boolean;
  23122. /**
  23123. * Affects position data to this target
  23124. * @param data defines the position data to use
  23125. */
  23126. setPositions(data: Nullable<FloatArray>): void;
  23127. /**
  23128. * Gets the position data stored in this target
  23129. * @returns a FloatArray containing the position data (or null if not present)
  23130. */
  23131. getPositions(): Nullable<FloatArray>;
  23132. /**
  23133. * Affects normal data to this target
  23134. * @param data defines the normal data to use
  23135. */
  23136. setNormals(data: Nullable<FloatArray>): void;
  23137. /**
  23138. * Gets the normal data stored in this target
  23139. * @returns a FloatArray containing the normal data (or null if not present)
  23140. */
  23141. getNormals(): Nullable<FloatArray>;
  23142. /**
  23143. * Affects tangent data to this target
  23144. * @param data defines the tangent data to use
  23145. */
  23146. setTangents(data: Nullable<FloatArray>): void;
  23147. /**
  23148. * Gets the tangent data stored in this target
  23149. * @returns a FloatArray containing the tangent data (or null if not present)
  23150. */
  23151. getTangents(): Nullable<FloatArray>;
  23152. /**
  23153. * Affects texture coordinates data to this target
  23154. * @param data defines the texture coordinates data to use
  23155. */
  23156. setUVs(data: Nullable<FloatArray>): void;
  23157. /**
  23158. * Gets the texture coordinates data stored in this target
  23159. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23160. */
  23161. getUVs(): Nullable<FloatArray>;
  23162. /**
  23163. * Clone the current target
  23164. * @returns a new MorphTarget
  23165. */
  23166. clone(): MorphTarget;
  23167. /**
  23168. * Serializes the current target into a Serialization object
  23169. * @returns the serialized object
  23170. */
  23171. serialize(): any;
  23172. /**
  23173. * Returns the string "MorphTarget"
  23174. * @returns "MorphTarget"
  23175. */
  23176. getClassName(): string;
  23177. /**
  23178. * Creates a new target from serialized data
  23179. * @param serializationObject defines the serialized data to use
  23180. * @returns a new MorphTarget
  23181. */
  23182. static Parse(serializationObject: any): MorphTarget;
  23183. /**
  23184. * Creates a MorphTarget from mesh data
  23185. * @param mesh defines the source mesh
  23186. * @param name defines the name to use for the new target
  23187. * @param influence defines the influence to attach to the target
  23188. * @returns a new MorphTarget
  23189. */
  23190. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23191. }
  23192. }
  23193. declare module BABYLON {
  23194. /**
  23195. * This class is used to deform meshes using morphing between different targets
  23196. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23197. */
  23198. export class MorphTargetManager {
  23199. private _targets;
  23200. private _targetInfluenceChangedObservers;
  23201. private _targetDataLayoutChangedObservers;
  23202. private _activeTargets;
  23203. private _scene;
  23204. private _influences;
  23205. private _supportsNormals;
  23206. private _supportsTangents;
  23207. private _supportsUVs;
  23208. private _vertexCount;
  23209. private _uniqueId;
  23210. private _tempInfluences;
  23211. /**
  23212. * Gets or sets a boolean indicating if normals must be morphed
  23213. */
  23214. enableNormalMorphing: boolean;
  23215. /**
  23216. * Gets or sets a boolean indicating if tangents must be morphed
  23217. */
  23218. enableTangentMorphing: boolean;
  23219. /**
  23220. * Gets or sets a boolean indicating if UV must be morphed
  23221. */
  23222. enableUVMorphing: boolean;
  23223. /**
  23224. * Creates a new MorphTargetManager
  23225. * @param scene defines the current scene
  23226. */
  23227. constructor(scene?: Nullable<Scene>);
  23228. /**
  23229. * Gets the unique ID of this manager
  23230. */
  23231. get uniqueId(): number;
  23232. /**
  23233. * Gets the number of vertices handled by this manager
  23234. */
  23235. get vertexCount(): number;
  23236. /**
  23237. * Gets a boolean indicating if this manager supports morphing of normals
  23238. */
  23239. get supportsNormals(): boolean;
  23240. /**
  23241. * Gets a boolean indicating if this manager supports morphing of tangents
  23242. */
  23243. get supportsTangents(): boolean;
  23244. /**
  23245. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23246. */
  23247. get supportsUVs(): boolean;
  23248. /**
  23249. * Gets the number of targets stored in this manager
  23250. */
  23251. get numTargets(): number;
  23252. /**
  23253. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23254. */
  23255. get numInfluencers(): number;
  23256. /**
  23257. * Gets the list of influences (one per target)
  23258. */
  23259. get influences(): Float32Array;
  23260. /**
  23261. * Gets the active target at specified index. An active target is a target with an influence > 0
  23262. * @param index defines the index to check
  23263. * @returns the requested target
  23264. */
  23265. getActiveTarget(index: number): MorphTarget;
  23266. /**
  23267. * Gets the target at specified index
  23268. * @param index defines the index to check
  23269. * @returns the requested target
  23270. */
  23271. getTarget(index: number): MorphTarget;
  23272. /**
  23273. * Add a new target to this manager
  23274. * @param target defines the target to add
  23275. */
  23276. addTarget(target: MorphTarget): void;
  23277. /**
  23278. * Removes a target from the manager
  23279. * @param target defines the target to remove
  23280. */
  23281. removeTarget(target: MorphTarget): void;
  23282. /**
  23283. * Clone the current manager
  23284. * @returns a new MorphTargetManager
  23285. */
  23286. clone(): MorphTargetManager;
  23287. /**
  23288. * Serializes the current manager into a Serialization object
  23289. * @returns the serialized object
  23290. */
  23291. serialize(): any;
  23292. private _syncActiveTargets;
  23293. /**
  23294. * Syncrhonize the targets with all the meshes using this morph target manager
  23295. */
  23296. synchronize(): void;
  23297. /**
  23298. * Creates a new MorphTargetManager from serialized data
  23299. * @param serializationObject defines the serialized data
  23300. * @param scene defines the hosting scene
  23301. * @returns the new MorphTargetManager
  23302. */
  23303. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23304. }
  23305. }
  23306. declare module BABYLON {
  23307. /**
  23308. * Class used to represent a specific level of detail of a mesh
  23309. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23310. */
  23311. export class MeshLODLevel {
  23312. /** Defines the distance where this level should start being displayed */
  23313. distance: number;
  23314. /** Defines the mesh to use to render this level */
  23315. mesh: Nullable<Mesh>;
  23316. /**
  23317. * Creates a new LOD level
  23318. * @param distance defines the distance where this level should star being displayed
  23319. * @param mesh defines the mesh to use to render this level
  23320. */
  23321. constructor(
  23322. /** Defines the distance where this level should start being displayed */
  23323. distance: number,
  23324. /** Defines the mesh to use to render this level */
  23325. mesh: Nullable<Mesh>);
  23326. }
  23327. }
  23328. declare module BABYLON {
  23329. /**
  23330. * Mesh representing the gorund
  23331. */
  23332. export class GroundMesh extends Mesh {
  23333. /** If octree should be generated */
  23334. generateOctree: boolean;
  23335. private _heightQuads;
  23336. /** @hidden */
  23337. _subdivisionsX: number;
  23338. /** @hidden */
  23339. _subdivisionsY: number;
  23340. /** @hidden */
  23341. _width: number;
  23342. /** @hidden */
  23343. _height: number;
  23344. /** @hidden */
  23345. _minX: number;
  23346. /** @hidden */
  23347. _maxX: number;
  23348. /** @hidden */
  23349. _minZ: number;
  23350. /** @hidden */
  23351. _maxZ: number;
  23352. constructor(name: string, scene: Scene);
  23353. /**
  23354. * "GroundMesh"
  23355. * @returns "GroundMesh"
  23356. */
  23357. getClassName(): string;
  23358. /**
  23359. * The minimum of x and y subdivisions
  23360. */
  23361. get subdivisions(): number;
  23362. /**
  23363. * X subdivisions
  23364. */
  23365. get subdivisionsX(): number;
  23366. /**
  23367. * Y subdivisions
  23368. */
  23369. get subdivisionsY(): number;
  23370. /**
  23371. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23372. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23373. * @param chunksCount the number of subdivisions for x and y
  23374. * @param octreeBlocksSize (Default: 32)
  23375. */
  23376. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23377. /**
  23378. * Returns a height (y) value in the Worl system :
  23379. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23380. * @param x x coordinate
  23381. * @param z z coordinate
  23382. * @returns the ground y position if (x, z) are outside the ground surface.
  23383. */
  23384. getHeightAtCoordinates(x: number, z: number): number;
  23385. /**
  23386. * Returns a normalized vector (Vector3) orthogonal to the ground
  23387. * at the ground coordinates (x, z) expressed in the World system.
  23388. * @param x x coordinate
  23389. * @param z z coordinate
  23390. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23391. */
  23392. getNormalAtCoordinates(x: number, z: number): Vector3;
  23393. /**
  23394. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23395. * at the ground coordinates (x, z) expressed in the World system.
  23396. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23397. * @param x x coordinate
  23398. * @param z z coordinate
  23399. * @param ref vector to store the result
  23400. * @returns the GroundMesh.
  23401. */
  23402. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23403. /**
  23404. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23405. * if the ground has been updated.
  23406. * This can be used in the render loop.
  23407. * @returns the GroundMesh.
  23408. */
  23409. updateCoordinateHeights(): GroundMesh;
  23410. private _getFacetAt;
  23411. private _initHeightQuads;
  23412. private _computeHeightQuads;
  23413. /**
  23414. * Serializes this ground mesh
  23415. * @param serializationObject object to write serialization to
  23416. */
  23417. serialize(serializationObject: any): void;
  23418. /**
  23419. * Parses a serialized ground mesh
  23420. * @param parsedMesh the serialized mesh
  23421. * @param scene the scene to create the ground mesh in
  23422. * @returns the created ground mesh
  23423. */
  23424. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23425. }
  23426. }
  23427. declare module BABYLON {
  23428. /**
  23429. * Interface for Physics-Joint data
  23430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23431. */
  23432. export interface PhysicsJointData {
  23433. /**
  23434. * The main pivot of the joint
  23435. */
  23436. mainPivot?: Vector3;
  23437. /**
  23438. * The connected pivot of the joint
  23439. */
  23440. connectedPivot?: Vector3;
  23441. /**
  23442. * The main axis of the joint
  23443. */
  23444. mainAxis?: Vector3;
  23445. /**
  23446. * The connected axis of the joint
  23447. */
  23448. connectedAxis?: Vector3;
  23449. /**
  23450. * The collision of the joint
  23451. */
  23452. collision?: boolean;
  23453. /**
  23454. * Native Oimo/Cannon/Energy data
  23455. */
  23456. nativeParams?: any;
  23457. }
  23458. /**
  23459. * This is a holder class for the physics joint created by the physics plugin
  23460. * It holds a set of functions to control the underlying joint
  23461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23462. */
  23463. export class PhysicsJoint {
  23464. /**
  23465. * The type of the physics joint
  23466. */
  23467. type: number;
  23468. /**
  23469. * The data for the physics joint
  23470. */
  23471. jointData: PhysicsJointData;
  23472. private _physicsJoint;
  23473. protected _physicsPlugin: IPhysicsEnginePlugin;
  23474. /**
  23475. * Initializes the physics joint
  23476. * @param type The type of the physics joint
  23477. * @param jointData The data for the physics joint
  23478. */
  23479. constructor(
  23480. /**
  23481. * The type of the physics joint
  23482. */
  23483. type: number,
  23484. /**
  23485. * The data for the physics joint
  23486. */
  23487. jointData: PhysicsJointData);
  23488. /**
  23489. * Gets the physics joint
  23490. */
  23491. get physicsJoint(): any;
  23492. /**
  23493. * Sets the physics joint
  23494. */
  23495. set physicsJoint(newJoint: any);
  23496. /**
  23497. * Sets the physics plugin
  23498. */
  23499. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23500. /**
  23501. * Execute a function that is physics-plugin specific.
  23502. * @param {Function} func the function that will be executed.
  23503. * It accepts two parameters: the physics world and the physics joint
  23504. */
  23505. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23506. /**
  23507. * Distance-Joint type
  23508. */
  23509. static DistanceJoint: number;
  23510. /**
  23511. * Hinge-Joint type
  23512. */
  23513. static HingeJoint: number;
  23514. /**
  23515. * Ball-and-Socket joint type
  23516. */
  23517. static BallAndSocketJoint: number;
  23518. /**
  23519. * Wheel-Joint type
  23520. */
  23521. static WheelJoint: number;
  23522. /**
  23523. * Slider-Joint type
  23524. */
  23525. static SliderJoint: number;
  23526. /**
  23527. * Prismatic-Joint type
  23528. */
  23529. static PrismaticJoint: number;
  23530. /**
  23531. * Universal-Joint type
  23532. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23533. */
  23534. static UniversalJoint: number;
  23535. /**
  23536. * Hinge-Joint 2 type
  23537. */
  23538. static Hinge2Joint: number;
  23539. /**
  23540. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23541. */
  23542. static PointToPointJoint: number;
  23543. /**
  23544. * Spring-Joint type
  23545. */
  23546. static SpringJoint: number;
  23547. /**
  23548. * Lock-Joint type
  23549. */
  23550. static LockJoint: number;
  23551. }
  23552. /**
  23553. * A class representing a physics distance joint
  23554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23555. */
  23556. export class DistanceJoint extends PhysicsJoint {
  23557. /**
  23558. *
  23559. * @param jointData The data for the Distance-Joint
  23560. */
  23561. constructor(jointData: DistanceJointData);
  23562. /**
  23563. * Update the predefined distance.
  23564. * @param maxDistance The maximum preferred distance
  23565. * @param minDistance The minimum preferred distance
  23566. */
  23567. updateDistance(maxDistance: number, minDistance?: number): void;
  23568. }
  23569. /**
  23570. * Represents a Motor-Enabled Joint
  23571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23572. */
  23573. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23574. /**
  23575. * Initializes the Motor-Enabled Joint
  23576. * @param type The type of the joint
  23577. * @param jointData The physica joint data for the joint
  23578. */
  23579. constructor(type: number, jointData: PhysicsJointData);
  23580. /**
  23581. * Set the motor values.
  23582. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23583. * @param force the force to apply
  23584. * @param maxForce max force for this motor.
  23585. */
  23586. setMotor(force?: number, maxForce?: number): void;
  23587. /**
  23588. * Set the motor's limits.
  23589. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23590. * @param upperLimit The upper limit of the motor
  23591. * @param lowerLimit The lower limit of the motor
  23592. */
  23593. setLimit(upperLimit: number, lowerLimit?: number): void;
  23594. }
  23595. /**
  23596. * This class represents a single physics Hinge-Joint
  23597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23598. */
  23599. export class HingeJoint extends MotorEnabledJoint {
  23600. /**
  23601. * Initializes the Hinge-Joint
  23602. * @param jointData The joint data for the Hinge-Joint
  23603. */
  23604. constructor(jointData: PhysicsJointData);
  23605. /**
  23606. * Set the motor values.
  23607. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23608. * @param {number} force the force to apply
  23609. * @param {number} maxForce max force for this motor.
  23610. */
  23611. setMotor(force?: number, maxForce?: number): void;
  23612. /**
  23613. * Set the motor's limits.
  23614. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23615. * @param upperLimit The upper limit of the motor
  23616. * @param lowerLimit The lower limit of the motor
  23617. */
  23618. setLimit(upperLimit: number, lowerLimit?: number): void;
  23619. }
  23620. /**
  23621. * This class represents a dual hinge physics joint (same as wheel joint)
  23622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23623. */
  23624. export class Hinge2Joint extends MotorEnabledJoint {
  23625. /**
  23626. * Initializes the Hinge2-Joint
  23627. * @param jointData The joint data for the Hinge2-Joint
  23628. */
  23629. constructor(jointData: PhysicsJointData);
  23630. /**
  23631. * Set the motor values.
  23632. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23633. * @param {number} targetSpeed the speed the motor is to reach
  23634. * @param {number} maxForce max force for this motor.
  23635. * @param {motorIndex} the motor's index, 0 or 1.
  23636. */
  23637. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23638. /**
  23639. * Set the motor limits.
  23640. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23641. * @param {number} upperLimit the upper limit
  23642. * @param {number} lowerLimit lower limit
  23643. * @param {motorIndex} the motor's index, 0 or 1.
  23644. */
  23645. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23646. }
  23647. /**
  23648. * Interface for a motor enabled joint
  23649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23650. */
  23651. export interface IMotorEnabledJoint {
  23652. /**
  23653. * Physics joint
  23654. */
  23655. physicsJoint: any;
  23656. /**
  23657. * Sets the motor of the motor-enabled joint
  23658. * @param force The force of the motor
  23659. * @param maxForce The maximum force of the motor
  23660. * @param motorIndex The index of the motor
  23661. */
  23662. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23663. /**
  23664. * Sets the limit of the motor
  23665. * @param upperLimit The upper limit of the motor
  23666. * @param lowerLimit The lower limit of the motor
  23667. * @param motorIndex The index of the motor
  23668. */
  23669. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23670. }
  23671. /**
  23672. * Joint data for a Distance-Joint
  23673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23674. */
  23675. export interface DistanceJointData extends PhysicsJointData {
  23676. /**
  23677. * Max distance the 2 joint objects can be apart
  23678. */
  23679. maxDistance: number;
  23680. }
  23681. /**
  23682. * Joint data from a spring joint
  23683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23684. */
  23685. export interface SpringJointData extends PhysicsJointData {
  23686. /**
  23687. * Length of the spring
  23688. */
  23689. length: number;
  23690. /**
  23691. * Stiffness of the spring
  23692. */
  23693. stiffness: number;
  23694. /**
  23695. * Damping of the spring
  23696. */
  23697. damping: number;
  23698. /** this callback will be called when applying the force to the impostors. */
  23699. forceApplicationCallback: () => void;
  23700. }
  23701. }
  23702. declare module BABYLON {
  23703. /**
  23704. * Holds the data for the raycast result
  23705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23706. */
  23707. export class PhysicsRaycastResult {
  23708. private _hasHit;
  23709. private _hitDistance;
  23710. private _hitNormalWorld;
  23711. private _hitPointWorld;
  23712. private _rayFromWorld;
  23713. private _rayToWorld;
  23714. /**
  23715. * Gets if there was a hit
  23716. */
  23717. get hasHit(): boolean;
  23718. /**
  23719. * Gets the distance from the hit
  23720. */
  23721. get hitDistance(): number;
  23722. /**
  23723. * Gets the hit normal/direction in the world
  23724. */
  23725. get hitNormalWorld(): Vector3;
  23726. /**
  23727. * Gets the hit point in the world
  23728. */
  23729. get hitPointWorld(): Vector3;
  23730. /**
  23731. * Gets the ray "start point" of the ray in the world
  23732. */
  23733. get rayFromWorld(): Vector3;
  23734. /**
  23735. * Gets the ray "end point" of the ray in the world
  23736. */
  23737. get rayToWorld(): Vector3;
  23738. /**
  23739. * Sets the hit data (normal & point in world space)
  23740. * @param hitNormalWorld defines the normal in world space
  23741. * @param hitPointWorld defines the point in world space
  23742. */
  23743. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23744. /**
  23745. * Sets the distance from the start point to the hit point
  23746. * @param distance
  23747. */
  23748. setHitDistance(distance: number): void;
  23749. /**
  23750. * Calculates the distance manually
  23751. */
  23752. calculateHitDistance(): void;
  23753. /**
  23754. * Resets all the values to default
  23755. * @param from The from point on world space
  23756. * @param to The to point on world space
  23757. */
  23758. reset(from?: Vector3, to?: Vector3): void;
  23759. }
  23760. /**
  23761. * Interface for the size containing width and height
  23762. */
  23763. interface IXYZ {
  23764. /**
  23765. * X
  23766. */
  23767. x: number;
  23768. /**
  23769. * Y
  23770. */
  23771. y: number;
  23772. /**
  23773. * Z
  23774. */
  23775. z: number;
  23776. }
  23777. }
  23778. declare module BABYLON {
  23779. /**
  23780. * Interface used to describe a physics joint
  23781. */
  23782. export interface PhysicsImpostorJoint {
  23783. /** Defines the main impostor to which the joint is linked */
  23784. mainImpostor: PhysicsImpostor;
  23785. /** Defines the impostor that is connected to the main impostor using this joint */
  23786. connectedImpostor: PhysicsImpostor;
  23787. /** Defines the joint itself */
  23788. joint: PhysicsJoint;
  23789. }
  23790. /** @hidden */
  23791. export interface IPhysicsEnginePlugin {
  23792. world: any;
  23793. name: string;
  23794. setGravity(gravity: Vector3): void;
  23795. setTimeStep(timeStep: number): void;
  23796. getTimeStep(): number;
  23797. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23798. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23799. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23800. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23801. removePhysicsBody(impostor: PhysicsImpostor): void;
  23802. generateJoint(joint: PhysicsImpostorJoint): void;
  23803. removeJoint(joint: PhysicsImpostorJoint): void;
  23804. isSupported(): boolean;
  23805. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23806. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23807. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23808. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23809. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23810. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23811. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23812. getBodyMass(impostor: PhysicsImpostor): number;
  23813. getBodyFriction(impostor: PhysicsImpostor): number;
  23814. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23815. getBodyRestitution(impostor: PhysicsImpostor): number;
  23816. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23817. getBodyPressure?(impostor: PhysicsImpostor): number;
  23818. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23819. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23820. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23821. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23822. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23823. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23824. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23825. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23826. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23827. sleepBody(impostor: PhysicsImpostor): void;
  23828. wakeUpBody(impostor: PhysicsImpostor): void;
  23829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23830. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23831. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23832. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23833. getRadius(impostor: PhysicsImpostor): number;
  23834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23836. dispose(): void;
  23837. }
  23838. /**
  23839. * Interface used to define a physics engine
  23840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23841. */
  23842. export interface IPhysicsEngine {
  23843. /**
  23844. * Gets the gravity vector used by the simulation
  23845. */
  23846. gravity: Vector3;
  23847. /**
  23848. * Sets the gravity vector used by the simulation
  23849. * @param gravity defines the gravity vector to use
  23850. */
  23851. setGravity(gravity: Vector3): void;
  23852. /**
  23853. * Set the time step of the physics engine.
  23854. * Default is 1/60.
  23855. * To slow it down, enter 1/600 for example.
  23856. * To speed it up, 1/30
  23857. * @param newTimeStep the new timestep to apply to this world.
  23858. */
  23859. setTimeStep(newTimeStep: number): void;
  23860. /**
  23861. * Get the time step of the physics engine.
  23862. * @returns the current time step
  23863. */
  23864. getTimeStep(): number;
  23865. /**
  23866. * Set the sub time step of the physics engine.
  23867. * Default is 0 meaning there is no sub steps
  23868. * To increase physics resolution precision, set a small value (like 1 ms)
  23869. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23870. */
  23871. setSubTimeStep(subTimeStep: number): void;
  23872. /**
  23873. * Get the sub time step of the physics engine.
  23874. * @returns the current sub time step
  23875. */
  23876. getSubTimeStep(): number;
  23877. /**
  23878. * Release all resources
  23879. */
  23880. dispose(): void;
  23881. /**
  23882. * Gets the name of the current physics plugin
  23883. * @returns the name of the plugin
  23884. */
  23885. getPhysicsPluginName(): string;
  23886. /**
  23887. * Adding a new impostor for the impostor tracking.
  23888. * This will be done by the impostor itself.
  23889. * @param impostor the impostor to add
  23890. */
  23891. addImpostor(impostor: PhysicsImpostor): void;
  23892. /**
  23893. * Remove an impostor from the engine.
  23894. * This impostor and its mesh will not longer be updated by the physics engine.
  23895. * @param impostor the impostor to remove
  23896. */
  23897. removeImpostor(impostor: PhysicsImpostor): void;
  23898. /**
  23899. * Add a joint to the physics engine
  23900. * @param mainImpostor defines the main impostor to which the joint is added.
  23901. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23902. * @param joint defines the joint that will connect both impostors.
  23903. */
  23904. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23905. /**
  23906. * Removes a joint from the simulation
  23907. * @param mainImpostor defines the impostor used with the joint
  23908. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23909. * @param joint defines the joint to remove
  23910. */
  23911. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23912. /**
  23913. * Gets the current plugin used to run the simulation
  23914. * @returns current plugin
  23915. */
  23916. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23917. /**
  23918. * Gets the list of physic impostors
  23919. * @returns an array of PhysicsImpostor
  23920. */
  23921. getImpostors(): Array<PhysicsImpostor>;
  23922. /**
  23923. * Gets the impostor for a physics enabled object
  23924. * @param object defines the object impersonated by the impostor
  23925. * @returns the PhysicsImpostor or null if not found
  23926. */
  23927. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23928. /**
  23929. * Gets the impostor for a physics body object
  23930. * @param body defines physics body used by the impostor
  23931. * @returns the PhysicsImpostor or null if not found
  23932. */
  23933. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23934. /**
  23935. * Does a raycast in the physics world
  23936. * @param from when should the ray start?
  23937. * @param to when should the ray end?
  23938. * @returns PhysicsRaycastResult
  23939. */
  23940. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23941. /**
  23942. * Called by the scene. No need to call it.
  23943. * @param delta defines the timespam between frames
  23944. */
  23945. _step(delta: number): void;
  23946. }
  23947. }
  23948. declare module BABYLON {
  23949. /**
  23950. * The interface for the physics imposter parameters
  23951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23952. */
  23953. export interface PhysicsImpostorParameters {
  23954. /**
  23955. * The mass of the physics imposter
  23956. */
  23957. mass: number;
  23958. /**
  23959. * The friction of the physics imposter
  23960. */
  23961. friction?: number;
  23962. /**
  23963. * The coefficient of restitution of the physics imposter
  23964. */
  23965. restitution?: number;
  23966. /**
  23967. * The native options of the physics imposter
  23968. */
  23969. nativeOptions?: any;
  23970. /**
  23971. * Specifies if the parent should be ignored
  23972. */
  23973. ignoreParent?: boolean;
  23974. /**
  23975. * Specifies if bi-directional transformations should be disabled
  23976. */
  23977. disableBidirectionalTransformation?: boolean;
  23978. /**
  23979. * The pressure inside the physics imposter, soft object only
  23980. */
  23981. pressure?: number;
  23982. /**
  23983. * The stiffness the physics imposter, soft object only
  23984. */
  23985. stiffness?: number;
  23986. /**
  23987. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23988. */
  23989. velocityIterations?: number;
  23990. /**
  23991. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23992. */
  23993. positionIterations?: number;
  23994. /**
  23995. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23996. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23997. * Add to fix multiple points
  23998. */
  23999. fixedPoints?: number;
  24000. /**
  24001. * The collision margin around a soft object
  24002. */
  24003. margin?: number;
  24004. /**
  24005. * The collision margin around a soft object
  24006. */
  24007. damping?: number;
  24008. /**
  24009. * The path for a rope based on an extrusion
  24010. */
  24011. path?: any;
  24012. /**
  24013. * The shape of an extrusion used for a rope based on an extrusion
  24014. */
  24015. shape?: any;
  24016. }
  24017. /**
  24018. * Interface for a physics-enabled object
  24019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24020. */
  24021. export interface IPhysicsEnabledObject {
  24022. /**
  24023. * The position of the physics-enabled object
  24024. */
  24025. position: Vector3;
  24026. /**
  24027. * The rotation of the physics-enabled object
  24028. */
  24029. rotationQuaternion: Nullable<Quaternion>;
  24030. /**
  24031. * The scale of the physics-enabled object
  24032. */
  24033. scaling: Vector3;
  24034. /**
  24035. * The rotation of the physics-enabled object
  24036. */
  24037. rotation?: Vector3;
  24038. /**
  24039. * The parent of the physics-enabled object
  24040. */
  24041. parent?: any;
  24042. /**
  24043. * The bounding info of the physics-enabled object
  24044. * @returns The bounding info of the physics-enabled object
  24045. */
  24046. getBoundingInfo(): BoundingInfo;
  24047. /**
  24048. * Computes the world matrix
  24049. * @param force Specifies if the world matrix should be computed by force
  24050. * @returns A world matrix
  24051. */
  24052. computeWorldMatrix(force: boolean): Matrix;
  24053. /**
  24054. * Gets the world matrix
  24055. * @returns A world matrix
  24056. */
  24057. getWorldMatrix?(): Matrix;
  24058. /**
  24059. * Gets the child meshes
  24060. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24061. * @returns An array of abstract meshes
  24062. */
  24063. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24064. /**
  24065. * Gets the vertex data
  24066. * @param kind The type of vertex data
  24067. * @returns A nullable array of numbers, or a float32 array
  24068. */
  24069. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24070. /**
  24071. * Gets the indices from the mesh
  24072. * @returns A nullable array of index arrays
  24073. */
  24074. getIndices?(): Nullable<IndicesArray>;
  24075. /**
  24076. * Gets the scene from the mesh
  24077. * @returns the indices array or null
  24078. */
  24079. getScene?(): Scene;
  24080. /**
  24081. * Gets the absolute position from the mesh
  24082. * @returns the absolute position
  24083. */
  24084. getAbsolutePosition(): Vector3;
  24085. /**
  24086. * Gets the absolute pivot point from the mesh
  24087. * @returns the absolute pivot point
  24088. */
  24089. getAbsolutePivotPoint(): Vector3;
  24090. /**
  24091. * Rotates the mesh
  24092. * @param axis The axis of rotation
  24093. * @param amount The amount of rotation
  24094. * @param space The space of the rotation
  24095. * @returns The rotation transform node
  24096. */
  24097. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24098. /**
  24099. * Translates the mesh
  24100. * @param axis The axis of translation
  24101. * @param distance The distance of translation
  24102. * @param space The space of the translation
  24103. * @returns The transform node
  24104. */
  24105. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24106. /**
  24107. * Sets the absolute position of the mesh
  24108. * @param absolutePosition The absolute position of the mesh
  24109. * @returns The transform node
  24110. */
  24111. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24112. /**
  24113. * Gets the class name of the mesh
  24114. * @returns The class name
  24115. */
  24116. getClassName(): string;
  24117. }
  24118. /**
  24119. * Represents a physics imposter
  24120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24121. */
  24122. export class PhysicsImpostor {
  24123. /**
  24124. * The physics-enabled object used as the physics imposter
  24125. */
  24126. object: IPhysicsEnabledObject;
  24127. /**
  24128. * The type of the physics imposter
  24129. */
  24130. type: number;
  24131. private _options;
  24132. private _scene?;
  24133. /**
  24134. * The default object size of the imposter
  24135. */
  24136. static DEFAULT_OBJECT_SIZE: Vector3;
  24137. /**
  24138. * The identity quaternion of the imposter
  24139. */
  24140. static IDENTITY_QUATERNION: Quaternion;
  24141. /** @hidden */
  24142. _pluginData: any;
  24143. private _physicsEngine;
  24144. private _physicsBody;
  24145. private _bodyUpdateRequired;
  24146. private _onBeforePhysicsStepCallbacks;
  24147. private _onAfterPhysicsStepCallbacks;
  24148. /** @hidden */
  24149. _onPhysicsCollideCallbacks: Array<{
  24150. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24151. otherImpostors: Array<PhysicsImpostor>;
  24152. }>;
  24153. private _deltaPosition;
  24154. private _deltaRotation;
  24155. private _deltaRotationConjugated;
  24156. /** @hidden */
  24157. _isFromLine: boolean;
  24158. private _parent;
  24159. private _isDisposed;
  24160. private static _tmpVecs;
  24161. private static _tmpQuat;
  24162. /**
  24163. * Specifies if the physics imposter is disposed
  24164. */
  24165. get isDisposed(): boolean;
  24166. /**
  24167. * Gets the mass of the physics imposter
  24168. */
  24169. get mass(): number;
  24170. set mass(value: number);
  24171. /**
  24172. * Gets the coefficient of friction
  24173. */
  24174. get friction(): number;
  24175. /**
  24176. * Sets the coefficient of friction
  24177. */
  24178. set friction(value: number);
  24179. /**
  24180. * Gets the coefficient of restitution
  24181. */
  24182. get restitution(): number;
  24183. /**
  24184. * Sets the coefficient of restitution
  24185. */
  24186. set restitution(value: number);
  24187. /**
  24188. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24189. */
  24190. get pressure(): number;
  24191. /**
  24192. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24193. */
  24194. set pressure(value: number);
  24195. /**
  24196. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24197. */
  24198. get stiffness(): number;
  24199. /**
  24200. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24201. */
  24202. set stiffness(value: number);
  24203. /**
  24204. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24205. */
  24206. get velocityIterations(): number;
  24207. /**
  24208. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24209. */
  24210. set velocityIterations(value: number);
  24211. /**
  24212. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24213. */
  24214. get positionIterations(): number;
  24215. /**
  24216. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24217. */
  24218. set positionIterations(value: number);
  24219. /**
  24220. * The unique id of the physics imposter
  24221. * set by the physics engine when adding this impostor to the array
  24222. */
  24223. uniqueId: number;
  24224. /**
  24225. * @hidden
  24226. */
  24227. soft: boolean;
  24228. /**
  24229. * @hidden
  24230. */
  24231. segments: number;
  24232. private _joints;
  24233. /**
  24234. * Initializes the physics imposter
  24235. * @param object The physics-enabled object used as the physics imposter
  24236. * @param type The type of the physics imposter
  24237. * @param _options The options for the physics imposter
  24238. * @param _scene The Babylon scene
  24239. */
  24240. constructor(
  24241. /**
  24242. * The physics-enabled object used as the physics imposter
  24243. */
  24244. object: IPhysicsEnabledObject,
  24245. /**
  24246. * The type of the physics imposter
  24247. */
  24248. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24249. /**
  24250. * This function will completly initialize this impostor.
  24251. * It will create a new body - but only if this mesh has no parent.
  24252. * If it has, this impostor will not be used other than to define the impostor
  24253. * of the child mesh.
  24254. * @hidden
  24255. */
  24256. _init(): void;
  24257. private _getPhysicsParent;
  24258. /**
  24259. * Should a new body be generated.
  24260. * @returns boolean specifying if body initialization is required
  24261. */
  24262. isBodyInitRequired(): boolean;
  24263. /**
  24264. * Sets the updated scaling
  24265. * @param updated Specifies if the scaling is updated
  24266. */
  24267. setScalingUpdated(): void;
  24268. /**
  24269. * Force a regeneration of this or the parent's impostor's body.
  24270. * Use under cautious - This will remove all joints already implemented.
  24271. */
  24272. forceUpdate(): void;
  24273. /**
  24274. * Gets the body that holds this impostor. Either its own, or its parent.
  24275. */
  24276. get physicsBody(): any;
  24277. /**
  24278. * Get the parent of the physics imposter
  24279. * @returns Physics imposter or null
  24280. */
  24281. get parent(): Nullable<PhysicsImpostor>;
  24282. /**
  24283. * Sets the parent of the physics imposter
  24284. */
  24285. set parent(value: Nullable<PhysicsImpostor>);
  24286. /**
  24287. * Set the physics body. Used mainly by the physics engine/plugin
  24288. */
  24289. set physicsBody(physicsBody: any);
  24290. /**
  24291. * Resets the update flags
  24292. */
  24293. resetUpdateFlags(): void;
  24294. /**
  24295. * Gets the object extend size
  24296. * @returns the object extend size
  24297. */
  24298. getObjectExtendSize(): Vector3;
  24299. /**
  24300. * Gets the object center
  24301. * @returns The object center
  24302. */
  24303. getObjectCenter(): Vector3;
  24304. /**
  24305. * Get a specific parameter from the options parameters
  24306. * @param paramName The object parameter name
  24307. * @returns The object parameter
  24308. */
  24309. getParam(paramName: string): any;
  24310. /**
  24311. * Sets a specific parameter in the options given to the physics plugin
  24312. * @param paramName The parameter name
  24313. * @param value The value of the parameter
  24314. */
  24315. setParam(paramName: string, value: number): void;
  24316. /**
  24317. * Specifically change the body's mass option. Won't recreate the physics body object
  24318. * @param mass The mass of the physics imposter
  24319. */
  24320. setMass(mass: number): void;
  24321. /**
  24322. * Gets the linear velocity
  24323. * @returns linear velocity or null
  24324. */
  24325. getLinearVelocity(): Nullable<Vector3>;
  24326. /**
  24327. * Sets the linear velocity
  24328. * @param velocity linear velocity or null
  24329. */
  24330. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24331. /**
  24332. * Gets the angular velocity
  24333. * @returns angular velocity or null
  24334. */
  24335. getAngularVelocity(): Nullable<Vector3>;
  24336. /**
  24337. * Sets the angular velocity
  24338. * @param velocity The velocity or null
  24339. */
  24340. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24341. /**
  24342. * Execute a function with the physics plugin native code
  24343. * Provide a function the will have two variables - the world object and the physics body object
  24344. * @param func The function to execute with the physics plugin native code
  24345. */
  24346. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24347. /**
  24348. * Register a function that will be executed before the physics world is stepping forward
  24349. * @param func The function to execute before the physics world is stepped forward
  24350. */
  24351. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24352. /**
  24353. * Unregister a function that will be executed before the physics world is stepping forward
  24354. * @param func The function to execute before the physics world is stepped forward
  24355. */
  24356. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24357. /**
  24358. * Register a function that will be executed after the physics step
  24359. * @param func The function to execute after physics step
  24360. */
  24361. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24362. /**
  24363. * Unregisters a function that will be executed after the physics step
  24364. * @param func The function to execute after physics step
  24365. */
  24366. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24367. /**
  24368. * register a function that will be executed when this impostor collides against a different body
  24369. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24370. * @param func Callback that is executed on collision
  24371. */
  24372. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24373. /**
  24374. * Unregisters the physics imposter on contact
  24375. * @param collideAgainst The physics object to collide against
  24376. * @param func Callback to execute on collision
  24377. */
  24378. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24379. private _tmpQuat;
  24380. private _tmpQuat2;
  24381. /**
  24382. * Get the parent rotation
  24383. * @returns The parent rotation
  24384. */
  24385. getParentsRotation(): Quaternion;
  24386. /**
  24387. * this function is executed by the physics engine.
  24388. */
  24389. beforeStep: () => void;
  24390. /**
  24391. * this function is executed by the physics engine
  24392. */
  24393. afterStep: () => void;
  24394. /**
  24395. * Legacy collision detection event support
  24396. */
  24397. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24398. /**
  24399. * event and body object due to cannon's event-based architecture.
  24400. */
  24401. onCollide: (e: {
  24402. body: any;
  24403. }) => void;
  24404. /**
  24405. * Apply a force
  24406. * @param force The force to apply
  24407. * @param contactPoint The contact point for the force
  24408. * @returns The physics imposter
  24409. */
  24410. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24411. /**
  24412. * Apply an impulse
  24413. * @param force The impulse force
  24414. * @param contactPoint The contact point for the impulse force
  24415. * @returns The physics imposter
  24416. */
  24417. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24418. /**
  24419. * A help function to create a joint
  24420. * @param otherImpostor A physics imposter used to create a joint
  24421. * @param jointType The type of joint
  24422. * @param jointData The data for the joint
  24423. * @returns The physics imposter
  24424. */
  24425. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24426. /**
  24427. * Add a joint to this impostor with a different impostor
  24428. * @param otherImpostor A physics imposter used to add a joint
  24429. * @param joint The joint to add
  24430. * @returns The physics imposter
  24431. */
  24432. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24433. /**
  24434. * Add an anchor to a cloth impostor
  24435. * @param otherImpostor rigid impostor to anchor to
  24436. * @param width ratio across width from 0 to 1
  24437. * @param height ratio up height from 0 to 1
  24438. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24439. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24440. * @returns impostor the soft imposter
  24441. */
  24442. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24443. /**
  24444. * Add a hook to a rope impostor
  24445. * @param otherImpostor rigid impostor to anchor to
  24446. * @param length ratio across rope from 0 to 1
  24447. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24448. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24449. * @returns impostor the rope imposter
  24450. */
  24451. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24452. /**
  24453. * Will keep this body still, in a sleep mode.
  24454. * @returns the physics imposter
  24455. */
  24456. sleep(): PhysicsImpostor;
  24457. /**
  24458. * Wake the body up.
  24459. * @returns The physics imposter
  24460. */
  24461. wakeUp(): PhysicsImpostor;
  24462. /**
  24463. * Clones the physics imposter
  24464. * @param newObject The physics imposter clones to this physics-enabled object
  24465. * @returns A nullable physics imposter
  24466. */
  24467. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24468. /**
  24469. * Disposes the physics imposter
  24470. */
  24471. dispose(): void;
  24472. /**
  24473. * Sets the delta position
  24474. * @param position The delta position amount
  24475. */
  24476. setDeltaPosition(position: Vector3): void;
  24477. /**
  24478. * Sets the delta rotation
  24479. * @param rotation The delta rotation amount
  24480. */
  24481. setDeltaRotation(rotation: Quaternion): void;
  24482. /**
  24483. * Gets the box size of the physics imposter and stores the result in the input parameter
  24484. * @param result Stores the box size
  24485. * @returns The physics imposter
  24486. */
  24487. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24488. /**
  24489. * Gets the radius of the physics imposter
  24490. * @returns Radius of the physics imposter
  24491. */
  24492. getRadius(): number;
  24493. /**
  24494. * Sync a bone with this impostor
  24495. * @param bone The bone to sync to the impostor.
  24496. * @param boneMesh The mesh that the bone is influencing.
  24497. * @param jointPivot The pivot of the joint / bone in local space.
  24498. * @param distToJoint Optional distance from the impostor to the joint.
  24499. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24500. */
  24501. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24502. /**
  24503. * Sync impostor to a bone
  24504. * @param bone The bone that the impostor will be synced to.
  24505. * @param boneMesh The mesh that the bone is influencing.
  24506. * @param jointPivot The pivot of the joint / bone in local space.
  24507. * @param distToJoint Optional distance from the impostor to the joint.
  24508. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24509. * @param boneAxis Optional vector3 axis the bone is aligned with
  24510. */
  24511. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24512. /**
  24513. * No-Imposter type
  24514. */
  24515. static NoImpostor: number;
  24516. /**
  24517. * Sphere-Imposter type
  24518. */
  24519. static SphereImpostor: number;
  24520. /**
  24521. * Box-Imposter type
  24522. */
  24523. static BoxImpostor: number;
  24524. /**
  24525. * Plane-Imposter type
  24526. */
  24527. static PlaneImpostor: number;
  24528. /**
  24529. * Mesh-imposter type
  24530. */
  24531. static MeshImpostor: number;
  24532. /**
  24533. * Capsule-Impostor type (Ammo.js plugin only)
  24534. */
  24535. static CapsuleImpostor: number;
  24536. /**
  24537. * Cylinder-Imposter type
  24538. */
  24539. static CylinderImpostor: number;
  24540. /**
  24541. * Particle-Imposter type
  24542. */
  24543. static ParticleImpostor: number;
  24544. /**
  24545. * Heightmap-Imposter type
  24546. */
  24547. static HeightmapImpostor: number;
  24548. /**
  24549. * ConvexHull-Impostor type (Ammo.js plugin only)
  24550. */
  24551. static ConvexHullImpostor: number;
  24552. /**
  24553. * Custom-Imposter type (Ammo.js plugin only)
  24554. */
  24555. static CustomImpostor: number;
  24556. /**
  24557. * Rope-Imposter type
  24558. */
  24559. static RopeImpostor: number;
  24560. /**
  24561. * Cloth-Imposter type
  24562. */
  24563. static ClothImpostor: number;
  24564. /**
  24565. * Softbody-Imposter type
  24566. */
  24567. static SoftbodyImpostor: number;
  24568. }
  24569. }
  24570. declare module BABYLON {
  24571. /**
  24572. * @hidden
  24573. **/
  24574. export class _CreationDataStorage {
  24575. closePath?: boolean;
  24576. closeArray?: boolean;
  24577. idx: number[];
  24578. dashSize: number;
  24579. gapSize: number;
  24580. path3D: Path3D;
  24581. pathArray: Vector3[][];
  24582. arc: number;
  24583. radius: number;
  24584. cap: number;
  24585. tessellation: number;
  24586. }
  24587. /**
  24588. * @hidden
  24589. **/
  24590. class _InstanceDataStorage {
  24591. visibleInstances: any;
  24592. batchCache: _InstancesBatch;
  24593. instancesBufferSize: number;
  24594. instancesBuffer: Nullable<Buffer>;
  24595. instancesData: Float32Array;
  24596. overridenInstanceCount: number;
  24597. isFrozen: boolean;
  24598. previousBatch: Nullable<_InstancesBatch>;
  24599. hardwareInstancedRendering: boolean;
  24600. sideOrientation: number;
  24601. manualUpdate: boolean;
  24602. }
  24603. /**
  24604. * @hidden
  24605. **/
  24606. export class _InstancesBatch {
  24607. mustReturn: boolean;
  24608. visibleInstances: Nullable<InstancedMesh[]>[];
  24609. renderSelf: boolean[];
  24610. hardwareInstancedRendering: boolean[];
  24611. }
  24612. /**
  24613. * Class used to represent renderable models
  24614. */
  24615. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24616. /**
  24617. * Mesh side orientation : usually the external or front surface
  24618. */
  24619. static readonly FRONTSIDE: number;
  24620. /**
  24621. * Mesh side orientation : usually the internal or back surface
  24622. */
  24623. static readonly BACKSIDE: number;
  24624. /**
  24625. * Mesh side orientation : both internal and external or front and back surfaces
  24626. */
  24627. static readonly DOUBLESIDE: number;
  24628. /**
  24629. * Mesh side orientation : by default, `FRONTSIDE`
  24630. */
  24631. static readonly DEFAULTSIDE: number;
  24632. /**
  24633. * Mesh cap setting : no cap
  24634. */
  24635. static readonly NO_CAP: number;
  24636. /**
  24637. * Mesh cap setting : one cap at the beginning of the mesh
  24638. */
  24639. static readonly CAP_START: number;
  24640. /**
  24641. * Mesh cap setting : one cap at the end of the mesh
  24642. */
  24643. static readonly CAP_END: number;
  24644. /**
  24645. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24646. */
  24647. static readonly CAP_ALL: number;
  24648. /**
  24649. * Mesh pattern setting : no flip or rotate
  24650. */
  24651. static readonly NO_FLIP: number;
  24652. /**
  24653. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24654. */
  24655. static readonly FLIP_TILE: number;
  24656. /**
  24657. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24658. */
  24659. static readonly ROTATE_TILE: number;
  24660. /**
  24661. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24662. */
  24663. static readonly FLIP_ROW: number;
  24664. /**
  24665. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24666. */
  24667. static readonly ROTATE_ROW: number;
  24668. /**
  24669. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24670. */
  24671. static readonly FLIP_N_ROTATE_TILE: number;
  24672. /**
  24673. * Mesh pattern setting : rotate pattern and rotate
  24674. */
  24675. static readonly FLIP_N_ROTATE_ROW: number;
  24676. /**
  24677. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24678. */
  24679. static readonly CENTER: number;
  24680. /**
  24681. * Mesh tile positioning : part tiles on left
  24682. */
  24683. static readonly LEFT: number;
  24684. /**
  24685. * Mesh tile positioning : part tiles on right
  24686. */
  24687. static readonly RIGHT: number;
  24688. /**
  24689. * Mesh tile positioning : part tiles on top
  24690. */
  24691. static readonly TOP: number;
  24692. /**
  24693. * Mesh tile positioning : part tiles on bottom
  24694. */
  24695. static readonly BOTTOM: number;
  24696. /**
  24697. * Gets the default side orientation.
  24698. * @param orientation the orientation to value to attempt to get
  24699. * @returns the default orientation
  24700. * @hidden
  24701. */
  24702. static _GetDefaultSideOrientation(orientation?: number): number;
  24703. private _internalMeshDataInfo;
  24704. /**
  24705. * An event triggered before rendering the mesh
  24706. */
  24707. get onBeforeRenderObservable(): Observable<Mesh>;
  24708. /**
  24709. * An event triggered before binding the mesh
  24710. */
  24711. get onBeforeBindObservable(): Observable<Mesh>;
  24712. /**
  24713. * An event triggered after rendering the mesh
  24714. */
  24715. get onAfterRenderObservable(): Observable<Mesh>;
  24716. /**
  24717. * An event triggered before drawing the mesh
  24718. */
  24719. get onBeforeDrawObservable(): Observable<Mesh>;
  24720. private _onBeforeDrawObserver;
  24721. /**
  24722. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24723. */
  24724. set onBeforeDraw(callback: () => void);
  24725. get hasInstances(): boolean;
  24726. /**
  24727. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24728. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24729. */
  24730. delayLoadState: number;
  24731. /**
  24732. * Gets the list of instances created from this mesh
  24733. * it is not supposed to be modified manually.
  24734. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24735. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24736. */
  24737. instances: InstancedMesh[];
  24738. /**
  24739. * Gets the file containing delay loading data for this mesh
  24740. */
  24741. delayLoadingFile: string;
  24742. /** @hidden */
  24743. _binaryInfo: any;
  24744. /**
  24745. * User defined function used to change how LOD level selection is done
  24746. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24747. */
  24748. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24749. /**
  24750. * Gets or sets the morph target manager
  24751. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24752. */
  24753. get morphTargetManager(): Nullable<MorphTargetManager>;
  24754. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24755. /** @hidden */
  24756. _creationDataStorage: Nullable<_CreationDataStorage>;
  24757. /** @hidden */
  24758. _geometry: Nullable<Geometry>;
  24759. /** @hidden */
  24760. _delayInfo: Array<string>;
  24761. /** @hidden */
  24762. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24763. /** @hidden */
  24764. _instanceDataStorage: _InstanceDataStorage;
  24765. private _effectiveMaterial;
  24766. /** @hidden */
  24767. _shouldGenerateFlatShading: boolean;
  24768. /** @hidden */
  24769. _originalBuilderSideOrientation: number;
  24770. /**
  24771. * Use this property to change the original side orientation defined at construction time
  24772. */
  24773. overrideMaterialSideOrientation: Nullable<number>;
  24774. /**
  24775. * Gets the source mesh (the one used to clone this one from)
  24776. */
  24777. get source(): Nullable<Mesh>;
  24778. /**
  24779. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24780. */
  24781. get isUnIndexed(): boolean;
  24782. set isUnIndexed(value: boolean);
  24783. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24784. get worldMatrixInstancedBuffer(): Float32Array;
  24785. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24786. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24787. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24788. /**
  24789. * @constructor
  24790. * @param name The value used by scene.getMeshByName() to do a lookup.
  24791. * @param scene The scene to add this mesh to.
  24792. * @param parent The parent of this mesh, if it has one
  24793. * @param source An optional Mesh from which geometry is shared, cloned.
  24794. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24795. * When false, achieved by calling a clone(), also passing False.
  24796. * This will make creation of children, recursive.
  24797. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24798. */
  24799. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24800. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24801. doNotInstantiate: boolean;
  24802. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24803. /**
  24804. * Gets the class name
  24805. * @returns the string "Mesh".
  24806. */
  24807. getClassName(): string;
  24808. /** @hidden */
  24809. get _isMesh(): boolean;
  24810. /**
  24811. * Returns a description of this mesh
  24812. * @param fullDetails define if full details about this mesh must be used
  24813. * @returns a descriptive string representing this mesh
  24814. */
  24815. toString(fullDetails?: boolean): string;
  24816. /** @hidden */
  24817. _unBindEffect(): void;
  24818. /**
  24819. * Gets a boolean indicating if this mesh has LOD
  24820. */
  24821. get hasLODLevels(): boolean;
  24822. /**
  24823. * Gets the list of MeshLODLevel associated with the current mesh
  24824. * @returns an array of MeshLODLevel
  24825. */
  24826. getLODLevels(): MeshLODLevel[];
  24827. private _sortLODLevels;
  24828. /**
  24829. * Add a mesh as LOD level triggered at the given distance.
  24830. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24831. * @param distance The distance from the center of the object to show this level
  24832. * @param mesh The mesh to be added as LOD level (can be null)
  24833. * @return This mesh (for chaining)
  24834. */
  24835. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24836. /**
  24837. * Returns the LOD level mesh at the passed distance or null if not found.
  24838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24839. * @param distance The distance from the center of the object to show this level
  24840. * @returns a Mesh or `null`
  24841. */
  24842. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24843. /**
  24844. * Remove a mesh from the LOD array
  24845. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24846. * @param mesh defines the mesh to be removed
  24847. * @return This mesh (for chaining)
  24848. */
  24849. removeLODLevel(mesh: Mesh): Mesh;
  24850. /**
  24851. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24852. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24853. * @param camera defines the camera to use to compute distance
  24854. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24855. * @return This mesh (for chaining)
  24856. */
  24857. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24858. /**
  24859. * Gets the mesh internal Geometry object
  24860. */
  24861. get geometry(): Nullable<Geometry>;
  24862. /**
  24863. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24864. * @returns the total number of vertices
  24865. */
  24866. getTotalVertices(): number;
  24867. /**
  24868. * Returns the content of an associated vertex buffer
  24869. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24870. * - VertexBuffer.PositionKind
  24871. * - VertexBuffer.UVKind
  24872. * - VertexBuffer.UV2Kind
  24873. * - VertexBuffer.UV3Kind
  24874. * - VertexBuffer.UV4Kind
  24875. * - VertexBuffer.UV5Kind
  24876. * - VertexBuffer.UV6Kind
  24877. * - VertexBuffer.ColorKind
  24878. * - VertexBuffer.MatricesIndicesKind
  24879. * - VertexBuffer.MatricesIndicesExtraKind
  24880. * - VertexBuffer.MatricesWeightsKind
  24881. * - VertexBuffer.MatricesWeightsExtraKind
  24882. * @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
  24883. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24884. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24885. */
  24886. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24887. /**
  24888. * Returns the mesh VertexBuffer object from the requested `kind`
  24889. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24890. * - VertexBuffer.PositionKind
  24891. * - VertexBuffer.NormalKind
  24892. * - VertexBuffer.UVKind
  24893. * - VertexBuffer.UV2Kind
  24894. * - VertexBuffer.UV3Kind
  24895. * - VertexBuffer.UV4Kind
  24896. * - VertexBuffer.UV5Kind
  24897. * - VertexBuffer.UV6Kind
  24898. * - VertexBuffer.ColorKind
  24899. * - VertexBuffer.MatricesIndicesKind
  24900. * - VertexBuffer.MatricesIndicesExtraKind
  24901. * - VertexBuffer.MatricesWeightsKind
  24902. * - VertexBuffer.MatricesWeightsExtraKind
  24903. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24904. */
  24905. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24906. /**
  24907. * Tests if a specific vertex buffer is associated with this mesh
  24908. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24909. * - VertexBuffer.PositionKind
  24910. * - VertexBuffer.NormalKind
  24911. * - VertexBuffer.UVKind
  24912. * - VertexBuffer.UV2Kind
  24913. * - VertexBuffer.UV3Kind
  24914. * - VertexBuffer.UV4Kind
  24915. * - VertexBuffer.UV5Kind
  24916. * - VertexBuffer.UV6Kind
  24917. * - VertexBuffer.ColorKind
  24918. * - VertexBuffer.MatricesIndicesKind
  24919. * - VertexBuffer.MatricesIndicesExtraKind
  24920. * - VertexBuffer.MatricesWeightsKind
  24921. * - VertexBuffer.MatricesWeightsExtraKind
  24922. * @returns a boolean
  24923. */
  24924. isVerticesDataPresent(kind: string): boolean;
  24925. /**
  24926. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24927. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24928. * - VertexBuffer.PositionKind
  24929. * - VertexBuffer.UVKind
  24930. * - VertexBuffer.UV2Kind
  24931. * - VertexBuffer.UV3Kind
  24932. * - VertexBuffer.UV4Kind
  24933. * - VertexBuffer.UV5Kind
  24934. * - VertexBuffer.UV6Kind
  24935. * - VertexBuffer.ColorKind
  24936. * - VertexBuffer.MatricesIndicesKind
  24937. * - VertexBuffer.MatricesIndicesExtraKind
  24938. * - VertexBuffer.MatricesWeightsKind
  24939. * - VertexBuffer.MatricesWeightsExtraKind
  24940. * @returns a boolean
  24941. */
  24942. isVertexBufferUpdatable(kind: string): boolean;
  24943. /**
  24944. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24945. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24946. * - VertexBuffer.PositionKind
  24947. * - VertexBuffer.NormalKind
  24948. * - VertexBuffer.UVKind
  24949. * - VertexBuffer.UV2Kind
  24950. * - VertexBuffer.UV3Kind
  24951. * - VertexBuffer.UV4Kind
  24952. * - VertexBuffer.UV5Kind
  24953. * - VertexBuffer.UV6Kind
  24954. * - VertexBuffer.ColorKind
  24955. * - VertexBuffer.MatricesIndicesKind
  24956. * - VertexBuffer.MatricesIndicesExtraKind
  24957. * - VertexBuffer.MatricesWeightsKind
  24958. * - VertexBuffer.MatricesWeightsExtraKind
  24959. * @returns an array of strings
  24960. */
  24961. getVerticesDataKinds(): string[];
  24962. /**
  24963. * Returns a positive integer : the total number of indices in this mesh geometry.
  24964. * @returns the numner of indices or zero if the mesh has no geometry.
  24965. */
  24966. getTotalIndices(): number;
  24967. /**
  24968. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24969. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24971. * @returns the indices array or an empty array if the mesh has no geometry
  24972. */
  24973. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24974. get isBlocked(): boolean;
  24975. /**
  24976. * Determine if the current mesh is ready to be rendered
  24977. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24978. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24979. * @returns true if all associated assets are ready (material, textures, shaders)
  24980. */
  24981. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24982. /**
  24983. * 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.
  24984. */
  24985. get areNormalsFrozen(): boolean;
  24986. /**
  24987. * 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.
  24988. * @returns the current mesh
  24989. */
  24990. freezeNormals(): Mesh;
  24991. /**
  24992. * 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
  24993. * @returns the current mesh
  24994. */
  24995. unfreezeNormals(): Mesh;
  24996. /**
  24997. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24998. */
  24999. set overridenInstanceCount(count: number);
  25000. /** @hidden */
  25001. _preActivate(): Mesh;
  25002. /** @hidden */
  25003. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25004. /** @hidden */
  25005. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25006. /**
  25007. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25008. * This means the mesh underlying bounding box and sphere are recomputed.
  25009. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25010. * @returns the current mesh
  25011. */
  25012. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25013. /** @hidden */
  25014. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25015. /**
  25016. * This function will subdivide the mesh into multiple submeshes
  25017. * @param count defines the expected number of submeshes
  25018. */
  25019. subdivide(count: number): void;
  25020. /**
  25021. * Copy a FloatArray into a specific associated vertex buffer
  25022. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25023. * - VertexBuffer.PositionKind
  25024. * - VertexBuffer.UVKind
  25025. * - VertexBuffer.UV2Kind
  25026. * - VertexBuffer.UV3Kind
  25027. * - VertexBuffer.UV4Kind
  25028. * - VertexBuffer.UV5Kind
  25029. * - VertexBuffer.UV6Kind
  25030. * - VertexBuffer.ColorKind
  25031. * - VertexBuffer.MatricesIndicesKind
  25032. * - VertexBuffer.MatricesIndicesExtraKind
  25033. * - VertexBuffer.MatricesWeightsKind
  25034. * - VertexBuffer.MatricesWeightsExtraKind
  25035. * @param data defines the data source
  25036. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25037. * @param stride defines the data stride size (can be null)
  25038. * @returns the current mesh
  25039. */
  25040. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25041. /**
  25042. * Delete a vertex buffer associated with this mesh
  25043. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25044. * - VertexBuffer.PositionKind
  25045. * - VertexBuffer.UVKind
  25046. * - VertexBuffer.UV2Kind
  25047. * - VertexBuffer.UV3Kind
  25048. * - VertexBuffer.UV4Kind
  25049. * - VertexBuffer.UV5Kind
  25050. * - VertexBuffer.UV6Kind
  25051. * - VertexBuffer.ColorKind
  25052. * - VertexBuffer.MatricesIndicesKind
  25053. * - VertexBuffer.MatricesIndicesExtraKind
  25054. * - VertexBuffer.MatricesWeightsKind
  25055. * - VertexBuffer.MatricesWeightsExtraKind
  25056. */
  25057. removeVerticesData(kind: string): void;
  25058. /**
  25059. * Flags an associated vertex buffer as updatable
  25060. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25061. * - VertexBuffer.PositionKind
  25062. * - VertexBuffer.UVKind
  25063. * - VertexBuffer.UV2Kind
  25064. * - VertexBuffer.UV3Kind
  25065. * - VertexBuffer.UV4Kind
  25066. * - VertexBuffer.UV5Kind
  25067. * - VertexBuffer.UV6Kind
  25068. * - VertexBuffer.ColorKind
  25069. * - VertexBuffer.MatricesIndicesKind
  25070. * - VertexBuffer.MatricesIndicesExtraKind
  25071. * - VertexBuffer.MatricesWeightsKind
  25072. * - VertexBuffer.MatricesWeightsExtraKind
  25073. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25074. */
  25075. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25076. /**
  25077. * Sets the mesh global Vertex Buffer
  25078. * @param buffer defines the buffer to use
  25079. * @returns the current mesh
  25080. */
  25081. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25082. /**
  25083. * Update a specific associated vertex buffer
  25084. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25085. * - VertexBuffer.PositionKind
  25086. * - VertexBuffer.UVKind
  25087. * - VertexBuffer.UV2Kind
  25088. * - VertexBuffer.UV3Kind
  25089. * - VertexBuffer.UV4Kind
  25090. * - VertexBuffer.UV5Kind
  25091. * - VertexBuffer.UV6Kind
  25092. * - VertexBuffer.ColorKind
  25093. * - VertexBuffer.MatricesIndicesKind
  25094. * - VertexBuffer.MatricesIndicesExtraKind
  25095. * - VertexBuffer.MatricesWeightsKind
  25096. * - VertexBuffer.MatricesWeightsExtraKind
  25097. * @param data defines the data source
  25098. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25099. * @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)
  25100. * @returns the current mesh
  25101. */
  25102. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25103. /**
  25104. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25105. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25106. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25107. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25108. * @returns the current mesh
  25109. */
  25110. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25111. /**
  25112. * Creates a un-shared specific occurence of the geometry for the mesh.
  25113. * @returns the current mesh
  25114. */
  25115. makeGeometryUnique(): Mesh;
  25116. /**
  25117. * Set the index buffer of this mesh
  25118. * @param indices defines the source data
  25119. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25120. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25121. * @returns the current mesh
  25122. */
  25123. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25124. /**
  25125. * Update the current index buffer
  25126. * @param indices defines the source data
  25127. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25128. * @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)
  25129. * @returns the current mesh
  25130. */
  25131. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25132. /**
  25133. * Invert the geometry to move from a right handed system to a left handed one.
  25134. * @returns the current mesh
  25135. */
  25136. toLeftHanded(): Mesh;
  25137. /** @hidden */
  25138. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25139. /** @hidden */
  25140. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25141. /**
  25142. * Registers for this mesh a javascript function called just before the rendering process
  25143. * @param func defines the function to call before rendering this mesh
  25144. * @returns the current mesh
  25145. */
  25146. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25147. /**
  25148. * Disposes a previously registered javascript function called before the rendering
  25149. * @param func defines the function to remove
  25150. * @returns the current mesh
  25151. */
  25152. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25153. /**
  25154. * Registers for this mesh a javascript function called just after the rendering is complete
  25155. * @param func defines the function to call after rendering this mesh
  25156. * @returns the current mesh
  25157. */
  25158. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25159. /**
  25160. * Disposes a previously registered javascript function called after the rendering.
  25161. * @param func defines the function to remove
  25162. * @returns the current mesh
  25163. */
  25164. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25165. /** @hidden */
  25166. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25167. /** @hidden */
  25168. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25169. /** @hidden */
  25170. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25171. /** @hidden */
  25172. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25173. /** @hidden */
  25174. _rebuild(): void;
  25175. /** @hidden */
  25176. _freeze(): void;
  25177. /** @hidden */
  25178. _unFreeze(): void;
  25179. /**
  25180. * 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
  25181. * @param subMesh defines the subMesh to render
  25182. * @param enableAlphaMode defines if alpha mode can be changed
  25183. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25184. * @returns the current mesh
  25185. */
  25186. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25187. private _onBeforeDraw;
  25188. /**
  25189. * Renormalize the mesh and patch it up if there are no weights
  25190. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25191. * However in the case of zero weights then we set just a single influence to 1.
  25192. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25193. */
  25194. cleanMatrixWeights(): void;
  25195. private normalizeSkinFourWeights;
  25196. private normalizeSkinWeightsAndExtra;
  25197. /**
  25198. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25199. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25200. * the user know there was an issue with importing the mesh
  25201. * @returns a validation object with skinned, valid and report string
  25202. */
  25203. validateSkinning(): {
  25204. skinned: boolean;
  25205. valid: boolean;
  25206. report: string;
  25207. };
  25208. /** @hidden */
  25209. _checkDelayState(): Mesh;
  25210. private _queueLoad;
  25211. /**
  25212. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25213. * A mesh is in the frustum if its bounding box intersects the frustum
  25214. * @param frustumPlanes defines the frustum to test
  25215. * @returns true if the mesh is in the frustum planes
  25216. */
  25217. isInFrustum(frustumPlanes: Plane[]): boolean;
  25218. /**
  25219. * Sets the mesh material by the material or multiMaterial `id` property
  25220. * @param id is a string identifying the material or the multiMaterial
  25221. * @returns the current mesh
  25222. */
  25223. setMaterialByID(id: string): Mesh;
  25224. /**
  25225. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25226. * @returns an array of IAnimatable
  25227. */
  25228. getAnimatables(): IAnimatable[];
  25229. /**
  25230. * Modifies the mesh geometry according to the passed transformation matrix.
  25231. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25232. * The mesh normals are modified using the same transformation.
  25233. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25234. * @param transform defines the transform matrix to use
  25235. * @see http://doc.babylonjs.com/resources/baking_transformations
  25236. * @returns the current mesh
  25237. */
  25238. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25239. /**
  25240. * Modifies the mesh geometry according to its own current World Matrix.
  25241. * The mesh World Matrix is then reset.
  25242. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25243. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25244. * @see http://doc.babylonjs.com/resources/baking_transformations
  25245. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25246. * @returns the current mesh
  25247. */
  25248. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25249. /** @hidden */
  25250. get _positions(): Nullable<Vector3[]>;
  25251. /** @hidden */
  25252. _resetPointsArrayCache(): Mesh;
  25253. /** @hidden */
  25254. _generatePointsArray(): boolean;
  25255. /**
  25256. * Returns a new Mesh object generated from the current mesh properties.
  25257. * This method must not get confused with createInstance()
  25258. * @param name is a string, the name given to the new mesh
  25259. * @param newParent can be any Node object (default `null`)
  25260. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25261. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25262. * @returns a new mesh
  25263. */
  25264. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25265. /**
  25266. * Releases resources associated with this mesh.
  25267. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25268. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25269. */
  25270. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25271. /** @hidden */
  25272. _disposeInstanceSpecificData(): void;
  25273. /**
  25274. * Modifies the mesh geometry according to a displacement map.
  25275. * 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.
  25276. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25277. * @param url is a string, the URL from the image file is to be downloaded.
  25278. * @param minHeight is the lower limit of the displacement.
  25279. * @param maxHeight is the upper limit of the displacement.
  25280. * @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.
  25281. * @param uvOffset is an optional vector2 used to offset UV.
  25282. * @param uvScale is an optional vector2 used to scale UV.
  25283. * @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.
  25284. * @returns the Mesh.
  25285. */
  25286. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25287. /**
  25288. * Modifies the mesh geometry according to a displacementMap buffer.
  25289. * 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.
  25290. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25291. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25292. * @param heightMapWidth is the width of the buffer image.
  25293. * @param heightMapHeight is the height of the buffer image.
  25294. * @param minHeight is the lower limit of the displacement.
  25295. * @param maxHeight is the upper limit of the displacement.
  25296. * @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.
  25297. * @param uvOffset is an optional vector2 used to offset UV.
  25298. * @param uvScale is an optional vector2 used to scale UV.
  25299. * @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.
  25300. * @returns the Mesh.
  25301. */
  25302. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25303. /**
  25304. * Modify the mesh to get a flat shading rendering.
  25305. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25306. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25307. * @returns current mesh
  25308. */
  25309. convertToFlatShadedMesh(): Mesh;
  25310. /**
  25311. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25312. * In other words, more vertices, no more indices and a single bigger VBO.
  25313. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25314. * @returns current mesh
  25315. */
  25316. convertToUnIndexedMesh(): Mesh;
  25317. /**
  25318. * Inverses facet orientations.
  25319. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25320. * @param flipNormals will also inverts the normals
  25321. * @returns current mesh
  25322. */
  25323. flipFaces(flipNormals?: boolean): Mesh;
  25324. /**
  25325. * Increase the number of facets and hence vertices in a mesh
  25326. * Vertex normals are interpolated from existing vertex normals
  25327. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25328. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25329. */
  25330. increaseVertices(numberPerEdge: number): void;
  25331. /**
  25332. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25333. * This will undo any application of covertToFlatShadedMesh
  25334. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25335. */
  25336. forceSharedVertices(): void;
  25337. /** @hidden */
  25338. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25339. /** @hidden */
  25340. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25341. /**
  25342. * Creates a new InstancedMesh object from the mesh model.
  25343. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25344. * @param name defines the name of the new instance
  25345. * @returns a new InstancedMesh
  25346. */
  25347. createInstance(name: string): InstancedMesh;
  25348. /**
  25349. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25350. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25351. * @returns the current mesh
  25352. */
  25353. synchronizeInstances(): Mesh;
  25354. /**
  25355. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25356. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25357. * This should be used together with the simplification to avoid disappearing triangles.
  25358. * @param successCallback an optional success callback to be called after the optimization finished.
  25359. * @returns the current mesh
  25360. */
  25361. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25362. /**
  25363. * Serialize current mesh
  25364. * @param serializationObject defines the object which will receive the serialization data
  25365. */
  25366. serialize(serializationObject: any): void;
  25367. /** @hidden */
  25368. _syncGeometryWithMorphTargetManager(): void;
  25369. /** @hidden */
  25370. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25371. /**
  25372. * Returns a new Mesh object parsed from the source provided.
  25373. * @param parsedMesh is the source
  25374. * @param scene defines the hosting scene
  25375. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25376. * @returns a new Mesh
  25377. */
  25378. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25379. /**
  25380. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25381. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25382. * @param name defines the name of the mesh to create
  25383. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25384. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25385. * @param closePath creates a seam between the first and the last points of each path of the path array
  25386. * @param offset is taken in account only if the `pathArray` is containing a single path
  25387. * @param scene defines the hosting scene
  25388. * @param updatable defines if the mesh must be flagged as updatable
  25389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25390. * @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)
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25394. /**
  25395. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25396. * @param name defines the name of the mesh to create
  25397. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25398. * @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
  25399. * @param scene defines the hosting scene
  25400. * @param updatable defines if the mesh must be flagged as updatable
  25401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25402. * @returns a new Mesh
  25403. */
  25404. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25405. /**
  25406. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25407. * @param name defines the name of the mesh to create
  25408. * @param size sets the size (float) of each box side (default 1)
  25409. * @param scene defines the hosting scene
  25410. * @param updatable defines if the mesh must be flagged as updatable
  25411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25412. * @returns a new Mesh
  25413. */
  25414. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25415. /**
  25416. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25417. * @param name defines the name of the mesh to create
  25418. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25419. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25420. * @param scene defines the hosting scene
  25421. * @param updatable defines if the mesh must be flagged as updatable
  25422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25423. * @returns a new Mesh
  25424. */
  25425. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25426. /**
  25427. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25428. * @param name defines the name of the mesh to create
  25429. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25430. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25431. * @param scene defines the hosting scene
  25432. * @returns a new Mesh
  25433. */
  25434. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25435. /**
  25436. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25437. * @param name defines the name of the mesh to create
  25438. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25439. * @param diameterTop set the top cap diameter (floats, default 1)
  25440. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25441. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25442. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25443. * @param scene defines the hosting scene
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @returns a new Mesh
  25447. */
  25448. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25449. /**
  25450. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25451. * @param name defines the name of the mesh to create
  25452. * @param diameter sets the diameter size (float) of the torus (default 1)
  25453. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25454. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25455. * @param scene defines the hosting scene
  25456. * @param updatable defines if the mesh must be flagged as updatable
  25457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25458. * @returns a new Mesh
  25459. */
  25460. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25461. /**
  25462. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25463. * @param name defines the name of the mesh to create
  25464. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25465. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25466. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25467. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25468. * @param p the number of windings on X axis (positive integers, default 2)
  25469. * @param q the number of windings on Y axis (positive integers, default 3)
  25470. * @param scene defines the hosting scene
  25471. * @param updatable defines if the mesh must be flagged as updatable
  25472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25473. * @returns a new Mesh
  25474. */
  25475. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25476. /**
  25477. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25478. * @param name defines the name of the mesh to create
  25479. * @param points is an array successive Vector3
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @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).
  25483. * @returns a new Mesh
  25484. */
  25485. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25486. /**
  25487. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25488. * @param name defines the name of the mesh to create
  25489. * @param points is an array successive Vector3
  25490. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25491. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25492. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25493. * @param scene defines the hosting scene
  25494. * @param updatable defines if the mesh must be flagged as updatable
  25495. * @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)
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25499. /**
  25500. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25501. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25502. * 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.
  25503. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25504. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25505. * Remember you can only change the shape positions, not their number when updating a polygon.
  25506. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25507. * @param name defines the name of the mesh to create
  25508. * @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
  25509. * @param scene defines the hosting scene
  25510. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25511. * @param updatable defines if the mesh must be flagged as updatable
  25512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25513. * @param earcutInjection can be used to inject your own earcut reference
  25514. * @returns a new Mesh
  25515. */
  25516. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25517. /**
  25518. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25519. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25520. * @param name defines the name of the mesh to create
  25521. * @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
  25522. * @param depth defines the height of extrusion
  25523. * @param scene defines the hosting scene
  25524. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25525. * @param updatable defines if the mesh must be flagged as updatable
  25526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25527. * @param earcutInjection can be used to inject your own earcut reference
  25528. * @returns a new Mesh
  25529. */
  25530. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25531. /**
  25532. * Creates an extruded shape mesh.
  25533. * 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
  25534. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25535. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25536. * @param name defines the name of the mesh to create
  25537. * @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
  25538. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25539. * @param scale is the value to scale the shape
  25540. * @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
  25541. * @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
  25542. * @param scene defines the hosting scene
  25543. * @param updatable defines if the mesh must be flagged as updatable
  25544. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25545. * @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)
  25546. * @returns a new Mesh
  25547. */
  25548. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25549. /**
  25550. * Creates an custom extruded shape mesh.
  25551. * The custom extrusion is a parametric shape.
  25552. * It has no predefined shape. Its final shape will depend on the input parameters.
  25553. * Please consider using the same method from the MeshBuilder class instead
  25554. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25555. * @param name defines the name of the mesh to create
  25556. * @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
  25557. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25558. * @param scaleFunction is a custom Javascript function called on each path point
  25559. * @param rotationFunction is a custom Javascript function called on each path point
  25560. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25561. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25562. * @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
  25563. * @param scene defines the hosting scene
  25564. * @param updatable defines if the mesh must be flagged as updatable
  25565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25566. * @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)
  25567. * @returns a new Mesh
  25568. */
  25569. 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;
  25570. /**
  25571. * Creates lathe mesh.
  25572. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25573. * Please consider using the same method from the MeshBuilder class instead
  25574. * @param name defines the name of the mesh to create
  25575. * @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
  25576. * @param radius is the radius value of the lathe
  25577. * @param tessellation is the side number of the lathe.
  25578. * @param scene defines the hosting scene
  25579. * @param updatable defines if the mesh must be flagged as updatable
  25580. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25581. * @returns a new Mesh
  25582. */
  25583. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25584. /**
  25585. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25586. * @param name defines the name of the mesh to create
  25587. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25588. * @param scene defines the hosting scene
  25589. * @param updatable defines if the mesh must be flagged as updatable
  25590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25591. * @returns a new Mesh
  25592. */
  25593. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25594. /**
  25595. * Creates a ground mesh.
  25596. * Please consider using the same method from the MeshBuilder class instead
  25597. * @param name defines the name of the mesh to create
  25598. * @param width set the width of the ground
  25599. * @param height set the height of the ground
  25600. * @param subdivisions sets the number of subdivisions per side
  25601. * @param scene defines the hosting scene
  25602. * @param updatable defines if the mesh must be flagged as updatable
  25603. * @returns a new Mesh
  25604. */
  25605. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25606. /**
  25607. * Creates a tiled ground mesh.
  25608. * Please consider using the same method from the MeshBuilder class instead
  25609. * @param name defines the name of the mesh to create
  25610. * @param xmin set the ground minimum X coordinate
  25611. * @param zmin set the ground minimum Y coordinate
  25612. * @param xmax set the ground maximum X coordinate
  25613. * @param zmax set the ground maximum Z coordinate
  25614. * @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
  25615. * @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
  25616. * @param scene defines the hosting scene
  25617. * @param updatable defines if the mesh must be flagged as updatable
  25618. * @returns a new Mesh
  25619. */
  25620. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25621. w: number;
  25622. h: number;
  25623. }, precision: {
  25624. w: number;
  25625. h: number;
  25626. }, scene: Scene, updatable?: boolean): Mesh;
  25627. /**
  25628. * Creates a ground mesh from a height map.
  25629. * Please consider using the same method from the MeshBuilder class instead
  25630. * @see http://doc.babylonjs.com/babylon101/height_map
  25631. * @param name defines the name of the mesh to create
  25632. * @param url sets the URL of the height map image resource
  25633. * @param width set the ground width size
  25634. * @param height set the ground height size
  25635. * @param subdivisions sets the number of subdivision per side
  25636. * @param minHeight is the minimum altitude on the ground
  25637. * @param maxHeight is the maximum altitude on the ground
  25638. * @param scene defines the hosting scene
  25639. * @param updatable defines if the mesh must be flagged as updatable
  25640. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25641. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25642. * @returns a new Mesh
  25643. */
  25644. 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;
  25645. /**
  25646. * Creates a tube mesh.
  25647. * The tube is a parametric shape.
  25648. * It has no predefined shape. Its final shape will depend on the input parameters.
  25649. * Please consider using the same method from the MeshBuilder class instead
  25650. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25651. * @param name defines the name of the mesh to create
  25652. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25653. * @param radius sets the tube radius size
  25654. * @param tessellation is the number of sides on the tubular surface
  25655. * @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
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25664. (i: number, distance: number): number;
  25665. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25666. /**
  25667. * Creates a polyhedron mesh.
  25668. * Please consider using the same method from the MeshBuilder class instead.
  25669. * * 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
  25670. * * The parameter `size` (positive float, default 1) sets the polygon size
  25671. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25672. * * 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`
  25673. * * 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
  25674. * * 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)`)
  25675. * * 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
  25676. * * 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
  25677. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25678. * * 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
  25679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25680. * @param name defines the name of the mesh to create
  25681. * @param options defines the options used to create the mesh
  25682. * @param scene defines the hosting scene
  25683. * @returns a new Mesh
  25684. */
  25685. static CreatePolyhedron(name: string, options: {
  25686. type?: number;
  25687. size?: number;
  25688. sizeX?: number;
  25689. sizeY?: number;
  25690. sizeZ?: number;
  25691. custom?: any;
  25692. faceUV?: Vector4[];
  25693. faceColors?: Color4[];
  25694. updatable?: boolean;
  25695. sideOrientation?: number;
  25696. }, scene: Scene): Mesh;
  25697. /**
  25698. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25699. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25700. * * 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`)
  25701. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25702. * * 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
  25703. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25704. * * 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
  25705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25706. * @param name defines the name of the mesh
  25707. * @param options defines the options used to create the mesh
  25708. * @param scene defines the hosting scene
  25709. * @returns a new Mesh
  25710. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25711. */
  25712. static CreateIcoSphere(name: string, options: {
  25713. radius?: number;
  25714. flat?: boolean;
  25715. subdivisions?: number;
  25716. sideOrientation?: number;
  25717. updatable?: boolean;
  25718. }, scene: Scene): Mesh;
  25719. /**
  25720. * Creates a decal mesh.
  25721. * Please consider using the same method from the MeshBuilder class instead.
  25722. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25723. * @param name defines the name of the mesh
  25724. * @param sourceMesh defines the mesh receiving the decal
  25725. * @param position sets the position of the decal in world coordinates
  25726. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25727. * @param size sets the decal scaling
  25728. * @param angle sets the angle to rotate the decal
  25729. * @returns a new Mesh
  25730. */
  25731. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25732. /**
  25733. * Prepare internal position array for software CPU skinning
  25734. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25735. */
  25736. setPositionsForCPUSkinning(): Float32Array;
  25737. /**
  25738. * Prepare internal normal array for software CPU skinning
  25739. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25740. */
  25741. setNormalsForCPUSkinning(): Float32Array;
  25742. /**
  25743. * Updates the vertex buffer by applying transformation from the bones
  25744. * @param skeleton defines the skeleton to apply to current mesh
  25745. * @returns the current mesh
  25746. */
  25747. applySkeleton(skeleton: Skeleton): Mesh;
  25748. /**
  25749. * 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
  25750. * @param meshes defines the list of meshes to scan
  25751. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25752. */
  25753. static MinMax(meshes: AbstractMesh[]): {
  25754. min: Vector3;
  25755. max: Vector3;
  25756. };
  25757. /**
  25758. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25759. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25760. * @returns a vector3
  25761. */
  25762. static Center(meshesOrMinMaxVector: {
  25763. min: Vector3;
  25764. max: Vector3;
  25765. } | AbstractMesh[]): Vector3;
  25766. /**
  25767. * Merge the array of meshes into a single mesh for performance reasons.
  25768. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25769. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25770. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25771. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25772. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25773. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25774. * @returns a new mesh
  25775. */
  25776. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25777. /** @hidden */
  25778. addInstance(instance: InstancedMesh): void;
  25779. /** @hidden */
  25780. removeInstance(instance: InstancedMesh): void;
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. /**
  25785. * This is the base class of all the camera used in the application.
  25786. * @see http://doc.babylonjs.com/features/cameras
  25787. */
  25788. export class Camera extends Node {
  25789. /** @hidden */
  25790. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25791. /**
  25792. * This is the default projection mode used by the cameras.
  25793. * It helps recreating a feeling of perspective and better appreciate depth.
  25794. * This is the best way to simulate real life cameras.
  25795. */
  25796. static readonly PERSPECTIVE_CAMERA: number;
  25797. /**
  25798. * This helps creating camera with an orthographic mode.
  25799. * 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.
  25800. */
  25801. static readonly ORTHOGRAPHIC_CAMERA: number;
  25802. /**
  25803. * This is the default FOV mode for perspective cameras.
  25804. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25805. */
  25806. static readonly FOVMODE_VERTICAL_FIXED: number;
  25807. /**
  25808. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25809. */
  25810. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25811. /**
  25812. * This specifies ther is no need for a camera rig.
  25813. * Basically only one eye is rendered corresponding to the camera.
  25814. */
  25815. static readonly RIG_MODE_NONE: number;
  25816. /**
  25817. * Simulates a camera Rig with one blue eye and one red eye.
  25818. * This can be use with 3d blue and red glasses.
  25819. */
  25820. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25821. /**
  25822. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25823. */
  25824. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25825. /**
  25826. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25827. */
  25828. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25829. /**
  25830. * Defines that both eyes of the camera will be rendered over under each other.
  25831. */
  25832. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25833. /**
  25834. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25835. */
  25836. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25837. /**
  25838. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25839. */
  25840. static readonly RIG_MODE_VR: number;
  25841. /**
  25842. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25843. */
  25844. static readonly RIG_MODE_WEBVR: number;
  25845. /**
  25846. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25847. */
  25848. static readonly RIG_MODE_CUSTOM: number;
  25849. /**
  25850. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25851. */
  25852. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25853. /**
  25854. * Define the input manager associated with the camera.
  25855. */
  25856. inputs: CameraInputsManager<Camera>;
  25857. /** @hidden */
  25858. _position: Vector3;
  25859. /**
  25860. * Define the current local position of the camera in the scene
  25861. */
  25862. get position(): Vector3;
  25863. set position(newPosition: Vector3);
  25864. /**
  25865. * The vector the camera should consider as up.
  25866. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25867. */
  25868. upVector: Vector3;
  25869. /**
  25870. * Define the current limit on the left side for an orthographic camera
  25871. * In scene unit
  25872. */
  25873. orthoLeft: Nullable<number>;
  25874. /**
  25875. * Define the current limit on the right side for an orthographic camera
  25876. * In scene unit
  25877. */
  25878. orthoRight: Nullable<number>;
  25879. /**
  25880. * Define the current limit on the bottom side for an orthographic camera
  25881. * In scene unit
  25882. */
  25883. orthoBottom: Nullable<number>;
  25884. /**
  25885. * Define the current limit on the top side for an orthographic camera
  25886. * In scene unit
  25887. */
  25888. orthoTop: Nullable<number>;
  25889. /**
  25890. * Field Of View is set in Radians. (default is 0.8)
  25891. */
  25892. fov: number;
  25893. /**
  25894. * Define the minimum distance the camera can see from.
  25895. * This is important to note that the depth buffer are not infinite and the closer it starts
  25896. * the more your scene might encounter depth fighting issue.
  25897. */
  25898. minZ: number;
  25899. /**
  25900. * Define the maximum distance the camera can see to.
  25901. * This is important to note that the depth buffer are not infinite and the further it end
  25902. * the more your scene might encounter depth fighting issue.
  25903. */
  25904. maxZ: number;
  25905. /**
  25906. * Define the default inertia of the camera.
  25907. * This helps giving a smooth feeling to the camera movement.
  25908. */
  25909. inertia: number;
  25910. /**
  25911. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25912. */
  25913. mode: number;
  25914. /**
  25915. * Define whether the camera is intermediate.
  25916. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25917. */
  25918. isIntermediate: boolean;
  25919. /**
  25920. * Define the viewport of the camera.
  25921. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25922. */
  25923. viewport: Viewport;
  25924. /**
  25925. * Restricts the camera to viewing objects with the same layerMask.
  25926. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25927. */
  25928. layerMask: number;
  25929. /**
  25930. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25931. */
  25932. fovMode: number;
  25933. /**
  25934. * Rig mode of the camera.
  25935. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25936. * This is normally controlled byt the camera themselves as internal use.
  25937. */
  25938. cameraRigMode: number;
  25939. /**
  25940. * Defines the distance between both "eyes" in case of a RIG
  25941. */
  25942. interaxialDistance: number;
  25943. /**
  25944. * Defines if stereoscopic rendering is done side by side or over under.
  25945. */
  25946. isStereoscopicSideBySide: boolean;
  25947. /**
  25948. * 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
  25949. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25950. * else in the scene. (Eg. security camera)
  25951. *
  25952. * 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)
  25953. */
  25954. customRenderTargets: RenderTargetTexture[];
  25955. /**
  25956. * When set, the camera will render to this render target instead of the default canvas
  25957. *
  25958. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25959. */
  25960. outputRenderTarget: Nullable<RenderTargetTexture>;
  25961. /**
  25962. * Observable triggered when the camera view matrix has changed.
  25963. */
  25964. onViewMatrixChangedObservable: Observable<Camera>;
  25965. /**
  25966. * Observable triggered when the camera Projection matrix has changed.
  25967. */
  25968. onProjectionMatrixChangedObservable: Observable<Camera>;
  25969. /**
  25970. * Observable triggered when the inputs have been processed.
  25971. */
  25972. onAfterCheckInputsObservable: Observable<Camera>;
  25973. /**
  25974. * Observable triggered when reset has been called and applied to the camera.
  25975. */
  25976. onRestoreStateObservable: Observable<Camera>;
  25977. /**
  25978. * Is this camera a part of a rig system?
  25979. */
  25980. isRigCamera: boolean;
  25981. /**
  25982. * If isRigCamera set to true this will be set with the parent camera.
  25983. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25984. */
  25985. rigParent?: Camera;
  25986. /** @hidden */
  25987. _cameraRigParams: any;
  25988. /** @hidden */
  25989. _rigCameras: Camera[];
  25990. /** @hidden */
  25991. _rigPostProcess: Nullable<PostProcess>;
  25992. protected _webvrViewMatrix: Matrix;
  25993. /** @hidden */
  25994. _skipRendering: boolean;
  25995. /** @hidden */
  25996. _projectionMatrix: Matrix;
  25997. /** @hidden */
  25998. _postProcesses: Nullable<PostProcess>[];
  25999. /** @hidden */
  26000. _activeMeshes: SmartArray<AbstractMesh>;
  26001. protected _globalPosition: Vector3;
  26002. /** @hidden */
  26003. _computedViewMatrix: Matrix;
  26004. private _doNotComputeProjectionMatrix;
  26005. private _transformMatrix;
  26006. private _frustumPlanes;
  26007. private _refreshFrustumPlanes;
  26008. private _storedFov;
  26009. private _stateStored;
  26010. /**
  26011. * Instantiates a new camera object.
  26012. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26013. * @see http://doc.babylonjs.com/features/cameras
  26014. * @param name Defines the name of the camera in the scene
  26015. * @param position Defines the position of the camera
  26016. * @param scene Defines the scene the camera belongs too
  26017. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26018. */
  26019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26020. /**
  26021. * Store current camera state (fov, position, etc..)
  26022. * @returns the camera
  26023. */
  26024. storeState(): Camera;
  26025. /**
  26026. * Restores the camera state values if it has been stored. You must call storeState() first
  26027. */
  26028. protected _restoreStateValues(): boolean;
  26029. /**
  26030. * Restored camera state. You must call storeState() first.
  26031. * @returns true if restored and false otherwise
  26032. */
  26033. restoreState(): boolean;
  26034. /**
  26035. * Gets the class name of the camera.
  26036. * @returns the class name
  26037. */
  26038. getClassName(): string;
  26039. /** @hidden */
  26040. readonly _isCamera: boolean;
  26041. /**
  26042. * Gets a string representation of the camera useful for debug purpose.
  26043. * @param fullDetails Defines that a more verboe level of logging is required
  26044. * @returns the string representation
  26045. */
  26046. toString(fullDetails?: boolean): string;
  26047. /**
  26048. * Gets the current world space position of the camera.
  26049. */
  26050. get globalPosition(): Vector3;
  26051. /**
  26052. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26053. * @returns the active meshe list
  26054. */
  26055. getActiveMeshes(): SmartArray<AbstractMesh>;
  26056. /**
  26057. * Check whether a mesh is part of the current active mesh list of the camera
  26058. * @param mesh Defines the mesh to check
  26059. * @returns true if active, false otherwise
  26060. */
  26061. isActiveMesh(mesh: Mesh): boolean;
  26062. /**
  26063. * Is this camera ready to be used/rendered
  26064. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26065. * @return true if the camera is ready
  26066. */
  26067. isReady(completeCheck?: boolean): boolean;
  26068. /** @hidden */
  26069. _initCache(): void;
  26070. /** @hidden */
  26071. _updateCache(ignoreParentClass?: boolean): void;
  26072. /** @hidden */
  26073. _isSynchronized(): boolean;
  26074. /** @hidden */
  26075. _isSynchronizedViewMatrix(): boolean;
  26076. /** @hidden */
  26077. _isSynchronizedProjectionMatrix(): boolean;
  26078. /**
  26079. * Attach the input controls to a specific dom element to get the input from.
  26080. * @param element Defines the element the controls should be listened from
  26081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26082. */
  26083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26084. /**
  26085. * Detach the current controls from the specified dom element.
  26086. * @param element Defines the element to stop listening the inputs from
  26087. */
  26088. detachControl(element: HTMLElement): void;
  26089. /**
  26090. * Update the camera state according to the different inputs gathered during the frame.
  26091. */
  26092. update(): void;
  26093. /** @hidden */
  26094. _checkInputs(): void;
  26095. /** @hidden */
  26096. get rigCameras(): Camera[];
  26097. /**
  26098. * Gets the post process used by the rig cameras
  26099. */
  26100. get rigPostProcess(): Nullable<PostProcess>;
  26101. /**
  26102. * Internal, gets the first post proces.
  26103. * @returns the first post process to be run on this camera.
  26104. */
  26105. _getFirstPostProcess(): Nullable<PostProcess>;
  26106. private _cascadePostProcessesToRigCams;
  26107. /**
  26108. * Attach a post process to the camera.
  26109. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26110. * @param postProcess The post process to attach to the camera
  26111. * @param insertAt The position of the post process in case several of them are in use in the scene
  26112. * @returns the position the post process has been inserted at
  26113. */
  26114. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26115. /**
  26116. * Detach a post process to the camera.
  26117. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26118. * @param postProcess The post process to detach from the camera
  26119. */
  26120. detachPostProcess(postProcess: PostProcess): void;
  26121. /**
  26122. * Gets the current world matrix of the camera
  26123. */
  26124. getWorldMatrix(): Matrix;
  26125. /** @hidden */
  26126. _getViewMatrix(): Matrix;
  26127. /**
  26128. * Gets the current view matrix of the camera.
  26129. * @param force forces the camera to recompute the matrix without looking at the cached state
  26130. * @returns the view matrix
  26131. */
  26132. getViewMatrix(force?: boolean): Matrix;
  26133. /**
  26134. * Freeze the projection matrix.
  26135. * It will prevent the cache check of the camera projection compute and can speed up perf
  26136. * if no parameter of the camera are meant to change
  26137. * @param projection Defines manually a projection if necessary
  26138. */
  26139. freezeProjectionMatrix(projection?: Matrix): void;
  26140. /**
  26141. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26142. */
  26143. unfreezeProjectionMatrix(): void;
  26144. /**
  26145. * Gets the current projection matrix of the camera.
  26146. * @param force forces the camera to recompute the matrix without looking at the cached state
  26147. * @returns the projection matrix
  26148. */
  26149. getProjectionMatrix(force?: boolean): Matrix;
  26150. /**
  26151. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26152. * @returns a Matrix
  26153. */
  26154. getTransformationMatrix(): Matrix;
  26155. private _updateFrustumPlanes;
  26156. /**
  26157. * Checks if a cullable object (mesh...) is in the camera frustum
  26158. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26159. * @param target The object to check
  26160. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26161. * @returns true if the object is in frustum otherwise false
  26162. */
  26163. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26164. /**
  26165. * Checks if a cullable object (mesh...) is in the camera frustum
  26166. * Unlike isInFrustum this cheks the full bounding box
  26167. * @param target The object to check
  26168. * @returns true if the object is in frustum otherwise false
  26169. */
  26170. isCompletelyInFrustum(target: ICullable): boolean;
  26171. /**
  26172. * Gets a ray in the forward direction from the camera.
  26173. * @param length Defines the length of the ray to create
  26174. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26175. * @param origin Defines the start point of the ray which defaults to the camera position
  26176. * @returns the forward ray
  26177. */
  26178. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26179. /**
  26180. * Releases resources associated with this node.
  26181. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26182. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26183. */
  26184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26185. /** @hidden */
  26186. _isLeftCamera: boolean;
  26187. /**
  26188. * Gets the left camera of a rig setup in case of Rigged Camera
  26189. */
  26190. get isLeftCamera(): boolean;
  26191. /** @hidden */
  26192. _isRightCamera: boolean;
  26193. /**
  26194. * Gets the right camera of a rig setup in case of Rigged Camera
  26195. */
  26196. get isRightCamera(): boolean;
  26197. /**
  26198. * Gets the left camera of a rig setup in case of Rigged Camera
  26199. */
  26200. get leftCamera(): Nullable<FreeCamera>;
  26201. /**
  26202. * Gets the right camera of a rig setup in case of Rigged Camera
  26203. */
  26204. get rightCamera(): Nullable<FreeCamera>;
  26205. /**
  26206. * Gets the left camera target of a rig setup in case of Rigged Camera
  26207. * @returns the target position
  26208. */
  26209. getLeftTarget(): Nullable<Vector3>;
  26210. /**
  26211. * Gets the right camera target of a rig setup in case of Rigged Camera
  26212. * @returns the target position
  26213. */
  26214. getRightTarget(): Nullable<Vector3>;
  26215. /**
  26216. * @hidden
  26217. */
  26218. setCameraRigMode(mode: number, rigParams: any): void;
  26219. /** @hidden */
  26220. static _setStereoscopicRigMode(camera: Camera): void;
  26221. /** @hidden */
  26222. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26223. /** @hidden */
  26224. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26225. /** @hidden */
  26226. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26227. /** @hidden */
  26228. _getVRProjectionMatrix(): Matrix;
  26229. protected _updateCameraRotationMatrix(): void;
  26230. protected _updateWebVRCameraRotationMatrix(): void;
  26231. /**
  26232. * This function MUST be overwritten by the different WebVR cameras available.
  26233. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26234. * @hidden
  26235. */
  26236. _getWebVRProjectionMatrix(): Matrix;
  26237. /**
  26238. * This function MUST be overwritten by the different WebVR cameras available.
  26239. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26240. * @hidden
  26241. */
  26242. _getWebVRViewMatrix(): Matrix;
  26243. /** @hidden */
  26244. setCameraRigParameter(name: string, value: any): void;
  26245. /**
  26246. * needs to be overridden by children so sub has required properties to be copied
  26247. * @hidden
  26248. */
  26249. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26250. /**
  26251. * May need to be overridden by children
  26252. * @hidden
  26253. */
  26254. _updateRigCameras(): void;
  26255. /** @hidden */
  26256. _setupInputs(): void;
  26257. /**
  26258. * Serialiaze the camera setup to a json represention
  26259. * @returns the JSON representation
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Clones the current camera.
  26264. * @param name The cloned camera name
  26265. * @returns the cloned camera
  26266. */
  26267. clone(name: string): Camera;
  26268. /**
  26269. * Gets the direction of the camera relative to a given local axis.
  26270. * @param localAxis Defines the reference axis to provide a relative direction.
  26271. * @return the direction
  26272. */
  26273. getDirection(localAxis: Vector3): Vector3;
  26274. /**
  26275. * Returns the current camera absolute rotation
  26276. */
  26277. get absoluteRotation(): Quaternion;
  26278. /**
  26279. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26280. * @param localAxis Defines the reference axis to provide a relative direction.
  26281. * @param result Defines the vector to store the result in
  26282. */
  26283. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26284. /**
  26285. * Gets a camera constructor for a given camera type
  26286. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26287. * @param name The name of the camera the result will be able to instantiate
  26288. * @param scene The scene the result will construct the camera in
  26289. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26290. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26291. * @returns a factory method to construc the camera
  26292. */
  26293. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26294. /**
  26295. * Compute the world matrix of the camera.
  26296. * @returns the camera world matrix
  26297. */
  26298. computeWorldMatrix(): Matrix;
  26299. /**
  26300. * Parse a JSON and creates the camera from the parsed information
  26301. * @param parsedCamera The JSON to parse
  26302. * @param scene The scene to instantiate the camera in
  26303. * @returns the newly constructed camera
  26304. */
  26305. static Parse(parsedCamera: any, scene: Scene): Camera;
  26306. }
  26307. }
  26308. declare module BABYLON {
  26309. /**
  26310. * Class containing static functions to help procedurally build meshes
  26311. */
  26312. export class DiscBuilder {
  26313. /**
  26314. * Creates a plane polygonal mesh. By default, this is a disc
  26315. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26316. * * 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
  26317. * * 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
  26318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26319. * * 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
  26320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26321. * @param name defines the name of the mesh
  26322. * @param options defines the options used to create the mesh
  26323. * @param scene defines the hosting scene
  26324. * @returns the plane polygonal mesh
  26325. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26326. */
  26327. static CreateDisc(name: string, options: {
  26328. radius?: number;
  26329. tessellation?: number;
  26330. arc?: number;
  26331. updatable?: boolean;
  26332. sideOrientation?: number;
  26333. frontUVs?: Vector4;
  26334. backUVs?: Vector4;
  26335. }, scene?: Nullable<Scene>): Mesh;
  26336. }
  26337. }
  26338. declare module BABYLON {
  26339. /**
  26340. * Options to be used when creating a FresnelParameters.
  26341. */
  26342. export type IFresnelParametersCreationOptions = {
  26343. /**
  26344. * Define the color used on edges (grazing angle)
  26345. */
  26346. leftColor?: Color3;
  26347. /**
  26348. * Define the color used on center
  26349. */
  26350. rightColor?: Color3;
  26351. /**
  26352. * Define bias applied to computed fresnel term
  26353. */
  26354. bias?: number;
  26355. /**
  26356. * Defined the power exponent applied to fresnel term
  26357. */
  26358. power?: number;
  26359. /**
  26360. * Define if the fresnel effect is enable or not.
  26361. */
  26362. isEnabled?: boolean;
  26363. };
  26364. /**
  26365. * Serialized format for FresnelParameters.
  26366. */
  26367. export type IFresnelParametersSerialized = {
  26368. /**
  26369. * Define the color used on edges (grazing angle) [as an array]
  26370. */
  26371. leftColor: number[];
  26372. /**
  26373. * Define the color used on center [as an array]
  26374. */
  26375. rightColor: number[];
  26376. /**
  26377. * Define bias applied to computed fresnel term
  26378. */
  26379. bias: number;
  26380. /**
  26381. * Defined the power exponent applied to fresnel term
  26382. */
  26383. power?: number;
  26384. /**
  26385. * Define if the fresnel effect is enable or not.
  26386. */
  26387. isEnabled: boolean;
  26388. };
  26389. /**
  26390. * This represents all the required information to add a fresnel effect on a material:
  26391. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26392. */
  26393. export class FresnelParameters {
  26394. private _isEnabled;
  26395. /**
  26396. * Define if the fresnel effect is enable or not.
  26397. */
  26398. get isEnabled(): boolean;
  26399. set isEnabled(value: boolean);
  26400. /**
  26401. * Define the color used on edges (grazing angle)
  26402. */
  26403. leftColor: Color3;
  26404. /**
  26405. * Define the color used on center
  26406. */
  26407. rightColor: Color3;
  26408. /**
  26409. * Define bias applied to computed fresnel term
  26410. */
  26411. bias: number;
  26412. /**
  26413. * Defined the power exponent applied to fresnel term
  26414. */
  26415. power: number;
  26416. /**
  26417. * Creates a new FresnelParameters object.
  26418. *
  26419. * @param options provide your own settings to optionally to override defaults
  26420. */
  26421. constructor(options?: IFresnelParametersCreationOptions);
  26422. /**
  26423. * Clones the current fresnel and its valuues
  26424. * @returns a clone fresnel configuration
  26425. */
  26426. clone(): FresnelParameters;
  26427. /**
  26428. * Determines equality between FresnelParameters objects
  26429. * @param otherFresnelParameters defines the second operand
  26430. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26431. */
  26432. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26433. /**
  26434. * Serializes the current fresnel parameters to a JSON representation.
  26435. * @return the JSON serialization
  26436. */
  26437. serialize(): IFresnelParametersSerialized;
  26438. /**
  26439. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26440. * @param parsedFresnelParameters Define the JSON representation
  26441. * @returns the parsed parameters
  26442. */
  26443. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26444. }
  26445. }
  26446. declare module BABYLON {
  26447. /**
  26448. * Base class of materials working in push mode in babylon JS
  26449. * @hidden
  26450. */
  26451. export class PushMaterial extends Material {
  26452. protected _activeEffect: Effect;
  26453. protected _normalMatrix: Matrix;
  26454. /**
  26455. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26456. * This means that the material can keep using a previous shader while a new one is being compiled.
  26457. * This is mostly used when shader parallel compilation is supported (true by default)
  26458. */
  26459. allowShaderHotSwapping: boolean;
  26460. constructor(name: string, scene: Scene);
  26461. getEffect(): Effect;
  26462. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26463. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26464. /**
  26465. * Binds the given world matrix to the active effect
  26466. *
  26467. * @param world the matrix to bind
  26468. */
  26469. bindOnlyWorldMatrix(world: Matrix): void;
  26470. /**
  26471. * Binds the given normal matrix to the active effect
  26472. *
  26473. * @param normalMatrix the matrix to bind
  26474. */
  26475. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26476. bind(world: Matrix, mesh?: Mesh): void;
  26477. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26478. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26479. }
  26480. }
  26481. declare module BABYLON {
  26482. /**
  26483. * This groups all the flags used to control the materials channel.
  26484. */
  26485. export class MaterialFlags {
  26486. private static _DiffuseTextureEnabled;
  26487. /**
  26488. * Are diffuse textures enabled in the application.
  26489. */
  26490. static get DiffuseTextureEnabled(): boolean;
  26491. static set DiffuseTextureEnabled(value: boolean);
  26492. private static _AmbientTextureEnabled;
  26493. /**
  26494. * Are ambient textures enabled in the application.
  26495. */
  26496. static get AmbientTextureEnabled(): boolean;
  26497. static set AmbientTextureEnabled(value: boolean);
  26498. private static _OpacityTextureEnabled;
  26499. /**
  26500. * Are opacity textures enabled in the application.
  26501. */
  26502. static get OpacityTextureEnabled(): boolean;
  26503. static set OpacityTextureEnabled(value: boolean);
  26504. private static _ReflectionTextureEnabled;
  26505. /**
  26506. * Are reflection textures enabled in the application.
  26507. */
  26508. static get ReflectionTextureEnabled(): boolean;
  26509. static set ReflectionTextureEnabled(value: boolean);
  26510. private static _EmissiveTextureEnabled;
  26511. /**
  26512. * Are emissive textures enabled in the application.
  26513. */
  26514. static get EmissiveTextureEnabled(): boolean;
  26515. static set EmissiveTextureEnabled(value: boolean);
  26516. private static _SpecularTextureEnabled;
  26517. /**
  26518. * Are specular textures enabled in the application.
  26519. */
  26520. static get SpecularTextureEnabled(): boolean;
  26521. static set SpecularTextureEnabled(value: boolean);
  26522. private static _BumpTextureEnabled;
  26523. /**
  26524. * Are bump textures enabled in the application.
  26525. */
  26526. static get BumpTextureEnabled(): boolean;
  26527. static set BumpTextureEnabled(value: boolean);
  26528. private static _LightmapTextureEnabled;
  26529. /**
  26530. * Are lightmap textures enabled in the application.
  26531. */
  26532. static get LightmapTextureEnabled(): boolean;
  26533. static set LightmapTextureEnabled(value: boolean);
  26534. private static _RefractionTextureEnabled;
  26535. /**
  26536. * Are refraction textures enabled in the application.
  26537. */
  26538. static get RefractionTextureEnabled(): boolean;
  26539. static set RefractionTextureEnabled(value: boolean);
  26540. private static _ColorGradingTextureEnabled;
  26541. /**
  26542. * Are color grading textures enabled in the application.
  26543. */
  26544. static get ColorGradingTextureEnabled(): boolean;
  26545. static set ColorGradingTextureEnabled(value: boolean);
  26546. private static _FresnelEnabled;
  26547. /**
  26548. * Are fresnels enabled in the application.
  26549. */
  26550. static get FresnelEnabled(): boolean;
  26551. static set FresnelEnabled(value: boolean);
  26552. private static _ClearCoatTextureEnabled;
  26553. /**
  26554. * Are clear coat textures enabled in the application.
  26555. */
  26556. static get ClearCoatTextureEnabled(): boolean;
  26557. static set ClearCoatTextureEnabled(value: boolean);
  26558. private static _ClearCoatBumpTextureEnabled;
  26559. /**
  26560. * Are clear coat bump textures enabled in the application.
  26561. */
  26562. static get ClearCoatBumpTextureEnabled(): boolean;
  26563. static set ClearCoatBumpTextureEnabled(value: boolean);
  26564. private static _ClearCoatTintTextureEnabled;
  26565. /**
  26566. * Are clear coat tint textures enabled in the application.
  26567. */
  26568. static get ClearCoatTintTextureEnabled(): boolean;
  26569. static set ClearCoatTintTextureEnabled(value: boolean);
  26570. private static _SheenTextureEnabled;
  26571. /**
  26572. * Are sheen textures enabled in the application.
  26573. */
  26574. static get SheenTextureEnabled(): boolean;
  26575. static set SheenTextureEnabled(value: boolean);
  26576. private static _AnisotropicTextureEnabled;
  26577. /**
  26578. * Are anisotropic textures enabled in the application.
  26579. */
  26580. static get AnisotropicTextureEnabled(): boolean;
  26581. static set AnisotropicTextureEnabled(value: boolean);
  26582. private static _ThicknessTextureEnabled;
  26583. /**
  26584. * Are thickness textures enabled in the application.
  26585. */
  26586. static get ThicknessTextureEnabled(): boolean;
  26587. static set ThicknessTextureEnabled(value: boolean);
  26588. }
  26589. }
  26590. declare module BABYLON {
  26591. /** @hidden */
  26592. export var defaultFragmentDeclaration: {
  26593. name: string;
  26594. shader: string;
  26595. };
  26596. }
  26597. declare module BABYLON {
  26598. /** @hidden */
  26599. export var defaultUboDeclaration: {
  26600. name: string;
  26601. shader: string;
  26602. };
  26603. }
  26604. declare module BABYLON {
  26605. /** @hidden */
  26606. export var lightFragmentDeclaration: {
  26607. name: string;
  26608. shader: string;
  26609. };
  26610. }
  26611. declare module BABYLON {
  26612. /** @hidden */
  26613. export var lightUboDeclaration: {
  26614. name: string;
  26615. shader: string;
  26616. };
  26617. }
  26618. declare module BABYLON {
  26619. /** @hidden */
  26620. export var lightsFragmentFunctions: {
  26621. name: string;
  26622. shader: string;
  26623. };
  26624. }
  26625. declare module BABYLON {
  26626. /** @hidden */
  26627. export var shadowsFragmentFunctions: {
  26628. name: string;
  26629. shader: string;
  26630. };
  26631. }
  26632. declare module BABYLON {
  26633. /** @hidden */
  26634. export var fresnelFunction: {
  26635. name: string;
  26636. shader: string;
  26637. };
  26638. }
  26639. declare module BABYLON {
  26640. /** @hidden */
  26641. export var reflectionFunction: {
  26642. name: string;
  26643. shader: string;
  26644. };
  26645. }
  26646. declare module BABYLON {
  26647. /** @hidden */
  26648. export var bumpFragmentFunctions: {
  26649. name: string;
  26650. shader: string;
  26651. };
  26652. }
  26653. declare module BABYLON {
  26654. /** @hidden */
  26655. export var logDepthDeclaration: {
  26656. name: string;
  26657. shader: string;
  26658. };
  26659. }
  26660. declare module BABYLON {
  26661. /** @hidden */
  26662. export var bumpFragment: {
  26663. name: string;
  26664. shader: string;
  26665. };
  26666. }
  26667. declare module BABYLON {
  26668. /** @hidden */
  26669. export var depthPrePass: {
  26670. name: string;
  26671. shader: string;
  26672. };
  26673. }
  26674. declare module BABYLON {
  26675. /** @hidden */
  26676. export var lightFragment: {
  26677. name: string;
  26678. shader: string;
  26679. };
  26680. }
  26681. declare module BABYLON {
  26682. /** @hidden */
  26683. export var logDepthFragment: {
  26684. name: string;
  26685. shader: string;
  26686. };
  26687. }
  26688. declare module BABYLON {
  26689. /** @hidden */
  26690. export var defaultPixelShader: {
  26691. name: string;
  26692. shader: string;
  26693. };
  26694. }
  26695. declare module BABYLON {
  26696. /** @hidden */
  26697. export var defaultVertexDeclaration: {
  26698. name: string;
  26699. shader: string;
  26700. };
  26701. }
  26702. declare module BABYLON {
  26703. /** @hidden */
  26704. export var bumpVertexDeclaration: {
  26705. name: string;
  26706. shader: string;
  26707. };
  26708. }
  26709. declare module BABYLON {
  26710. /** @hidden */
  26711. export var bumpVertex: {
  26712. name: string;
  26713. shader: string;
  26714. };
  26715. }
  26716. declare module BABYLON {
  26717. /** @hidden */
  26718. export var fogVertex: {
  26719. name: string;
  26720. shader: string;
  26721. };
  26722. }
  26723. declare module BABYLON {
  26724. /** @hidden */
  26725. export var shadowsVertex: {
  26726. name: string;
  26727. shader: string;
  26728. };
  26729. }
  26730. declare module BABYLON {
  26731. /** @hidden */
  26732. export var pointCloudVertex: {
  26733. name: string;
  26734. shader: string;
  26735. };
  26736. }
  26737. declare module BABYLON {
  26738. /** @hidden */
  26739. export var logDepthVertex: {
  26740. name: string;
  26741. shader: string;
  26742. };
  26743. }
  26744. declare module BABYLON {
  26745. /** @hidden */
  26746. export var defaultVertexShader: {
  26747. name: string;
  26748. shader: string;
  26749. };
  26750. }
  26751. declare module BABYLON {
  26752. /** @hidden */
  26753. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26754. MAINUV1: boolean;
  26755. MAINUV2: boolean;
  26756. DIFFUSE: boolean;
  26757. DIFFUSEDIRECTUV: number;
  26758. AMBIENT: boolean;
  26759. AMBIENTDIRECTUV: number;
  26760. OPACITY: boolean;
  26761. OPACITYDIRECTUV: number;
  26762. OPACITYRGB: boolean;
  26763. REFLECTION: boolean;
  26764. EMISSIVE: boolean;
  26765. EMISSIVEDIRECTUV: number;
  26766. SPECULAR: boolean;
  26767. SPECULARDIRECTUV: number;
  26768. BUMP: boolean;
  26769. BUMPDIRECTUV: number;
  26770. PARALLAX: boolean;
  26771. PARALLAXOCCLUSION: boolean;
  26772. SPECULAROVERALPHA: boolean;
  26773. CLIPPLANE: boolean;
  26774. CLIPPLANE2: boolean;
  26775. CLIPPLANE3: boolean;
  26776. CLIPPLANE4: boolean;
  26777. CLIPPLANE5: boolean;
  26778. CLIPPLANE6: boolean;
  26779. ALPHATEST: boolean;
  26780. DEPTHPREPASS: boolean;
  26781. ALPHAFROMDIFFUSE: boolean;
  26782. POINTSIZE: boolean;
  26783. FOG: boolean;
  26784. SPECULARTERM: boolean;
  26785. DIFFUSEFRESNEL: boolean;
  26786. OPACITYFRESNEL: boolean;
  26787. REFLECTIONFRESNEL: boolean;
  26788. REFRACTIONFRESNEL: boolean;
  26789. EMISSIVEFRESNEL: boolean;
  26790. FRESNEL: boolean;
  26791. NORMAL: boolean;
  26792. UV1: boolean;
  26793. UV2: boolean;
  26794. VERTEXCOLOR: boolean;
  26795. VERTEXALPHA: boolean;
  26796. NUM_BONE_INFLUENCERS: number;
  26797. BonesPerMesh: number;
  26798. BONETEXTURE: boolean;
  26799. INSTANCES: boolean;
  26800. GLOSSINESS: boolean;
  26801. ROUGHNESS: boolean;
  26802. EMISSIVEASILLUMINATION: boolean;
  26803. LINKEMISSIVEWITHDIFFUSE: boolean;
  26804. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26805. LIGHTMAP: boolean;
  26806. LIGHTMAPDIRECTUV: number;
  26807. OBJECTSPACE_NORMALMAP: boolean;
  26808. USELIGHTMAPASSHADOWMAP: boolean;
  26809. REFLECTIONMAP_3D: boolean;
  26810. REFLECTIONMAP_SPHERICAL: boolean;
  26811. REFLECTIONMAP_PLANAR: boolean;
  26812. REFLECTIONMAP_CUBIC: boolean;
  26813. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26814. REFLECTIONMAP_PROJECTION: boolean;
  26815. REFLECTIONMAP_SKYBOX: boolean;
  26816. REFLECTIONMAP_EXPLICIT: boolean;
  26817. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26818. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26819. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26820. INVERTCUBICMAP: boolean;
  26821. LOGARITHMICDEPTH: boolean;
  26822. REFRACTION: boolean;
  26823. REFRACTIONMAP_3D: boolean;
  26824. REFLECTIONOVERALPHA: boolean;
  26825. TWOSIDEDLIGHTING: boolean;
  26826. SHADOWFLOAT: boolean;
  26827. MORPHTARGETS: boolean;
  26828. MORPHTARGETS_NORMAL: boolean;
  26829. MORPHTARGETS_TANGENT: boolean;
  26830. MORPHTARGETS_UV: boolean;
  26831. NUM_MORPH_INFLUENCERS: number;
  26832. NONUNIFORMSCALING: boolean;
  26833. PREMULTIPLYALPHA: boolean;
  26834. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26835. ALPHABLEND: boolean;
  26836. IMAGEPROCESSING: boolean;
  26837. VIGNETTE: boolean;
  26838. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26839. VIGNETTEBLENDMODEOPAQUE: boolean;
  26840. TONEMAPPING: boolean;
  26841. TONEMAPPING_ACES: boolean;
  26842. CONTRAST: boolean;
  26843. COLORCURVES: boolean;
  26844. COLORGRADING: boolean;
  26845. COLORGRADING3D: boolean;
  26846. SAMPLER3DGREENDEPTH: boolean;
  26847. SAMPLER3DBGRMAP: boolean;
  26848. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26849. MULTIVIEW: boolean;
  26850. /**
  26851. * If the reflection texture on this material is in linear color space
  26852. * @hidden
  26853. */
  26854. IS_REFLECTION_LINEAR: boolean;
  26855. /**
  26856. * If the refraction texture on this material is in linear color space
  26857. * @hidden
  26858. */
  26859. IS_REFRACTION_LINEAR: boolean;
  26860. EXPOSURE: boolean;
  26861. constructor();
  26862. setReflectionMode(modeToEnable: string): void;
  26863. }
  26864. /**
  26865. * This is the default material used in Babylon. It is the best trade off between quality
  26866. * and performances.
  26867. * @see http://doc.babylonjs.com/babylon101/materials
  26868. */
  26869. export class StandardMaterial extends PushMaterial {
  26870. private _diffuseTexture;
  26871. /**
  26872. * The basic texture of the material as viewed under a light.
  26873. */
  26874. diffuseTexture: Nullable<BaseTexture>;
  26875. private _ambientTexture;
  26876. /**
  26877. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26878. */
  26879. ambientTexture: Nullable<BaseTexture>;
  26880. private _opacityTexture;
  26881. /**
  26882. * Define the transparency of the material from a texture.
  26883. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26884. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26885. */
  26886. opacityTexture: Nullable<BaseTexture>;
  26887. private _reflectionTexture;
  26888. /**
  26889. * Define the texture used to display the reflection.
  26890. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26891. */
  26892. reflectionTexture: Nullable<BaseTexture>;
  26893. private _emissiveTexture;
  26894. /**
  26895. * Define texture of the material as if self lit.
  26896. * This will be mixed in the final result even in the absence of light.
  26897. */
  26898. emissiveTexture: Nullable<BaseTexture>;
  26899. private _specularTexture;
  26900. /**
  26901. * Define how the color and intensity of the highlight given by the light in the material.
  26902. */
  26903. specularTexture: Nullable<BaseTexture>;
  26904. private _bumpTexture;
  26905. /**
  26906. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26907. * 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.
  26908. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26909. */
  26910. bumpTexture: Nullable<BaseTexture>;
  26911. private _lightmapTexture;
  26912. /**
  26913. * Complex lighting can be computationally expensive to compute at runtime.
  26914. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26915. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26916. */
  26917. lightmapTexture: Nullable<BaseTexture>;
  26918. private _refractionTexture;
  26919. /**
  26920. * Define the texture used to display the refraction.
  26921. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26922. */
  26923. refractionTexture: Nullable<BaseTexture>;
  26924. /**
  26925. * The color of the material lit by the environmental background lighting.
  26926. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26927. */
  26928. ambientColor: Color3;
  26929. /**
  26930. * The basic color of the material as viewed under a light.
  26931. */
  26932. diffuseColor: Color3;
  26933. /**
  26934. * Define how the color and intensity of the highlight given by the light in the material.
  26935. */
  26936. specularColor: Color3;
  26937. /**
  26938. * Define the color of the material as if self lit.
  26939. * This will be mixed in the final result even in the absence of light.
  26940. */
  26941. emissiveColor: Color3;
  26942. /**
  26943. * Defines how sharp are the highlights in the material.
  26944. * The bigger the value the sharper giving a more glossy feeling to the result.
  26945. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26946. */
  26947. specularPower: number;
  26948. private _useAlphaFromDiffuseTexture;
  26949. /**
  26950. * Does the transparency come from the diffuse texture alpha channel.
  26951. */
  26952. useAlphaFromDiffuseTexture: boolean;
  26953. private _useEmissiveAsIllumination;
  26954. /**
  26955. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26956. */
  26957. useEmissiveAsIllumination: boolean;
  26958. private _linkEmissiveWithDiffuse;
  26959. /**
  26960. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26961. * the emissive level when the final color is close to one.
  26962. */
  26963. linkEmissiveWithDiffuse: boolean;
  26964. private _useSpecularOverAlpha;
  26965. /**
  26966. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26967. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26968. */
  26969. useSpecularOverAlpha: boolean;
  26970. private _useReflectionOverAlpha;
  26971. /**
  26972. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26973. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26974. */
  26975. useReflectionOverAlpha: boolean;
  26976. private _disableLighting;
  26977. /**
  26978. * Does lights from the scene impacts this material.
  26979. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26980. */
  26981. disableLighting: boolean;
  26982. private _useObjectSpaceNormalMap;
  26983. /**
  26984. * Allows using an object space normal map (instead of tangent space).
  26985. */
  26986. useObjectSpaceNormalMap: boolean;
  26987. private _useParallax;
  26988. /**
  26989. * Is parallax enabled or not.
  26990. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26991. */
  26992. useParallax: boolean;
  26993. private _useParallaxOcclusion;
  26994. /**
  26995. * Is parallax occlusion enabled or not.
  26996. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26997. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26998. */
  26999. useParallaxOcclusion: boolean;
  27000. /**
  27001. * 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.
  27002. */
  27003. parallaxScaleBias: number;
  27004. private _roughness;
  27005. /**
  27006. * Helps to define how blurry the reflections should appears in the material.
  27007. */
  27008. roughness: number;
  27009. /**
  27010. * In case of refraction, define the value of the index of refraction.
  27011. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27012. */
  27013. indexOfRefraction: number;
  27014. /**
  27015. * Invert the refraction texture alongside the y axis.
  27016. * It can be useful with procedural textures or probe for instance.
  27017. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27018. */
  27019. invertRefractionY: boolean;
  27020. /**
  27021. * Defines the alpha limits in alpha test mode.
  27022. */
  27023. alphaCutOff: number;
  27024. private _useLightmapAsShadowmap;
  27025. /**
  27026. * In case of light mapping, define whether the map contains light or shadow informations.
  27027. */
  27028. useLightmapAsShadowmap: boolean;
  27029. private _diffuseFresnelParameters;
  27030. /**
  27031. * Define the diffuse fresnel parameters of the material.
  27032. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27033. */
  27034. diffuseFresnelParameters: FresnelParameters;
  27035. private _opacityFresnelParameters;
  27036. /**
  27037. * Define the opacity fresnel parameters of the material.
  27038. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27039. */
  27040. opacityFresnelParameters: FresnelParameters;
  27041. private _reflectionFresnelParameters;
  27042. /**
  27043. * Define the reflection fresnel parameters of the material.
  27044. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27045. */
  27046. reflectionFresnelParameters: FresnelParameters;
  27047. private _refractionFresnelParameters;
  27048. /**
  27049. * Define the refraction fresnel parameters of the material.
  27050. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27051. */
  27052. refractionFresnelParameters: FresnelParameters;
  27053. private _emissiveFresnelParameters;
  27054. /**
  27055. * Define the emissive fresnel parameters of the material.
  27056. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27057. */
  27058. emissiveFresnelParameters: FresnelParameters;
  27059. private _useReflectionFresnelFromSpecular;
  27060. /**
  27061. * If true automatically deducts the fresnels values from the material specularity.
  27062. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27063. */
  27064. useReflectionFresnelFromSpecular: boolean;
  27065. private _useGlossinessFromSpecularMapAlpha;
  27066. /**
  27067. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27068. */
  27069. useGlossinessFromSpecularMapAlpha: boolean;
  27070. private _maxSimultaneousLights;
  27071. /**
  27072. * Defines the maximum number of lights that can be used in the material
  27073. */
  27074. maxSimultaneousLights: number;
  27075. private _invertNormalMapX;
  27076. /**
  27077. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27078. */
  27079. invertNormalMapX: boolean;
  27080. private _invertNormalMapY;
  27081. /**
  27082. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27083. */
  27084. invertNormalMapY: boolean;
  27085. private _twoSidedLighting;
  27086. /**
  27087. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27088. */
  27089. twoSidedLighting: boolean;
  27090. /**
  27091. * Default configuration related to image processing available in the standard Material.
  27092. */
  27093. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27094. /**
  27095. * Gets the image processing configuration used either in this material.
  27096. */
  27097. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27098. /**
  27099. * Sets the Default image processing configuration used either in the this material.
  27100. *
  27101. * If sets to null, the scene one is in use.
  27102. */
  27103. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27104. /**
  27105. * Keep track of the image processing observer to allow dispose and replace.
  27106. */
  27107. private _imageProcessingObserver;
  27108. /**
  27109. * Attaches a new image processing configuration to the Standard Material.
  27110. * @param configuration
  27111. */
  27112. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27113. /**
  27114. * Gets wether the color curves effect is enabled.
  27115. */
  27116. get cameraColorCurvesEnabled(): boolean;
  27117. /**
  27118. * Sets wether the color curves effect is enabled.
  27119. */
  27120. set cameraColorCurvesEnabled(value: boolean);
  27121. /**
  27122. * Gets wether the color grading effect is enabled.
  27123. */
  27124. get cameraColorGradingEnabled(): boolean;
  27125. /**
  27126. * Gets wether the color grading effect is enabled.
  27127. */
  27128. set cameraColorGradingEnabled(value: boolean);
  27129. /**
  27130. * Gets wether tonemapping is enabled or not.
  27131. */
  27132. get cameraToneMappingEnabled(): boolean;
  27133. /**
  27134. * Sets wether tonemapping is enabled or not
  27135. */
  27136. set cameraToneMappingEnabled(value: boolean);
  27137. /**
  27138. * The camera exposure used on this material.
  27139. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27140. * This corresponds to a photographic exposure.
  27141. */
  27142. get cameraExposure(): number;
  27143. /**
  27144. * The camera exposure used on this material.
  27145. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27146. * This corresponds to a photographic exposure.
  27147. */
  27148. set cameraExposure(value: number);
  27149. /**
  27150. * Gets The camera contrast used on this material.
  27151. */
  27152. get cameraContrast(): number;
  27153. /**
  27154. * Sets The camera contrast used on this material.
  27155. */
  27156. set cameraContrast(value: number);
  27157. /**
  27158. * Gets the Color Grading 2D Lookup Texture.
  27159. */
  27160. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27161. /**
  27162. * Sets the Color Grading 2D Lookup Texture.
  27163. */
  27164. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27165. /**
  27166. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27167. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27168. * 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;
  27169. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27170. */
  27171. get cameraColorCurves(): Nullable<ColorCurves>;
  27172. /**
  27173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27175. * 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;
  27176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27177. */
  27178. set cameraColorCurves(value: Nullable<ColorCurves>);
  27179. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27180. protected _worldViewProjectionMatrix: Matrix;
  27181. protected _globalAmbientColor: Color3;
  27182. protected _useLogarithmicDepth: boolean;
  27183. protected _rebuildInParallel: boolean;
  27184. /**
  27185. * Instantiates a new standard material.
  27186. * This is the default material used in Babylon. It is the best trade off between quality
  27187. * and performances.
  27188. * @see http://doc.babylonjs.com/babylon101/materials
  27189. * @param name Define the name of the material in the scene
  27190. * @param scene Define the scene the material belong to
  27191. */
  27192. constructor(name: string, scene: Scene);
  27193. /**
  27194. * Gets a boolean indicating that current material needs to register RTT
  27195. */
  27196. get hasRenderTargetTextures(): boolean;
  27197. /**
  27198. * Gets the current class name of the material e.g. "StandardMaterial"
  27199. * Mainly use in serialization.
  27200. * @returns the class name
  27201. */
  27202. getClassName(): string;
  27203. /**
  27204. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27205. * You can try switching to logarithmic depth.
  27206. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27207. */
  27208. get useLogarithmicDepth(): boolean;
  27209. set useLogarithmicDepth(value: boolean);
  27210. /**
  27211. * Specifies if the material will require alpha blending
  27212. * @returns a boolean specifying if alpha blending is needed
  27213. */
  27214. needAlphaBlending(): boolean;
  27215. /**
  27216. * Specifies if this material should be rendered in alpha test mode
  27217. * @returns a boolean specifying if an alpha test is needed.
  27218. */
  27219. needAlphaTesting(): boolean;
  27220. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27221. /**
  27222. * Get the texture used for alpha test purpose.
  27223. * @returns the diffuse texture in case of the standard material.
  27224. */
  27225. getAlphaTestTexture(): Nullable<BaseTexture>;
  27226. /**
  27227. * Get if the submesh is ready to be used and all its information available.
  27228. * Child classes can use it to update shaders
  27229. * @param mesh defines the mesh to check
  27230. * @param subMesh defines which submesh to check
  27231. * @param useInstances specifies that instances should be used
  27232. * @returns a boolean indicating that the submesh is ready or not
  27233. */
  27234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27235. /**
  27236. * Builds the material UBO layouts.
  27237. * Used internally during the effect preparation.
  27238. */
  27239. buildUniformLayout(): void;
  27240. /**
  27241. * Unbinds the material from the mesh
  27242. */
  27243. unbind(): void;
  27244. /**
  27245. * Binds the submesh to this material by preparing the effect and shader to draw
  27246. * @param world defines the world transformation matrix
  27247. * @param mesh defines the mesh containing the submesh
  27248. * @param subMesh defines the submesh to bind the material to
  27249. */
  27250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27251. /**
  27252. * Get the list of animatables in the material.
  27253. * @returns the list of animatables object used in the material
  27254. */
  27255. getAnimatables(): IAnimatable[];
  27256. /**
  27257. * Gets the active textures from the material
  27258. * @returns an array of textures
  27259. */
  27260. getActiveTextures(): BaseTexture[];
  27261. /**
  27262. * Specifies if the material uses a texture
  27263. * @param texture defines the texture to check against the material
  27264. * @returns a boolean specifying if the material uses the texture
  27265. */
  27266. hasTexture(texture: BaseTexture): boolean;
  27267. /**
  27268. * Disposes the material
  27269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27271. */
  27272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27273. /**
  27274. * Makes a duplicate of the material, and gives it a new name
  27275. * @param name defines the new name for the duplicated material
  27276. * @returns the cloned material
  27277. */
  27278. clone(name: string): StandardMaterial;
  27279. /**
  27280. * Serializes this material in a JSON representation
  27281. * @returns the serialized material object
  27282. */
  27283. serialize(): any;
  27284. /**
  27285. * Creates a standard material from parsed material data
  27286. * @param source defines the JSON representation of the material
  27287. * @param scene defines the hosting scene
  27288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27289. * @returns a new standard material
  27290. */
  27291. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27292. /**
  27293. * Are diffuse textures enabled in the application.
  27294. */
  27295. static get DiffuseTextureEnabled(): boolean;
  27296. static set DiffuseTextureEnabled(value: boolean);
  27297. /**
  27298. * Are ambient textures enabled in the application.
  27299. */
  27300. static get AmbientTextureEnabled(): boolean;
  27301. static set AmbientTextureEnabled(value: boolean);
  27302. /**
  27303. * Are opacity textures enabled in the application.
  27304. */
  27305. static get OpacityTextureEnabled(): boolean;
  27306. static set OpacityTextureEnabled(value: boolean);
  27307. /**
  27308. * Are reflection textures enabled in the application.
  27309. */
  27310. static get ReflectionTextureEnabled(): boolean;
  27311. static set ReflectionTextureEnabled(value: boolean);
  27312. /**
  27313. * Are emissive textures enabled in the application.
  27314. */
  27315. static get EmissiveTextureEnabled(): boolean;
  27316. static set EmissiveTextureEnabled(value: boolean);
  27317. /**
  27318. * Are specular textures enabled in the application.
  27319. */
  27320. static get SpecularTextureEnabled(): boolean;
  27321. static set SpecularTextureEnabled(value: boolean);
  27322. /**
  27323. * Are bump textures enabled in the application.
  27324. */
  27325. static get BumpTextureEnabled(): boolean;
  27326. static set BumpTextureEnabled(value: boolean);
  27327. /**
  27328. * Are lightmap textures enabled in the application.
  27329. */
  27330. static get LightmapTextureEnabled(): boolean;
  27331. static set LightmapTextureEnabled(value: boolean);
  27332. /**
  27333. * Are refraction textures enabled in the application.
  27334. */
  27335. static get RefractionTextureEnabled(): boolean;
  27336. static set RefractionTextureEnabled(value: boolean);
  27337. /**
  27338. * Are color grading textures enabled in the application.
  27339. */
  27340. static get ColorGradingTextureEnabled(): boolean;
  27341. static set ColorGradingTextureEnabled(value: boolean);
  27342. /**
  27343. * Are fresnels enabled in the application.
  27344. */
  27345. static get FresnelEnabled(): boolean;
  27346. static set FresnelEnabled(value: boolean);
  27347. }
  27348. }
  27349. declare module BABYLON {
  27350. /**
  27351. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27352. *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.
  27353. * The SPS is also a particle system. It provides some methods to manage the particles.
  27354. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27355. *
  27356. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27357. */
  27358. export class SolidParticleSystem implements IDisposable {
  27359. /**
  27360. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27361. * Example : var p = SPS.particles[i];
  27362. */
  27363. particles: SolidParticle[];
  27364. /**
  27365. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27366. */
  27367. nbParticles: number;
  27368. /**
  27369. * If the particles must ever face the camera (default false). Useful for planar particles.
  27370. */
  27371. billboard: boolean;
  27372. /**
  27373. * Recompute normals when adding a shape
  27374. */
  27375. recomputeNormals: boolean;
  27376. /**
  27377. * This a counter ofr your own usage. It's not set by any SPS functions.
  27378. */
  27379. counter: number;
  27380. /**
  27381. * The SPS name. This name is also given to the underlying mesh.
  27382. */
  27383. name: string;
  27384. /**
  27385. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27386. */
  27387. mesh: Mesh;
  27388. /**
  27389. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27390. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27391. */
  27392. vars: any;
  27393. /**
  27394. * This array is populated when the SPS is set as 'pickable'.
  27395. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27396. * Each element of this array is an object `{idx: int, faceId: int}`.
  27397. * `idx` is the picked particle index in the `SPS.particles` array
  27398. * `faceId` is the picked face index counted within this particle.
  27399. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27400. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27401. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27402. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27403. */
  27404. pickedParticles: {
  27405. idx: number;
  27406. faceId: number;
  27407. }[];
  27408. /**
  27409. * This array is populated when the SPS is set as 'pickable'
  27410. * Each key of this array is a submesh index.
  27411. * Each element of this array is a second array defined like this :
  27412. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27413. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27414. * `idx` is the picked particle index in the `SPS.particles` array
  27415. * `faceId` is the picked face index counted within this particle.
  27416. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27417. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27418. */
  27419. pickedBySubMesh: {
  27420. idx: number;
  27421. faceId: number;
  27422. }[][];
  27423. /**
  27424. * This array is populated when `enableDepthSort` is set to true.
  27425. * Each element of this array is an instance of the class DepthSortedParticle.
  27426. */
  27427. depthSortedParticles: DepthSortedParticle[];
  27428. /**
  27429. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27430. * @hidden
  27431. */
  27432. _bSphereOnly: boolean;
  27433. /**
  27434. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27435. * @hidden
  27436. */
  27437. _bSphereRadiusFactor: number;
  27438. private _scene;
  27439. private _positions;
  27440. private _indices;
  27441. private _normals;
  27442. private _colors;
  27443. private _uvs;
  27444. private _indices32;
  27445. private _positions32;
  27446. private _normals32;
  27447. private _fixedNormal32;
  27448. private _colors32;
  27449. private _uvs32;
  27450. private _index;
  27451. private _updatable;
  27452. private _pickable;
  27453. private _isVisibilityBoxLocked;
  27454. private _alwaysVisible;
  27455. private _depthSort;
  27456. private _expandable;
  27457. private _shapeCounter;
  27458. private _copy;
  27459. private _color;
  27460. private _computeParticleColor;
  27461. private _computeParticleTexture;
  27462. private _computeParticleRotation;
  27463. private _computeParticleVertex;
  27464. private _computeBoundingBox;
  27465. private _depthSortParticles;
  27466. private _camera;
  27467. private _mustUnrotateFixedNormals;
  27468. private _particlesIntersect;
  27469. private _needs32Bits;
  27470. private _isNotBuilt;
  27471. private _lastParticleId;
  27472. private _idxOfId;
  27473. private _multimaterialEnabled;
  27474. private _useModelMaterial;
  27475. private _indicesByMaterial;
  27476. private _materialIndexes;
  27477. private _depthSortFunction;
  27478. private _materialSortFunction;
  27479. private _materials;
  27480. private _multimaterial;
  27481. private _materialIndexesById;
  27482. private _defaultMaterial;
  27483. private _autoUpdateSubMeshes;
  27484. /**
  27485. * Creates a SPS (Solid Particle System) object.
  27486. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27487. * @param scene (Scene) is the scene in which the SPS is added.
  27488. * @param options defines the options of the sps e.g.
  27489. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27490. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27491. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27492. * * 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.
  27493. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27494. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27495. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27496. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27497. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27498. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27499. */
  27500. constructor(name: string, scene: Scene, options?: {
  27501. updatable?: boolean;
  27502. isPickable?: boolean;
  27503. enableDepthSort?: boolean;
  27504. particleIntersection?: boolean;
  27505. boundingSphereOnly?: boolean;
  27506. bSphereRadiusFactor?: number;
  27507. expandable?: boolean;
  27508. useModelMaterial?: boolean;
  27509. enableMultiMaterial?: boolean;
  27510. });
  27511. /**
  27512. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27513. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27514. * @returns the created mesh
  27515. */
  27516. buildMesh(): Mesh;
  27517. /**
  27518. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27519. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27520. * Thus the particles generated from `digest()` have their property `position` set yet.
  27521. * @param mesh ( Mesh ) is the mesh to be digested
  27522. * @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
  27523. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27524. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27525. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27526. * @returns the current SPS
  27527. */
  27528. digest(mesh: Mesh, options?: {
  27529. facetNb?: number;
  27530. number?: number;
  27531. delta?: number;
  27532. storage?: [];
  27533. }): SolidParticleSystem;
  27534. /**
  27535. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27536. * @hidden
  27537. */
  27538. private _unrotateFixedNormals;
  27539. /**
  27540. * Resets the temporary working copy particle
  27541. * @hidden
  27542. */
  27543. private _resetCopy;
  27544. /**
  27545. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27546. * @param p the current index in the positions array to be updated
  27547. * @param ind the current index in the indices array
  27548. * @param shape a Vector3 array, the shape geometry
  27549. * @param positions the positions array to be updated
  27550. * @param meshInd the shape indices array
  27551. * @param indices the indices array to be updated
  27552. * @param meshUV the shape uv array
  27553. * @param uvs the uv array to be updated
  27554. * @param meshCol the shape color array
  27555. * @param colors the color array to be updated
  27556. * @param meshNor the shape normals array
  27557. * @param normals the normals array to be updated
  27558. * @param idx the particle index
  27559. * @param idxInShape the particle index in its shape
  27560. * @param options the addShape() method passed options
  27561. * @model the particle model
  27562. * @hidden
  27563. */
  27564. private _meshBuilder;
  27565. /**
  27566. * Returns a shape Vector3 array from positions float array
  27567. * @param positions float array
  27568. * @returns a vector3 array
  27569. * @hidden
  27570. */
  27571. private _posToShape;
  27572. /**
  27573. * Returns a shapeUV array from a float uvs (array deep copy)
  27574. * @param uvs as a float array
  27575. * @returns a shapeUV array
  27576. * @hidden
  27577. */
  27578. private _uvsToShapeUV;
  27579. /**
  27580. * Adds a new particle object in the particles array
  27581. * @param idx particle index in particles array
  27582. * @param id particle id
  27583. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27584. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27585. * @param model particle ModelShape object
  27586. * @param shapeId model shape identifier
  27587. * @param idxInShape index of the particle in the current model
  27588. * @param bInfo model bounding info object
  27589. * @param storage target storage array, if any
  27590. * @hidden
  27591. */
  27592. private _addParticle;
  27593. /**
  27594. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27595. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27596. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27597. * @param nb (positive integer) the number of particles to be created from this model
  27598. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27599. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27600. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27601. * @returns the number of shapes in the system
  27602. */
  27603. addShape(mesh: Mesh, nb: number, options?: {
  27604. positionFunction?: any;
  27605. vertexFunction?: any;
  27606. storage?: [];
  27607. }): number;
  27608. /**
  27609. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27610. * @hidden
  27611. */
  27612. private _rebuildParticle;
  27613. /**
  27614. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27615. * @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.
  27616. * @returns the SPS.
  27617. */
  27618. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27619. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27620. * Returns an array with the removed particles.
  27621. * 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.
  27622. * The SPS can't be empty so at least one particle needs to remain in place.
  27623. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27624. * @param start index of the first particle to remove
  27625. * @param end index of the last particle to remove (included)
  27626. * @returns an array populated with the removed particles
  27627. */
  27628. removeParticles(start: number, end: number): SolidParticle[];
  27629. /**
  27630. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27631. * @param solidParticleArray an array populated with Solid Particles objects
  27632. * @returns the SPS
  27633. */
  27634. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27635. /**
  27636. * Creates a new particle and modifies the SPS mesh geometry :
  27637. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27638. * - calls _addParticle() to populate the particle array
  27639. * factorized code from addShape() and insertParticlesFromArray()
  27640. * @param idx particle index in the particles array
  27641. * @param i particle index in its shape
  27642. * @param modelShape particle ModelShape object
  27643. * @param shape shape vertex array
  27644. * @param meshInd shape indices array
  27645. * @param meshUV shape uv array
  27646. * @param meshCol shape color array
  27647. * @param meshNor shape normals array
  27648. * @param bbInfo shape bounding info
  27649. * @param storage target particle storage
  27650. * @options addShape() passed options
  27651. * @hidden
  27652. */
  27653. private _insertNewParticle;
  27654. /**
  27655. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27656. * This method calls `updateParticle()` for each particle of the SPS.
  27657. * For an animated SPS, it is usually called within the render loop.
  27658. * 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.
  27659. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27660. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27661. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27662. * @returns the SPS.
  27663. */
  27664. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27665. /**
  27666. * Disposes the SPS.
  27667. */
  27668. dispose(): void;
  27669. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27670. * idx is the particle index in the SPS
  27671. * faceId is the picked face index counted within this particle.
  27672. * Returns null if the pickInfo can't identify a picked particle.
  27673. * @param pickingInfo (PickingInfo object)
  27674. * @returns {idx: number, faceId: number} or null
  27675. */
  27676. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27677. idx: number;
  27678. faceId: number;
  27679. }>;
  27680. /**
  27681. * Returns a SolidParticle object from its identifier : particle.id
  27682. * @param id (integer) the particle Id
  27683. * @returns the searched particle or null if not found in the SPS.
  27684. */
  27685. getParticleById(id: number): Nullable<SolidParticle>;
  27686. /**
  27687. * Returns a new array populated with the particles having the passed shapeId.
  27688. * @param shapeId (integer) the shape identifier
  27689. * @returns a new solid particle array
  27690. */
  27691. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27692. /**
  27693. * Populates the passed array "ref" with the particles having the passed shapeId.
  27694. * @param shapeId the shape identifier
  27695. * @returns the SPS
  27696. * @param ref
  27697. */
  27698. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27699. /**
  27700. * Computes the required SubMeshes according the materials assigned to the particles.
  27701. * @returns the solid particle system.
  27702. * Does nothing if called before the SPS mesh is built.
  27703. */
  27704. computeSubMeshes(): SolidParticleSystem;
  27705. /**
  27706. * Sorts the solid particles by material when MultiMaterial is enabled.
  27707. * Updates the indices32 array.
  27708. * Updates the indicesByMaterial array.
  27709. * Updates the mesh indices array.
  27710. * @returns the SPS
  27711. * @hidden
  27712. */
  27713. private _sortParticlesByMaterial;
  27714. /**
  27715. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27716. * @hidden
  27717. */
  27718. private _setMaterialIndexesById;
  27719. /**
  27720. * Returns an array with unique values of Materials from the passed array
  27721. * @param array the material array to be checked and filtered
  27722. * @hidden
  27723. */
  27724. private _filterUniqueMaterialId;
  27725. /**
  27726. * Sets a new Standard Material as _defaultMaterial if not already set.
  27727. * @hidden
  27728. */
  27729. private _setDefaultMaterial;
  27730. /**
  27731. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27732. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27733. * @returns the SPS.
  27734. */
  27735. refreshVisibleSize(): SolidParticleSystem;
  27736. /**
  27737. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27738. * @param size the size (float) of the visibility box
  27739. * note : this doesn't lock the SPS mesh bounding box.
  27740. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27741. */
  27742. setVisibilityBox(size: number): void;
  27743. /**
  27744. * Gets whether the SPS as always visible or not
  27745. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27746. */
  27747. get isAlwaysVisible(): boolean;
  27748. /**
  27749. * Sets the SPS as always visible or not
  27750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27751. */
  27752. set isAlwaysVisible(val: boolean);
  27753. /**
  27754. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27756. */
  27757. set isVisibilityBoxLocked(val: boolean);
  27758. /**
  27759. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27760. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27761. */
  27762. get isVisibilityBoxLocked(): boolean;
  27763. /**
  27764. * Tells to `setParticles()` to compute the particle rotations or not.
  27765. * Default value : true. The SPS is faster when it's set to false.
  27766. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27767. */
  27768. set computeParticleRotation(val: boolean);
  27769. /**
  27770. * Tells to `setParticles()` to compute the particle colors or not.
  27771. * Default value : true. The SPS is faster when it's set to false.
  27772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27773. */
  27774. set computeParticleColor(val: boolean);
  27775. set computeParticleTexture(val: boolean);
  27776. /**
  27777. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27778. * Default value : false. The SPS is faster when it's set to false.
  27779. * Note : the particle custom vertex positions aren't stored values.
  27780. */
  27781. set computeParticleVertex(val: boolean);
  27782. /**
  27783. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27784. */
  27785. set computeBoundingBox(val: boolean);
  27786. /**
  27787. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27788. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27789. * Default : `true`
  27790. */
  27791. set depthSortParticles(val: boolean);
  27792. /**
  27793. * Gets if `setParticles()` computes the particle rotations or not.
  27794. * Default value : true. The SPS is faster when it's set to false.
  27795. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27796. */
  27797. get computeParticleRotation(): boolean;
  27798. /**
  27799. * Gets if `setParticles()` computes the particle colors or not.
  27800. * Default value : true. The SPS is faster when it's set to false.
  27801. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27802. */
  27803. get computeParticleColor(): boolean;
  27804. /**
  27805. * Gets if `setParticles()` computes the particle textures or not.
  27806. * Default value : true. The SPS is faster when it's set to false.
  27807. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27808. */
  27809. get computeParticleTexture(): boolean;
  27810. /**
  27811. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27812. * Default value : false. The SPS is faster when it's set to false.
  27813. * Note : the particle custom vertex positions aren't stored values.
  27814. */
  27815. get computeParticleVertex(): boolean;
  27816. /**
  27817. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27818. */
  27819. get computeBoundingBox(): boolean;
  27820. /**
  27821. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27822. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27823. * Default : `true`
  27824. */
  27825. get depthSortParticles(): boolean;
  27826. /**
  27827. * Gets if the SPS is created as expandable at construction time.
  27828. * Default : `false`
  27829. */
  27830. get expandable(): boolean;
  27831. /**
  27832. * Gets if the SPS supports the Multi Materials
  27833. */
  27834. get multimaterialEnabled(): boolean;
  27835. /**
  27836. * Gets if the SPS uses the model materials for its own multimaterial.
  27837. */
  27838. get useModelMaterial(): boolean;
  27839. /**
  27840. * The SPS used material array.
  27841. */
  27842. get materials(): Material[];
  27843. /**
  27844. * Sets the SPS MultiMaterial from the passed materials.
  27845. * Note : the passed array is internally copied and not used then by reference.
  27846. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27847. */
  27848. setMultiMaterial(materials: Material[]): void;
  27849. /**
  27850. * The SPS computed multimaterial object
  27851. */
  27852. get multimaterial(): MultiMaterial;
  27853. set multimaterial(mm: MultiMaterial);
  27854. /**
  27855. * If the subMeshes must be updated on the next call to setParticles()
  27856. */
  27857. get autoUpdateSubMeshes(): boolean;
  27858. set autoUpdateSubMeshes(val: boolean);
  27859. /**
  27860. * This function does nothing. It may be overwritten to set all the particle first values.
  27861. * The SPS doesn't call this function, you may have to call it by your own.
  27862. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27863. */
  27864. initParticles(): void;
  27865. /**
  27866. * This function does nothing. It may be overwritten to recycle a particle.
  27867. * The SPS doesn't call this function, you may have to call it by your own.
  27868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27869. * @param particle The particle to recycle
  27870. * @returns the recycled particle
  27871. */
  27872. recycleParticle(particle: SolidParticle): SolidParticle;
  27873. /**
  27874. * Updates a particle : this function should be overwritten by the user.
  27875. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27876. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27877. * @example : just set a particle position or velocity and recycle conditions
  27878. * @param particle The particle to update
  27879. * @returns the updated particle
  27880. */
  27881. updateParticle(particle: SolidParticle): SolidParticle;
  27882. /**
  27883. * Updates a vertex of a particle : it can be overwritten by the user.
  27884. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27885. * @param particle the current particle
  27886. * @param vertex the current index of the current particle
  27887. * @param pt the index of the current vertex in the particle shape
  27888. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27889. * @example : just set a vertex particle position
  27890. * @returns the updated vertex
  27891. */
  27892. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27893. /**
  27894. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27895. * This does nothing and may be overwritten by the user.
  27896. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27897. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27898. * @param update the boolean update value actually passed to setParticles()
  27899. */
  27900. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27901. /**
  27902. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27903. * This will be passed three parameters.
  27904. * This does nothing and may be overwritten by the user.
  27905. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27906. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27907. * @param update the boolean update value actually passed to setParticles()
  27908. */
  27909. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27910. }
  27911. }
  27912. declare module BABYLON {
  27913. /**
  27914. * Represents one particle of a solid particle system.
  27915. */
  27916. export class SolidParticle {
  27917. /**
  27918. * particle global index
  27919. */
  27920. idx: number;
  27921. /**
  27922. * particle identifier
  27923. */
  27924. id: number;
  27925. /**
  27926. * The color of the particle
  27927. */
  27928. color: Nullable<Color4>;
  27929. /**
  27930. * The world space position of the particle.
  27931. */
  27932. position: Vector3;
  27933. /**
  27934. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27935. */
  27936. rotation: Vector3;
  27937. /**
  27938. * The world space rotation quaternion of the particle.
  27939. */
  27940. rotationQuaternion: Nullable<Quaternion>;
  27941. /**
  27942. * The scaling of the particle.
  27943. */
  27944. scaling: Vector3;
  27945. /**
  27946. * The uvs of the particle.
  27947. */
  27948. uvs: Vector4;
  27949. /**
  27950. * The current speed of the particle.
  27951. */
  27952. velocity: Vector3;
  27953. /**
  27954. * The pivot point in the particle local space.
  27955. */
  27956. pivot: Vector3;
  27957. /**
  27958. * Must the particle be translated from its pivot point in its local space ?
  27959. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27960. * Default : false
  27961. */
  27962. translateFromPivot: boolean;
  27963. /**
  27964. * Is the particle active or not ?
  27965. */
  27966. alive: boolean;
  27967. /**
  27968. * Is the particle visible or not ?
  27969. */
  27970. isVisible: boolean;
  27971. /**
  27972. * Index of this particle in the global "positions" array (Internal use)
  27973. * @hidden
  27974. */
  27975. _pos: number;
  27976. /**
  27977. * @hidden Index of this particle in the global "indices" array (Internal use)
  27978. */
  27979. _ind: number;
  27980. /**
  27981. * @hidden ModelShape of this particle (Internal use)
  27982. */
  27983. _model: ModelShape;
  27984. /**
  27985. * ModelShape id of this particle
  27986. */
  27987. shapeId: number;
  27988. /**
  27989. * Index of the particle in its shape id
  27990. */
  27991. idxInShape: number;
  27992. /**
  27993. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27994. */
  27995. _modelBoundingInfo: BoundingInfo;
  27996. /**
  27997. * @hidden Particle BoundingInfo object (Internal use)
  27998. */
  27999. _boundingInfo: BoundingInfo;
  28000. /**
  28001. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28002. */
  28003. _sps: SolidParticleSystem;
  28004. /**
  28005. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28006. */
  28007. _stillInvisible: boolean;
  28008. /**
  28009. * @hidden Last computed particle rotation matrix
  28010. */
  28011. _rotationMatrix: number[];
  28012. /**
  28013. * Parent particle Id, if any.
  28014. * Default null.
  28015. */
  28016. parentId: Nullable<number>;
  28017. /**
  28018. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28019. */
  28020. materialIndex: Nullable<number>;
  28021. /**
  28022. * Custom object or properties.
  28023. */
  28024. props: Nullable<any>;
  28025. /**
  28026. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28027. * The possible values are :
  28028. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28029. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28032. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28033. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28034. * */
  28035. cullingStrategy: number;
  28036. /**
  28037. * @hidden Internal global position in the SPS.
  28038. */
  28039. _globalPosition: Vector3;
  28040. /**
  28041. * Creates a Solid Particle object.
  28042. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28043. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28044. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28045. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28046. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28047. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28048. * @param shapeId (integer) is the model shape identifier in the SPS.
  28049. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28050. * @param sps defines the sps it is associated to
  28051. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28052. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28053. */
  28054. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28055. /**
  28056. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28057. * @param target the particle target
  28058. * @returns the current particle
  28059. */
  28060. copyToRef(target: SolidParticle): SolidParticle;
  28061. /**
  28062. * Legacy support, changed scale to scaling
  28063. */
  28064. get scale(): Vector3;
  28065. /**
  28066. * Legacy support, changed scale to scaling
  28067. */
  28068. set scale(scale: Vector3);
  28069. /**
  28070. * Legacy support, changed quaternion to rotationQuaternion
  28071. */
  28072. get quaternion(): Nullable<Quaternion>;
  28073. /**
  28074. * Legacy support, changed quaternion to rotationQuaternion
  28075. */
  28076. set quaternion(q: Nullable<Quaternion>);
  28077. /**
  28078. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28079. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28080. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28081. * @returns true if it intersects
  28082. */
  28083. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28084. /**
  28085. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28086. * A particle is in the frustum if its bounding box intersects the frustum
  28087. * @param frustumPlanes defines the frustum to test
  28088. * @returns true if the particle is in the frustum planes
  28089. */
  28090. isInFrustum(frustumPlanes: Plane[]): boolean;
  28091. /**
  28092. * get the rotation matrix of the particle
  28093. * @hidden
  28094. */
  28095. getRotationMatrix(m: Matrix): void;
  28096. }
  28097. /**
  28098. * Represents the shape of the model used by one particle of a solid particle system.
  28099. * SPS internal tool, don't use it manually.
  28100. */
  28101. export class ModelShape {
  28102. /**
  28103. * The shape id
  28104. * @hidden
  28105. */
  28106. shapeID: number;
  28107. /**
  28108. * flat array of model positions (internal use)
  28109. * @hidden
  28110. */
  28111. _shape: Vector3[];
  28112. /**
  28113. * flat array of model UVs (internal use)
  28114. * @hidden
  28115. */
  28116. _shapeUV: number[];
  28117. /**
  28118. * color array of the model
  28119. * @hidden
  28120. */
  28121. _shapeColors: number[];
  28122. /**
  28123. * indices array of the model
  28124. * @hidden
  28125. */
  28126. _indices: number[];
  28127. /**
  28128. * normals array of the model
  28129. * @hidden
  28130. */
  28131. _normals: number[];
  28132. /**
  28133. * length of the shape in the model indices array (internal use)
  28134. * @hidden
  28135. */
  28136. _indicesLength: number;
  28137. /**
  28138. * Custom position function (internal use)
  28139. * @hidden
  28140. */
  28141. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28142. /**
  28143. * Custom vertex function (internal use)
  28144. * @hidden
  28145. */
  28146. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28147. /**
  28148. * Model material (internal use)
  28149. * @hidden
  28150. */
  28151. _material: Nullable<Material>;
  28152. /**
  28153. * 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.
  28154. * SPS internal tool, don't use it manually.
  28155. * @hidden
  28156. */
  28157. 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>);
  28158. }
  28159. /**
  28160. * Represents a Depth Sorted Particle in the solid particle system.
  28161. * @hidden
  28162. */
  28163. export class DepthSortedParticle {
  28164. /**
  28165. * Particle index
  28166. */
  28167. idx: number;
  28168. /**
  28169. * Index of the particle in the "indices" array
  28170. */
  28171. ind: number;
  28172. /**
  28173. * Length of the particle shape in the "indices" array
  28174. */
  28175. indicesLength: number;
  28176. /**
  28177. * Squared distance from the particle to the camera
  28178. */
  28179. sqDistance: number;
  28180. /**
  28181. * Material index when used with MultiMaterials
  28182. */
  28183. materialIndex: number;
  28184. /**
  28185. * Creates a new sorted particle
  28186. * @param materialIndex
  28187. */
  28188. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28189. }
  28190. }
  28191. declare module BABYLON {
  28192. /**
  28193. * @hidden
  28194. */
  28195. export class _MeshCollisionData {
  28196. _checkCollisions: boolean;
  28197. _collisionMask: number;
  28198. _collisionGroup: number;
  28199. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28200. _collider: Nullable<Collider>;
  28201. _oldPositionForCollisions: Vector3;
  28202. _diffPositionForCollisions: Vector3;
  28203. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28204. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28205. }
  28206. }
  28207. declare module BABYLON {
  28208. /** @hidden */
  28209. class _FacetDataStorage {
  28210. facetPositions: Vector3[];
  28211. facetNormals: Vector3[];
  28212. facetPartitioning: number[][];
  28213. facetNb: number;
  28214. partitioningSubdivisions: number;
  28215. partitioningBBoxRatio: number;
  28216. facetDataEnabled: boolean;
  28217. facetParameters: any;
  28218. bbSize: Vector3;
  28219. subDiv: {
  28220. max: number;
  28221. X: number;
  28222. Y: number;
  28223. Z: number;
  28224. };
  28225. facetDepthSort: boolean;
  28226. facetDepthSortEnabled: boolean;
  28227. depthSortedIndices: IndicesArray;
  28228. depthSortedFacets: {
  28229. ind: number;
  28230. sqDistance: number;
  28231. }[];
  28232. facetDepthSortFunction: (f1: {
  28233. ind: number;
  28234. sqDistance: number;
  28235. }, f2: {
  28236. ind: number;
  28237. sqDistance: number;
  28238. }) => number;
  28239. facetDepthSortFrom: Vector3;
  28240. facetDepthSortOrigin: Vector3;
  28241. invertedMatrix: Matrix;
  28242. }
  28243. /**
  28244. * @hidden
  28245. **/
  28246. class _InternalAbstractMeshDataInfo {
  28247. _hasVertexAlpha: boolean;
  28248. _useVertexColors: boolean;
  28249. _numBoneInfluencers: number;
  28250. _applyFog: boolean;
  28251. _receiveShadows: boolean;
  28252. _facetData: _FacetDataStorage;
  28253. _visibility: number;
  28254. _skeleton: Nullable<Skeleton>;
  28255. _layerMask: number;
  28256. _computeBonesUsingShaders: boolean;
  28257. _isActive: boolean;
  28258. _onlyForInstances: boolean;
  28259. _isActiveIntermediate: boolean;
  28260. _onlyForInstancesIntermediate: boolean;
  28261. _actAsRegularMesh: boolean;
  28262. }
  28263. /**
  28264. * Class used to store all common mesh properties
  28265. */
  28266. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28267. /** No occlusion */
  28268. static OCCLUSION_TYPE_NONE: number;
  28269. /** Occlusion set to optimisitic */
  28270. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28271. /** Occlusion set to strict */
  28272. static OCCLUSION_TYPE_STRICT: number;
  28273. /** Use an accurante occlusion algorithm */
  28274. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28275. /** Use a conservative occlusion algorithm */
  28276. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28277. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28278. * Test order :
  28279. * Is the bounding sphere outside the frustum ?
  28280. * If not, are the bounding box vertices outside the frustum ?
  28281. * It not, then the cullable object is in the frustum.
  28282. */
  28283. static readonly CULLINGSTRATEGY_STANDARD: number;
  28284. /** Culling strategy : Bounding Sphere Only.
  28285. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28286. * It's also less accurate than the standard because some not visible objects can still be selected.
  28287. * Test : is the bounding sphere outside the frustum ?
  28288. * If not, then the cullable object is in the frustum.
  28289. */
  28290. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28291. /** Culling strategy : Optimistic Inclusion.
  28292. * This in an inclusion test first, then the standard exclusion test.
  28293. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28294. * 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.
  28295. * Anyway, it's as accurate as the standard strategy.
  28296. * Test :
  28297. * Is the cullable object bounding sphere center in the frustum ?
  28298. * If not, apply the default culling strategy.
  28299. */
  28300. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28301. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28302. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28303. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28304. * 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.
  28305. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28306. * Test :
  28307. * Is the cullable object bounding sphere center in the frustum ?
  28308. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28309. */
  28310. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28311. /**
  28312. * No billboard
  28313. */
  28314. static get BILLBOARDMODE_NONE(): number;
  28315. /** Billboard on X axis */
  28316. static get BILLBOARDMODE_X(): number;
  28317. /** Billboard on Y axis */
  28318. static get BILLBOARDMODE_Y(): number;
  28319. /** Billboard on Z axis */
  28320. static get BILLBOARDMODE_Z(): number;
  28321. /** Billboard on all axes */
  28322. static get BILLBOARDMODE_ALL(): number;
  28323. /** Billboard on using position instead of orientation */
  28324. static get BILLBOARDMODE_USE_POSITION(): number;
  28325. /** @hidden */
  28326. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28327. /**
  28328. * The culling strategy to use to check whether the mesh must be rendered or not.
  28329. * This value can be changed at any time and will be used on the next render mesh selection.
  28330. * The possible values are :
  28331. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28332. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28333. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28334. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28335. * Please read each static variable documentation to get details about the culling process.
  28336. * */
  28337. cullingStrategy: number;
  28338. /**
  28339. * Gets the number of facets in the mesh
  28340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28341. */
  28342. get facetNb(): number;
  28343. /**
  28344. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28346. */
  28347. get partitioningSubdivisions(): number;
  28348. set partitioningSubdivisions(nb: number);
  28349. /**
  28350. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28351. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28353. */
  28354. get partitioningBBoxRatio(): number;
  28355. set partitioningBBoxRatio(ratio: number);
  28356. /**
  28357. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28358. * Works only for updatable meshes.
  28359. * Doesn't work with multi-materials
  28360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28361. */
  28362. get mustDepthSortFacets(): boolean;
  28363. set mustDepthSortFacets(sort: boolean);
  28364. /**
  28365. * The location (Vector3) where the facet depth sort must be computed from.
  28366. * By default, the active camera position.
  28367. * Used only when facet depth sort is enabled
  28368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28369. */
  28370. get facetDepthSortFrom(): Vector3;
  28371. set facetDepthSortFrom(location: Vector3);
  28372. /**
  28373. * gets a boolean indicating if facetData is enabled
  28374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28375. */
  28376. get isFacetDataEnabled(): boolean;
  28377. /** @hidden */
  28378. _updateNonUniformScalingState(value: boolean): boolean;
  28379. /**
  28380. * An event triggered when this mesh collides with another one
  28381. */
  28382. onCollideObservable: Observable<AbstractMesh>;
  28383. /** Set a function to call when this mesh collides with another one */
  28384. set onCollide(callback: () => void);
  28385. /**
  28386. * An event triggered when the collision's position changes
  28387. */
  28388. onCollisionPositionChangeObservable: Observable<Vector3>;
  28389. /** Set a function to call when the collision's position changes */
  28390. set onCollisionPositionChange(callback: () => void);
  28391. /**
  28392. * An event triggered when material is changed
  28393. */
  28394. onMaterialChangedObservable: Observable<AbstractMesh>;
  28395. /**
  28396. * Gets or sets the orientation for POV movement & rotation
  28397. */
  28398. definedFacingForward: boolean;
  28399. /** @hidden */
  28400. _occlusionQuery: Nullable<WebGLQuery>;
  28401. /** @hidden */
  28402. _renderingGroup: Nullable<RenderingGroup>;
  28403. /**
  28404. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28405. */
  28406. get visibility(): number;
  28407. /**
  28408. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28409. */
  28410. set visibility(value: number);
  28411. /** Gets or sets the alpha index used to sort transparent meshes
  28412. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28413. */
  28414. alphaIndex: number;
  28415. /**
  28416. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28417. */
  28418. isVisible: boolean;
  28419. /**
  28420. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28421. */
  28422. isPickable: boolean;
  28423. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28424. showSubMeshesBoundingBox: boolean;
  28425. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28426. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28427. */
  28428. isBlocker: boolean;
  28429. /**
  28430. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28431. */
  28432. enablePointerMoveEvents: boolean;
  28433. /**
  28434. * Specifies the rendering group id for this mesh (0 by default)
  28435. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28436. */
  28437. renderingGroupId: number;
  28438. private _material;
  28439. /** Gets or sets current material */
  28440. get material(): Nullable<Material>;
  28441. set material(value: Nullable<Material>);
  28442. /**
  28443. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28444. * @see http://doc.babylonjs.com/babylon101/shadows
  28445. */
  28446. get receiveShadows(): boolean;
  28447. set receiveShadows(value: boolean);
  28448. /** Defines color to use when rendering outline */
  28449. outlineColor: Color3;
  28450. /** Define width to use when rendering outline */
  28451. outlineWidth: number;
  28452. /** Defines color to use when rendering overlay */
  28453. overlayColor: Color3;
  28454. /** Defines alpha to use when rendering overlay */
  28455. overlayAlpha: number;
  28456. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28457. get hasVertexAlpha(): boolean;
  28458. set hasVertexAlpha(value: boolean);
  28459. /** 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) */
  28460. get useVertexColors(): boolean;
  28461. set useVertexColors(value: boolean);
  28462. /**
  28463. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28464. */
  28465. get computeBonesUsingShaders(): boolean;
  28466. set computeBonesUsingShaders(value: boolean);
  28467. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28468. get numBoneInfluencers(): number;
  28469. set numBoneInfluencers(value: number);
  28470. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28471. get applyFog(): boolean;
  28472. set applyFog(value: boolean);
  28473. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28474. useOctreeForRenderingSelection: boolean;
  28475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28476. useOctreeForPicking: boolean;
  28477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28478. useOctreeForCollisions: boolean;
  28479. /**
  28480. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28481. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28482. */
  28483. get layerMask(): number;
  28484. set layerMask(value: number);
  28485. /**
  28486. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28487. */
  28488. alwaysSelectAsActiveMesh: boolean;
  28489. /**
  28490. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28491. */
  28492. doNotSyncBoundingInfo: boolean;
  28493. /**
  28494. * Gets or sets the current action manager
  28495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28496. */
  28497. actionManager: Nullable<AbstractActionManager>;
  28498. private _meshCollisionData;
  28499. /**
  28500. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28502. */
  28503. ellipsoid: Vector3;
  28504. /**
  28505. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28507. */
  28508. ellipsoidOffset: Vector3;
  28509. /**
  28510. * Gets or sets a collision mask used to mask collisions (default is -1).
  28511. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28512. */
  28513. get collisionMask(): number;
  28514. set collisionMask(mask: number);
  28515. /**
  28516. * Gets or sets the current collision group mask (-1 by default).
  28517. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28518. */
  28519. get collisionGroup(): number;
  28520. set collisionGroup(mask: number);
  28521. /**
  28522. * Gets or sets current surrounding meshes (null by default).
  28523. *
  28524. * By default collision detection is tested against every mesh in the scene.
  28525. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28526. * meshes will be tested for the collision.
  28527. *
  28528. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28529. */
  28530. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28531. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28532. /**
  28533. * Defines edge width used when edgesRenderer is enabled
  28534. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28535. */
  28536. edgesWidth: number;
  28537. /**
  28538. * Defines edge color used when edgesRenderer is enabled
  28539. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28540. */
  28541. edgesColor: Color4;
  28542. /** @hidden */
  28543. _edgesRenderer: Nullable<IEdgesRenderer>;
  28544. /** @hidden */
  28545. _masterMesh: Nullable<AbstractMesh>;
  28546. /** @hidden */
  28547. _boundingInfo: Nullable<BoundingInfo>;
  28548. /** @hidden */
  28549. _renderId: number;
  28550. /**
  28551. * Gets or sets the list of subMeshes
  28552. * @see http://doc.babylonjs.com/how_to/multi_materials
  28553. */
  28554. subMeshes: SubMesh[];
  28555. /** @hidden */
  28556. _intersectionsInProgress: AbstractMesh[];
  28557. /** @hidden */
  28558. _unIndexed: boolean;
  28559. /** @hidden */
  28560. _lightSources: Light[];
  28561. /** Gets the list of lights affecting that mesh */
  28562. get lightSources(): Light[];
  28563. /** @hidden */
  28564. get _positions(): Nullable<Vector3[]>;
  28565. /** @hidden */
  28566. _waitingData: {
  28567. lods: Nullable<any>;
  28568. actions: Nullable<any>;
  28569. freezeWorldMatrix: Nullable<boolean>;
  28570. };
  28571. /** @hidden */
  28572. _bonesTransformMatrices: Nullable<Float32Array>;
  28573. /** @hidden */
  28574. _transformMatrixTexture: Nullable<RawTexture>;
  28575. /**
  28576. * Gets or sets a skeleton to apply skining transformations
  28577. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28578. */
  28579. set skeleton(value: Nullable<Skeleton>);
  28580. get skeleton(): Nullable<Skeleton>;
  28581. /**
  28582. * An event triggered when the mesh is rebuilt.
  28583. */
  28584. onRebuildObservable: Observable<AbstractMesh>;
  28585. /**
  28586. * Creates a new AbstractMesh
  28587. * @param name defines the name of the mesh
  28588. * @param scene defines the hosting scene
  28589. */
  28590. constructor(name: string, scene?: Nullable<Scene>);
  28591. /**
  28592. * Returns the string "AbstractMesh"
  28593. * @returns "AbstractMesh"
  28594. */
  28595. getClassName(): string;
  28596. /**
  28597. * Gets a string representation of the current mesh
  28598. * @param fullDetails defines a boolean indicating if full details must be included
  28599. * @returns a string representation of the current mesh
  28600. */
  28601. toString(fullDetails?: boolean): string;
  28602. /**
  28603. * @hidden
  28604. */
  28605. protected _getEffectiveParent(): Nullable<Node>;
  28606. /** @hidden */
  28607. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28608. /** @hidden */
  28609. _rebuild(): void;
  28610. /** @hidden */
  28611. _resyncLightSources(): void;
  28612. /** @hidden */
  28613. _resyncLightSource(light: Light): void;
  28614. /** @hidden */
  28615. _unBindEffect(): void;
  28616. /** @hidden */
  28617. _removeLightSource(light: Light, dispose: boolean): void;
  28618. private _markSubMeshesAsDirty;
  28619. /** @hidden */
  28620. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28621. /** @hidden */
  28622. _markSubMeshesAsAttributesDirty(): void;
  28623. /** @hidden */
  28624. _markSubMeshesAsMiscDirty(): void;
  28625. /**
  28626. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28627. */
  28628. get scaling(): Vector3;
  28629. set scaling(newScaling: Vector3);
  28630. /**
  28631. * Returns true if the mesh is blocked. Implemented by child classes
  28632. */
  28633. get isBlocked(): boolean;
  28634. /**
  28635. * Returns the mesh itself by default. Implemented by child classes
  28636. * @param camera defines the camera to use to pick the right LOD level
  28637. * @returns the currentAbstractMesh
  28638. */
  28639. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28640. /**
  28641. * Returns 0 by default. Implemented by child classes
  28642. * @returns an integer
  28643. */
  28644. getTotalVertices(): number;
  28645. /**
  28646. * Returns a positive integer : the total number of indices in this mesh geometry.
  28647. * @returns the numner of indices or zero if the mesh has no geometry.
  28648. */
  28649. getTotalIndices(): number;
  28650. /**
  28651. * Returns null by default. Implemented by child classes
  28652. * @returns null
  28653. */
  28654. getIndices(): Nullable<IndicesArray>;
  28655. /**
  28656. * Returns the array of the requested vertex data kind. Implemented by child classes
  28657. * @param kind defines the vertex data kind to use
  28658. * @returns null
  28659. */
  28660. getVerticesData(kind: string): Nullable<FloatArray>;
  28661. /**
  28662. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28663. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28664. * Note that a new underlying VertexBuffer object is created each call.
  28665. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28666. * @param kind defines vertex data kind:
  28667. * * VertexBuffer.PositionKind
  28668. * * VertexBuffer.UVKind
  28669. * * VertexBuffer.UV2Kind
  28670. * * VertexBuffer.UV3Kind
  28671. * * VertexBuffer.UV4Kind
  28672. * * VertexBuffer.UV5Kind
  28673. * * VertexBuffer.UV6Kind
  28674. * * VertexBuffer.ColorKind
  28675. * * VertexBuffer.MatricesIndicesKind
  28676. * * VertexBuffer.MatricesIndicesExtraKind
  28677. * * VertexBuffer.MatricesWeightsKind
  28678. * * VertexBuffer.MatricesWeightsExtraKind
  28679. * @param data defines the data source
  28680. * @param updatable defines if the data must be flagged as updatable (or static)
  28681. * @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
  28682. * @returns the current mesh
  28683. */
  28684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28685. /**
  28686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28687. * If the mesh has no geometry, it is simply returned as it is.
  28688. * @param kind defines vertex data kind:
  28689. * * VertexBuffer.PositionKind
  28690. * * VertexBuffer.UVKind
  28691. * * VertexBuffer.UV2Kind
  28692. * * VertexBuffer.UV3Kind
  28693. * * VertexBuffer.UV4Kind
  28694. * * VertexBuffer.UV5Kind
  28695. * * VertexBuffer.UV6Kind
  28696. * * VertexBuffer.ColorKind
  28697. * * VertexBuffer.MatricesIndicesKind
  28698. * * VertexBuffer.MatricesIndicesExtraKind
  28699. * * VertexBuffer.MatricesWeightsKind
  28700. * * VertexBuffer.MatricesWeightsExtraKind
  28701. * @param data defines the data source
  28702. * @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
  28703. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28704. * @returns the current mesh
  28705. */
  28706. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28707. /**
  28708. * Sets the mesh indices,
  28709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28710. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28711. * @param totalVertices Defines the total number of vertices
  28712. * @returns the current mesh
  28713. */
  28714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28715. /**
  28716. * Gets a boolean indicating if specific vertex data is present
  28717. * @param kind defines the vertex data kind to use
  28718. * @returns true is data kind is present
  28719. */
  28720. isVerticesDataPresent(kind: string): boolean;
  28721. /**
  28722. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28723. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28724. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28725. * @returns a BoundingInfo
  28726. */
  28727. getBoundingInfo(): BoundingInfo;
  28728. /**
  28729. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28730. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28731. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28732. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28733. * @returns the current mesh
  28734. */
  28735. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28736. /**
  28737. * Overwrite the current bounding info
  28738. * @param boundingInfo defines the new bounding info
  28739. * @returns the current mesh
  28740. */
  28741. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28742. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28743. get useBones(): boolean;
  28744. /** @hidden */
  28745. _preActivate(): void;
  28746. /** @hidden */
  28747. _preActivateForIntermediateRendering(renderId: number): void;
  28748. /** @hidden */
  28749. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28750. /** @hidden */
  28751. _postActivate(): void;
  28752. /** @hidden */
  28753. _freeze(): void;
  28754. /** @hidden */
  28755. _unFreeze(): void;
  28756. /**
  28757. * Gets the current world matrix
  28758. * @returns a Matrix
  28759. */
  28760. getWorldMatrix(): Matrix;
  28761. /** @hidden */
  28762. _getWorldMatrixDeterminant(): number;
  28763. /**
  28764. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28765. */
  28766. get isAnInstance(): boolean;
  28767. /**
  28768. * Gets a boolean indicating if this mesh has instances
  28769. */
  28770. get hasInstances(): boolean;
  28771. /**
  28772. * Perform relative position change from the point of view of behind the front of the mesh.
  28773. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28774. * Supports definition of mesh facing forward or backward
  28775. * @param amountRight defines the distance on the right axis
  28776. * @param amountUp defines the distance on the up axis
  28777. * @param amountForward defines the distance on the forward axis
  28778. * @returns the current mesh
  28779. */
  28780. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28781. /**
  28782. * Calculate relative position change from the point of view of behind the front of the mesh.
  28783. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28784. * Supports definition of mesh facing forward or backward
  28785. * @param amountRight defines the distance on the right axis
  28786. * @param amountUp defines the distance on the up axis
  28787. * @param amountForward defines the distance on the forward axis
  28788. * @returns the new displacement vector
  28789. */
  28790. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28791. /**
  28792. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28793. * Supports definition of mesh facing forward or backward
  28794. * @param flipBack defines the flip
  28795. * @param twirlClockwise defines the twirl
  28796. * @param tiltRight defines the tilt
  28797. * @returns the current mesh
  28798. */
  28799. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28800. /**
  28801. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28802. * Supports definition of mesh facing forward or backward.
  28803. * @param flipBack defines the flip
  28804. * @param twirlClockwise defines the twirl
  28805. * @param tiltRight defines the tilt
  28806. * @returns the new rotation vector
  28807. */
  28808. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28809. /**
  28810. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28811. * This means the mesh underlying bounding box and sphere are recomputed.
  28812. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28813. * @returns the current mesh
  28814. */
  28815. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28816. /** @hidden */
  28817. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28818. /** @hidden */
  28819. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28820. /** @hidden */
  28821. _updateBoundingInfo(): AbstractMesh;
  28822. /** @hidden */
  28823. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28824. /** @hidden */
  28825. protected _afterComputeWorldMatrix(): void;
  28826. /** @hidden */
  28827. get _effectiveMesh(): AbstractMesh;
  28828. /**
  28829. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28830. * A mesh is in the frustum if its bounding box intersects the frustum
  28831. * @param frustumPlanes defines the frustum to test
  28832. * @returns true if the mesh is in the frustum planes
  28833. */
  28834. isInFrustum(frustumPlanes: Plane[]): boolean;
  28835. /**
  28836. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28837. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28838. * @param frustumPlanes defines the frustum to test
  28839. * @returns true if the mesh is completely in the frustum planes
  28840. */
  28841. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28842. /**
  28843. * True if the mesh intersects another mesh or a SolidParticle object
  28844. * @param mesh defines a target mesh or SolidParticle to test
  28845. * @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)
  28846. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28847. * @returns true if there is an intersection
  28848. */
  28849. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28850. /**
  28851. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28852. * @param point defines the point to test
  28853. * @returns true if there is an intersection
  28854. */
  28855. intersectsPoint(point: Vector3): boolean;
  28856. /**
  28857. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28859. */
  28860. get checkCollisions(): boolean;
  28861. set checkCollisions(collisionEnabled: boolean);
  28862. /**
  28863. * Gets Collider object used to compute collisions (not physics)
  28864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28865. */
  28866. get collider(): Nullable<Collider>;
  28867. /**
  28868. * Move the mesh using collision engine
  28869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28870. * @param displacement defines the requested displacement vector
  28871. * @returns the current mesh
  28872. */
  28873. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28874. private _onCollisionPositionChange;
  28875. /** @hidden */
  28876. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28877. /** @hidden */
  28878. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28879. /** @hidden */
  28880. _checkCollision(collider: Collider): AbstractMesh;
  28881. /** @hidden */
  28882. _generatePointsArray(): boolean;
  28883. /**
  28884. * Checks if the passed Ray intersects with the mesh
  28885. * @param ray defines the ray to use
  28886. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28887. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28888. * @returns the picking info
  28889. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28890. */
  28891. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28892. /**
  28893. * Clones the current mesh
  28894. * @param name defines the mesh name
  28895. * @param newParent defines the new mesh parent
  28896. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28897. * @returns the new mesh
  28898. */
  28899. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28900. /**
  28901. * Disposes all the submeshes of the current meshnp
  28902. * @returns the current mesh
  28903. */
  28904. releaseSubMeshes(): AbstractMesh;
  28905. /**
  28906. * Releases resources associated with this abstract mesh.
  28907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28909. */
  28910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28911. /**
  28912. * Adds the passed mesh as a child to the current mesh
  28913. * @param mesh defines the child mesh
  28914. * @returns the current mesh
  28915. */
  28916. addChild(mesh: AbstractMesh): AbstractMesh;
  28917. /**
  28918. * Removes the passed mesh from the current mesh children list
  28919. * @param mesh defines the child mesh
  28920. * @returns the current mesh
  28921. */
  28922. removeChild(mesh: AbstractMesh): AbstractMesh;
  28923. /** @hidden */
  28924. private _initFacetData;
  28925. /**
  28926. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28927. * This method can be called within the render loop.
  28928. * 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
  28929. * @returns the current mesh
  28930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28931. */
  28932. updateFacetData(): AbstractMesh;
  28933. /**
  28934. * Returns the facetLocalNormals array.
  28935. * The normals are expressed in the mesh local spac
  28936. * @returns an array of Vector3
  28937. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28938. */
  28939. getFacetLocalNormals(): Vector3[];
  28940. /**
  28941. * Returns the facetLocalPositions array.
  28942. * The facet positions are expressed in the mesh local space
  28943. * @returns an array of Vector3
  28944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28945. */
  28946. getFacetLocalPositions(): Vector3[];
  28947. /**
  28948. * Returns the facetLocalPartioning array
  28949. * @returns an array of array of numbers
  28950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28951. */
  28952. getFacetLocalPartitioning(): number[][];
  28953. /**
  28954. * Returns the i-th facet position in the world system.
  28955. * This method allocates a new Vector3 per call
  28956. * @param i defines the facet index
  28957. * @returns a new Vector3
  28958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28959. */
  28960. getFacetPosition(i: number): Vector3;
  28961. /**
  28962. * Sets the reference Vector3 with the i-th facet position in the world system
  28963. * @param i defines the facet index
  28964. * @param ref defines the target vector
  28965. * @returns the current mesh
  28966. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28967. */
  28968. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28969. /**
  28970. * Returns the i-th facet normal in the world system.
  28971. * This method allocates a new Vector3 per call
  28972. * @param i defines the facet index
  28973. * @returns a new Vector3
  28974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28975. */
  28976. getFacetNormal(i: number): Vector3;
  28977. /**
  28978. * Sets the reference Vector3 with the i-th facet normal in the world system
  28979. * @param i defines the facet index
  28980. * @param ref defines the target vector
  28981. * @returns the current mesh
  28982. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28983. */
  28984. getFacetNormalToRef(i: number, ref: Vector3): this;
  28985. /**
  28986. * 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)
  28987. * @param x defines x coordinate
  28988. * @param y defines y coordinate
  28989. * @param z defines z coordinate
  28990. * @returns the array of facet indexes
  28991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28992. */
  28993. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28994. /**
  28995. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28996. * @param projected sets as the (x,y,z) world projection on the facet
  28997. * @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
  28998. * @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
  28999. * @param x defines x coordinate
  29000. * @param y defines y coordinate
  29001. * @param z defines z coordinate
  29002. * @returns the face index if found (or null instead)
  29003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29004. */
  29005. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29006. /**
  29007. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29008. * @param projected sets as the (x,y,z) local projection on the facet
  29009. * @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
  29010. * @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
  29011. * @param x defines x coordinate
  29012. * @param y defines y coordinate
  29013. * @param z defines z coordinate
  29014. * @returns the face index if found (or null instead)
  29015. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29016. */
  29017. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29018. /**
  29019. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29020. * @returns the parameters
  29021. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29022. */
  29023. getFacetDataParameters(): any;
  29024. /**
  29025. * Disables the feature FacetData and frees the related memory
  29026. * @returns the current mesh
  29027. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29028. */
  29029. disableFacetData(): AbstractMesh;
  29030. /**
  29031. * Updates the AbstractMesh indices array
  29032. * @param indices defines the data source
  29033. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29034. * @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)
  29035. * @returns the current mesh
  29036. */
  29037. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29038. /**
  29039. * Creates new normals data for the mesh
  29040. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29041. * @returns the current mesh
  29042. */
  29043. createNormals(updatable: boolean): AbstractMesh;
  29044. /**
  29045. * Align the mesh with a normal
  29046. * @param normal defines the normal to use
  29047. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29048. * @returns the current mesh
  29049. */
  29050. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29051. /** @hidden */
  29052. _checkOcclusionQuery(): boolean;
  29053. /**
  29054. * Disables the mesh edge rendering mode
  29055. * @returns the currentAbstractMesh
  29056. */
  29057. disableEdgesRendering(): AbstractMesh;
  29058. /**
  29059. * Enables the edge rendering mode on the mesh.
  29060. * This mode makes the mesh edges visible
  29061. * @param epsilon defines the maximal distance between two angles to detect a face
  29062. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29063. * @returns the currentAbstractMesh
  29064. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29065. */
  29066. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29067. }
  29068. }
  29069. declare module BABYLON {
  29070. /**
  29071. * Interface used to define ActionEvent
  29072. */
  29073. export interface IActionEvent {
  29074. /** The mesh or sprite that triggered the action */
  29075. source: any;
  29076. /** The X mouse cursor position at the time of the event */
  29077. pointerX: number;
  29078. /** The Y mouse cursor position at the time of the event */
  29079. pointerY: number;
  29080. /** The mesh that is currently pointed at (can be null) */
  29081. meshUnderPointer: Nullable<AbstractMesh>;
  29082. /** the original (browser) event that triggered the ActionEvent */
  29083. sourceEvent?: any;
  29084. /** additional data for the event */
  29085. additionalData?: any;
  29086. }
  29087. /**
  29088. * ActionEvent is the event being sent when an action is triggered.
  29089. */
  29090. export class ActionEvent implements IActionEvent {
  29091. /** The mesh or sprite that triggered the action */
  29092. source: any;
  29093. /** The X mouse cursor position at the time of the event */
  29094. pointerX: number;
  29095. /** The Y mouse cursor position at the time of the event */
  29096. pointerY: number;
  29097. /** The mesh that is currently pointed at (can be null) */
  29098. meshUnderPointer: Nullable<AbstractMesh>;
  29099. /** the original (browser) event that triggered the ActionEvent */
  29100. sourceEvent?: any;
  29101. /** additional data for the event */
  29102. additionalData?: any;
  29103. /**
  29104. * Creates a new ActionEvent
  29105. * @param source The mesh or sprite that triggered the action
  29106. * @param pointerX The X mouse cursor position at the time of the event
  29107. * @param pointerY The Y mouse cursor position at the time of the event
  29108. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29109. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29110. * @param additionalData additional data for the event
  29111. */
  29112. constructor(
  29113. /** The mesh or sprite that triggered the action */
  29114. source: any,
  29115. /** The X mouse cursor position at the time of the event */
  29116. pointerX: number,
  29117. /** The Y mouse cursor position at the time of the event */
  29118. pointerY: number,
  29119. /** The mesh that is currently pointed at (can be null) */
  29120. meshUnderPointer: Nullable<AbstractMesh>,
  29121. /** the original (browser) event that triggered the ActionEvent */
  29122. sourceEvent?: any,
  29123. /** additional data for the event */
  29124. additionalData?: any);
  29125. /**
  29126. * Helper function to auto-create an ActionEvent from a source mesh.
  29127. * @param source The source mesh that triggered the event
  29128. * @param evt The original (browser) event
  29129. * @param additionalData additional data for the event
  29130. * @returns the new ActionEvent
  29131. */
  29132. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29133. /**
  29134. * Helper function to auto-create an ActionEvent from a source sprite
  29135. * @param source The source sprite that triggered the event
  29136. * @param scene Scene associated with the sprite
  29137. * @param evt The original (browser) event
  29138. * @param additionalData additional data for the event
  29139. * @returns the new ActionEvent
  29140. */
  29141. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29142. /**
  29143. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29144. * @param scene the scene where the event occurred
  29145. * @param evt The original (browser) event
  29146. * @returns the new ActionEvent
  29147. */
  29148. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29149. /**
  29150. * Helper function to auto-create an ActionEvent from a primitive
  29151. * @param prim defines the target primitive
  29152. * @param pointerPos defines the pointer position
  29153. * @param evt The original (browser) event
  29154. * @param additionalData additional data for the event
  29155. * @returns the new ActionEvent
  29156. */
  29157. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29158. }
  29159. }
  29160. declare module BABYLON {
  29161. /**
  29162. * Abstract class used to decouple action Manager from scene and meshes.
  29163. * Do not instantiate.
  29164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29165. */
  29166. export abstract class AbstractActionManager implements IDisposable {
  29167. /** Gets the list of active triggers */
  29168. static Triggers: {
  29169. [key: string]: number;
  29170. };
  29171. /** Gets the cursor to use when hovering items */
  29172. hoverCursor: string;
  29173. /** Gets the list of actions */
  29174. actions: IAction[];
  29175. /**
  29176. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29177. */
  29178. isRecursive: boolean;
  29179. /**
  29180. * Releases all associated resources
  29181. */
  29182. abstract dispose(): void;
  29183. /**
  29184. * Does this action manager has pointer triggers
  29185. */
  29186. abstract get hasPointerTriggers(): boolean;
  29187. /**
  29188. * Does this action manager has pick triggers
  29189. */
  29190. abstract get hasPickTriggers(): boolean;
  29191. /**
  29192. * Process a specific trigger
  29193. * @param trigger defines the trigger to process
  29194. * @param evt defines the event details to be processed
  29195. */
  29196. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29197. /**
  29198. * Does this action manager handles actions of any of the given triggers
  29199. * @param triggers defines the triggers to be tested
  29200. * @return a boolean indicating whether one (or more) of the triggers is handled
  29201. */
  29202. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29203. /**
  29204. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29205. * speed.
  29206. * @param triggerA defines the trigger to be tested
  29207. * @param triggerB defines the trigger to be tested
  29208. * @return a boolean indicating whether one (or more) of the triggers is handled
  29209. */
  29210. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29211. /**
  29212. * Does this action manager handles actions of a given trigger
  29213. * @param trigger defines the trigger to be tested
  29214. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29215. * @return whether the trigger is handled
  29216. */
  29217. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29218. /**
  29219. * Serialize this manager to a JSON object
  29220. * @param name defines the property name to store this manager
  29221. * @returns a JSON representation of this manager
  29222. */
  29223. abstract serialize(name: string): any;
  29224. /**
  29225. * Registers an action to this action manager
  29226. * @param action defines the action to be registered
  29227. * @return the action amended (prepared) after registration
  29228. */
  29229. abstract registerAction(action: IAction): Nullable<IAction>;
  29230. /**
  29231. * Unregisters an action to this action manager
  29232. * @param action defines the action to be unregistered
  29233. * @return a boolean indicating whether the action has been unregistered
  29234. */
  29235. abstract unregisterAction(action: IAction): Boolean;
  29236. /**
  29237. * Does exist one action manager with at least one trigger
  29238. **/
  29239. static get HasTriggers(): boolean;
  29240. /**
  29241. * Does exist one action manager with at least one pick trigger
  29242. **/
  29243. static get HasPickTriggers(): boolean;
  29244. /**
  29245. * Does exist one action manager that handles actions of a given trigger
  29246. * @param trigger defines the trigger to be tested
  29247. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29248. **/
  29249. static HasSpecificTrigger(trigger: number): boolean;
  29250. }
  29251. }
  29252. declare module BABYLON {
  29253. /**
  29254. * Defines how a node can be built from a string name.
  29255. */
  29256. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29257. /**
  29258. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29259. */
  29260. export class Node implements IBehaviorAware<Node> {
  29261. /** @hidden */
  29262. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29263. private static _NodeConstructors;
  29264. /**
  29265. * Add a new node constructor
  29266. * @param type defines the type name of the node to construct
  29267. * @param constructorFunc defines the constructor function
  29268. */
  29269. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29270. /**
  29271. * Returns a node constructor based on type name
  29272. * @param type defines the type name
  29273. * @param name defines the new node name
  29274. * @param scene defines the hosting scene
  29275. * @param options defines optional options to transmit to constructors
  29276. * @returns the new constructor or null
  29277. */
  29278. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29279. /**
  29280. * Gets or sets the name of the node
  29281. */
  29282. name: string;
  29283. /**
  29284. * Gets or sets the id of the node
  29285. */
  29286. id: string;
  29287. /**
  29288. * Gets or sets the unique id of the node
  29289. */
  29290. uniqueId: number;
  29291. /**
  29292. * Gets or sets a string used to store user defined state for the node
  29293. */
  29294. state: string;
  29295. /**
  29296. * Gets or sets an object used to store user defined information for the node
  29297. */
  29298. metadata: any;
  29299. /**
  29300. * For internal use only. Please do not use.
  29301. */
  29302. reservedDataStore: any;
  29303. /**
  29304. * List of inspectable custom properties (used by the Inspector)
  29305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29306. */
  29307. inspectableCustomProperties: IInspectable[];
  29308. private _doNotSerialize;
  29309. /**
  29310. * Gets or sets a boolean used to define if the node must be serialized
  29311. */
  29312. get doNotSerialize(): boolean;
  29313. set doNotSerialize(value: boolean);
  29314. /** @hidden */
  29315. _isDisposed: boolean;
  29316. /**
  29317. * Gets a list of Animations associated with the node
  29318. */
  29319. animations: Animation[];
  29320. protected _ranges: {
  29321. [name: string]: Nullable<AnimationRange>;
  29322. };
  29323. /**
  29324. * Callback raised when the node is ready to be used
  29325. */
  29326. onReady: Nullable<(node: Node) => void>;
  29327. private _isEnabled;
  29328. private _isParentEnabled;
  29329. private _isReady;
  29330. /** @hidden */
  29331. _currentRenderId: number;
  29332. private _parentUpdateId;
  29333. /** @hidden */
  29334. _childUpdateId: number;
  29335. /** @hidden */
  29336. _waitingParentId: Nullable<string>;
  29337. /** @hidden */
  29338. _scene: Scene;
  29339. /** @hidden */
  29340. _cache: any;
  29341. private _parentNode;
  29342. private _children;
  29343. /** @hidden */
  29344. _worldMatrix: Matrix;
  29345. /** @hidden */
  29346. _worldMatrixDeterminant: number;
  29347. /** @hidden */
  29348. _worldMatrixDeterminantIsDirty: boolean;
  29349. /** @hidden */
  29350. private _sceneRootNodesIndex;
  29351. /**
  29352. * Gets a boolean indicating if the node has been disposed
  29353. * @returns true if the node was disposed
  29354. */
  29355. isDisposed(): boolean;
  29356. /**
  29357. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29358. * @see https://doc.babylonjs.com/how_to/parenting
  29359. */
  29360. set parent(parent: Nullable<Node>);
  29361. get parent(): Nullable<Node>;
  29362. /** @hidden */
  29363. _addToSceneRootNodes(): void;
  29364. /** @hidden */
  29365. _removeFromSceneRootNodes(): void;
  29366. private _animationPropertiesOverride;
  29367. /**
  29368. * Gets or sets the animation properties override
  29369. */
  29370. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29371. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29372. /**
  29373. * Gets a string idenfifying the name of the class
  29374. * @returns "Node" string
  29375. */
  29376. getClassName(): string;
  29377. /** @hidden */
  29378. readonly _isNode: boolean;
  29379. /**
  29380. * An event triggered when the mesh is disposed
  29381. */
  29382. onDisposeObservable: Observable<Node>;
  29383. private _onDisposeObserver;
  29384. /**
  29385. * Sets a callback that will be raised when the node will be disposed
  29386. */
  29387. set onDispose(callback: () => void);
  29388. /**
  29389. * Creates a new Node
  29390. * @param name the name and id to be given to this node
  29391. * @param scene the scene this node will be added to
  29392. */
  29393. constructor(name: string, scene?: Nullable<Scene>);
  29394. /**
  29395. * Gets the scene of the node
  29396. * @returns a scene
  29397. */
  29398. getScene(): Scene;
  29399. /**
  29400. * Gets the engine of the node
  29401. * @returns a Engine
  29402. */
  29403. getEngine(): Engine;
  29404. private _behaviors;
  29405. /**
  29406. * Attach a behavior to the node
  29407. * @see http://doc.babylonjs.com/features/behaviour
  29408. * @param behavior defines the behavior to attach
  29409. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29410. * @returns the current Node
  29411. */
  29412. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29413. /**
  29414. * Remove an attached behavior
  29415. * @see http://doc.babylonjs.com/features/behaviour
  29416. * @param behavior defines the behavior to attach
  29417. * @returns the current Node
  29418. */
  29419. removeBehavior(behavior: Behavior<Node>): Node;
  29420. /**
  29421. * Gets the list of attached behaviors
  29422. * @see http://doc.babylonjs.com/features/behaviour
  29423. */
  29424. get behaviors(): Behavior<Node>[];
  29425. /**
  29426. * Gets an attached behavior by name
  29427. * @param name defines the name of the behavior to look for
  29428. * @see http://doc.babylonjs.com/features/behaviour
  29429. * @returns null if behavior was not found else the requested behavior
  29430. */
  29431. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29432. /**
  29433. * Returns the latest update of the World matrix
  29434. * @returns a Matrix
  29435. */
  29436. getWorldMatrix(): Matrix;
  29437. /** @hidden */
  29438. _getWorldMatrixDeterminant(): number;
  29439. /**
  29440. * Returns directly the latest state of the mesh World matrix.
  29441. * A Matrix is returned.
  29442. */
  29443. get worldMatrixFromCache(): Matrix;
  29444. /** @hidden */
  29445. _initCache(): void;
  29446. /** @hidden */
  29447. updateCache(force?: boolean): void;
  29448. /** @hidden */
  29449. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29450. /** @hidden */
  29451. _updateCache(ignoreParentClass?: boolean): void;
  29452. /** @hidden */
  29453. _isSynchronized(): boolean;
  29454. /** @hidden */
  29455. _markSyncedWithParent(): void;
  29456. /** @hidden */
  29457. isSynchronizedWithParent(): boolean;
  29458. /** @hidden */
  29459. isSynchronized(): boolean;
  29460. /**
  29461. * Is this node ready to be used/rendered
  29462. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29463. * @return true if the node is ready
  29464. */
  29465. isReady(completeCheck?: boolean): boolean;
  29466. /**
  29467. * Is this node enabled?
  29468. * 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
  29469. * @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
  29470. * @return whether this node (and its parent) is enabled
  29471. */
  29472. isEnabled(checkAncestors?: boolean): boolean;
  29473. /** @hidden */
  29474. protected _syncParentEnabledState(): void;
  29475. /**
  29476. * Set the enabled state of this node
  29477. * @param value defines the new enabled state
  29478. */
  29479. setEnabled(value: boolean): void;
  29480. /**
  29481. * Is this node a descendant of the given node?
  29482. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29483. * @param ancestor defines the parent node to inspect
  29484. * @returns a boolean indicating if this node is a descendant of the given node
  29485. */
  29486. isDescendantOf(ancestor: Node): boolean;
  29487. /** @hidden */
  29488. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29489. /**
  29490. * Will return all nodes that have this node as ascendant
  29491. * @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
  29492. * @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
  29493. * @return all children nodes of all types
  29494. */
  29495. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29496. /**
  29497. * Get all child-meshes of this node
  29498. * @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)
  29499. * @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
  29500. * @returns an array of AbstractMesh
  29501. */
  29502. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29503. /**
  29504. * Get all direct children of this node
  29505. * @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
  29506. * @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)
  29507. * @returns an array of Node
  29508. */
  29509. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29510. /** @hidden */
  29511. _setReady(state: boolean): void;
  29512. /**
  29513. * Get an animation by name
  29514. * @param name defines the name of the animation to look for
  29515. * @returns null if not found else the requested animation
  29516. */
  29517. getAnimationByName(name: string): Nullable<Animation>;
  29518. /**
  29519. * Creates an animation range for this node
  29520. * @param name defines the name of the range
  29521. * @param from defines the starting key
  29522. * @param to defines the end key
  29523. */
  29524. createAnimationRange(name: string, from: number, to: number): void;
  29525. /**
  29526. * Delete a specific animation range
  29527. * @param name defines the name of the range to delete
  29528. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29529. */
  29530. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29531. /**
  29532. * Get an animation range by name
  29533. * @param name defines the name of the animation range to look for
  29534. * @returns null if not found else the requested animation range
  29535. */
  29536. getAnimationRange(name: string): Nullable<AnimationRange>;
  29537. /**
  29538. * Gets the list of all animation ranges defined on this node
  29539. * @returns an array
  29540. */
  29541. getAnimationRanges(): Nullable<AnimationRange>[];
  29542. /**
  29543. * Will start the animation sequence
  29544. * @param name defines the range frames for animation sequence
  29545. * @param loop defines if the animation should loop (false by default)
  29546. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29547. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29548. * @returns the object created for this animation. If range does not exist, it will return null
  29549. */
  29550. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29551. /**
  29552. * Serialize animation ranges into a JSON compatible object
  29553. * @returns serialization object
  29554. */
  29555. serializeAnimationRanges(): any;
  29556. /**
  29557. * Computes the world matrix of the node
  29558. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29559. * @returns the world matrix
  29560. */
  29561. computeWorldMatrix(force?: boolean): Matrix;
  29562. /**
  29563. * Releases resources associated with this node.
  29564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29566. */
  29567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29568. /**
  29569. * Parse animation range data from a serialization object and store them into a given node
  29570. * @param node defines where to store the animation ranges
  29571. * @param parsedNode defines the serialization object to read data from
  29572. * @param scene defines the hosting scene
  29573. */
  29574. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29575. /**
  29576. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29577. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29578. * @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
  29579. * @returns the new bounding vectors
  29580. */
  29581. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29582. min: Vector3;
  29583. max: Vector3;
  29584. };
  29585. }
  29586. }
  29587. declare module BABYLON {
  29588. /**
  29589. * @hidden
  29590. */
  29591. export class _IAnimationState {
  29592. key: number;
  29593. repeatCount: number;
  29594. workValue?: any;
  29595. loopMode?: number;
  29596. offsetValue?: any;
  29597. highLimitValue?: any;
  29598. }
  29599. /**
  29600. * Class used to store any kind of animation
  29601. */
  29602. export class Animation {
  29603. /**Name of the animation */
  29604. name: string;
  29605. /**Property to animate */
  29606. targetProperty: string;
  29607. /**The frames per second of the animation */
  29608. framePerSecond: number;
  29609. /**The data type of the animation */
  29610. dataType: number;
  29611. /**The loop mode of the animation */
  29612. loopMode?: number | undefined;
  29613. /**Specifies if blending should be enabled */
  29614. enableBlending?: boolean | undefined;
  29615. /**
  29616. * Use matrix interpolation instead of using direct key value when animating matrices
  29617. */
  29618. static AllowMatricesInterpolation: boolean;
  29619. /**
  29620. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29621. */
  29622. static AllowMatrixDecomposeForInterpolation: boolean;
  29623. /**
  29624. * Stores the key frames of the animation
  29625. */
  29626. private _keys;
  29627. /**
  29628. * Stores the easing function of the animation
  29629. */
  29630. private _easingFunction;
  29631. /**
  29632. * @hidden Internal use only
  29633. */
  29634. _runtimeAnimations: RuntimeAnimation[];
  29635. /**
  29636. * The set of event that will be linked to this animation
  29637. */
  29638. private _events;
  29639. /**
  29640. * Stores an array of target property paths
  29641. */
  29642. targetPropertyPath: string[];
  29643. /**
  29644. * Stores the blending speed of the animation
  29645. */
  29646. blendingSpeed: number;
  29647. /**
  29648. * Stores the animation ranges for the animation
  29649. */
  29650. private _ranges;
  29651. /**
  29652. * @hidden Internal use
  29653. */
  29654. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29655. /**
  29656. * Sets up an animation
  29657. * @param property The property to animate
  29658. * @param animationType The animation type to apply
  29659. * @param framePerSecond The frames per second of the animation
  29660. * @param easingFunction The easing function used in the animation
  29661. * @returns The created animation
  29662. */
  29663. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29664. /**
  29665. * Create and start an animation on a node
  29666. * @param name defines the name of the global animation that will be run on all nodes
  29667. * @param node defines the root node where the animation will take place
  29668. * @param targetProperty defines property to animate
  29669. * @param framePerSecond defines the number of frame per second yo use
  29670. * @param totalFrame defines the number of frames in total
  29671. * @param from defines the initial value
  29672. * @param to defines the final value
  29673. * @param loopMode defines which loop mode you want to use (off by default)
  29674. * @param easingFunction defines the easing function to use (linear by default)
  29675. * @param onAnimationEnd defines the callback to call when animation end
  29676. * @returns the animatable created for this animation
  29677. */
  29678. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29679. /**
  29680. * Create and start an animation on a node and its descendants
  29681. * @param name defines the name of the global animation that will be run on all nodes
  29682. * @param node defines the root node where the animation will take place
  29683. * @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
  29684. * @param targetProperty defines property to animate
  29685. * @param framePerSecond defines the number of frame per second to use
  29686. * @param totalFrame defines the number of frames in total
  29687. * @param from defines the initial value
  29688. * @param to defines the final value
  29689. * @param loopMode defines which loop mode you want to use (off by default)
  29690. * @param easingFunction defines the easing function to use (linear by default)
  29691. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29692. * @returns the list of animatables created for all nodes
  29693. * @example https://www.babylonjs-playground.com/#MH0VLI
  29694. */
  29695. 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[]>;
  29696. /**
  29697. * Creates a new animation, merges it with the existing animations and starts it
  29698. * @param name Name of the animation
  29699. * @param node Node which contains the scene that begins the animations
  29700. * @param targetProperty Specifies which property to animate
  29701. * @param framePerSecond The frames per second of the animation
  29702. * @param totalFrame The total number of frames
  29703. * @param from The frame at the beginning of the animation
  29704. * @param to The frame at the end of the animation
  29705. * @param loopMode Specifies the loop mode of the animation
  29706. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29707. * @param onAnimationEnd Callback to run once the animation is complete
  29708. * @returns Nullable animation
  29709. */
  29710. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29711. /**
  29712. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29713. * @param sourceAnimation defines the Animation containing keyframes to convert
  29714. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29715. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29716. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29717. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29718. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29719. */
  29720. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29721. /**
  29722. * Transition property of an host to the target Value
  29723. * @param property The property to transition
  29724. * @param targetValue The target Value of the property
  29725. * @param host The object where the property to animate belongs
  29726. * @param scene Scene used to run the animation
  29727. * @param frameRate Framerate (in frame/s) to use
  29728. * @param transition The transition type we want to use
  29729. * @param duration The duration of the animation, in milliseconds
  29730. * @param onAnimationEnd Callback trigger at the end of the animation
  29731. * @returns Nullable animation
  29732. */
  29733. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29734. /**
  29735. * Return the array of runtime animations currently using this animation
  29736. */
  29737. get runtimeAnimations(): RuntimeAnimation[];
  29738. /**
  29739. * Specifies if any of the runtime animations are currently running
  29740. */
  29741. get hasRunningRuntimeAnimations(): boolean;
  29742. /**
  29743. * Initializes the animation
  29744. * @param name Name of the animation
  29745. * @param targetProperty Property to animate
  29746. * @param framePerSecond The frames per second of the animation
  29747. * @param dataType The data type of the animation
  29748. * @param loopMode The loop mode of the animation
  29749. * @param enableBlending Specifies if blending should be enabled
  29750. */
  29751. constructor(
  29752. /**Name of the animation */
  29753. name: string,
  29754. /**Property to animate */
  29755. targetProperty: string,
  29756. /**The frames per second of the animation */
  29757. framePerSecond: number,
  29758. /**The data type of the animation */
  29759. dataType: number,
  29760. /**The loop mode of the animation */
  29761. loopMode?: number | undefined,
  29762. /**Specifies if blending should be enabled */
  29763. enableBlending?: boolean | undefined);
  29764. /**
  29765. * Converts the animation to a string
  29766. * @param fullDetails support for multiple levels of logging within scene loading
  29767. * @returns String form of the animation
  29768. */
  29769. toString(fullDetails?: boolean): string;
  29770. /**
  29771. * Add an event to this animation
  29772. * @param event Event to add
  29773. */
  29774. addEvent(event: AnimationEvent): void;
  29775. /**
  29776. * Remove all events found at the given frame
  29777. * @param frame The frame to remove events from
  29778. */
  29779. removeEvents(frame: number): void;
  29780. /**
  29781. * Retrieves all the events from the animation
  29782. * @returns Events from the animation
  29783. */
  29784. getEvents(): AnimationEvent[];
  29785. /**
  29786. * Creates an animation range
  29787. * @param name Name of the animation range
  29788. * @param from Starting frame of the animation range
  29789. * @param to Ending frame of the animation
  29790. */
  29791. createRange(name: string, from: number, to: number): void;
  29792. /**
  29793. * Deletes an animation range by name
  29794. * @param name Name of the animation range to delete
  29795. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29796. */
  29797. deleteRange(name: string, deleteFrames?: boolean): void;
  29798. /**
  29799. * Gets the animation range by name, or null if not defined
  29800. * @param name Name of the animation range
  29801. * @returns Nullable animation range
  29802. */
  29803. getRange(name: string): Nullable<AnimationRange>;
  29804. /**
  29805. * Gets the key frames from the animation
  29806. * @returns The key frames of the animation
  29807. */
  29808. getKeys(): Array<IAnimationKey>;
  29809. /**
  29810. * Gets the highest frame rate of the animation
  29811. * @returns Highest frame rate of the animation
  29812. */
  29813. getHighestFrame(): number;
  29814. /**
  29815. * Gets the easing function of the animation
  29816. * @returns Easing function of the animation
  29817. */
  29818. getEasingFunction(): IEasingFunction;
  29819. /**
  29820. * Sets the easing function of the animation
  29821. * @param easingFunction A custom mathematical formula for animation
  29822. */
  29823. setEasingFunction(easingFunction: EasingFunction): void;
  29824. /**
  29825. * Interpolates a scalar linearly
  29826. * @param startValue Start value of the animation curve
  29827. * @param endValue End value of the animation curve
  29828. * @param gradient Scalar amount to interpolate
  29829. * @returns Interpolated scalar value
  29830. */
  29831. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29832. /**
  29833. * Interpolates a scalar cubically
  29834. * @param startValue Start value of the animation curve
  29835. * @param outTangent End tangent of the animation
  29836. * @param endValue End value of the animation curve
  29837. * @param inTangent Start tangent of the animation curve
  29838. * @param gradient Scalar amount to interpolate
  29839. * @returns Interpolated scalar value
  29840. */
  29841. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29842. /**
  29843. * Interpolates a quaternion using a spherical linear interpolation
  29844. * @param startValue Start value of the animation curve
  29845. * @param endValue End value of the animation curve
  29846. * @param gradient Scalar amount to interpolate
  29847. * @returns Interpolated quaternion value
  29848. */
  29849. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29850. /**
  29851. * Interpolates a quaternion cubically
  29852. * @param startValue Start value of the animation curve
  29853. * @param outTangent End tangent of the animation curve
  29854. * @param endValue End value of the animation curve
  29855. * @param inTangent Start tangent of the animation curve
  29856. * @param gradient Scalar amount to interpolate
  29857. * @returns Interpolated quaternion value
  29858. */
  29859. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29860. /**
  29861. * Interpolates a Vector3 linearl
  29862. * @param startValue Start value of the animation curve
  29863. * @param endValue End value of the animation curve
  29864. * @param gradient Scalar amount to interpolate
  29865. * @returns Interpolated scalar value
  29866. */
  29867. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29868. /**
  29869. * Interpolates a Vector3 cubically
  29870. * @param startValue Start value of the animation curve
  29871. * @param outTangent End tangent of the animation
  29872. * @param endValue End value of the animation curve
  29873. * @param inTangent Start tangent of the animation curve
  29874. * @param gradient Scalar amount to interpolate
  29875. * @returns InterpolatedVector3 value
  29876. */
  29877. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29878. /**
  29879. * Interpolates a Vector2 linearly
  29880. * @param startValue Start value of the animation curve
  29881. * @param endValue End value of the animation curve
  29882. * @param gradient Scalar amount to interpolate
  29883. * @returns Interpolated Vector2 value
  29884. */
  29885. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29886. /**
  29887. * Interpolates a Vector2 cubically
  29888. * @param startValue Start value of the animation curve
  29889. * @param outTangent End tangent of the animation
  29890. * @param endValue End value of the animation curve
  29891. * @param inTangent Start tangent of the animation curve
  29892. * @param gradient Scalar amount to interpolate
  29893. * @returns Interpolated Vector2 value
  29894. */
  29895. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29896. /**
  29897. * Interpolates a size linearly
  29898. * @param startValue Start value of the animation curve
  29899. * @param endValue End value of the animation curve
  29900. * @param gradient Scalar amount to interpolate
  29901. * @returns Interpolated Size value
  29902. */
  29903. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29904. /**
  29905. * Interpolates a Color3 linearly
  29906. * @param startValue Start value of the animation curve
  29907. * @param endValue End value of the animation curve
  29908. * @param gradient Scalar amount to interpolate
  29909. * @returns Interpolated Color3 value
  29910. */
  29911. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29912. /**
  29913. * Interpolates a Color4 linearly
  29914. * @param startValue Start value of the animation curve
  29915. * @param endValue End value of the animation curve
  29916. * @param gradient Scalar amount to interpolate
  29917. * @returns Interpolated Color3 value
  29918. */
  29919. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29920. /**
  29921. * @hidden Internal use only
  29922. */
  29923. _getKeyValue(value: any): any;
  29924. /**
  29925. * @hidden Internal use only
  29926. */
  29927. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29928. /**
  29929. * Defines the function to use to interpolate matrices
  29930. * @param startValue defines the start matrix
  29931. * @param endValue defines the end matrix
  29932. * @param gradient defines the gradient between both matrices
  29933. * @param result defines an optional target matrix where to store the interpolation
  29934. * @returns the interpolated matrix
  29935. */
  29936. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29937. /**
  29938. * Makes a copy of the animation
  29939. * @returns Cloned animation
  29940. */
  29941. clone(): Animation;
  29942. /**
  29943. * Sets the key frames of the animation
  29944. * @param values The animation key frames to set
  29945. */
  29946. setKeys(values: Array<IAnimationKey>): void;
  29947. /**
  29948. * Serializes the animation to an object
  29949. * @returns Serialized object
  29950. */
  29951. serialize(): any;
  29952. /**
  29953. * Float animation type
  29954. */
  29955. static readonly ANIMATIONTYPE_FLOAT: number;
  29956. /**
  29957. * Vector3 animation type
  29958. */
  29959. static readonly ANIMATIONTYPE_VECTOR3: number;
  29960. /**
  29961. * Quaternion animation type
  29962. */
  29963. static readonly ANIMATIONTYPE_QUATERNION: number;
  29964. /**
  29965. * Matrix animation type
  29966. */
  29967. static readonly ANIMATIONTYPE_MATRIX: number;
  29968. /**
  29969. * Color3 animation type
  29970. */
  29971. static readonly ANIMATIONTYPE_COLOR3: number;
  29972. /**
  29973. * Color3 animation type
  29974. */
  29975. static readonly ANIMATIONTYPE_COLOR4: number;
  29976. /**
  29977. * Vector2 animation type
  29978. */
  29979. static readonly ANIMATIONTYPE_VECTOR2: number;
  29980. /**
  29981. * Size animation type
  29982. */
  29983. static readonly ANIMATIONTYPE_SIZE: number;
  29984. /**
  29985. * Relative Loop Mode
  29986. */
  29987. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29988. /**
  29989. * Cycle Loop Mode
  29990. */
  29991. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29992. /**
  29993. * Constant Loop Mode
  29994. */
  29995. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29996. /** @hidden */
  29997. static _UniversalLerp(left: any, right: any, amount: number): any;
  29998. /**
  29999. * Parses an animation object and creates an animation
  30000. * @param parsedAnimation Parsed animation object
  30001. * @returns Animation object
  30002. */
  30003. static Parse(parsedAnimation: any): Animation;
  30004. /**
  30005. * Appends the serialized animations from the source animations
  30006. * @param source Source containing the animations
  30007. * @param destination Target to store the animations
  30008. */
  30009. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30010. }
  30011. }
  30012. declare module BABYLON {
  30013. /**
  30014. * Interface containing an array of animations
  30015. */
  30016. export interface IAnimatable {
  30017. /**
  30018. * Array of animations
  30019. */
  30020. animations: Nullable<Array<Animation>>;
  30021. }
  30022. }
  30023. declare module BABYLON {
  30024. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30025. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30026. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30027. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30028. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30029. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30030. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30031. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30032. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30033. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30034. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30035. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30036. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30037. /**
  30038. * Decorator used to define property that can be serialized as reference to a camera
  30039. * @param sourceName defines the name of the property to decorate
  30040. */
  30041. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30042. /**
  30043. * Class used to help serialization objects
  30044. */
  30045. export class SerializationHelper {
  30046. /** @hidden */
  30047. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30048. /** @hidden */
  30049. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30050. /** @hidden */
  30051. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30052. /** @hidden */
  30053. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30054. /**
  30055. * Appends the serialized animations from the source animations
  30056. * @param source Source containing the animations
  30057. * @param destination Target to store the animations
  30058. */
  30059. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30060. /**
  30061. * Static function used to serialized a specific entity
  30062. * @param entity defines the entity to serialize
  30063. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30064. * @returns a JSON compatible object representing the serialization of the entity
  30065. */
  30066. static Serialize<T>(entity: T, serializationObject?: any): any;
  30067. /**
  30068. * Creates a new entity from a serialization data object
  30069. * @param creationFunction defines a function used to instanciated the new entity
  30070. * @param source defines the source serialization data
  30071. * @param scene defines the hosting scene
  30072. * @param rootUrl defines the root url for resources
  30073. * @returns a new entity
  30074. */
  30075. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30076. /**
  30077. * Clones an object
  30078. * @param creationFunction defines the function used to instanciate the new object
  30079. * @param source defines the source object
  30080. * @returns the cloned object
  30081. */
  30082. static Clone<T>(creationFunction: () => T, source: T): T;
  30083. /**
  30084. * Instanciates a new object based on a source one (some data will be shared between both object)
  30085. * @param creationFunction defines the function used to instanciate the new object
  30086. * @param source defines the source object
  30087. * @returns the new object
  30088. */
  30089. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30090. }
  30091. }
  30092. declare module BABYLON {
  30093. /**
  30094. * Base class of all the textures in babylon.
  30095. * It groups all the common properties the materials, post process, lights... might need
  30096. * in order to make a correct use of the texture.
  30097. */
  30098. export class BaseTexture implements IAnimatable {
  30099. /**
  30100. * Default anisotropic filtering level for the application.
  30101. * It is set to 4 as a good tradeoff between perf and quality.
  30102. */
  30103. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30104. /**
  30105. * Gets or sets the unique id of the texture
  30106. */
  30107. uniqueId: number;
  30108. /**
  30109. * Define the name of the texture.
  30110. */
  30111. name: string;
  30112. /**
  30113. * Gets or sets an object used to store user defined information.
  30114. */
  30115. metadata: any;
  30116. /**
  30117. * For internal use only. Please do not use.
  30118. */
  30119. reservedDataStore: any;
  30120. private _hasAlpha;
  30121. /**
  30122. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30123. */
  30124. set hasAlpha(value: boolean);
  30125. get hasAlpha(): boolean;
  30126. /**
  30127. * Defines if the alpha value should be determined via the rgb values.
  30128. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30129. */
  30130. getAlphaFromRGB: boolean;
  30131. /**
  30132. * Intensity or strength of the texture.
  30133. * It is commonly used by materials to fine tune the intensity of the texture
  30134. */
  30135. level: number;
  30136. /**
  30137. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30138. * This is part of the texture as textures usually maps to one uv set.
  30139. */
  30140. coordinatesIndex: number;
  30141. private _coordinatesMode;
  30142. /**
  30143. * How a texture is mapped.
  30144. *
  30145. * | Value | Type | Description |
  30146. * | ----- | ----------------------------------- | ----------- |
  30147. * | 0 | EXPLICIT_MODE | |
  30148. * | 1 | SPHERICAL_MODE | |
  30149. * | 2 | PLANAR_MODE | |
  30150. * | 3 | CUBIC_MODE | |
  30151. * | 4 | PROJECTION_MODE | |
  30152. * | 5 | SKYBOX_MODE | |
  30153. * | 6 | INVCUBIC_MODE | |
  30154. * | 7 | EQUIRECTANGULAR_MODE | |
  30155. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30156. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30157. */
  30158. set coordinatesMode(value: number);
  30159. get coordinatesMode(): number;
  30160. /**
  30161. * | Value | Type | Description |
  30162. * | ----- | ------------------ | ----------- |
  30163. * | 0 | CLAMP_ADDRESSMODE | |
  30164. * | 1 | WRAP_ADDRESSMODE | |
  30165. * | 2 | MIRROR_ADDRESSMODE | |
  30166. */
  30167. wrapU: number;
  30168. /**
  30169. * | Value | Type | Description |
  30170. * | ----- | ------------------ | ----------- |
  30171. * | 0 | CLAMP_ADDRESSMODE | |
  30172. * | 1 | WRAP_ADDRESSMODE | |
  30173. * | 2 | MIRROR_ADDRESSMODE | |
  30174. */
  30175. wrapV: number;
  30176. /**
  30177. * | Value | Type | Description |
  30178. * | ----- | ------------------ | ----------- |
  30179. * | 0 | CLAMP_ADDRESSMODE | |
  30180. * | 1 | WRAP_ADDRESSMODE | |
  30181. * | 2 | MIRROR_ADDRESSMODE | |
  30182. */
  30183. wrapR: number;
  30184. /**
  30185. * With compliant hardware and browser (supporting anisotropic filtering)
  30186. * this defines the level of anisotropic filtering in the texture.
  30187. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30188. */
  30189. anisotropicFilteringLevel: number;
  30190. /**
  30191. * Define if the texture is a cube texture or if false a 2d texture.
  30192. */
  30193. get isCube(): boolean;
  30194. set isCube(value: boolean);
  30195. /**
  30196. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30197. */
  30198. get is3D(): boolean;
  30199. set is3D(value: boolean);
  30200. /**
  30201. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30202. */
  30203. get is2DArray(): boolean;
  30204. set is2DArray(value: boolean);
  30205. /**
  30206. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30207. * HDR texture are usually stored in linear space.
  30208. * This only impacts the PBR and Background materials
  30209. */
  30210. gammaSpace: boolean;
  30211. /**
  30212. * Gets or sets whether or not the texture contains RGBD data.
  30213. */
  30214. get isRGBD(): boolean;
  30215. set isRGBD(value: boolean);
  30216. /**
  30217. * Is Z inverted in the texture (useful in a cube texture).
  30218. */
  30219. invertZ: boolean;
  30220. /**
  30221. * Are mip maps generated for this texture or not.
  30222. */
  30223. get noMipmap(): boolean;
  30224. /**
  30225. * @hidden
  30226. */
  30227. lodLevelInAlpha: boolean;
  30228. /**
  30229. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30230. */
  30231. get lodGenerationOffset(): number;
  30232. set lodGenerationOffset(value: number);
  30233. /**
  30234. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30235. */
  30236. get lodGenerationScale(): number;
  30237. set lodGenerationScale(value: number);
  30238. /**
  30239. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30240. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30241. * average roughness values.
  30242. */
  30243. get linearSpecularLOD(): boolean;
  30244. set linearSpecularLOD(value: boolean);
  30245. /**
  30246. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30247. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30248. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30249. */
  30250. get irradianceTexture(): Nullable<BaseTexture>;
  30251. set irradianceTexture(value: Nullable<BaseTexture>);
  30252. /**
  30253. * Define if the texture is a render target.
  30254. */
  30255. isRenderTarget: boolean;
  30256. /**
  30257. * Define the unique id of the texture in the scene.
  30258. */
  30259. get uid(): string;
  30260. /**
  30261. * Return a string representation of the texture.
  30262. * @returns the texture as a string
  30263. */
  30264. toString(): string;
  30265. /**
  30266. * Get the class name of the texture.
  30267. * @returns "BaseTexture"
  30268. */
  30269. getClassName(): string;
  30270. /**
  30271. * Define the list of animation attached to the texture.
  30272. */
  30273. animations: Animation[];
  30274. /**
  30275. * An event triggered when the texture is disposed.
  30276. */
  30277. onDisposeObservable: Observable<BaseTexture>;
  30278. private _onDisposeObserver;
  30279. /**
  30280. * Callback triggered when the texture has been disposed.
  30281. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30282. */
  30283. set onDispose(callback: () => void);
  30284. /**
  30285. * Define the current state of the loading sequence when in delayed load mode.
  30286. */
  30287. delayLoadState: number;
  30288. private _scene;
  30289. /** @hidden */
  30290. _texture: Nullable<InternalTexture>;
  30291. private _uid;
  30292. /**
  30293. * Define if the texture is preventinga material to render or not.
  30294. * If not and the texture is not ready, the engine will use a default black texture instead.
  30295. */
  30296. get isBlocking(): boolean;
  30297. /**
  30298. * Instantiates a new BaseTexture.
  30299. * Base class of all the textures in babylon.
  30300. * It groups all the common properties the materials, post process, lights... might need
  30301. * in order to make a correct use of the texture.
  30302. * @param scene Define the scene the texture blongs to
  30303. */
  30304. constructor(scene: Nullable<Scene>);
  30305. /**
  30306. * Get the scene the texture belongs to.
  30307. * @returns the scene or null if undefined
  30308. */
  30309. getScene(): Nullable<Scene>;
  30310. /**
  30311. * Get the texture transform matrix used to offset tile the texture for istance.
  30312. * @returns the transformation matrix
  30313. */
  30314. getTextureMatrix(): Matrix;
  30315. /**
  30316. * Get the texture reflection matrix used to rotate/transform the reflection.
  30317. * @returns the reflection matrix
  30318. */
  30319. getReflectionTextureMatrix(): Matrix;
  30320. /**
  30321. * Get the underlying lower level texture from Babylon.
  30322. * @returns the insternal texture
  30323. */
  30324. getInternalTexture(): Nullable<InternalTexture>;
  30325. /**
  30326. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30327. * @returns true if ready or not blocking
  30328. */
  30329. isReadyOrNotBlocking(): boolean;
  30330. /**
  30331. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30332. * @returns true if fully ready
  30333. */
  30334. isReady(): boolean;
  30335. private _cachedSize;
  30336. /**
  30337. * Get the size of the texture.
  30338. * @returns the texture size.
  30339. */
  30340. getSize(): ISize;
  30341. /**
  30342. * Get the base size of the texture.
  30343. * It can be different from the size if the texture has been resized for POT for instance
  30344. * @returns the base size
  30345. */
  30346. getBaseSize(): ISize;
  30347. /**
  30348. * Update the sampling mode of the texture.
  30349. * Default is Trilinear mode.
  30350. *
  30351. * | Value | Type | Description |
  30352. * | ----- | ------------------ | ----------- |
  30353. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30354. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30355. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30356. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30357. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30358. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30359. * | 7 | NEAREST_LINEAR | |
  30360. * | 8 | NEAREST_NEAREST | |
  30361. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30362. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30363. * | 11 | LINEAR_LINEAR | |
  30364. * | 12 | LINEAR_NEAREST | |
  30365. *
  30366. * > _mag_: magnification filter (close to the viewer)
  30367. * > _min_: minification filter (far from the viewer)
  30368. * > _mip_: filter used between mip map levels
  30369. *@param samplingMode Define the new sampling mode of the texture
  30370. */
  30371. updateSamplingMode(samplingMode: number): void;
  30372. /**
  30373. * Scales the texture if is `canRescale()`
  30374. * @param ratio the resize factor we want to use to rescale
  30375. */
  30376. scale(ratio: number): void;
  30377. /**
  30378. * Get if the texture can rescale.
  30379. */
  30380. get canRescale(): boolean;
  30381. /** @hidden */
  30382. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30383. /** @hidden */
  30384. _rebuild(): void;
  30385. /**
  30386. * Triggers the load sequence in delayed load mode.
  30387. */
  30388. delayLoad(): void;
  30389. /**
  30390. * Clones the texture.
  30391. * @returns the cloned texture
  30392. */
  30393. clone(): Nullable<BaseTexture>;
  30394. /**
  30395. * Get the texture underlying type (INT, FLOAT...)
  30396. */
  30397. get textureType(): number;
  30398. /**
  30399. * Get the texture underlying format (RGB, RGBA...)
  30400. */
  30401. get textureFormat(): number;
  30402. /**
  30403. * Indicates that textures need to be re-calculated for all materials
  30404. */
  30405. protected _markAllSubMeshesAsTexturesDirty(): void;
  30406. /**
  30407. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30408. * This will returns an RGBA array buffer containing either in values (0-255) or
  30409. * float values (0-1) depending of the underlying buffer type.
  30410. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30411. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30412. * @param buffer defines a user defined buffer to fill with data (can be null)
  30413. * @returns The Array buffer containing the pixels data.
  30414. */
  30415. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30416. /**
  30417. * Release and destroy the underlying lower level texture aka internalTexture.
  30418. */
  30419. releaseInternalTexture(): void;
  30420. /** @hidden */
  30421. get _lodTextureHigh(): Nullable<BaseTexture>;
  30422. /** @hidden */
  30423. get _lodTextureMid(): Nullable<BaseTexture>;
  30424. /** @hidden */
  30425. get _lodTextureLow(): Nullable<BaseTexture>;
  30426. /**
  30427. * Dispose the texture and release its associated resources.
  30428. */
  30429. dispose(): void;
  30430. /**
  30431. * Serialize the texture into a JSON representation that can be parsed later on.
  30432. * @returns the JSON representation of the texture
  30433. */
  30434. serialize(): any;
  30435. /**
  30436. * Helper function to be called back once a list of texture contains only ready textures.
  30437. * @param textures Define the list of textures to wait for
  30438. * @param callback Define the callback triggered once the entire list will be ready
  30439. */
  30440. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30441. }
  30442. }
  30443. declare module BABYLON {
  30444. /**
  30445. * Options to be used when creating an effect.
  30446. */
  30447. export interface IEffectCreationOptions {
  30448. /**
  30449. * Atrributes that will be used in the shader.
  30450. */
  30451. attributes: string[];
  30452. /**
  30453. * Uniform varible names that will be set in the shader.
  30454. */
  30455. uniformsNames: string[];
  30456. /**
  30457. * Uniform buffer variable names that will be set in the shader.
  30458. */
  30459. uniformBuffersNames: string[];
  30460. /**
  30461. * Sampler texture variable names that will be set in the shader.
  30462. */
  30463. samplers: string[];
  30464. /**
  30465. * Define statements that will be set in the shader.
  30466. */
  30467. defines: any;
  30468. /**
  30469. * Possible fallbacks for this effect to improve performance when needed.
  30470. */
  30471. fallbacks: Nullable<IEffectFallbacks>;
  30472. /**
  30473. * Callback that will be called when the shader is compiled.
  30474. */
  30475. onCompiled: Nullable<(effect: Effect) => void>;
  30476. /**
  30477. * Callback that will be called if an error occurs during shader compilation.
  30478. */
  30479. onError: Nullable<(effect: Effect, errors: string) => void>;
  30480. /**
  30481. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30482. */
  30483. indexParameters?: any;
  30484. /**
  30485. * Max number of lights that can be used in the shader.
  30486. */
  30487. maxSimultaneousLights?: number;
  30488. /**
  30489. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30490. */
  30491. transformFeedbackVaryings?: Nullable<string[]>;
  30492. }
  30493. /**
  30494. * Effect containing vertex and fragment shader that can be executed on an object.
  30495. */
  30496. export class Effect implements IDisposable {
  30497. /**
  30498. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30499. */
  30500. static ShadersRepository: string;
  30501. /**
  30502. * Enable logging of the shader code when a compilation error occurs
  30503. */
  30504. static LogShaderCodeOnCompilationError: boolean;
  30505. /**
  30506. * Name of the effect.
  30507. */
  30508. name: any;
  30509. /**
  30510. * String container all the define statements that should be set on the shader.
  30511. */
  30512. defines: string;
  30513. /**
  30514. * Callback that will be called when the shader is compiled.
  30515. */
  30516. onCompiled: Nullable<(effect: Effect) => void>;
  30517. /**
  30518. * Callback that will be called if an error occurs during shader compilation.
  30519. */
  30520. onError: Nullable<(effect: Effect, errors: string) => void>;
  30521. /**
  30522. * Callback that will be called when effect is bound.
  30523. */
  30524. onBind: Nullable<(effect: Effect) => void>;
  30525. /**
  30526. * Unique ID of the effect.
  30527. */
  30528. uniqueId: number;
  30529. /**
  30530. * Observable that will be called when the shader is compiled.
  30531. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30532. */
  30533. onCompileObservable: Observable<Effect>;
  30534. /**
  30535. * Observable that will be called if an error occurs during shader compilation.
  30536. */
  30537. onErrorObservable: Observable<Effect>;
  30538. /** @hidden */
  30539. _onBindObservable: Nullable<Observable<Effect>>;
  30540. /**
  30541. * @hidden
  30542. * Specifies if the effect was previously ready
  30543. */
  30544. _wasPreviouslyReady: boolean;
  30545. /**
  30546. * Observable that will be called when effect is bound.
  30547. */
  30548. get onBindObservable(): Observable<Effect>;
  30549. /** @hidden */
  30550. _bonesComputationForcedToCPU: boolean;
  30551. private static _uniqueIdSeed;
  30552. private _engine;
  30553. private _uniformBuffersNames;
  30554. private _uniformBuffersNamesList;
  30555. private _uniformsNames;
  30556. private _samplerList;
  30557. private _samplers;
  30558. private _isReady;
  30559. private _compilationError;
  30560. private _allFallbacksProcessed;
  30561. private _attributesNames;
  30562. private _attributes;
  30563. private _attributeLocationByName;
  30564. private _uniforms;
  30565. /**
  30566. * Key for the effect.
  30567. * @hidden
  30568. */
  30569. _key: string;
  30570. private _indexParameters;
  30571. private _fallbacks;
  30572. private _vertexSourceCode;
  30573. private _fragmentSourceCode;
  30574. private _vertexSourceCodeOverride;
  30575. private _fragmentSourceCodeOverride;
  30576. private _transformFeedbackVaryings;
  30577. /**
  30578. * Compiled shader to webGL program.
  30579. * @hidden
  30580. */
  30581. _pipelineContext: Nullable<IPipelineContext>;
  30582. private _valueCache;
  30583. private static _baseCache;
  30584. /**
  30585. * Instantiates an effect.
  30586. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30587. * @param baseName Name of the effect.
  30588. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30589. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30590. * @param samplers List of sampler variables that will be passed to the shader.
  30591. * @param engine Engine to be used to render the effect
  30592. * @param defines Define statements to be added to the shader.
  30593. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30594. * @param onCompiled Callback that will be called when the shader is compiled.
  30595. * @param onError Callback that will be called if an error occurs during shader compilation.
  30596. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30597. */
  30598. 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);
  30599. private _useFinalCode;
  30600. /**
  30601. * Unique key for this effect
  30602. */
  30603. get key(): string;
  30604. /**
  30605. * If the effect has been compiled and prepared.
  30606. * @returns if the effect is compiled and prepared.
  30607. */
  30608. isReady(): boolean;
  30609. private _isReadyInternal;
  30610. /**
  30611. * The engine the effect was initialized with.
  30612. * @returns the engine.
  30613. */
  30614. getEngine(): Engine;
  30615. /**
  30616. * The pipeline context for this effect
  30617. * @returns the associated pipeline context
  30618. */
  30619. getPipelineContext(): Nullable<IPipelineContext>;
  30620. /**
  30621. * The set of names of attribute variables for the shader.
  30622. * @returns An array of attribute names.
  30623. */
  30624. getAttributesNames(): string[];
  30625. /**
  30626. * Returns the attribute at the given index.
  30627. * @param index The index of the attribute.
  30628. * @returns The location of the attribute.
  30629. */
  30630. getAttributeLocation(index: number): number;
  30631. /**
  30632. * Returns the attribute based on the name of the variable.
  30633. * @param name of the attribute to look up.
  30634. * @returns the attribute location.
  30635. */
  30636. getAttributeLocationByName(name: string): number;
  30637. /**
  30638. * The number of attributes.
  30639. * @returns the numnber of attributes.
  30640. */
  30641. getAttributesCount(): number;
  30642. /**
  30643. * Gets the index of a uniform variable.
  30644. * @param uniformName of the uniform to look up.
  30645. * @returns the index.
  30646. */
  30647. getUniformIndex(uniformName: string): number;
  30648. /**
  30649. * Returns the attribute based on the name of the variable.
  30650. * @param uniformName of the uniform to look up.
  30651. * @returns the location of the uniform.
  30652. */
  30653. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30654. /**
  30655. * Returns an array of sampler variable names
  30656. * @returns The array of sampler variable names.
  30657. */
  30658. getSamplers(): string[];
  30659. /**
  30660. * Returns an array of uniform variable names
  30661. * @returns The array of uniform variable names.
  30662. */
  30663. getUniformNames(): string[];
  30664. /**
  30665. * Returns an array of uniform buffer variable names
  30666. * @returns The array of uniform buffer variable names.
  30667. */
  30668. getUniformBuffersNames(): string[];
  30669. /**
  30670. * Returns the index parameters used to create the effect
  30671. * @returns The index parameters object
  30672. */
  30673. getIndexParameters(): any;
  30674. /**
  30675. * The error from the last compilation.
  30676. * @returns the error string.
  30677. */
  30678. getCompilationError(): string;
  30679. /**
  30680. * Gets a boolean indicating that all fallbacks were used during compilation
  30681. * @returns true if all fallbacks were used
  30682. */
  30683. allFallbacksProcessed(): boolean;
  30684. /**
  30685. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30686. * @param func The callback to be used.
  30687. */
  30688. executeWhenCompiled(func: (effect: Effect) => void): void;
  30689. private _checkIsReady;
  30690. private _loadShader;
  30691. /**
  30692. * Gets the vertex shader source code of this effect
  30693. */
  30694. get vertexSourceCode(): string;
  30695. /**
  30696. * Gets the fragment shader source code of this effect
  30697. */
  30698. get fragmentSourceCode(): string;
  30699. /**
  30700. * Recompiles the webGL program
  30701. * @param vertexSourceCode The source code for the vertex shader.
  30702. * @param fragmentSourceCode The source code for the fragment shader.
  30703. * @param onCompiled Callback called when completed.
  30704. * @param onError Callback called on error.
  30705. * @hidden
  30706. */
  30707. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30708. /**
  30709. * Prepares the effect
  30710. * @hidden
  30711. */
  30712. _prepareEffect(): void;
  30713. private _getShaderCodeAndErrorLine;
  30714. private _processCompilationErrors;
  30715. /**
  30716. * Checks if the effect is supported. (Must be called after compilation)
  30717. */
  30718. get isSupported(): boolean;
  30719. /**
  30720. * Binds a texture to the engine to be used as output of the shader.
  30721. * @param channel Name of the output variable.
  30722. * @param texture Texture to bind.
  30723. * @hidden
  30724. */
  30725. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30726. /**
  30727. * Sets a texture on the engine to be used in the shader.
  30728. * @param channel Name of the sampler variable.
  30729. * @param texture Texture to set.
  30730. */
  30731. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30732. /**
  30733. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30734. * @param channel Name of the sampler variable.
  30735. * @param texture Texture to set.
  30736. */
  30737. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30738. /**
  30739. * Sets an array of textures on the engine to be used in the shader.
  30740. * @param channel Name of the variable.
  30741. * @param textures Textures to set.
  30742. */
  30743. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30744. /**
  30745. * 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)
  30746. * @param channel Name of the sampler variable.
  30747. * @param postProcess Post process to get the input texture from.
  30748. */
  30749. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30750. /**
  30751. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30752. * 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)
  30753. * @param channel Name of the sampler variable.
  30754. * @param postProcess Post process to get the output texture from.
  30755. */
  30756. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30757. /** @hidden */
  30758. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30759. /** @hidden */
  30760. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30761. /** @hidden */
  30762. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30763. /** @hidden */
  30764. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30765. /**
  30766. * Binds a buffer to a uniform.
  30767. * @param buffer Buffer to bind.
  30768. * @param name Name of the uniform variable to bind to.
  30769. */
  30770. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30771. /**
  30772. * Binds block to a uniform.
  30773. * @param blockName Name of the block to bind.
  30774. * @param index Index to bind.
  30775. */
  30776. bindUniformBlock(blockName: string, index: number): void;
  30777. /**
  30778. * Sets an interger value on a uniform variable.
  30779. * @param uniformName Name of the variable.
  30780. * @param value Value to be set.
  30781. * @returns this effect.
  30782. */
  30783. setInt(uniformName: string, value: number): Effect;
  30784. /**
  30785. * Sets an int array on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param array array to be set.
  30788. * @returns this effect.
  30789. */
  30790. setIntArray(uniformName: string, array: Int32Array): Effect;
  30791. /**
  30792. * 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)
  30793. * @param uniformName Name of the variable.
  30794. * @param array array to be set.
  30795. * @returns this effect.
  30796. */
  30797. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30798. /**
  30799. * 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)
  30800. * @param uniformName Name of the variable.
  30801. * @param array array to be set.
  30802. * @returns this effect.
  30803. */
  30804. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30805. /**
  30806. * 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)
  30807. * @param uniformName Name of the variable.
  30808. * @param array array to be set.
  30809. * @returns this effect.
  30810. */
  30811. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30812. /**
  30813. * Sets an float array on a uniform variable.
  30814. * @param uniformName Name of the variable.
  30815. * @param array array to be set.
  30816. * @returns this effect.
  30817. */
  30818. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30819. /**
  30820. * 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)
  30821. * @param uniformName Name of the variable.
  30822. * @param array array to be set.
  30823. * @returns this effect.
  30824. */
  30825. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30826. /**
  30827. * 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)
  30828. * @param uniformName Name of the variable.
  30829. * @param array array to be set.
  30830. * @returns this effect.
  30831. */
  30832. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30833. /**
  30834. * 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)
  30835. * @param uniformName Name of the variable.
  30836. * @param array array to be set.
  30837. * @returns this effect.
  30838. */
  30839. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30840. /**
  30841. * Sets an array on a uniform variable.
  30842. * @param uniformName Name of the variable.
  30843. * @param array array to be set.
  30844. * @returns this effect.
  30845. */
  30846. setArray(uniformName: string, array: number[]): Effect;
  30847. /**
  30848. * 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)
  30849. * @param uniformName Name of the variable.
  30850. * @param array array to be set.
  30851. * @returns this effect.
  30852. */
  30853. setArray2(uniformName: string, array: number[]): Effect;
  30854. /**
  30855. * 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)
  30856. * @param uniformName Name of the variable.
  30857. * @param array array to be set.
  30858. * @returns this effect.
  30859. */
  30860. setArray3(uniformName: string, array: number[]): Effect;
  30861. /**
  30862. * 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)
  30863. * @param uniformName Name of the variable.
  30864. * @param array array to be set.
  30865. * @returns this effect.
  30866. */
  30867. setArray4(uniformName: string, array: number[]): Effect;
  30868. /**
  30869. * Sets matrices on a uniform variable.
  30870. * @param uniformName Name of the variable.
  30871. * @param matrices matrices to be set.
  30872. * @returns this effect.
  30873. */
  30874. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30875. /**
  30876. * Sets matrix on a uniform variable.
  30877. * @param uniformName Name of the variable.
  30878. * @param matrix matrix to be set.
  30879. * @returns this effect.
  30880. */
  30881. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30882. /**
  30883. * 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)
  30884. * @param uniformName Name of the variable.
  30885. * @param matrix matrix to be set.
  30886. * @returns this effect.
  30887. */
  30888. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30889. /**
  30890. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30891. * @param uniformName Name of the variable.
  30892. * @param matrix matrix to be set.
  30893. * @returns this effect.
  30894. */
  30895. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30896. /**
  30897. * Sets a float on a uniform variable.
  30898. * @param uniformName Name of the variable.
  30899. * @param value value to be set.
  30900. * @returns this effect.
  30901. */
  30902. setFloat(uniformName: string, value: number): Effect;
  30903. /**
  30904. * Sets a boolean on a uniform variable.
  30905. * @param uniformName Name of the variable.
  30906. * @param bool value to be set.
  30907. * @returns this effect.
  30908. */
  30909. setBool(uniformName: string, bool: boolean): Effect;
  30910. /**
  30911. * Sets a Vector2 on a uniform variable.
  30912. * @param uniformName Name of the variable.
  30913. * @param vector2 vector2 to be set.
  30914. * @returns this effect.
  30915. */
  30916. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30917. /**
  30918. * Sets a float2 on a uniform variable.
  30919. * @param uniformName Name of the variable.
  30920. * @param x First float in float2.
  30921. * @param y Second float in float2.
  30922. * @returns this effect.
  30923. */
  30924. setFloat2(uniformName: string, x: number, y: number): Effect;
  30925. /**
  30926. * Sets a Vector3 on a uniform variable.
  30927. * @param uniformName Name of the variable.
  30928. * @param vector3 Value to be set.
  30929. * @returns this effect.
  30930. */
  30931. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30932. /**
  30933. * Sets a float3 on a uniform variable.
  30934. * @param uniformName Name of the variable.
  30935. * @param x First float in float3.
  30936. * @param y Second float in float3.
  30937. * @param z Third float in float3.
  30938. * @returns this effect.
  30939. */
  30940. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30941. /**
  30942. * Sets a Vector4 on a uniform variable.
  30943. * @param uniformName Name of the variable.
  30944. * @param vector4 Value to be set.
  30945. * @returns this effect.
  30946. */
  30947. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30948. /**
  30949. * Sets a float4 on a uniform variable.
  30950. * @param uniformName Name of the variable.
  30951. * @param x First float in float4.
  30952. * @param y Second float in float4.
  30953. * @param z Third float in float4.
  30954. * @param w Fourth float in float4.
  30955. * @returns this effect.
  30956. */
  30957. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30958. /**
  30959. * Sets a Color3 on a uniform variable.
  30960. * @param uniformName Name of the variable.
  30961. * @param color3 Value to be set.
  30962. * @returns this effect.
  30963. */
  30964. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30965. /**
  30966. * Sets a Color4 on a uniform variable.
  30967. * @param uniformName Name of the variable.
  30968. * @param color3 Value to be set.
  30969. * @param alpha Alpha value to be set.
  30970. * @returns this effect.
  30971. */
  30972. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30973. /**
  30974. * Sets a Color4 on a uniform variable
  30975. * @param uniformName defines the name of the variable
  30976. * @param color4 defines the value to be set
  30977. * @returns this effect.
  30978. */
  30979. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30980. /** Release all associated resources */
  30981. dispose(): void;
  30982. /**
  30983. * This function will add a new shader to the shader store
  30984. * @param name the name of the shader
  30985. * @param pixelShader optional pixel shader content
  30986. * @param vertexShader optional vertex shader content
  30987. */
  30988. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30989. /**
  30990. * Store of each shader (The can be looked up using effect.key)
  30991. */
  30992. static ShadersStore: {
  30993. [key: string]: string;
  30994. };
  30995. /**
  30996. * Store of each included file for a shader (The can be looked up using effect.key)
  30997. */
  30998. static IncludesShadersStore: {
  30999. [key: string]: string;
  31000. };
  31001. /**
  31002. * Resets the cache of effects.
  31003. */
  31004. static ResetCache(): void;
  31005. }
  31006. }
  31007. declare module BABYLON {
  31008. /**
  31009. * Interface used to describe the capabilities of the engine relatively to the current browser
  31010. */
  31011. export interface EngineCapabilities {
  31012. /** Maximum textures units per fragment shader */
  31013. maxTexturesImageUnits: number;
  31014. /** Maximum texture units per vertex shader */
  31015. maxVertexTextureImageUnits: number;
  31016. /** Maximum textures units in the entire pipeline */
  31017. maxCombinedTexturesImageUnits: number;
  31018. /** Maximum texture size */
  31019. maxTextureSize: number;
  31020. /** Maximum texture samples */
  31021. maxSamples?: number;
  31022. /** Maximum cube texture size */
  31023. maxCubemapTextureSize: number;
  31024. /** Maximum render texture size */
  31025. maxRenderTextureSize: number;
  31026. /** Maximum number of vertex attributes */
  31027. maxVertexAttribs: number;
  31028. /** Maximum number of varyings */
  31029. maxVaryingVectors: number;
  31030. /** Maximum number of uniforms per vertex shader */
  31031. maxVertexUniformVectors: number;
  31032. /** Maximum number of uniforms per fragment shader */
  31033. maxFragmentUniformVectors: number;
  31034. /** Defines if standard derivates (dx/dy) are supported */
  31035. standardDerivatives: boolean;
  31036. /** Defines if s3tc texture compression is supported */
  31037. s3tc?: WEBGL_compressed_texture_s3tc;
  31038. /** Defines if pvrtc texture compression is supported */
  31039. pvrtc: any;
  31040. /** Defines if etc1 texture compression is supported */
  31041. etc1: any;
  31042. /** Defines if etc2 texture compression is supported */
  31043. etc2: any;
  31044. /** Defines if astc texture compression is supported */
  31045. astc: any;
  31046. /** Defines if float textures are supported */
  31047. textureFloat: boolean;
  31048. /** Defines if vertex array objects are supported */
  31049. vertexArrayObject: boolean;
  31050. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31051. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31052. /** Gets the maximum level of anisotropy supported */
  31053. maxAnisotropy: number;
  31054. /** Defines if instancing is supported */
  31055. instancedArrays: boolean;
  31056. /** Defines if 32 bits indices are supported */
  31057. uintIndices: boolean;
  31058. /** Defines if high precision shaders are supported */
  31059. highPrecisionShaderSupported: boolean;
  31060. /** Defines if depth reading in the fragment shader is supported */
  31061. fragmentDepthSupported: boolean;
  31062. /** Defines if float texture linear filtering is supported*/
  31063. textureFloatLinearFiltering: boolean;
  31064. /** Defines if rendering to float textures is supported */
  31065. textureFloatRender: boolean;
  31066. /** Defines if half float textures are supported*/
  31067. textureHalfFloat: boolean;
  31068. /** Defines if half float texture linear filtering is supported*/
  31069. textureHalfFloatLinearFiltering: boolean;
  31070. /** Defines if rendering to half float textures is supported */
  31071. textureHalfFloatRender: boolean;
  31072. /** Defines if textureLOD shader command is supported */
  31073. textureLOD: boolean;
  31074. /** Defines if draw buffers extension is supported */
  31075. drawBuffersExtension: boolean;
  31076. /** Defines if depth textures are supported */
  31077. depthTextureExtension: boolean;
  31078. /** Defines if float color buffer are supported */
  31079. colorBufferFloat: boolean;
  31080. /** Gets disjoint timer query extension (null if not supported) */
  31081. timerQuery?: EXT_disjoint_timer_query;
  31082. /** Defines if timestamp can be used with timer query */
  31083. canUseTimestampForTimerQuery: boolean;
  31084. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31085. multiview?: any;
  31086. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31087. oculusMultiview?: any;
  31088. /** Function used to let the system compiles shaders in background */
  31089. parallelShaderCompile?: {
  31090. COMPLETION_STATUS_KHR: number;
  31091. };
  31092. /** Max number of texture samples for MSAA */
  31093. maxMSAASamples: number;
  31094. /** Defines if the blend min max extension is supported */
  31095. blendMinMax: boolean;
  31096. }
  31097. }
  31098. declare module BABYLON {
  31099. /**
  31100. * @hidden
  31101. **/
  31102. export class DepthCullingState {
  31103. private _isDepthTestDirty;
  31104. private _isDepthMaskDirty;
  31105. private _isDepthFuncDirty;
  31106. private _isCullFaceDirty;
  31107. private _isCullDirty;
  31108. private _isZOffsetDirty;
  31109. private _isFrontFaceDirty;
  31110. private _depthTest;
  31111. private _depthMask;
  31112. private _depthFunc;
  31113. private _cull;
  31114. private _cullFace;
  31115. private _zOffset;
  31116. private _frontFace;
  31117. /**
  31118. * Initializes the state.
  31119. */
  31120. constructor();
  31121. get isDirty(): boolean;
  31122. get zOffset(): number;
  31123. set zOffset(value: number);
  31124. get cullFace(): Nullable<number>;
  31125. set cullFace(value: Nullable<number>);
  31126. get cull(): Nullable<boolean>;
  31127. set cull(value: Nullable<boolean>);
  31128. get depthFunc(): Nullable<number>;
  31129. set depthFunc(value: Nullable<number>);
  31130. get depthMask(): boolean;
  31131. set depthMask(value: boolean);
  31132. get depthTest(): boolean;
  31133. set depthTest(value: boolean);
  31134. get frontFace(): Nullable<number>;
  31135. set frontFace(value: Nullable<number>);
  31136. reset(): void;
  31137. apply(gl: WebGLRenderingContext): void;
  31138. }
  31139. }
  31140. declare module BABYLON {
  31141. /**
  31142. * @hidden
  31143. **/
  31144. export class StencilState {
  31145. /** 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 */
  31146. static readonly ALWAYS: number;
  31147. /** Passed to stencilOperation to specify that stencil value must be kept */
  31148. static readonly KEEP: number;
  31149. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31150. static readonly REPLACE: number;
  31151. private _isStencilTestDirty;
  31152. private _isStencilMaskDirty;
  31153. private _isStencilFuncDirty;
  31154. private _isStencilOpDirty;
  31155. private _stencilTest;
  31156. private _stencilMask;
  31157. private _stencilFunc;
  31158. private _stencilFuncRef;
  31159. private _stencilFuncMask;
  31160. private _stencilOpStencilFail;
  31161. private _stencilOpDepthFail;
  31162. private _stencilOpStencilDepthPass;
  31163. get isDirty(): boolean;
  31164. get stencilFunc(): number;
  31165. set stencilFunc(value: number);
  31166. get stencilFuncRef(): number;
  31167. set stencilFuncRef(value: number);
  31168. get stencilFuncMask(): number;
  31169. set stencilFuncMask(value: number);
  31170. get stencilOpStencilFail(): number;
  31171. set stencilOpStencilFail(value: number);
  31172. get stencilOpDepthFail(): number;
  31173. set stencilOpDepthFail(value: number);
  31174. get stencilOpStencilDepthPass(): number;
  31175. set stencilOpStencilDepthPass(value: number);
  31176. get stencilMask(): number;
  31177. set stencilMask(value: number);
  31178. get stencilTest(): boolean;
  31179. set stencilTest(value: boolean);
  31180. constructor();
  31181. reset(): void;
  31182. apply(gl: WebGLRenderingContext): void;
  31183. }
  31184. }
  31185. declare module BABYLON {
  31186. /**
  31187. * @hidden
  31188. **/
  31189. export class AlphaState {
  31190. private _isAlphaBlendDirty;
  31191. private _isBlendFunctionParametersDirty;
  31192. private _isBlendEquationParametersDirty;
  31193. private _isBlendConstantsDirty;
  31194. private _alphaBlend;
  31195. private _blendFunctionParameters;
  31196. private _blendEquationParameters;
  31197. private _blendConstants;
  31198. /**
  31199. * Initializes the state.
  31200. */
  31201. constructor();
  31202. get isDirty(): boolean;
  31203. get alphaBlend(): boolean;
  31204. set alphaBlend(value: boolean);
  31205. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31206. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31207. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31208. reset(): void;
  31209. apply(gl: WebGLRenderingContext): void;
  31210. }
  31211. }
  31212. declare module BABYLON {
  31213. /** @hidden */
  31214. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31215. attributeProcessor(attribute: string): string;
  31216. varyingProcessor(varying: string, isFragment: boolean): string;
  31217. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31218. }
  31219. }
  31220. declare module BABYLON {
  31221. /**
  31222. * Interface for attribute information associated with buffer instanciation
  31223. */
  31224. export interface InstancingAttributeInfo {
  31225. /**
  31226. * Name of the GLSL attribute
  31227. * if attribute index is not specified, this is used to retrieve the index from the effect
  31228. */
  31229. attributeName: string;
  31230. /**
  31231. * Index/offset of the attribute in the vertex shader
  31232. * if not specified, this will be computes from the name.
  31233. */
  31234. index?: number;
  31235. /**
  31236. * size of the attribute, 1, 2, 3 or 4
  31237. */
  31238. attributeSize: number;
  31239. /**
  31240. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31241. */
  31242. offset: number;
  31243. /**
  31244. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31245. * default to 1
  31246. */
  31247. divisor?: number;
  31248. /**
  31249. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31250. * default is FLOAT
  31251. */
  31252. attributeType?: number;
  31253. /**
  31254. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31255. */
  31256. normalized?: boolean;
  31257. }
  31258. }
  31259. declare module BABYLON {
  31260. interface ThinEngine {
  31261. /**
  31262. * Update a video texture
  31263. * @param texture defines the texture to update
  31264. * @param video defines the video element to use
  31265. * @param invertY defines if data must be stored with Y axis inverted
  31266. */
  31267. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31268. }
  31269. }
  31270. declare module BABYLON {
  31271. /**
  31272. * Settings for finer control over video usage
  31273. */
  31274. export interface VideoTextureSettings {
  31275. /**
  31276. * Applies `autoplay` to video, if specified
  31277. */
  31278. autoPlay?: boolean;
  31279. /**
  31280. * Applies `loop` to video, if specified
  31281. */
  31282. loop?: boolean;
  31283. /**
  31284. * Automatically updates internal texture from video at every frame in the render loop
  31285. */
  31286. autoUpdateTexture: boolean;
  31287. /**
  31288. * Image src displayed during the video loading or until the user interacts with the video.
  31289. */
  31290. poster?: string;
  31291. }
  31292. /**
  31293. * If you want to display a video in your scene, this is the special texture for that.
  31294. * This special texture works similar to other textures, with the exception of a few parameters.
  31295. * @see https://doc.babylonjs.com/how_to/video_texture
  31296. */
  31297. export class VideoTexture extends Texture {
  31298. /**
  31299. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31300. */
  31301. readonly autoUpdateTexture: boolean;
  31302. /**
  31303. * The video instance used by the texture internally
  31304. */
  31305. readonly video: HTMLVideoElement;
  31306. private _onUserActionRequestedObservable;
  31307. /**
  31308. * Event triggerd when a dom action is required by the user to play the video.
  31309. * This happens due to recent changes in browser policies preventing video to auto start.
  31310. */
  31311. get onUserActionRequestedObservable(): Observable<Texture>;
  31312. private _generateMipMaps;
  31313. private _engine;
  31314. private _stillImageCaptured;
  31315. private _displayingPosterTexture;
  31316. private _settings;
  31317. private _createInternalTextureOnEvent;
  31318. private _frameId;
  31319. private _currentSrc;
  31320. /**
  31321. * Creates a video texture.
  31322. * If you want to display a video in your scene, this is the special texture for that.
  31323. * This special texture works similar to other textures, with the exception of a few parameters.
  31324. * @see https://doc.babylonjs.com/how_to/video_texture
  31325. * @param name optional name, will detect from video source, if not defined
  31326. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31327. * @param scene is obviously the current scene.
  31328. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31329. * @param invertY is false by default but can be used to invert video on Y axis
  31330. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31331. * @param settings allows finer control over video usage
  31332. */
  31333. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31334. private _getName;
  31335. private _getVideo;
  31336. private _createInternalTexture;
  31337. private reset;
  31338. /**
  31339. * @hidden Internal method to initiate `update`.
  31340. */
  31341. _rebuild(): void;
  31342. /**
  31343. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31344. */
  31345. update(): void;
  31346. /**
  31347. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31348. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31349. */
  31350. updateTexture(isVisible: boolean): void;
  31351. protected _updateInternalTexture: () => void;
  31352. /**
  31353. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31354. * @param url New url.
  31355. */
  31356. updateURL(url: string): void;
  31357. /**
  31358. * Clones the texture.
  31359. * @returns the cloned texture
  31360. */
  31361. clone(): VideoTexture;
  31362. /**
  31363. * Dispose the texture and release its associated resources.
  31364. */
  31365. dispose(): void;
  31366. /**
  31367. * Creates a video texture straight from a stream.
  31368. * @param scene Define the scene the texture should be created in
  31369. * @param stream Define the stream the texture should be created from
  31370. * @returns The created video texture as a promise
  31371. */
  31372. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31373. /**
  31374. * Creates a video texture straight from your WebCam video feed.
  31375. * @param scene Define the scene the texture should be created in
  31376. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31377. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31378. * @returns The created video texture as a promise
  31379. */
  31380. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31381. minWidth: number;
  31382. maxWidth: number;
  31383. minHeight: number;
  31384. maxHeight: number;
  31385. deviceId: string;
  31386. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31387. /**
  31388. * Creates a video texture straight from your WebCam video feed.
  31389. * @param scene Define the scene the texture should be created in
  31390. * @param onReady Define a callback to triggered once the texture will be ready
  31391. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31392. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31393. */
  31394. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31395. minWidth: number;
  31396. maxWidth: number;
  31397. minHeight: number;
  31398. maxHeight: number;
  31399. deviceId: string;
  31400. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31401. }
  31402. }
  31403. declare module BABYLON {
  31404. /**
  31405. * Defines the interface used by objects working like Scene
  31406. * @hidden
  31407. */
  31408. export interface ISceneLike {
  31409. _addPendingData(data: any): void;
  31410. _removePendingData(data: any): void;
  31411. offlineProvider: IOfflineProvider;
  31412. }
  31413. /** Interface defining initialization parameters for Engine class */
  31414. export interface EngineOptions extends WebGLContextAttributes {
  31415. /**
  31416. * Defines if the engine should no exceed a specified device ratio
  31417. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31418. */
  31419. limitDeviceRatio?: number;
  31420. /**
  31421. * Defines if webvr should be enabled automatically
  31422. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31423. */
  31424. autoEnableWebVR?: boolean;
  31425. /**
  31426. * Defines if webgl2 should be turned off even if supported
  31427. * @see http://doc.babylonjs.com/features/webgl2
  31428. */
  31429. disableWebGL2Support?: boolean;
  31430. /**
  31431. * Defines if webaudio should be initialized as well
  31432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31433. */
  31434. audioEngine?: boolean;
  31435. /**
  31436. * Defines if animations should run using a deterministic lock step
  31437. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31438. */
  31439. deterministicLockstep?: boolean;
  31440. /** Defines the maximum steps to use with deterministic lock step mode */
  31441. lockstepMaxSteps?: number;
  31442. /** Defines the seconds between each deterministic lock step */
  31443. timeStep?: number;
  31444. /**
  31445. * Defines that engine should ignore context lost events
  31446. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31447. */
  31448. doNotHandleContextLost?: boolean;
  31449. /**
  31450. * Defines that engine should ignore modifying touch action attribute and style
  31451. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31452. */
  31453. doNotHandleTouchAction?: boolean;
  31454. /**
  31455. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31456. */
  31457. useHighPrecisionFloats?: boolean;
  31458. }
  31459. /**
  31460. * The base engine class (root of all engines)
  31461. */
  31462. export class ThinEngine {
  31463. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31464. static ExceptionList: ({
  31465. key: string;
  31466. capture: string;
  31467. captureConstraint: number;
  31468. targets: string[];
  31469. } | {
  31470. key: string;
  31471. capture: null;
  31472. captureConstraint: null;
  31473. targets: string[];
  31474. })[];
  31475. /** @hidden */
  31476. static _TextureLoaders: IInternalTextureLoader[];
  31477. /**
  31478. * Returns the current npm package of the sdk
  31479. */
  31480. static get NpmPackage(): string;
  31481. /**
  31482. * Returns the current version of the framework
  31483. */
  31484. static get Version(): string;
  31485. /**
  31486. * Returns a string describing the current engine
  31487. */
  31488. get description(): string;
  31489. /**
  31490. * Gets or sets the epsilon value used by collision engine
  31491. */
  31492. static CollisionsEpsilon: number;
  31493. /**
  31494. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31495. */
  31496. static get ShadersRepository(): string;
  31497. static set ShadersRepository(value: string);
  31498. /** @hidden */
  31499. _shaderProcessor: IShaderProcessor;
  31500. /**
  31501. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31502. */
  31503. forcePOTTextures: boolean;
  31504. /**
  31505. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31506. */
  31507. isFullscreen: boolean;
  31508. /**
  31509. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31510. */
  31511. cullBackFaces: boolean;
  31512. /**
  31513. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31514. */
  31515. renderEvenInBackground: boolean;
  31516. /**
  31517. * Gets or sets a boolean indicating that cache can be kept between frames
  31518. */
  31519. preventCacheWipeBetweenFrames: boolean;
  31520. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31521. validateShaderPrograms: boolean;
  31522. /**
  31523. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31524. * This can provide greater z depth for distant objects.
  31525. */
  31526. useReverseDepthBuffer: boolean;
  31527. /**
  31528. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31529. */
  31530. disableUniformBuffers: boolean;
  31531. /** @hidden */
  31532. _uniformBuffers: UniformBuffer[];
  31533. /**
  31534. * Gets a boolean indicating that the engine supports uniform buffers
  31535. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31536. */
  31537. get supportsUniformBuffers(): boolean;
  31538. /** @hidden */
  31539. _gl: WebGLRenderingContext;
  31540. /** @hidden */
  31541. _webGLVersion: number;
  31542. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31543. protected _windowIsBackground: boolean;
  31544. protected _creationOptions: EngineOptions;
  31545. protected _highPrecisionShadersAllowed: boolean;
  31546. /** @hidden */
  31547. get _shouldUseHighPrecisionShader(): boolean;
  31548. /**
  31549. * Gets a boolean indicating that only power of 2 textures are supported
  31550. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31551. */
  31552. get needPOTTextures(): boolean;
  31553. /** @hidden */
  31554. _badOS: boolean;
  31555. /** @hidden */
  31556. _badDesktopOS: boolean;
  31557. private _hardwareScalingLevel;
  31558. /** @hidden */
  31559. _caps: EngineCapabilities;
  31560. private _isStencilEnable;
  31561. private _glVersion;
  31562. private _glRenderer;
  31563. private _glVendor;
  31564. /** @hidden */
  31565. _videoTextureSupported: boolean;
  31566. protected _renderingQueueLaunched: boolean;
  31567. protected _activeRenderLoops: (() => void)[];
  31568. /**
  31569. * Observable signaled when a context lost event is raised
  31570. */
  31571. onContextLostObservable: Observable<ThinEngine>;
  31572. /**
  31573. * Observable signaled when a context restored event is raised
  31574. */
  31575. onContextRestoredObservable: Observable<ThinEngine>;
  31576. private _onContextLost;
  31577. private _onContextRestored;
  31578. protected _contextWasLost: boolean;
  31579. /** @hidden */
  31580. _doNotHandleContextLost: boolean;
  31581. /**
  31582. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31584. */
  31585. get doNotHandleContextLost(): boolean;
  31586. set doNotHandleContextLost(value: boolean);
  31587. /**
  31588. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31589. */
  31590. disableVertexArrayObjects: boolean;
  31591. /** @hidden */
  31592. protected _colorWrite: boolean;
  31593. /** @hidden */
  31594. protected _colorWriteChanged: boolean;
  31595. /** @hidden */
  31596. protected _depthCullingState: DepthCullingState;
  31597. /** @hidden */
  31598. protected _stencilState: StencilState;
  31599. /** @hidden */
  31600. _alphaState: AlphaState;
  31601. /** @hidden */
  31602. _alphaMode: number;
  31603. /** @hidden */
  31604. _alphaEquation: number;
  31605. /** @hidden */
  31606. _internalTexturesCache: InternalTexture[];
  31607. /** @hidden */
  31608. protected _activeChannel: number;
  31609. private _currentTextureChannel;
  31610. /** @hidden */
  31611. protected _boundTexturesCache: {
  31612. [key: string]: Nullable<InternalTexture>;
  31613. };
  31614. /** @hidden */
  31615. protected _currentEffect: Nullable<Effect>;
  31616. /** @hidden */
  31617. protected _currentProgram: Nullable<WebGLProgram>;
  31618. private _compiledEffects;
  31619. private _vertexAttribArraysEnabled;
  31620. /** @hidden */
  31621. protected _cachedViewport: Nullable<IViewportLike>;
  31622. private _cachedVertexArrayObject;
  31623. /** @hidden */
  31624. protected _cachedVertexBuffers: any;
  31625. /** @hidden */
  31626. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31627. /** @hidden */
  31628. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31629. /** @hidden */
  31630. _currentRenderTarget: Nullable<InternalTexture>;
  31631. private _uintIndicesCurrentlySet;
  31632. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31633. /** @hidden */
  31634. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31635. private _currentBufferPointers;
  31636. private _currentInstanceLocations;
  31637. private _currentInstanceBuffers;
  31638. private _textureUnits;
  31639. /** @hidden */
  31640. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31641. /** @hidden */
  31642. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31643. /** @hidden */
  31644. _boundRenderFunction: any;
  31645. private _vaoRecordInProgress;
  31646. private _mustWipeVertexAttributes;
  31647. private _emptyTexture;
  31648. private _emptyCubeTexture;
  31649. private _emptyTexture3D;
  31650. private _emptyTexture2DArray;
  31651. /** @hidden */
  31652. _frameHandler: number;
  31653. private _nextFreeTextureSlots;
  31654. private _maxSimultaneousTextures;
  31655. private _activeRequests;
  31656. /** @hidden */
  31657. _transformTextureUrl: Nullable<(url: string) => string>;
  31658. protected get _supportsHardwareTextureRescaling(): boolean;
  31659. private _framebufferDimensionsObject;
  31660. /**
  31661. * sets the object from which width and height will be taken from when getting render width and height
  31662. * Will fallback to the gl object
  31663. * @param dimensions the framebuffer width and height that will be used.
  31664. */
  31665. set framebufferDimensionsObject(dimensions: Nullable<{
  31666. framebufferWidth: number;
  31667. framebufferHeight: number;
  31668. }>);
  31669. /**
  31670. * Gets the current viewport
  31671. */
  31672. get currentViewport(): Nullable<IViewportLike>;
  31673. /**
  31674. * Gets the default empty texture
  31675. */
  31676. get emptyTexture(): InternalTexture;
  31677. /**
  31678. * Gets the default empty 3D texture
  31679. */
  31680. get emptyTexture3D(): InternalTexture;
  31681. /**
  31682. * Gets the default empty 2D array texture
  31683. */
  31684. get emptyTexture2DArray(): InternalTexture;
  31685. /**
  31686. * Gets the default empty cube texture
  31687. */
  31688. get emptyCubeTexture(): InternalTexture;
  31689. /**
  31690. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31691. */
  31692. readonly premultipliedAlpha: boolean;
  31693. /**
  31694. * Observable event triggered before each texture is initialized
  31695. */
  31696. onBeforeTextureInitObservable: Observable<Texture>;
  31697. /**
  31698. * Creates a new engine
  31699. * @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
  31700. * @param antialias defines enable antialiasing (default: false)
  31701. * @param options defines further options to be sent to the getContext() function
  31702. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31703. */
  31704. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31705. private _rebuildInternalTextures;
  31706. private _rebuildEffects;
  31707. /**
  31708. * Gets a boolean indicating if all created effects are ready
  31709. * @returns true if all effects are ready
  31710. */
  31711. areAllEffectsReady(): boolean;
  31712. protected _rebuildBuffers(): void;
  31713. protected _initGLContext(): void;
  31714. /**
  31715. * Gets version of the current webGL context
  31716. */
  31717. get webGLVersion(): number;
  31718. /**
  31719. * Gets a string idenfifying the name of the class
  31720. * @returns "Engine" string
  31721. */
  31722. getClassName(): string;
  31723. /**
  31724. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31725. */
  31726. get isStencilEnable(): boolean;
  31727. /** @hidden */
  31728. _prepareWorkingCanvas(): void;
  31729. /**
  31730. * Reset the texture cache to empty state
  31731. */
  31732. resetTextureCache(): void;
  31733. /**
  31734. * Gets an object containing information about the current webGL context
  31735. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31736. */
  31737. getGlInfo(): {
  31738. vendor: string;
  31739. renderer: string;
  31740. version: string;
  31741. };
  31742. /**
  31743. * Defines the hardware scaling level.
  31744. * By default the hardware scaling level is computed from the window device ratio.
  31745. * 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.
  31746. * @param level defines the level to use
  31747. */
  31748. setHardwareScalingLevel(level: number): void;
  31749. /**
  31750. * Gets the current hardware scaling level.
  31751. * By default the hardware scaling level is computed from the window device ratio.
  31752. * 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.
  31753. * @returns a number indicating the current hardware scaling level
  31754. */
  31755. getHardwareScalingLevel(): number;
  31756. /**
  31757. * Gets the list of loaded textures
  31758. * @returns an array containing all loaded textures
  31759. */
  31760. getLoadedTexturesCache(): InternalTexture[];
  31761. /**
  31762. * Gets the object containing all engine capabilities
  31763. * @returns the EngineCapabilities object
  31764. */
  31765. getCaps(): EngineCapabilities;
  31766. /**
  31767. * stop executing a render loop function and remove it from the execution array
  31768. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31769. */
  31770. stopRenderLoop(renderFunction?: () => void): void;
  31771. /** @hidden */
  31772. _renderLoop(): void;
  31773. /**
  31774. * Gets the HTML canvas attached with the current webGL context
  31775. * @returns a HTML canvas
  31776. */
  31777. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31778. /**
  31779. * Gets host window
  31780. * @returns the host window object
  31781. */
  31782. getHostWindow(): Nullable<Window>;
  31783. /**
  31784. * Gets the current render width
  31785. * @param useScreen defines if screen size must be used (or the current render target if any)
  31786. * @returns a number defining the current render width
  31787. */
  31788. getRenderWidth(useScreen?: boolean): number;
  31789. /**
  31790. * Gets the current render height
  31791. * @param useScreen defines if screen size must be used (or the current render target if any)
  31792. * @returns a number defining the current render height
  31793. */
  31794. getRenderHeight(useScreen?: boolean): number;
  31795. /**
  31796. * Can be used to override the current requestAnimationFrame requester.
  31797. * @hidden
  31798. */
  31799. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31800. /**
  31801. * Register and execute a render loop. The engine can have more than one render function
  31802. * @param renderFunction defines the function to continuously execute
  31803. */
  31804. runRenderLoop(renderFunction: () => void): void;
  31805. /**
  31806. * Clear the current render buffer or the current render target (if any is set up)
  31807. * @param color defines the color to use
  31808. * @param backBuffer defines if the back buffer must be cleared
  31809. * @param depth defines if the depth buffer must be cleared
  31810. * @param stencil defines if the stencil buffer must be cleared
  31811. */
  31812. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31813. private _viewportCached;
  31814. /** @hidden */
  31815. _viewport(x: number, y: number, width: number, height: number): void;
  31816. /**
  31817. * Set the WebGL's viewport
  31818. * @param viewport defines the viewport element to be used
  31819. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31820. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31821. */
  31822. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31823. /**
  31824. * Begin a new frame
  31825. */
  31826. beginFrame(): void;
  31827. /**
  31828. * Enf the current frame
  31829. */
  31830. endFrame(): void;
  31831. /**
  31832. * Resize the view according to the canvas' size
  31833. */
  31834. resize(): void;
  31835. /**
  31836. * Force a specific size of the canvas
  31837. * @param width defines the new canvas' width
  31838. * @param height defines the new canvas' height
  31839. */
  31840. setSize(width: number, height: number): void;
  31841. /**
  31842. * Binds the frame buffer to the specified texture.
  31843. * @param texture The texture to render to or null for the default canvas
  31844. * @param faceIndex The face of the texture to render to in case of cube texture
  31845. * @param requiredWidth The width of the target to render to
  31846. * @param requiredHeight The height of the target to render to
  31847. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31848. * @param lodLevel defines the lod level to bind to the frame buffer
  31849. * @param layer defines the 2d array index to bind to frame buffer to
  31850. */
  31851. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31852. /** @hidden */
  31853. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31854. /**
  31855. * Unbind the current render target texture from the webGL context
  31856. * @param texture defines the render target texture to unbind
  31857. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31858. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31859. */
  31860. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31861. /**
  31862. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31863. */
  31864. flushFramebuffer(): void;
  31865. /**
  31866. * Unbind the current render target and bind the default framebuffer
  31867. */
  31868. restoreDefaultFramebuffer(): void;
  31869. /** @hidden */
  31870. protected _resetVertexBufferBinding(): void;
  31871. /**
  31872. * Creates a vertex buffer
  31873. * @param data the data for the vertex buffer
  31874. * @returns the new WebGL static buffer
  31875. */
  31876. createVertexBuffer(data: DataArray): DataBuffer;
  31877. private _createVertexBuffer;
  31878. /**
  31879. * Creates a dynamic vertex buffer
  31880. * @param data the data for the dynamic vertex buffer
  31881. * @returns the new WebGL dynamic buffer
  31882. */
  31883. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31884. protected _resetIndexBufferBinding(): void;
  31885. /**
  31886. * Creates a new index buffer
  31887. * @param indices defines the content of the index buffer
  31888. * @param updatable defines if the index buffer must be updatable
  31889. * @returns a new webGL buffer
  31890. */
  31891. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31892. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31893. /**
  31894. * Bind a webGL buffer to the webGL context
  31895. * @param buffer defines the buffer to bind
  31896. */
  31897. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31898. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31899. private bindBuffer;
  31900. /**
  31901. * update the bound buffer with the given data
  31902. * @param data defines the data to update
  31903. */
  31904. updateArrayBuffer(data: Float32Array): void;
  31905. private _vertexAttribPointer;
  31906. /** @hidden */
  31907. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31908. private _bindVertexBuffersAttributes;
  31909. /**
  31910. * Records a vertex array object
  31911. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31912. * @param vertexBuffers defines the list of vertex buffers to store
  31913. * @param indexBuffer defines the index buffer to store
  31914. * @param effect defines the effect to store
  31915. * @returns the new vertex array object
  31916. */
  31917. recordVertexArrayObject(vertexBuffers: {
  31918. [key: string]: VertexBuffer;
  31919. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31920. /**
  31921. * Bind a specific vertex array object
  31922. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31923. * @param vertexArrayObject defines the vertex array object to bind
  31924. * @param indexBuffer defines the index buffer to bind
  31925. */
  31926. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31927. /**
  31928. * Bind webGl buffers directly to the webGL context
  31929. * @param vertexBuffer defines the vertex buffer to bind
  31930. * @param indexBuffer defines the index buffer to bind
  31931. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31932. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31933. * @param effect defines the effect associated with the vertex buffer
  31934. */
  31935. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31936. private _unbindVertexArrayObject;
  31937. /**
  31938. * Bind a list of vertex buffers to the webGL context
  31939. * @param vertexBuffers defines the list of vertex buffers to bind
  31940. * @param indexBuffer defines the index buffer to bind
  31941. * @param effect defines the effect associated with the vertex buffers
  31942. */
  31943. bindBuffers(vertexBuffers: {
  31944. [key: string]: Nullable<VertexBuffer>;
  31945. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31946. /**
  31947. * Unbind all instance attributes
  31948. */
  31949. unbindInstanceAttributes(): void;
  31950. /**
  31951. * Release and free the memory of a vertex array object
  31952. * @param vao defines the vertex array object to delete
  31953. */
  31954. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31955. /** @hidden */
  31956. _releaseBuffer(buffer: DataBuffer): boolean;
  31957. protected _deleteBuffer(buffer: DataBuffer): void;
  31958. /**
  31959. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31960. * @param instancesBuffer defines the webGL buffer to update and bind
  31961. * @param data defines the data to store in the buffer
  31962. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31963. */
  31964. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31965. /**
  31966. * Bind the content of a webGL buffer used with instantiation
  31967. * @param instancesBuffer defines the webGL buffer to bind
  31968. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31969. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31970. */
  31971. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31972. /**
  31973. * Disable the instance attribute corresponding to the name in parameter
  31974. * @param name defines the name of the attribute to disable
  31975. */
  31976. disableInstanceAttributeByName(name: string): void;
  31977. /**
  31978. * Disable the instance attribute corresponding to the location in parameter
  31979. * @param attributeLocation defines the attribute location of the attribute to disable
  31980. */
  31981. disableInstanceAttribute(attributeLocation: number): void;
  31982. /**
  31983. * Disable the attribute corresponding to the location in parameter
  31984. * @param attributeLocation defines the attribute location of the attribute to disable
  31985. */
  31986. disableAttributeByIndex(attributeLocation: number): void;
  31987. /**
  31988. * Send a draw order
  31989. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31990. * @param indexStart defines the starting index
  31991. * @param indexCount defines the number of index to draw
  31992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31993. */
  31994. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31995. /**
  31996. * Draw a list of points
  31997. * @param verticesStart defines the index of first vertex to draw
  31998. * @param verticesCount defines the count of vertices to draw
  31999. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32000. */
  32001. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32002. /**
  32003. * Draw a list of unindexed primitives
  32004. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32005. * @param verticesStart defines the index of first vertex to draw
  32006. * @param verticesCount defines the count of vertices to draw
  32007. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32008. */
  32009. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32010. /**
  32011. * Draw a list of indexed primitives
  32012. * @param fillMode defines the primitive to use
  32013. * @param indexStart defines the starting index
  32014. * @param indexCount defines the number of index to draw
  32015. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32016. */
  32017. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32018. /**
  32019. * Draw a list of unindexed primitives
  32020. * @param fillMode defines the primitive to use
  32021. * @param verticesStart defines the index of first vertex to draw
  32022. * @param verticesCount defines the count of vertices to draw
  32023. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32024. */
  32025. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32026. private _drawMode;
  32027. /** @hidden */
  32028. protected _reportDrawCall(): void;
  32029. /** @hidden */
  32030. _releaseEffect(effect: Effect): void;
  32031. /** @hidden */
  32032. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32033. /**
  32034. * Create a new effect (used to store vertex/fragment shaders)
  32035. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32036. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32037. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32038. * @param samplers defines an array of string used to represent textures
  32039. * @param defines defines the string containing the defines to use to compile the shaders
  32040. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32041. * @param onCompiled defines a function to call when the effect creation is successful
  32042. * @param onError defines a function to call when the effect creation has failed
  32043. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32044. * @returns the new Effect
  32045. */
  32046. 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;
  32047. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32048. private _compileShader;
  32049. private _compileRawShader;
  32050. /** @hidden */
  32051. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32052. /**
  32053. * Directly creates a webGL program
  32054. * @param pipelineContext defines the pipeline context to attach to
  32055. * @param vertexCode defines the vertex shader code to use
  32056. * @param fragmentCode defines the fragment shader code to use
  32057. * @param context defines the webGL context to use (if not set, the current one will be used)
  32058. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32059. * @returns the new webGL program
  32060. */
  32061. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32062. /**
  32063. * Creates a webGL program
  32064. * @param pipelineContext defines the pipeline context to attach to
  32065. * @param vertexCode defines the vertex shader code to use
  32066. * @param fragmentCode defines the fragment shader code to use
  32067. * @param defines defines the string containing the defines to use to compile the shaders
  32068. * @param context defines the webGL context to use (if not set, the current one will be used)
  32069. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32070. * @returns the new webGL program
  32071. */
  32072. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32073. /**
  32074. * Creates a new pipeline context
  32075. * @returns the new pipeline
  32076. */
  32077. createPipelineContext(): IPipelineContext;
  32078. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32079. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32080. /** @hidden */
  32081. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32082. /** @hidden */
  32083. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32084. /** @hidden */
  32085. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32086. /**
  32087. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32088. * @param pipelineContext defines the pipeline context to use
  32089. * @param uniformsNames defines the list of uniform names
  32090. * @returns an array of webGL uniform locations
  32091. */
  32092. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32093. /**
  32094. * Gets the lsit of active attributes for a given webGL program
  32095. * @param pipelineContext defines the pipeline context to use
  32096. * @param attributesNames defines the list of attribute names to get
  32097. * @returns an array of indices indicating the offset of each attribute
  32098. */
  32099. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32100. /**
  32101. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32102. * @param effect defines the effect to activate
  32103. */
  32104. enableEffect(effect: Nullable<Effect>): void;
  32105. /**
  32106. * Set the value of an uniform to a number (int)
  32107. * @param uniform defines the webGL uniform location where to store the value
  32108. * @param value defines the int number to store
  32109. */
  32110. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32111. /**
  32112. * Set the value of an uniform to an array of int32
  32113. * @param uniform defines the webGL uniform location where to store the value
  32114. * @param array defines the array of int32 to store
  32115. */
  32116. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32117. /**
  32118. * Set the value of an uniform to an array of int32 (stored as vec2)
  32119. * @param uniform defines the webGL uniform location where to store the value
  32120. * @param array defines the array of int32 to store
  32121. */
  32122. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32123. /**
  32124. * Set the value of an uniform to an array of int32 (stored as vec3)
  32125. * @param uniform defines the webGL uniform location where to store the value
  32126. * @param array defines the array of int32 to store
  32127. */
  32128. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32129. /**
  32130. * Set the value of an uniform to an array of int32 (stored as vec4)
  32131. * @param uniform defines the webGL uniform location where to store the value
  32132. * @param array defines the array of int32 to store
  32133. */
  32134. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32135. /**
  32136. * Set the value of an uniform to an array of number
  32137. * @param uniform defines the webGL uniform location where to store the value
  32138. * @param array defines the array of number to store
  32139. */
  32140. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32141. /**
  32142. * Set the value of an uniform to an array of number (stored as vec2)
  32143. * @param uniform defines the webGL uniform location where to store the value
  32144. * @param array defines the array of number to store
  32145. */
  32146. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32147. /**
  32148. * Set the value of an uniform to an array of number (stored as vec3)
  32149. * @param uniform defines the webGL uniform location where to store the value
  32150. * @param array defines the array of number to store
  32151. */
  32152. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32153. /**
  32154. * Set the value of an uniform to an array of number (stored as vec4)
  32155. * @param uniform defines the webGL uniform location where to store the value
  32156. * @param array defines the array of number to store
  32157. */
  32158. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32159. /**
  32160. * Set the value of an uniform to an array of float32 (stored as matrices)
  32161. * @param uniform defines the webGL uniform location where to store the value
  32162. * @param matrices defines the array of float32 to store
  32163. */
  32164. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32165. /**
  32166. * Set the value of an uniform to a matrix (3x3)
  32167. * @param uniform defines the webGL uniform location where to store the value
  32168. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32169. */
  32170. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32171. /**
  32172. * Set the value of an uniform to a matrix (2x2)
  32173. * @param uniform defines the webGL uniform location where to store the value
  32174. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32175. */
  32176. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32177. /**
  32178. * Set the value of an uniform to a number (float)
  32179. * @param uniform defines the webGL uniform location where to store the value
  32180. * @param value defines the float number to store
  32181. */
  32182. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32183. /**
  32184. * Set the value of an uniform to a vec2
  32185. * @param uniform defines the webGL uniform location where to store the value
  32186. * @param x defines the 1st component of the value
  32187. * @param y defines the 2nd component of the value
  32188. */
  32189. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32190. /**
  32191. * Set the value of an uniform to a vec3
  32192. * @param uniform defines the webGL uniform location where to store the value
  32193. * @param x defines the 1st component of the value
  32194. * @param y defines the 2nd component of the value
  32195. * @param z defines the 3rd component of the value
  32196. */
  32197. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32198. /**
  32199. * Set the value of an uniform to a vec4
  32200. * @param uniform defines the webGL uniform location where to store the value
  32201. * @param x defines the 1st component of the value
  32202. * @param y defines the 2nd component of the value
  32203. * @param z defines the 3rd component of the value
  32204. * @param w defines the 4th component of the value
  32205. */
  32206. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32207. /**
  32208. * Apply all cached states (depth, culling, stencil and alpha)
  32209. */
  32210. applyStates(): void;
  32211. /**
  32212. * Enable or disable color writing
  32213. * @param enable defines the state to set
  32214. */
  32215. setColorWrite(enable: boolean): void;
  32216. /**
  32217. * Gets a boolean indicating if color writing is enabled
  32218. * @returns the current color writing state
  32219. */
  32220. getColorWrite(): boolean;
  32221. /**
  32222. * Gets the depth culling state manager
  32223. */
  32224. get depthCullingState(): DepthCullingState;
  32225. /**
  32226. * Gets the alpha state manager
  32227. */
  32228. get alphaState(): AlphaState;
  32229. /**
  32230. * Gets the stencil state manager
  32231. */
  32232. get stencilState(): StencilState;
  32233. /**
  32234. * Clears the list of texture accessible through engine.
  32235. * This can help preventing texture load conflict due to name collision.
  32236. */
  32237. clearInternalTexturesCache(): void;
  32238. /**
  32239. * Force the entire cache to be cleared
  32240. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32241. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32242. */
  32243. wipeCaches(bruteForce?: boolean): void;
  32244. /** @hidden */
  32245. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32246. min: number;
  32247. mag: number;
  32248. };
  32249. /** @hidden */
  32250. _createTexture(): WebGLTexture;
  32251. /**
  32252. * Usually called from Texture.ts.
  32253. * Passed information to create a WebGLTexture
  32254. * @param url defines a value which contains one of the following:
  32255. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32256. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32257. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32258. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32259. * @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)
  32260. * @param scene needed for loading to the correct scene
  32261. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32262. * @param onLoad optional callback to be called upon successful completion
  32263. * @param onError optional callback to be called upon failure
  32264. * @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
  32265. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32266. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32267. * @param forcedExtension defines the extension to use to pick the right loader
  32268. * @param mimeType defines an optional mime type
  32269. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32270. */
  32271. 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;
  32272. /**
  32273. * Loads an image as an HTMLImageElement.
  32274. * @param input url string, ArrayBuffer, or Blob to load
  32275. * @param onLoad callback called when the image successfully loads
  32276. * @param onError callback called when the image fails to load
  32277. * @param offlineProvider offline provider for caching
  32278. * @param mimeType optional mime type
  32279. * @returns the HTMLImageElement of the loaded image
  32280. * @hidden
  32281. */
  32282. 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>;
  32283. /**
  32284. * @hidden
  32285. */
  32286. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32287. private _unpackFlipYCached;
  32288. /**
  32289. * In case you are sharing the context with other applications, it might
  32290. * be interested to not cache the unpack flip y state to ensure a consistent
  32291. * value would be set.
  32292. */
  32293. enableUnpackFlipYCached: boolean;
  32294. /** @hidden */
  32295. _unpackFlipY(value: boolean): void;
  32296. /** @hidden */
  32297. _getUnpackAlignement(): number;
  32298. private _getTextureTarget;
  32299. /**
  32300. * Update the sampling mode of a given texture
  32301. * @param samplingMode defines the required sampling mode
  32302. * @param texture defines the texture to update
  32303. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32304. */
  32305. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32306. /**
  32307. * Update the sampling mode of a given texture
  32308. * @param texture defines the texture to update
  32309. * @param wrapU defines the texture wrap mode of the u coordinates
  32310. * @param wrapV defines the texture wrap mode of the v coordinates
  32311. * @param wrapR defines the texture wrap mode of the r coordinates
  32312. */
  32313. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32314. /** @hidden */
  32315. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32316. width: number;
  32317. height: number;
  32318. layers?: number;
  32319. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32320. /** @hidden */
  32321. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32322. /** @hidden */
  32323. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32324. /**
  32325. * Update a portion of an internal texture
  32326. * @param texture defines the texture to update
  32327. * @param imageData defines the data to store into the texture
  32328. * @param xOffset defines the x coordinates of the update rectangle
  32329. * @param yOffset defines the y coordinates of the update rectangle
  32330. * @param width defines the width of the update rectangle
  32331. * @param height defines the height of the update rectangle
  32332. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32333. * @param lod defines the lod level to update (0 by default)
  32334. */
  32335. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32336. /** @hidden */
  32337. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32338. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32339. private _prepareWebGLTexture;
  32340. /** @hidden */
  32341. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32342. private _getDepthStencilBuffer;
  32343. /** @hidden */
  32344. _releaseFramebufferObjects(texture: InternalTexture): void;
  32345. /** @hidden */
  32346. _releaseTexture(texture: InternalTexture): void;
  32347. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32348. protected _setProgram(program: WebGLProgram): void;
  32349. protected _boundUniforms: {
  32350. [key: number]: WebGLUniformLocation;
  32351. };
  32352. /**
  32353. * Binds an effect to the webGL context
  32354. * @param effect defines the effect to bind
  32355. */
  32356. bindSamplers(effect: Effect): void;
  32357. private _activateCurrentTexture;
  32358. /** @hidden */
  32359. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32360. /** @hidden */
  32361. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32362. /**
  32363. * Unbind all textures from the webGL context
  32364. */
  32365. unbindAllTextures(): void;
  32366. /**
  32367. * Sets a texture to the according uniform.
  32368. * @param channel The texture channel
  32369. * @param uniform The uniform to set
  32370. * @param texture The texture to apply
  32371. */
  32372. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32373. private _bindSamplerUniformToChannel;
  32374. private _getTextureWrapMode;
  32375. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32376. /**
  32377. * Sets an array of texture to the webGL context
  32378. * @param channel defines the channel where the texture array must be set
  32379. * @param uniform defines the associated uniform location
  32380. * @param textures defines the array of textures to bind
  32381. */
  32382. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32383. /** @hidden */
  32384. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32385. private _setTextureParameterFloat;
  32386. private _setTextureParameterInteger;
  32387. /**
  32388. * Unbind all vertex attributes from the webGL context
  32389. */
  32390. unbindAllAttributes(): void;
  32391. /**
  32392. * 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
  32393. */
  32394. releaseEffects(): void;
  32395. /**
  32396. * Dispose and release all associated resources
  32397. */
  32398. dispose(): void;
  32399. /**
  32400. * Attach a new callback raised when context lost event is fired
  32401. * @param callback defines the callback to call
  32402. */
  32403. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32404. /**
  32405. * Attach a new callback raised when context restored event is fired
  32406. * @param callback defines the callback to call
  32407. */
  32408. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32409. /**
  32410. * Get the current error code of the webGL context
  32411. * @returns the error code
  32412. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32413. */
  32414. getError(): number;
  32415. private _canRenderToFloatFramebuffer;
  32416. private _canRenderToHalfFloatFramebuffer;
  32417. private _canRenderToFramebuffer;
  32418. /** @hidden */
  32419. _getWebGLTextureType(type: number): number;
  32420. /** @hidden */
  32421. _getInternalFormat(format: number): number;
  32422. /** @hidden */
  32423. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32424. /** @hidden */
  32425. _getRGBAMultiSampleBufferFormat(type: number): number;
  32426. /** @hidden */
  32427. _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;
  32428. /**
  32429. * Loads a file from a url
  32430. * @param url url to load
  32431. * @param onSuccess callback called when the file successfully loads
  32432. * @param onProgress callback called while file is loading (if the server supports this mode)
  32433. * @param offlineProvider defines the offline provider for caching
  32434. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32435. * @param onError callback called when the file fails to load
  32436. * @returns a file request object
  32437. * @hidden
  32438. */
  32439. 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;
  32440. /**
  32441. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32442. * @param x defines the x coordinate of the rectangle where pixels must be read
  32443. * @param y defines the y coordinate of the rectangle where pixels must be read
  32444. * @param width defines the width of the rectangle where pixels must be read
  32445. * @param height defines the height of the rectangle where pixels must be read
  32446. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32447. * @returns a Uint8Array containing RGBA colors
  32448. */
  32449. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32450. private static _isSupported;
  32451. /**
  32452. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32453. * @returns true if the engine can be created
  32454. * @ignorenaming
  32455. */
  32456. static isSupported(): boolean;
  32457. /**
  32458. * Find the next highest power of two.
  32459. * @param x Number to start search from.
  32460. * @return Next highest power of two.
  32461. */
  32462. static CeilingPOT(x: number): number;
  32463. /**
  32464. * Find the next lowest power of two.
  32465. * @param x Number to start search from.
  32466. * @return Next lowest power of two.
  32467. */
  32468. static FloorPOT(x: number): number;
  32469. /**
  32470. * Find the nearest power of two.
  32471. * @param x Number to start search from.
  32472. * @return Next nearest power of two.
  32473. */
  32474. static NearestPOT(x: number): number;
  32475. /**
  32476. * Get the closest exponent of two
  32477. * @param value defines the value to approximate
  32478. * @param max defines the maximum value to return
  32479. * @param mode defines how to define the closest value
  32480. * @returns closest exponent of two of the given value
  32481. */
  32482. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32483. /**
  32484. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32485. * @param func - the function to be called
  32486. * @param requester - the object that will request the next frame. Falls back to window.
  32487. * @returns frame number
  32488. */
  32489. static QueueNewFrame(func: () => void, requester?: any): number;
  32490. /**
  32491. * Gets host document
  32492. * @returns the host document object
  32493. */
  32494. getHostDocument(): Nullable<Document>;
  32495. }
  32496. }
  32497. declare module BABYLON {
  32498. /**
  32499. * Class representing spherical harmonics coefficients to the 3rd degree
  32500. */
  32501. export class SphericalHarmonics {
  32502. /**
  32503. * Defines whether or not the harmonics have been prescaled for rendering.
  32504. */
  32505. preScaled: boolean;
  32506. /**
  32507. * The l0,0 coefficients of the spherical harmonics
  32508. */
  32509. l00: Vector3;
  32510. /**
  32511. * The l1,-1 coefficients of the spherical harmonics
  32512. */
  32513. l1_1: Vector3;
  32514. /**
  32515. * The l1,0 coefficients of the spherical harmonics
  32516. */
  32517. l10: Vector3;
  32518. /**
  32519. * The l1,1 coefficients of the spherical harmonics
  32520. */
  32521. l11: Vector3;
  32522. /**
  32523. * The l2,-2 coefficients of the spherical harmonics
  32524. */
  32525. l2_2: Vector3;
  32526. /**
  32527. * The l2,-1 coefficients of the spherical harmonics
  32528. */
  32529. l2_1: Vector3;
  32530. /**
  32531. * The l2,0 coefficients of the spherical harmonics
  32532. */
  32533. l20: Vector3;
  32534. /**
  32535. * The l2,1 coefficients of the spherical harmonics
  32536. */
  32537. l21: Vector3;
  32538. /**
  32539. * The l2,2 coefficients of the spherical harmonics
  32540. */
  32541. l22: Vector3;
  32542. /**
  32543. * Adds a light to the spherical harmonics
  32544. * @param direction the direction of the light
  32545. * @param color the color of the light
  32546. * @param deltaSolidAngle the delta solid angle of the light
  32547. */
  32548. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32549. /**
  32550. * Scales the spherical harmonics by the given amount
  32551. * @param scale the amount to scale
  32552. */
  32553. scaleInPlace(scale: number): void;
  32554. /**
  32555. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32556. *
  32557. * ```
  32558. * E_lm = A_l * L_lm
  32559. * ```
  32560. *
  32561. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32562. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32563. * the scaling factors are given in equation 9.
  32564. */
  32565. convertIncidentRadianceToIrradiance(): void;
  32566. /**
  32567. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32568. *
  32569. * ```
  32570. * L = (1/pi) * E * rho
  32571. * ```
  32572. *
  32573. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32574. */
  32575. convertIrradianceToLambertianRadiance(): void;
  32576. /**
  32577. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32578. * required operations at run time.
  32579. *
  32580. * This is simply done by scaling back the SH with Ylm constants parameter.
  32581. * The trigonometric part being applied by the shader at run time.
  32582. */
  32583. preScaleForRendering(): void;
  32584. /**
  32585. * Constructs a spherical harmonics from an array.
  32586. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32587. * @returns the spherical harmonics
  32588. */
  32589. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32590. /**
  32591. * Gets the spherical harmonics from polynomial
  32592. * @param polynomial the spherical polynomial
  32593. * @returns the spherical harmonics
  32594. */
  32595. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32596. }
  32597. /**
  32598. * Class representing spherical polynomial coefficients to the 3rd degree
  32599. */
  32600. export class SphericalPolynomial {
  32601. private _harmonics;
  32602. /**
  32603. * The spherical harmonics used to create the polynomials.
  32604. */
  32605. get preScaledHarmonics(): SphericalHarmonics;
  32606. /**
  32607. * The x coefficients of the spherical polynomial
  32608. */
  32609. x: Vector3;
  32610. /**
  32611. * The y coefficients of the spherical polynomial
  32612. */
  32613. y: Vector3;
  32614. /**
  32615. * The z coefficients of the spherical polynomial
  32616. */
  32617. z: Vector3;
  32618. /**
  32619. * The xx coefficients of the spherical polynomial
  32620. */
  32621. xx: Vector3;
  32622. /**
  32623. * The yy coefficients of the spherical polynomial
  32624. */
  32625. yy: Vector3;
  32626. /**
  32627. * The zz coefficients of the spherical polynomial
  32628. */
  32629. zz: Vector3;
  32630. /**
  32631. * The xy coefficients of the spherical polynomial
  32632. */
  32633. xy: Vector3;
  32634. /**
  32635. * The yz coefficients of the spherical polynomial
  32636. */
  32637. yz: Vector3;
  32638. /**
  32639. * The zx coefficients of the spherical polynomial
  32640. */
  32641. zx: Vector3;
  32642. /**
  32643. * Adds an ambient color to the spherical polynomial
  32644. * @param color the color to add
  32645. */
  32646. addAmbient(color: Color3): void;
  32647. /**
  32648. * Scales the spherical polynomial by the given amount
  32649. * @param scale the amount to scale
  32650. */
  32651. scaleInPlace(scale: number): void;
  32652. /**
  32653. * Gets the spherical polynomial from harmonics
  32654. * @param harmonics the spherical harmonics
  32655. * @returns the spherical polynomial
  32656. */
  32657. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32658. /**
  32659. * Constructs a spherical polynomial from an array.
  32660. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32661. * @returns the spherical polynomial
  32662. */
  32663. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32664. }
  32665. }
  32666. declare module BABYLON {
  32667. /**
  32668. * Defines the source of the internal texture
  32669. */
  32670. export enum InternalTextureSource {
  32671. /**
  32672. * The source of the texture data is unknown
  32673. */
  32674. Unknown = 0,
  32675. /**
  32676. * Texture data comes from an URL
  32677. */
  32678. Url = 1,
  32679. /**
  32680. * Texture data is only used for temporary storage
  32681. */
  32682. Temp = 2,
  32683. /**
  32684. * Texture data comes from raw data (ArrayBuffer)
  32685. */
  32686. Raw = 3,
  32687. /**
  32688. * Texture content is dynamic (video or dynamic texture)
  32689. */
  32690. Dynamic = 4,
  32691. /**
  32692. * Texture content is generated by rendering to it
  32693. */
  32694. RenderTarget = 5,
  32695. /**
  32696. * Texture content is part of a multi render target process
  32697. */
  32698. MultiRenderTarget = 6,
  32699. /**
  32700. * Texture data comes from a cube data file
  32701. */
  32702. Cube = 7,
  32703. /**
  32704. * Texture data comes from a raw cube data
  32705. */
  32706. CubeRaw = 8,
  32707. /**
  32708. * Texture data come from a prefiltered cube data file
  32709. */
  32710. CubePrefiltered = 9,
  32711. /**
  32712. * Texture content is raw 3D data
  32713. */
  32714. Raw3D = 10,
  32715. /**
  32716. * Texture content is raw 2D array data
  32717. */
  32718. Raw2DArray = 11,
  32719. /**
  32720. * Texture content is a depth texture
  32721. */
  32722. Depth = 12,
  32723. /**
  32724. * Texture data comes from a raw cube data encoded with RGBD
  32725. */
  32726. CubeRawRGBD = 13
  32727. }
  32728. /**
  32729. * Class used to store data associated with WebGL texture data for the engine
  32730. * This class should not be used directly
  32731. */
  32732. export class InternalTexture {
  32733. /** @hidden */
  32734. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32735. /**
  32736. * Defines if the texture is ready
  32737. */
  32738. isReady: boolean;
  32739. /**
  32740. * Defines if the texture is a cube texture
  32741. */
  32742. isCube: boolean;
  32743. /**
  32744. * Defines if the texture contains 3D data
  32745. */
  32746. is3D: boolean;
  32747. /**
  32748. * Defines if the texture contains 2D array data
  32749. */
  32750. is2DArray: boolean;
  32751. /**
  32752. * Defines if the texture contains multiview data
  32753. */
  32754. isMultiview: boolean;
  32755. /**
  32756. * Gets the URL used to load this texture
  32757. */
  32758. url: string;
  32759. /**
  32760. * Gets the sampling mode of the texture
  32761. */
  32762. samplingMode: number;
  32763. /**
  32764. * Gets a boolean indicating if the texture needs mipmaps generation
  32765. */
  32766. generateMipMaps: boolean;
  32767. /**
  32768. * Gets the number of samples used by the texture (WebGL2+ only)
  32769. */
  32770. samples: number;
  32771. /**
  32772. * Gets the type of the texture (int, float...)
  32773. */
  32774. type: number;
  32775. /**
  32776. * Gets the format of the texture (RGB, RGBA...)
  32777. */
  32778. format: number;
  32779. /**
  32780. * Observable called when the texture is loaded
  32781. */
  32782. onLoadedObservable: Observable<InternalTexture>;
  32783. /**
  32784. * Gets the width of the texture
  32785. */
  32786. width: number;
  32787. /**
  32788. * Gets the height of the texture
  32789. */
  32790. height: number;
  32791. /**
  32792. * Gets the depth of the texture
  32793. */
  32794. depth: number;
  32795. /**
  32796. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32797. */
  32798. baseWidth: number;
  32799. /**
  32800. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32801. */
  32802. baseHeight: number;
  32803. /**
  32804. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32805. */
  32806. baseDepth: number;
  32807. /**
  32808. * Gets a boolean indicating if the texture is inverted on Y axis
  32809. */
  32810. invertY: boolean;
  32811. /** @hidden */
  32812. _invertVScale: boolean;
  32813. /** @hidden */
  32814. _associatedChannel: number;
  32815. /** @hidden */
  32816. _source: InternalTextureSource;
  32817. /** @hidden */
  32818. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32819. /** @hidden */
  32820. _bufferView: Nullable<ArrayBufferView>;
  32821. /** @hidden */
  32822. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32823. /** @hidden */
  32824. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32825. /** @hidden */
  32826. _size: number;
  32827. /** @hidden */
  32828. _extension: string;
  32829. /** @hidden */
  32830. _files: Nullable<string[]>;
  32831. /** @hidden */
  32832. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32833. /** @hidden */
  32834. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32835. /** @hidden */
  32836. _framebuffer: Nullable<WebGLFramebuffer>;
  32837. /** @hidden */
  32838. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32839. /** @hidden */
  32840. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32841. /** @hidden */
  32842. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32843. /** @hidden */
  32844. _attachments: Nullable<number[]>;
  32845. /** @hidden */
  32846. _cachedCoordinatesMode: Nullable<number>;
  32847. /** @hidden */
  32848. _cachedWrapU: Nullable<number>;
  32849. /** @hidden */
  32850. _cachedWrapV: Nullable<number>;
  32851. /** @hidden */
  32852. _cachedWrapR: Nullable<number>;
  32853. /** @hidden */
  32854. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32855. /** @hidden */
  32856. _isDisabled: boolean;
  32857. /** @hidden */
  32858. _compression: Nullable<string>;
  32859. /** @hidden */
  32860. _generateStencilBuffer: boolean;
  32861. /** @hidden */
  32862. _generateDepthBuffer: boolean;
  32863. /** @hidden */
  32864. _comparisonFunction: number;
  32865. /** @hidden */
  32866. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32867. /** @hidden */
  32868. _lodGenerationScale: number;
  32869. /** @hidden */
  32870. _lodGenerationOffset: number;
  32871. /** @hidden */
  32872. _depthStencilTexture: Nullable<InternalTexture>;
  32873. /** @hidden */
  32874. _colorTextureArray: Nullable<WebGLTexture>;
  32875. /** @hidden */
  32876. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32877. /** @hidden */
  32878. _lodTextureHigh: Nullable<BaseTexture>;
  32879. /** @hidden */
  32880. _lodTextureMid: Nullable<BaseTexture>;
  32881. /** @hidden */
  32882. _lodTextureLow: Nullable<BaseTexture>;
  32883. /** @hidden */
  32884. _isRGBD: boolean;
  32885. /** @hidden */
  32886. _linearSpecularLOD: boolean;
  32887. /** @hidden */
  32888. _irradianceTexture: Nullable<BaseTexture>;
  32889. /** @hidden */
  32890. _webGLTexture: Nullable<WebGLTexture>;
  32891. /** @hidden */
  32892. _references: number;
  32893. private _engine;
  32894. /**
  32895. * Gets the Engine the texture belongs to.
  32896. * @returns The babylon engine
  32897. */
  32898. getEngine(): ThinEngine;
  32899. /**
  32900. * Gets the data source type of the texture
  32901. */
  32902. get source(): InternalTextureSource;
  32903. /**
  32904. * Creates a new InternalTexture
  32905. * @param engine defines the engine to use
  32906. * @param source defines the type of data that will be used
  32907. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32908. */
  32909. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32910. /**
  32911. * Increments the number of references (ie. the number of Texture that point to it)
  32912. */
  32913. incrementReferences(): void;
  32914. /**
  32915. * Change the size of the texture (not the size of the content)
  32916. * @param width defines the new width
  32917. * @param height defines the new height
  32918. * @param depth defines the new depth (1 by default)
  32919. */
  32920. updateSize(width: int, height: int, depth?: int): void;
  32921. /** @hidden */
  32922. _rebuild(): void;
  32923. /** @hidden */
  32924. _swapAndDie(target: InternalTexture): void;
  32925. /**
  32926. * Dispose the current allocated resources
  32927. */
  32928. dispose(): void;
  32929. }
  32930. }
  32931. declare module BABYLON {
  32932. /**
  32933. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32935. */
  32936. export class Analyser {
  32937. /**
  32938. * Gets or sets the smoothing
  32939. * @ignorenaming
  32940. */
  32941. SMOOTHING: number;
  32942. /**
  32943. * Gets or sets the FFT table size
  32944. * @ignorenaming
  32945. */
  32946. FFT_SIZE: number;
  32947. /**
  32948. * Gets or sets the bar graph amplitude
  32949. * @ignorenaming
  32950. */
  32951. BARGRAPHAMPLITUDE: number;
  32952. /**
  32953. * Gets or sets the position of the debug canvas
  32954. * @ignorenaming
  32955. */
  32956. DEBUGCANVASPOS: {
  32957. x: number;
  32958. y: number;
  32959. };
  32960. /**
  32961. * Gets or sets the debug canvas size
  32962. * @ignorenaming
  32963. */
  32964. DEBUGCANVASSIZE: {
  32965. width: number;
  32966. height: number;
  32967. };
  32968. private _byteFreqs;
  32969. private _byteTime;
  32970. private _floatFreqs;
  32971. private _webAudioAnalyser;
  32972. private _debugCanvas;
  32973. private _debugCanvasContext;
  32974. private _scene;
  32975. private _registerFunc;
  32976. private _audioEngine;
  32977. /**
  32978. * Creates a new analyser
  32979. * @param scene defines hosting scene
  32980. */
  32981. constructor(scene: Scene);
  32982. /**
  32983. * Get the number of data values you will have to play with for the visualization
  32984. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32985. * @returns a number
  32986. */
  32987. getFrequencyBinCount(): number;
  32988. /**
  32989. * Gets the current frequency data as a byte array
  32990. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32991. * @returns a Uint8Array
  32992. */
  32993. getByteFrequencyData(): Uint8Array;
  32994. /**
  32995. * Gets the current waveform as a byte array
  32996. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32997. * @returns a Uint8Array
  32998. */
  32999. getByteTimeDomainData(): Uint8Array;
  33000. /**
  33001. * Gets the current frequency data as a float array
  33002. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33003. * @returns a Float32Array
  33004. */
  33005. getFloatFrequencyData(): Float32Array;
  33006. /**
  33007. * Renders the debug canvas
  33008. */
  33009. drawDebugCanvas(): void;
  33010. /**
  33011. * Stops rendering the debug canvas and removes it
  33012. */
  33013. stopDebugCanvas(): void;
  33014. /**
  33015. * Connects two audio nodes
  33016. * @param inputAudioNode defines first node to connect
  33017. * @param outputAudioNode defines second node to connect
  33018. */
  33019. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33020. /**
  33021. * Releases all associated resources
  33022. */
  33023. dispose(): void;
  33024. }
  33025. }
  33026. declare module BABYLON {
  33027. /**
  33028. * This represents an audio engine and it is responsible
  33029. * to play, synchronize and analyse sounds throughout the application.
  33030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33031. */
  33032. export interface IAudioEngine extends IDisposable {
  33033. /**
  33034. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33035. */
  33036. readonly canUseWebAudio: boolean;
  33037. /**
  33038. * Gets the current AudioContext if available.
  33039. */
  33040. readonly audioContext: Nullable<AudioContext>;
  33041. /**
  33042. * The master gain node defines the global audio volume of your audio engine.
  33043. */
  33044. readonly masterGain: GainNode;
  33045. /**
  33046. * Gets whether or not mp3 are supported by your browser.
  33047. */
  33048. readonly isMP3supported: boolean;
  33049. /**
  33050. * Gets whether or not ogg are supported by your browser.
  33051. */
  33052. readonly isOGGsupported: boolean;
  33053. /**
  33054. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33055. * @ignoreNaming
  33056. */
  33057. WarnedWebAudioUnsupported: boolean;
  33058. /**
  33059. * Defines if the audio engine relies on a custom unlocked button.
  33060. * In this case, the embedded button will not be displayed.
  33061. */
  33062. useCustomUnlockedButton: boolean;
  33063. /**
  33064. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33065. */
  33066. readonly unlocked: boolean;
  33067. /**
  33068. * Event raised when audio has been unlocked on the browser.
  33069. */
  33070. onAudioUnlockedObservable: Observable<AudioEngine>;
  33071. /**
  33072. * Event raised when audio has been locked on the browser.
  33073. */
  33074. onAudioLockedObservable: Observable<AudioEngine>;
  33075. /**
  33076. * Flags the audio engine in Locked state.
  33077. * This happens due to new browser policies preventing audio to autoplay.
  33078. */
  33079. lock(): void;
  33080. /**
  33081. * Unlocks the audio engine once a user action has been done on the dom.
  33082. * This is helpful to resume play once browser policies have been satisfied.
  33083. */
  33084. unlock(): void;
  33085. /**
  33086. * Gets the global volume sets on the master gain.
  33087. * @returns the global volume if set or -1 otherwise
  33088. */
  33089. getGlobalVolume(): number;
  33090. /**
  33091. * Sets the global volume of your experience (sets on the master gain).
  33092. * @param newVolume Defines the new global volume of the application
  33093. */
  33094. setGlobalVolume(newVolume: number): void;
  33095. /**
  33096. * Connect the audio engine to an audio analyser allowing some amazing
  33097. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33099. * @param analyser The analyser to connect to the engine
  33100. */
  33101. connectToAnalyser(analyser: Analyser): void;
  33102. }
  33103. /**
  33104. * This represents the default audio engine used in babylon.
  33105. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33107. */
  33108. export class AudioEngine implements IAudioEngine {
  33109. private _audioContext;
  33110. private _audioContextInitialized;
  33111. private _muteButton;
  33112. private _hostElement;
  33113. /**
  33114. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33115. */
  33116. canUseWebAudio: boolean;
  33117. /**
  33118. * The master gain node defines the global audio volume of your audio engine.
  33119. */
  33120. masterGain: GainNode;
  33121. /**
  33122. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33123. * @ignoreNaming
  33124. */
  33125. WarnedWebAudioUnsupported: boolean;
  33126. /**
  33127. * Gets whether or not mp3 are supported by your browser.
  33128. */
  33129. isMP3supported: boolean;
  33130. /**
  33131. * Gets whether or not ogg are supported by your browser.
  33132. */
  33133. isOGGsupported: boolean;
  33134. /**
  33135. * Gets whether audio has been unlocked on the device.
  33136. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33137. * a user interaction has happened.
  33138. */
  33139. unlocked: boolean;
  33140. /**
  33141. * Defines if the audio engine relies on a custom unlocked button.
  33142. * In this case, the embedded button will not be displayed.
  33143. */
  33144. useCustomUnlockedButton: boolean;
  33145. /**
  33146. * Event raised when audio has been unlocked on the browser.
  33147. */
  33148. onAudioUnlockedObservable: Observable<AudioEngine>;
  33149. /**
  33150. * Event raised when audio has been locked on the browser.
  33151. */
  33152. onAudioLockedObservable: Observable<AudioEngine>;
  33153. /**
  33154. * Gets the current AudioContext if available.
  33155. */
  33156. get audioContext(): Nullable<AudioContext>;
  33157. private _connectedAnalyser;
  33158. /**
  33159. * Instantiates a new audio engine.
  33160. *
  33161. * There should be only one per page as some browsers restrict the number
  33162. * of audio contexts you can create.
  33163. * @param hostElement defines the host element where to display the mute icon if necessary
  33164. */
  33165. constructor(hostElement?: Nullable<HTMLElement>);
  33166. /**
  33167. * Flags the audio engine in Locked state.
  33168. * This happens due to new browser policies preventing audio to autoplay.
  33169. */
  33170. lock(): void;
  33171. /**
  33172. * Unlocks the audio engine once a user action has been done on the dom.
  33173. * This is helpful to resume play once browser policies have been satisfied.
  33174. */
  33175. unlock(): void;
  33176. private _resumeAudioContext;
  33177. private _initializeAudioContext;
  33178. private _tryToRun;
  33179. private _triggerRunningState;
  33180. private _triggerSuspendedState;
  33181. private _displayMuteButton;
  33182. private _moveButtonToTopLeft;
  33183. private _onResize;
  33184. private _hideMuteButton;
  33185. /**
  33186. * Destroy and release the resources associated with the audio ccontext.
  33187. */
  33188. dispose(): void;
  33189. /**
  33190. * Gets the global volume sets on the master gain.
  33191. * @returns the global volume if set or -1 otherwise
  33192. */
  33193. getGlobalVolume(): number;
  33194. /**
  33195. * Sets the global volume of your experience (sets on the master gain).
  33196. * @param newVolume Defines the new global volume of the application
  33197. */
  33198. setGlobalVolume(newVolume: number): void;
  33199. /**
  33200. * Connect the audio engine to an audio analyser allowing some amazing
  33201. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33203. * @param analyser The analyser to connect to the engine
  33204. */
  33205. connectToAnalyser(analyser: Analyser): void;
  33206. }
  33207. }
  33208. declare module BABYLON {
  33209. /**
  33210. * Interface used to present a loading screen while loading a scene
  33211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33212. */
  33213. export interface ILoadingScreen {
  33214. /**
  33215. * Function called to display the loading screen
  33216. */
  33217. displayLoadingUI: () => void;
  33218. /**
  33219. * Function called to hide the loading screen
  33220. */
  33221. hideLoadingUI: () => void;
  33222. /**
  33223. * Gets or sets the color to use for the background
  33224. */
  33225. loadingUIBackgroundColor: string;
  33226. /**
  33227. * Gets or sets the text to display while loading
  33228. */
  33229. loadingUIText: string;
  33230. }
  33231. /**
  33232. * Class used for the default loading screen
  33233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33234. */
  33235. export class DefaultLoadingScreen implements ILoadingScreen {
  33236. private _renderingCanvas;
  33237. private _loadingText;
  33238. private _loadingDivBackgroundColor;
  33239. private _loadingDiv;
  33240. private _loadingTextDiv;
  33241. /** Gets or sets the logo url to use for the default loading screen */
  33242. static DefaultLogoUrl: string;
  33243. /** Gets or sets the spinner url to use for the default loading screen */
  33244. static DefaultSpinnerUrl: string;
  33245. /**
  33246. * Creates a new default loading screen
  33247. * @param _renderingCanvas defines the canvas used to render the scene
  33248. * @param _loadingText defines the default text to display
  33249. * @param _loadingDivBackgroundColor defines the default background color
  33250. */
  33251. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33252. /**
  33253. * Function called to display the loading screen
  33254. */
  33255. displayLoadingUI(): void;
  33256. /**
  33257. * Function called to hide the loading screen
  33258. */
  33259. hideLoadingUI(): void;
  33260. /**
  33261. * Gets or sets the text to display while loading
  33262. */
  33263. set loadingUIText(text: string);
  33264. get loadingUIText(): string;
  33265. /**
  33266. * Gets or sets the color to use for the background
  33267. */
  33268. get loadingUIBackgroundColor(): string;
  33269. set loadingUIBackgroundColor(color: string);
  33270. private _resizeLoadingUI;
  33271. }
  33272. }
  33273. declare module BABYLON {
  33274. /**
  33275. * Interface for any object that can request an animation frame
  33276. */
  33277. export interface ICustomAnimationFrameRequester {
  33278. /**
  33279. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33280. */
  33281. renderFunction?: Function;
  33282. /**
  33283. * Called to request the next frame to render to
  33284. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33285. */
  33286. requestAnimationFrame: Function;
  33287. /**
  33288. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33289. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33290. */
  33291. requestID?: number;
  33292. }
  33293. }
  33294. declare module BABYLON {
  33295. /**
  33296. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33297. */
  33298. export class PerformanceMonitor {
  33299. private _enabled;
  33300. private _rollingFrameTime;
  33301. private _lastFrameTimeMs;
  33302. /**
  33303. * constructor
  33304. * @param frameSampleSize The number of samples required to saturate the sliding window
  33305. */
  33306. constructor(frameSampleSize?: number);
  33307. /**
  33308. * Samples current frame
  33309. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33310. */
  33311. sampleFrame(timeMs?: number): void;
  33312. /**
  33313. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33314. */
  33315. get averageFrameTime(): number;
  33316. /**
  33317. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33318. */
  33319. get averageFrameTimeVariance(): number;
  33320. /**
  33321. * Returns the frame time of the most recent frame
  33322. */
  33323. get instantaneousFrameTime(): number;
  33324. /**
  33325. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33326. */
  33327. get averageFPS(): number;
  33328. /**
  33329. * Returns the average framerate in frames per second using the most recent frame time
  33330. */
  33331. get instantaneousFPS(): number;
  33332. /**
  33333. * Returns true if enough samples have been taken to completely fill the sliding window
  33334. */
  33335. get isSaturated(): boolean;
  33336. /**
  33337. * Enables contributions to the sliding window sample set
  33338. */
  33339. enable(): void;
  33340. /**
  33341. * Disables contributions to the sliding window sample set
  33342. * Samples will not be interpolated over the disabled period
  33343. */
  33344. disable(): void;
  33345. /**
  33346. * Returns true if sampling is enabled
  33347. */
  33348. get isEnabled(): boolean;
  33349. /**
  33350. * Resets performance monitor
  33351. */
  33352. reset(): void;
  33353. }
  33354. /**
  33355. * RollingAverage
  33356. *
  33357. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33358. */
  33359. export class RollingAverage {
  33360. /**
  33361. * Current average
  33362. */
  33363. average: number;
  33364. /**
  33365. * Current variance
  33366. */
  33367. variance: number;
  33368. protected _samples: Array<number>;
  33369. protected _sampleCount: number;
  33370. protected _pos: number;
  33371. protected _m2: number;
  33372. /**
  33373. * constructor
  33374. * @param length The number of samples required to saturate the sliding window
  33375. */
  33376. constructor(length: number);
  33377. /**
  33378. * Adds a sample to the sample set
  33379. * @param v The sample value
  33380. */
  33381. add(v: number): void;
  33382. /**
  33383. * Returns previously added values or null if outside of history or outside the sliding window domain
  33384. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33385. * @return Value previously recorded with add() or null if outside of range
  33386. */
  33387. history(i: number): number;
  33388. /**
  33389. * Returns true if enough samples have been taken to completely fill the sliding window
  33390. * @return true if sample-set saturated
  33391. */
  33392. isSaturated(): boolean;
  33393. /**
  33394. * Resets the rolling average (equivalent to 0 samples taken so far)
  33395. */
  33396. reset(): void;
  33397. /**
  33398. * Wraps a value around the sample range boundaries
  33399. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33400. * @return Wrapped position in sample range
  33401. */
  33402. protected _wrapPosition(i: number): number;
  33403. }
  33404. }
  33405. declare module BABYLON {
  33406. /**
  33407. * This class is used to track a performance counter which is number based.
  33408. * The user has access to many properties which give statistics of different nature.
  33409. *
  33410. * The implementer can track two kinds of Performance Counter: time and count.
  33411. * 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.
  33412. * 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.
  33413. */
  33414. export class PerfCounter {
  33415. /**
  33416. * Gets or sets a global boolean to turn on and off all the counters
  33417. */
  33418. static Enabled: boolean;
  33419. /**
  33420. * Returns the smallest value ever
  33421. */
  33422. get min(): number;
  33423. /**
  33424. * Returns the biggest value ever
  33425. */
  33426. get max(): number;
  33427. /**
  33428. * Returns the average value since the performance counter is running
  33429. */
  33430. get average(): number;
  33431. /**
  33432. * Returns the average value of the last second the counter was monitored
  33433. */
  33434. get lastSecAverage(): number;
  33435. /**
  33436. * Returns the current value
  33437. */
  33438. get current(): number;
  33439. /**
  33440. * Gets the accumulated total
  33441. */
  33442. get total(): number;
  33443. /**
  33444. * Gets the total value count
  33445. */
  33446. get count(): number;
  33447. /**
  33448. * Creates a new counter
  33449. */
  33450. constructor();
  33451. /**
  33452. * Call this method to start monitoring a new frame.
  33453. * 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.
  33454. */
  33455. fetchNewFrame(): void;
  33456. /**
  33457. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33458. * @param newCount the count value to add to the monitored count
  33459. * @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.
  33460. */
  33461. addCount(newCount: number, fetchResult: boolean): void;
  33462. /**
  33463. * Start monitoring this performance counter
  33464. */
  33465. beginMonitoring(): void;
  33466. /**
  33467. * Compute the time lapsed since the previous beginMonitoring() call.
  33468. * @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
  33469. */
  33470. endMonitoring(newFrame?: boolean): void;
  33471. private _fetchResult;
  33472. private _startMonitoringTime;
  33473. private _min;
  33474. private _max;
  33475. private _average;
  33476. private _current;
  33477. private _totalValueCount;
  33478. private _totalAccumulated;
  33479. private _lastSecAverage;
  33480. private _lastSecAccumulated;
  33481. private _lastSecTime;
  33482. private _lastSecValueCount;
  33483. }
  33484. }
  33485. declare module BABYLON {
  33486. interface ThinEngine {
  33487. /**
  33488. * Sets alpha constants used by some alpha blending modes
  33489. * @param r defines the red component
  33490. * @param g defines the green component
  33491. * @param b defines the blue component
  33492. * @param a defines the alpha component
  33493. */
  33494. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33495. /**
  33496. * Sets the current alpha mode
  33497. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33498. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33500. */
  33501. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33502. /**
  33503. * Gets the current alpha mode
  33504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33505. * @returns the current alpha mode
  33506. */
  33507. getAlphaMode(): number;
  33508. /**
  33509. * Sets the current alpha equation
  33510. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33511. */
  33512. setAlphaEquation(equation: number): void;
  33513. /**
  33514. * Gets the current alpha equation.
  33515. * @returns the current alpha equation
  33516. */
  33517. getAlphaEquation(): number;
  33518. }
  33519. }
  33520. declare module BABYLON {
  33521. /**
  33522. * Defines the interface used by display changed events
  33523. */
  33524. export interface IDisplayChangedEventArgs {
  33525. /** Gets the vrDisplay object (if any) */
  33526. vrDisplay: Nullable<any>;
  33527. /** Gets a boolean indicating if webVR is supported */
  33528. vrSupported: boolean;
  33529. }
  33530. /**
  33531. * Defines the interface used by objects containing a viewport (like a camera)
  33532. */
  33533. interface IViewportOwnerLike {
  33534. /**
  33535. * Gets or sets the viewport
  33536. */
  33537. viewport: IViewportLike;
  33538. }
  33539. /**
  33540. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33541. */
  33542. export class Engine extends ThinEngine {
  33543. /** Defines that alpha blending is disabled */
  33544. static readonly ALPHA_DISABLE: number;
  33545. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33546. static readonly ALPHA_ADD: number;
  33547. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33548. static readonly ALPHA_COMBINE: number;
  33549. /** Defines that alpha blending to DEST - SRC * DEST */
  33550. static readonly ALPHA_SUBTRACT: number;
  33551. /** Defines that alpha blending to SRC * DEST */
  33552. static readonly ALPHA_MULTIPLY: number;
  33553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33554. static readonly ALPHA_MAXIMIZED: number;
  33555. /** Defines that alpha blending to SRC + DEST */
  33556. static readonly ALPHA_ONEONE: number;
  33557. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33558. static readonly ALPHA_PREMULTIPLIED: number;
  33559. /**
  33560. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33561. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33562. */
  33563. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33564. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33565. static readonly ALPHA_INTERPOLATE: number;
  33566. /**
  33567. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33568. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33569. */
  33570. static readonly ALPHA_SCREENMODE: number;
  33571. /** Defines that the ressource is not delayed*/
  33572. static readonly DELAYLOADSTATE_NONE: number;
  33573. /** Defines that the ressource was successfully delay loaded */
  33574. static readonly DELAYLOADSTATE_LOADED: number;
  33575. /** Defines that the ressource is currently delay loading */
  33576. static readonly DELAYLOADSTATE_LOADING: number;
  33577. /** Defines that the ressource is delayed and has not started loading */
  33578. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33579. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33580. static readonly NEVER: number;
  33581. /** 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 */
  33582. static readonly ALWAYS: number;
  33583. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33584. static readonly LESS: number;
  33585. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33586. static readonly EQUAL: number;
  33587. /** 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 */
  33588. static readonly LEQUAL: number;
  33589. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33590. static readonly GREATER: number;
  33591. /** 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 */
  33592. static readonly GEQUAL: number;
  33593. /** 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 */
  33594. static readonly NOTEQUAL: number;
  33595. /** Passed to stencilOperation to specify that stencil value must be kept */
  33596. static readonly KEEP: number;
  33597. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33598. static readonly REPLACE: number;
  33599. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33600. static readonly INCR: number;
  33601. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33602. static readonly DECR: number;
  33603. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33604. static readonly INVERT: number;
  33605. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33606. static readonly INCR_WRAP: number;
  33607. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33608. static readonly DECR_WRAP: number;
  33609. /** Texture is not repeating outside of 0..1 UVs */
  33610. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33611. /** Texture is repeating outside of 0..1 UVs */
  33612. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33613. /** Texture is repeating and mirrored */
  33614. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33615. /** ALPHA */
  33616. static readonly TEXTUREFORMAT_ALPHA: number;
  33617. /** LUMINANCE */
  33618. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33619. /** LUMINANCE_ALPHA */
  33620. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33621. /** RGB */
  33622. static readonly TEXTUREFORMAT_RGB: number;
  33623. /** RGBA */
  33624. static readonly TEXTUREFORMAT_RGBA: number;
  33625. /** RED */
  33626. static readonly TEXTUREFORMAT_RED: number;
  33627. /** RED (2nd reference) */
  33628. static readonly TEXTUREFORMAT_R: number;
  33629. /** RG */
  33630. static readonly TEXTUREFORMAT_RG: number;
  33631. /** RED_INTEGER */
  33632. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33633. /** RED_INTEGER (2nd reference) */
  33634. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33635. /** RG_INTEGER */
  33636. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33637. /** RGB_INTEGER */
  33638. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33639. /** RGBA_INTEGER */
  33640. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33641. /** UNSIGNED_BYTE */
  33642. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33643. /** UNSIGNED_BYTE (2nd reference) */
  33644. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33645. /** FLOAT */
  33646. static readonly TEXTURETYPE_FLOAT: number;
  33647. /** HALF_FLOAT */
  33648. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33649. /** BYTE */
  33650. static readonly TEXTURETYPE_BYTE: number;
  33651. /** SHORT */
  33652. static readonly TEXTURETYPE_SHORT: number;
  33653. /** UNSIGNED_SHORT */
  33654. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33655. /** INT */
  33656. static readonly TEXTURETYPE_INT: number;
  33657. /** UNSIGNED_INT */
  33658. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33659. /** UNSIGNED_SHORT_4_4_4_4 */
  33660. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33661. /** UNSIGNED_SHORT_5_5_5_1 */
  33662. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33663. /** UNSIGNED_SHORT_5_6_5 */
  33664. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33665. /** UNSIGNED_INT_2_10_10_10_REV */
  33666. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33667. /** UNSIGNED_INT_24_8 */
  33668. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33669. /** UNSIGNED_INT_10F_11F_11F_REV */
  33670. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33671. /** UNSIGNED_INT_5_9_9_9_REV */
  33672. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33673. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33674. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33675. /** nearest is mag = nearest and min = nearest and mip = linear */
  33676. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33678. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33679. /** Trilinear is mag = linear and min = linear and mip = linear */
  33680. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33681. /** nearest is mag = nearest and min = nearest and mip = linear */
  33682. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33683. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33684. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33685. /** Trilinear is mag = linear and min = linear and mip = linear */
  33686. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33687. /** mag = nearest and min = nearest and mip = nearest */
  33688. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33689. /** mag = nearest and min = linear and mip = nearest */
  33690. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33691. /** mag = nearest and min = linear and mip = linear */
  33692. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33693. /** mag = nearest and min = linear and mip = none */
  33694. static readonly TEXTURE_NEAREST_LINEAR: number;
  33695. /** mag = nearest and min = nearest and mip = none */
  33696. static readonly TEXTURE_NEAREST_NEAREST: number;
  33697. /** mag = linear and min = nearest and mip = nearest */
  33698. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33699. /** mag = linear and min = nearest and mip = linear */
  33700. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33701. /** mag = linear and min = linear and mip = none */
  33702. static readonly TEXTURE_LINEAR_LINEAR: number;
  33703. /** mag = linear and min = nearest and mip = none */
  33704. static readonly TEXTURE_LINEAR_NEAREST: number;
  33705. /** Explicit coordinates mode */
  33706. static readonly TEXTURE_EXPLICIT_MODE: number;
  33707. /** Spherical coordinates mode */
  33708. static readonly TEXTURE_SPHERICAL_MODE: number;
  33709. /** Planar coordinates mode */
  33710. static readonly TEXTURE_PLANAR_MODE: number;
  33711. /** Cubic coordinates mode */
  33712. static readonly TEXTURE_CUBIC_MODE: number;
  33713. /** Projection coordinates mode */
  33714. static readonly TEXTURE_PROJECTION_MODE: number;
  33715. /** Skybox coordinates mode */
  33716. static readonly TEXTURE_SKYBOX_MODE: number;
  33717. /** Inverse Cubic coordinates mode */
  33718. static readonly TEXTURE_INVCUBIC_MODE: number;
  33719. /** Equirectangular coordinates mode */
  33720. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33721. /** Equirectangular Fixed coordinates mode */
  33722. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33723. /** Equirectangular Fixed Mirrored coordinates mode */
  33724. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33725. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33726. static readonly SCALEMODE_FLOOR: number;
  33727. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33728. static readonly SCALEMODE_NEAREST: number;
  33729. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33730. static readonly SCALEMODE_CEILING: number;
  33731. /**
  33732. * Returns the current npm package of the sdk
  33733. */
  33734. static get NpmPackage(): string;
  33735. /**
  33736. * Returns the current version of the framework
  33737. */
  33738. static get Version(): string;
  33739. /** Gets the list of created engines */
  33740. static get Instances(): Engine[];
  33741. /**
  33742. * Gets the latest created engine
  33743. */
  33744. static get LastCreatedEngine(): Nullable<Engine>;
  33745. /**
  33746. * Gets the latest created scene
  33747. */
  33748. static get LastCreatedScene(): Nullable<Scene>;
  33749. /**
  33750. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33751. * @param flag defines which part of the materials must be marked as dirty
  33752. * @param predicate defines a predicate used to filter which materials should be affected
  33753. */
  33754. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33755. /**
  33756. * Method called to create the default loading screen.
  33757. * This can be overriden in your own app.
  33758. * @param canvas The rendering canvas element
  33759. * @returns The loading screen
  33760. */
  33761. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33762. /**
  33763. * Method called to create the default rescale post process on each engine.
  33764. */
  33765. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33766. /**
  33767. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33768. **/
  33769. enableOfflineSupport: boolean;
  33770. /**
  33771. * 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)
  33772. **/
  33773. disableManifestCheck: boolean;
  33774. /**
  33775. * Gets the list of created scenes
  33776. */
  33777. scenes: Scene[];
  33778. /**
  33779. * Event raised when a new scene is created
  33780. */
  33781. onNewSceneAddedObservable: Observable<Scene>;
  33782. /**
  33783. * Gets the list of created postprocesses
  33784. */
  33785. postProcesses: PostProcess[];
  33786. /**
  33787. * Gets a boolean indicating if the pointer is currently locked
  33788. */
  33789. isPointerLock: boolean;
  33790. /**
  33791. * Observable event triggered each time the rendering canvas is resized
  33792. */
  33793. onResizeObservable: Observable<Engine>;
  33794. /**
  33795. * Observable event triggered each time the canvas loses focus
  33796. */
  33797. onCanvasBlurObservable: Observable<Engine>;
  33798. /**
  33799. * Observable event triggered each time the canvas gains focus
  33800. */
  33801. onCanvasFocusObservable: Observable<Engine>;
  33802. /**
  33803. * Observable event triggered each time the canvas receives pointerout event
  33804. */
  33805. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33806. /**
  33807. * Observable raised when the engine begins a new frame
  33808. */
  33809. onBeginFrameObservable: Observable<Engine>;
  33810. /**
  33811. * If set, will be used to request the next animation frame for the render loop
  33812. */
  33813. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33814. /**
  33815. * Observable raised when the engine ends the current frame
  33816. */
  33817. onEndFrameObservable: Observable<Engine>;
  33818. /**
  33819. * Observable raised when the engine is about to compile a shader
  33820. */
  33821. onBeforeShaderCompilationObservable: Observable<Engine>;
  33822. /**
  33823. * Observable raised when the engine has jsut compiled a shader
  33824. */
  33825. onAfterShaderCompilationObservable: Observable<Engine>;
  33826. /**
  33827. * Gets the audio engine
  33828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33829. * @ignorenaming
  33830. */
  33831. static audioEngine: IAudioEngine;
  33832. /**
  33833. * Default AudioEngine factory responsible of creating the Audio Engine.
  33834. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33835. */
  33836. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33837. /**
  33838. * Default offline support factory responsible of creating a tool used to store data locally.
  33839. * By default, this will create a Database object if the workload has been embedded.
  33840. */
  33841. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33842. private _loadingScreen;
  33843. private _pointerLockRequested;
  33844. private _dummyFramebuffer;
  33845. private _rescalePostProcess;
  33846. private _deterministicLockstep;
  33847. private _lockstepMaxSteps;
  33848. private _timeStep;
  33849. protected get _supportsHardwareTextureRescaling(): boolean;
  33850. private _fps;
  33851. private _deltaTime;
  33852. /** @hidden */
  33853. _drawCalls: PerfCounter;
  33854. /** 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 */
  33855. canvasTabIndex: number;
  33856. /**
  33857. * Turn this value on if you want to pause FPS computation when in background
  33858. */
  33859. disablePerformanceMonitorInBackground: boolean;
  33860. private _performanceMonitor;
  33861. /**
  33862. * Gets the performance monitor attached to this engine
  33863. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33864. */
  33865. get performanceMonitor(): PerformanceMonitor;
  33866. private _onFocus;
  33867. private _onBlur;
  33868. private _onCanvasPointerOut;
  33869. private _onCanvasBlur;
  33870. private _onCanvasFocus;
  33871. private _onFullscreenChange;
  33872. private _onPointerLockChange;
  33873. /**
  33874. * Gets the HTML element used to attach event listeners
  33875. * @returns a HTML element
  33876. */
  33877. getInputElement(): Nullable<HTMLElement>;
  33878. /**
  33879. * Creates a new engine
  33880. * @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
  33881. * @param antialias defines enable antialiasing (default: false)
  33882. * @param options defines further options to be sent to the getContext() function
  33883. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33884. */
  33885. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33886. /**
  33887. * Gets current aspect ratio
  33888. * @param viewportOwner defines the camera to use to get the aspect ratio
  33889. * @param useScreen defines if screen size must be used (or the current render target if any)
  33890. * @returns a number defining the aspect ratio
  33891. */
  33892. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33893. /**
  33894. * Gets current screen aspect ratio
  33895. * @returns a number defining the aspect ratio
  33896. */
  33897. getScreenAspectRatio(): number;
  33898. /**
  33899. * Gets the client rect of the HTML canvas attached with the current webGL context
  33900. * @returns a client rectanglee
  33901. */
  33902. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33903. /**
  33904. * Gets the client rect of the HTML element used for events
  33905. * @returns a client rectanglee
  33906. */
  33907. getInputElementClientRect(): Nullable<ClientRect>;
  33908. /**
  33909. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33911. * @returns true if engine is in deterministic lock step mode
  33912. */
  33913. isDeterministicLockStep(): boolean;
  33914. /**
  33915. * Gets the max steps when engine is running in deterministic lock step
  33916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33917. * @returns the max steps
  33918. */
  33919. getLockstepMaxSteps(): number;
  33920. /**
  33921. * Returns the time in ms between steps when using deterministic lock step.
  33922. * @returns time step in (ms)
  33923. */
  33924. getTimeStep(): number;
  33925. /**
  33926. * Force the mipmap generation for the given render target texture
  33927. * @param texture defines the render target texture to use
  33928. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33929. */
  33930. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33931. /** States */
  33932. /**
  33933. * Set various states to the webGL context
  33934. * @param culling defines backface culling state
  33935. * @param zOffset defines the value to apply to zOffset (0 by default)
  33936. * @param force defines if states must be applied even if cache is up to date
  33937. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33938. */
  33939. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33940. /**
  33941. * Set the z offset to apply to current rendering
  33942. * @param value defines the offset to apply
  33943. */
  33944. setZOffset(value: number): void;
  33945. /**
  33946. * Gets the current value of the zOffset
  33947. * @returns the current zOffset state
  33948. */
  33949. getZOffset(): number;
  33950. /**
  33951. * Enable or disable depth buffering
  33952. * @param enable defines the state to set
  33953. */
  33954. setDepthBuffer(enable: boolean): void;
  33955. /**
  33956. * Gets a boolean indicating if depth writing is enabled
  33957. * @returns the current depth writing state
  33958. */
  33959. getDepthWrite(): boolean;
  33960. /**
  33961. * Enable or disable depth writing
  33962. * @param enable defines the state to set
  33963. */
  33964. setDepthWrite(enable: boolean): void;
  33965. /**
  33966. * Gets a boolean indicating if stencil buffer is enabled
  33967. * @returns the current stencil buffer state
  33968. */
  33969. getStencilBuffer(): boolean;
  33970. /**
  33971. * Enable or disable the stencil buffer
  33972. * @param enable defines if the stencil buffer must be enabled or disabled
  33973. */
  33974. setStencilBuffer(enable: boolean): void;
  33975. /**
  33976. * Gets the current stencil mask
  33977. * @returns a number defining the new stencil mask to use
  33978. */
  33979. getStencilMask(): number;
  33980. /**
  33981. * Sets the current stencil mask
  33982. * @param mask defines the new stencil mask to use
  33983. */
  33984. setStencilMask(mask: number): void;
  33985. /**
  33986. * Gets the current stencil function
  33987. * @returns a number defining the stencil function to use
  33988. */
  33989. getStencilFunction(): number;
  33990. /**
  33991. * Gets the current stencil reference value
  33992. * @returns a number defining the stencil reference value to use
  33993. */
  33994. getStencilFunctionReference(): number;
  33995. /**
  33996. * Gets the current stencil mask
  33997. * @returns a number defining the stencil mask to use
  33998. */
  33999. getStencilFunctionMask(): number;
  34000. /**
  34001. * Sets the current stencil function
  34002. * @param stencilFunc defines the new stencil function to use
  34003. */
  34004. setStencilFunction(stencilFunc: number): void;
  34005. /**
  34006. * Sets the current stencil reference
  34007. * @param reference defines the new stencil reference to use
  34008. */
  34009. setStencilFunctionReference(reference: number): void;
  34010. /**
  34011. * Sets the current stencil mask
  34012. * @param mask defines the new stencil mask to use
  34013. */
  34014. setStencilFunctionMask(mask: number): void;
  34015. /**
  34016. * Gets the current stencil operation when stencil fails
  34017. * @returns a number defining stencil operation to use when stencil fails
  34018. */
  34019. getStencilOperationFail(): number;
  34020. /**
  34021. * Gets the current stencil operation when depth fails
  34022. * @returns a number defining stencil operation to use when depth fails
  34023. */
  34024. getStencilOperationDepthFail(): number;
  34025. /**
  34026. * Gets the current stencil operation when stencil passes
  34027. * @returns a number defining stencil operation to use when stencil passes
  34028. */
  34029. getStencilOperationPass(): number;
  34030. /**
  34031. * Sets the stencil operation to use when stencil fails
  34032. * @param operation defines the stencil operation to use when stencil fails
  34033. */
  34034. setStencilOperationFail(operation: number): void;
  34035. /**
  34036. * Sets the stencil operation to use when depth fails
  34037. * @param operation defines the stencil operation to use when depth fails
  34038. */
  34039. setStencilOperationDepthFail(operation: number): void;
  34040. /**
  34041. * Sets the stencil operation to use when stencil passes
  34042. * @param operation defines the stencil operation to use when stencil passes
  34043. */
  34044. setStencilOperationPass(operation: number): void;
  34045. /**
  34046. * Sets a boolean indicating if the dithering state is enabled or disabled
  34047. * @param value defines the dithering state
  34048. */
  34049. setDitheringState(value: boolean): void;
  34050. /**
  34051. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34052. * @param value defines the rasterizer state
  34053. */
  34054. setRasterizerState(value: boolean): void;
  34055. /**
  34056. * Gets the current depth function
  34057. * @returns a number defining the depth function
  34058. */
  34059. getDepthFunction(): Nullable<number>;
  34060. /**
  34061. * Sets the current depth function
  34062. * @param depthFunc defines the function to use
  34063. */
  34064. setDepthFunction(depthFunc: number): void;
  34065. /**
  34066. * Sets the current depth function to GREATER
  34067. */
  34068. setDepthFunctionToGreater(): void;
  34069. /**
  34070. * Sets the current depth function to GEQUAL
  34071. */
  34072. setDepthFunctionToGreaterOrEqual(): void;
  34073. /**
  34074. * Sets the current depth function to LESS
  34075. */
  34076. setDepthFunctionToLess(): void;
  34077. /**
  34078. * Sets the current depth function to LEQUAL
  34079. */
  34080. setDepthFunctionToLessOrEqual(): void;
  34081. private _cachedStencilBuffer;
  34082. private _cachedStencilFunction;
  34083. private _cachedStencilMask;
  34084. private _cachedStencilOperationPass;
  34085. private _cachedStencilOperationFail;
  34086. private _cachedStencilOperationDepthFail;
  34087. private _cachedStencilReference;
  34088. /**
  34089. * Caches the the state of the stencil buffer
  34090. */
  34091. cacheStencilState(): void;
  34092. /**
  34093. * Restores the state of the stencil buffer
  34094. */
  34095. restoreStencilState(): void;
  34096. /**
  34097. * Directly set the WebGL Viewport
  34098. * @param x defines the x coordinate of the viewport (in screen space)
  34099. * @param y defines the y coordinate of the viewport (in screen space)
  34100. * @param width defines the width of the viewport (in screen space)
  34101. * @param height defines the height of the viewport (in screen space)
  34102. * @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
  34103. */
  34104. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34105. /**
  34106. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34107. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34108. * @param y defines the y-coordinate of the corner of the clear rectangle
  34109. * @param width defines the width of the clear rectangle
  34110. * @param height defines the height of the clear rectangle
  34111. * @param clearColor defines the clear color
  34112. */
  34113. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34114. /**
  34115. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34116. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34117. * @param y defines the y-coordinate of the corner of the clear rectangle
  34118. * @param width defines the width of the clear rectangle
  34119. * @param height defines the height of the clear rectangle
  34120. */
  34121. enableScissor(x: number, y: number, width: number, height: number): void;
  34122. /**
  34123. * Disable previously set scissor test rectangle
  34124. */
  34125. disableScissor(): void;
  34126. protected _reportDrawCall(): void;
  34127. /**
  34128. * Initializes a webVR display and starts listening to display change events
  34129. * The onVRDisplayChangedObservable will be notified upon these changes
  34130. * @returns The onVRDisplayChangedObservable
  34131. */
  34132. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34133. /** @hidden */
  34134. _prepareVRComponent(): void;
  34135. /** @hidden */
  34136. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34137. /** @hidden */
  34138. _submitVRFrame(): void;
  34139. /**
  34140. * Call this function to leave webVR mode
  34141. * Will do nothing if webVR is not supported or if there is no webVR device
  34142. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34143. */
  34144. disableVR(): void;
  34145. /**
  34146. * Gets a boolean indicating that the system is in VR mode and is presenting
  34147. * @returns true if VR mode is engaged
  34148. */
  34149. isVRPresenting(): boolean;
  34150. /** @hidden */
  34151. _requestVRFrame(): void;
  34152. /** @hidden */
  34153. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34154. /**
  34155. * Gets the source code of the vertex shader associated with a specific webGL program
  34156. * @param program defines the program to use
  34157. * @returns a string containing the source code of the vertex shader associated with the program
  34158. */
  34159. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34160. /**
  34161. * Gets the source code of the fragment shader associated with a specific webGL program
  34162. * @param program defines the program to use
  34163. * @returns a string containing the source code of the fragment shader associated with the program
  34164. */
  34165. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34166. /**
  34167. * Sets a depth stencil texture from a render target to the according uniform.
  34168. * @param channel The texture channel
  34169. * @param uniform The uniform to set
  34170. * @param texture The render target texture containing the depth stencil texture to apply
  34171. */
  34172. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34173. /**
  34174. * Sets a texture to the webGL context from a postprocess
  34175. * @param channel defines the channel to use
  34176. * @param postProcess defines the source postprocess
  34177. */
  34178. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34179. /**
  34180. * Binds the output of the passed in post process to the texture channel specified
  34181. * @param channel The channel the texture should be bound to
  34182. * @param postProcess The post process which's output should be bound
  34183. */
  34184. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34185. protected _rebuildBuffers(): void;
  34186. /** @hidden */
  34187. _renderFrame(): void;
  34188. _renderLoop(): void;
  34189. /** @hidden */
  34190. _renderViews(): boolean;
  34191. /**
  34192. * Toggle full screen mode
  34193. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34194. */
  34195. switchFullscreen(requestPointerLock: boolean): void;
  34196. /**
  34197. * Enters full screen mode
  34198. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34199. */
  34200. enterFullscreen(requestPointerLock: boolean): void;
  34201. /**
  34202. * Exits full screen mode
  34203. */
  34204. exitFullscreen(): void;
  34205. /**
  34206. * Enters Pointerlock mode
  34207. */
  34208. enterPointerlock(): void;
  34209. /**
  34210. * Exits Pointerlock mode
  34211. */
  34212. exitPointerlock(): void;
  34213. /**
  34214. * Begin a new frame
  34215. */
  34216. beginFrame(): void;
  34217. /**
  34218. * Enf the current frame
  34219. */
  34220. endFrame(): void;
  34221. resize(): void;
  34222. /**
  34223. * Force a specific size of the canvas
  34224. * @param width defines the new canvas' width
  34225. * @param height defines the new canvas' height
  34226. */
  34227. setSize(width: number, height: number): void;
  34228. /**
  34229. * Updates a dynamic vertex buffer.
  34230. * @param vertexBuffer the vertex buffer to update
  34231. * @param data the data used to update the vertex buffer
  34232. * @param byteOffset the byte offset of the data
  34233. * @param byteLength the byte length of the data
  34234. */
  34235. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34236. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34237. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34238. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34239. _releaseTexture(texture: InternalTexture): void;
  34240. /**
  34241. * @hidden
  34242. * Rescales a texture
  34243. * @param source input texutre
  34244. * @param destination destination texture
  34245. * @param scene scene to use to render the resize
  34246. * @param internalFormat format to use when resizing
  34247. * @param onComplete callback to be called when resize has completed
  34248. */
  34249. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34250. /**
  34251. * Gets the current framerate
  34252. * @returns a number representing the framerate
  34253. */
  34254. getFps(): number;
  34255. /**
  34256. * Gets the time spent between current and previous frame
  34257. * @returns a number representing the delta time in ms
  34258. */
  34259. getDeltaTime(): number;
  34260. private _measureFps;
  34261. /** @hidden */
  34262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34263. /**
  34264. * Update a dynamic index buffer
  34265. * @param indexBuffer defines the target index buffer
  34266. * @param indices defines the data to update
  34267. * @param offset defines the offset in the target index buffer where update should start
  34268. */
  34269. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34270. /**
  34271. * Updates the sample count of a render target texture
  34272. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34273. * @param texture defines the texture to update
  34274. * @param samples defines the sample count to set
  34275. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34276. */
  34277. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34278. /**
  34279. * Updates a depth texture Comparison Mode and Function.
  34280. * If the comparison Function is equal to 0, the mode will be set to none.
  34281. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34282. * @param texture The texture to set the comparison function for
  34283. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34284. */
  34285. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34286. /**
  34287. * Creates a webGL buffer to use with instanciation
  34288. * @param capacity defines the size of the buffer
  34289. * @returns the webGL buffer
  34290. */
  34291. createInstancesBuffer(capacity: number): DataBuffer;
  34292. /**
  34293. * Delete a webGL buffer used with instanciation
  34294. * @param buffer defines the webGL buffer to delete
  34295. */
  34296. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34297. private _clientWaitAsync;
  34298. /** @hidden */
  34299. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34300. /** @hidden */
  34301. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34302. dispose(): void;
  34303. private _disableTouchAction;
  34304. /**
  34305. * Display the loading screen
  34306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34307. */
  34308. displayLoadingUI(): void;
  34309. /**
  34310. * Hide the loading screen
  34311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34312. */
  34313. hideLoadingUI(): void;
  34314. /**
  34315. * Gets the current loading screen object
  34316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34317. */
  34318. get loadingScreen(): ILoadingScreen;
  34319. /**
  34320. * Sets the current loading screen object
  34321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34322. */
  34323. set loadingScreen(loadingScreen: ILoadingScreen);
  34324. /**
  34325. * Sets the current loading screen text
  34326. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34327. */
  34328. set loadingUIText(text: string);
  34329. /**
  34330. * Sets the current loading screen background color
  34331. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34332. */
  34333. set loadingUIBackgroundColor(color: string);
  34334. /** Pointerlock and fullscreen */
  34335. /**
  34336. * Ask the browser to promote the current element to pointerlock mode
  34337. * @param element defines the DOM element to promote
  34338. */
  34339. static _RequestPointerlock(element: HTMLElement): void;
  34340. /**
  34341. * Asks the browser to exit pointerlock mode
  34342. */
  34343. static _ExitPointerlock(): void;
  34344. /**
  34345. * Ask the browser to promote the current element to fullscreen rendering mode
  34346. * @param element defines the DOM element to promote
  34347. */
  34348. static _RequestFullscreen(element: HTMLElement): void;
  34349. /**
  34350. * Asks the browser to exit fullscreen mode
  34351. */
  34352. static _ExitFullscreen(): void;
  34353. }
  34354. }
  34355. declare module BABYLON {
  34356. /**
  34357. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34358. * during the life time of the application.
  34359. */
  34360. export class EngineStore {
  34361. /** Gets the list of created engines */
  34362. static Instances: Engine[];
  34363. /** @hidden */
  34364. static _LastCreatedScene: Nullable<Scene>;
  34365. /**
  34366. * Gets the latest created engine
  34367. */
  34368. static get LastCreatedEngine(): Nullable<Engine>;
  34369. /**
  34370. * Gets the latest created scene
  34371. */
  34372. static get LastCreatedScene(): Nullable<Scene>;
  34373. /**
  34374. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34375. * @ignorenaming
  34376. */
  34377. static UseFallbackTexture: boolean;
  34378. /**
  34379. * Texture content used if a texture cannot loaded
  34380. * @ignorenaming
  34381. */
  34382. static FallbackTexture: string;
  34383. }
  34384. }
  34385. declare module BABYLON {
  34386. /**
  34387. * Helper class that provides a small promise polyfill
  34388. */
  34389. export class PromisePolyfill {
  34390. /**
  34391. * Static function used to check if the polyfill is required
  34392. * If this is the case then the function will inject the polyfill to window.Promise
  34393. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34394. */
  34395. static Apply(force?: boolean): void;
  34396. }
  34397. }
  34398. declare module BABYLON {
  34399. /**
  34400. * Interface for screenshot methods with describe argument called `size` as object with options
  34401. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34402. */
  34403. export interface IScreenshotSize {
  34404. /**
  34405. * number in pixels for canvas height
  34406. */
  34407. height?: number;
  34408. /**
  34409. * multiplier allowing render at a higher or lower resolution
  34410. * If value is defined then height and width will be ignored and taken from camera
  34411. */
  34412. precision?: number;
  34413. /**
  34414. * number in pixels for canvas width
  34415. */
  34416. width?: number;
  34417. }
  34418. }
  34419. declare module BABYLON {
  34420. interface IColor4Like {
  34421. r: float;
  34422. g: float;
  34423. b: float;
  34424. a: float;
  34425. }
  34426. /**
  34427. * Class containing a set of static utilities functions
  34428. */
  34429. export class Tools {
  34430. /**
  34431. * Gets or sets the base URL to use to load assets
  34432. */
  34433. static get BaseUrl(): string;
  34434. static set BaseUrl(value: string);
  34435. /**
  34436. * Enable/Disable Custom HTTP Request Headers globally.
  34437. * default = false
  34438. * @see CustomRequestHeaders
  34439. */
  34440. static UseCustomRequestHeaders: boolean;
  34441. /**
  34442. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34443. * i.e. when loading files, where the server/service expects an Authorization header
  34444. */
  34445. static CustomRequestHeaders: {
  34446. [key: string]: string;
  34447. };
  34448. /**
  34449. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34450. */
  34451. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34452. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34453. /**
  34454. * Default behaviour for cors in the application.
  34455. * It can be a string if the expected behavior is identical in the entire app.
  34456. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34457. */
  34458. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34459. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34460. /**
  34461. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34462. * @ignorenaming
  34463. */
  34464. static get UseFallbackTexture(): boolean;
  34465. static set UseFallbackTexture(value: boolean);
  34466. /**
  34467. * Use this object to register external classes like custom textures or material
  34468. * to allow the laoders to instantiate them
  34469. */
  34470. static get RegisteredExternalClasses(): {
  34471. [key: string]: Object;
  34472. };
  34473. static set RegisteredExternalClasses(classes: {
  34474. [key: string]: Object;
  34475. });
  34476. /**
  34477. * Texture content used if a texture cannot loaded
  34478. * @ignorenaming
  34479. */
  34480. static get fallbackTexture(): string;
  34481. static set fallbackTexture(value: string);
  34482. /**
  34483. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34484. * @param u defines the coordinate on X axis
  34485. * @param v defines the coordinate on Y axis
  34486. * @param width defines the width of the source data
  34487. * @param height defines the height of the source data
  34488. * @param pixels defines the source byte array
  34489. * @param color defines the output color
  34490. */
  34491. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34492. /**
  34493. * Interpolates between a and b via alpha
  34494. * @param a The lower value (returned when alpha = 0)
  34495. * @param b The upper value (returned when alpha = 1)
  34496. * @param alpha The interpolation-factor
  34497. * @return The mixed value
  34498. */
  34499. static Mix(a: number, b: number, alpha: number): number;
  34500. /**
  34501. * Tries to instantiate a new object from a given class name
  34502. * @param className defines the class name to instantiate
  34503. * @returns the new object or null if the system was not able to do the instantiation
  34504. */
  34505. static Instantiate(className: string): any;
  34506. /**
  34507. * Provides a slice function that will work even on IE
  34508. * @param data defines the array to slice
  34509. * @param start defines the start of the data (optional)
  34510. * @param end defines the end of the data (optional)
  34511. * @returns the new sliced array
  34512. */
  34513. static Slice<T>(data: T, start?: number, end?: number): T;
  34514. /**
  34515. * Polyfill for setImmediate
  34516. * @param action defines the action to execute after the current execution block
  34517. */
  34518. static SetImmediate(action: () => void): void;
  34519. /**
  34520. * Function indicating if a number is an exponent of 2
  34521. * @param value defines the value to test
  34522. * @returns true if the value is an exponent of 2
  34523. */
  34524. static IsExponentOfTwo(value: number): boolean;
  34525. private static _tmpFloatArray;
  34526. /**
  34527. * Returns the nearest 32-bit single precision float representation of a Number
  34528. * @param value A Number. If the parameter is of a different type, it will get converted
  34529. * to a number or to NaN if it cannot be converted
  34530. * @returns number
  34531. */
  34532. static FloatRound(value: number): number;
  34533. /**
  34534. * Extracts the filename from a path
  34535. * @param path defines the path to use
  34536. * @returns the filename
  34537. */
  34538. static GetFilename(path: string): string;
  34539. /**
  34540. * Extracts the "folder" part of a path (everything before the filename).
  34541. * @param uri The URI to extract the info from
  34542. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34543. * @returns The "folder" part of the path
  34544. */
  34545. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34546. /**
  34547. * Extracts text content from a DOM element hierarchy
  34548. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34549. */
  34550. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34551. /**
  34552. * Convert an angle in radians to degrees
  34553. * @param angle defines the angle to convert
  34554. * @returns the angle in degrees
  34555. */
  34556. static ToDegrees(angle: number): number;
  34557. /**
  34558. * Convert an angle in degrees to radians
  34559. * @param angle defines the angle to convert
  34560. * @returns the angle in radians
  34561. */
  34562. static ToRadians(angle: number): number;
  34563. /**
  34564. * Returns an array if obj is not an array
  34565. * @param obj defines the object to evaluate as an array
  34566. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34567. * @returns either obj directly if obj is an array or a new array containing obj
  34568. */
  34569. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34570. /**
  34571. * Gets the pointer prefix to use
  34572. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34573. */
  34574. static GetPointerPrefix(): string;
  34575. /**
  34576. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34577. * @param url define the url we are trying
  34578. * @param element define the dom element where to configure the cors policy
  34579. */
  34580. static SetCorsBehavior(url: string | string[], element: {
  34581. crossOrigin: string | null;
  34582. }): void;
  34583. /**
  34584. * Removes unwanted characters from an url
  34585. * @param url defines the url to clean
  34586. * @returns the cleaned url
  34587. */
  34588. static CleanUrl(url: string): string;
  34589. /**
  34590. * Gets or sets a function used to pre-process url before using them to load assets
  34591. */
  34592. static get PreprocessUrl(): (url: string) => string;
  34593. static set PreprocessUrl(processor: (url: string) => string);
  34594. /**
  34595. * Loads an image as an HTMLImageElement.
  34596. * @param input url string, ArrayBuffer, or Blob to load
  34597. * @param onLoad callback called when the image successfully loads
  34598. * @param onError callback called when the image fails to load
  34599. * @param offlineProvider offline provider for caching
  34600. * @param mimeType optional mime type
  34601. * @returns the HTMLImageElement of the loaded image
  34602. */
  34603. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34604. /**
  34605. * Loads a file from a url
  34606. * @param url url string, ArrayBuffer, or Blob to load
  34607. * @param onSuccess callback called when the file successfully loads
  34608. * @param onProgress callback called while file is loading (if the server supports this mode)
  34609. * @param offlineProvider defines the offline provider for caching
  34610. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34611. * @param onError callback called when the file fails to load
  34612. * @returns a file request object
  34613. */
  34614. 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;
  34615. /**
  34616. * Loads a file from a url
  34617. * @param url the file url to load
  34618. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34619. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34620. */
  34621. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34622. /**
  34623. * Load a script (identified by an url). When the url returns, the
  34624. * content of this file is added into a new script element, attached to the DOM (body element)
  34625. * @param scriptUrl defines the url of the script to laod
  34626. * @param onSuccess defines the callback called when the script is loaded
  34627. * @param onError defines the callback to call if an error occurs
  34628. * @param scriptId defines the id of the script element
  34629. */
  34630. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34631. /**
  34632. * Load an asynchronous script (identified by an url). When the url returns, the
  34633. * content of this file is added into a new script element, attached to the DOM (body element)
  34634. * @param scriptUrl defines the url of the script to laod
  34635. * @param scriptId defines the id of the script element
  34636. * @returns a promise request object
  34637. */
  34638. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34639. /**
  34640. * Loads a file from a blob
  34641. * @param fileToLoad defines the blob to use
  34642. * @param callback defines the callback to call when data is loaded
  34643. * @param progressCallback defines the callback to call during loading process
  34644. * @returns a file request object
  34645. */
  34646. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34647. /**
  34648. * Reads a file from a File object
  34649. * @param file defines the file to load
  34650. * @param onSuccess defines the callback to call when data is loaded
  34651. * @param onProgress defines the callback to call during loading process
  34652. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34653. * @param onError defines the callback to call when an error occurs
  34654. * @returns a file request object
  34655. */
  34656. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34657. /**
  34658. * Creates a data url from a given string content
  34659. * @param content defines the content to convert
  34660. * @returns the new data url link
  34661. */
  34662. static FileAsURL(content: string): string;
  34663. /**
  34664. * Format the given number to a specific decimal format
  34665. * @param value defines the number to format
  34666. * @param decimals defines the number of decimals to use
  34667. * @returns the formatted string
  34668. */
  34669. static Format(value: number, decimals?: number): string;
  34670. /**
  34671. * Tries to copy an object by duplicating every property
  34672. * @param source defines the source object
  34673. * @param destination defines the target object
  34674. * @param doNotCopyList defines a list of properties to avoid
  34675. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34676. */
  34677. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34678. /**
  34679. * Gets a boolean indicating if the given object has no own property
  34680. * @param obj defines the object to test
  34681. * @returns true if object has no own property
  34682. */
  34683. static IsEmpty(obj: any): boolean;
  34684. /**
  34685. * Function used to register events at window level
  34686. * @param windowElement defines the Window object to use
  34687. * @param events defines the events to register
  34688. */
  34689. static RegisterTopRootEvents(windowElement: Window, events: {
  34690. name: string;
  34691. handler: Nullable<(e: FocusEvent) => any>;
  34692. }[]): void;
  34693. /**
  34694. * Function used to unregister events from window level
  34695. * @param windowElement defines the Window object to use
  34696. * @param events defines the events to unregister
  34697. */
  34698. static UnregisterTopRootEvents(windowElement: Window, events: {
  34699. name: string;
  34700. handler: Nullable<(e: FocusEvent) => any>;
  34701. }[]): void;
  34702. /**
  34703. * @ignore
  34704. */
  34705. static _ScreenshotCanvas: HTMLCanvasElement;
  34706. /**
  34707. * Dumps the current bound framebuffer
  34708. * @param width defines the rendering width
  34709. * @param height defines the rendering height
  34710. * @param engine defines the hosting engine
  34711. * @param successCallback defines the callback triggered once the data are available
  34712. * @param mimeType defines the mime type of the result
  34713. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34714. */
  34715. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34716. /**
  34717. * Converts the canvas data to blob.
  34718. * This acts as a polyfill for browsers not supporting the to blob function.
  34719. * @param canvas Defines the canvas to extract the data from
  34720. * @param successCallback Defines the callback triggered once the data are available
  34721. * @param mimeType Defines the mime type of the result
  34722. */
  34723. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34724. /**
  34725. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34726. * @param successCallback defines the callback triggered once the data are available
  34727. * @param mimeType defines the mime type of the result
  34728. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34729. */
  34730. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34731. /**
  34732. * Downloads a blob in the browser
  34733. * @param blob defines the blob to download
  34734. * @param fileName defines the name of the downloaded file
  34735. */
  34736. static Download(blob: Blob, fileName: string): void;
  34737. /**
  34738. * Captures a screenshot of the current rendering
  34739. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34740. * @param engine defines the rendering engine
  34741. * @param camera defines the source camera
  34742. * @param size This parameter can be set to a single number or to an object with the
  34743. * following (optional) properties: precision, width, height. If a single number is passed,
  34744. * it will be used for both width and height. If an object is passed, the screenshot size
  34745. * will be derived from the parameters. The precision property is a multiplier allowing
  34746. * rendering at a higher or lower resolution
  34747. * @param successCallback defines the callback receives a single parameter which contains the
  34748. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34749. * src parameter of an <img> to display it
  34750. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34751. * Check your browser for supported MIME types
  34752. */
  34753. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34754. /**
  34755. * Captures a screenshot of the current rendering
  34756. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34757. * @param engine defines the rendering engine
  34758. * @param camera defines the source camera
  34759. * @param size This parameter can be set to a single number or to an object with the
  34760. * following (optional) properties: precision, width, height. If a single number is passed,
  34761. * it will be used for both width and height. If an object is passed, the screenshot size
  34762. * will be derived from the parameters. The precision property is a multiplier allowing
  34763. * rendering at a higher or lower resolution
  34764. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34765. * Check your browser for supported MIME types
  34766. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34767. * to the src parameter of an <img> to display it
  34768. */
  34769. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34770. /**
  34771. * Generates an image screenshot from the specified camera.
  34772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34773. * @param engine The engine to use for rendering
  34774. * @param camera The camera to use for rendering
  34775. * @param size This parameter can be set to a single number or to an object with the
  34776. * following (optional) properties: precision, width, height. If a single number is passed,
  34777. * it will be used for both width and height. If an object is passed, the screenshot size
  34778. * will be derived from the parameters. The precision property is a multiplier allowing
  34779. * rendering at a higher or lower resolution
  34780. * @param successCallback The callback receives a single parameter which contains the
  34781. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34782. * src parameter of an <img> to display it
  34783. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34784. * Check your browser for supported MIME types
  34785. * @param samples Texture samples (default: 1)
  34786. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34787. * @param fileName A name for for the downloaded file.
  34788. */
  34789. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34790. /**
  34791. * Generates an image screenshot from the specified camera.
  34792. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34793. * @param engine The engine to use for rendering
  34794. * @param camera The camera to use for rendering
  34795. * @param size This parameter can be set to a single number or to an object with the
  34796. * following (optional) properties: precision, width, height. If a single number is passed,
  34797. * it will be used for both width and height. If an object is passed, the screenshot size
  34798. * will be derived from the parameters. The precision property is a multiplier allowing
  34799. * rendering at a higher or lower resolution
  34800. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34801. * Check your browser for supported MIME types
  34802. * @param samples Texture samples (default: 1)
  34803. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34804. * @param fileName A name for for the downloaded file.
  34805. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34806. * to the src parameter of an <img> to display it
  34807. */
  34808. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34809. /**
  34810. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34811. * Be aware Math.random() could cause collisions, but:
  34812. * "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"
  34813. * @returns a pseudo random id
  34814. */
  34815. static RandomId(): string;
  34816. /**
  34817. * Test if the given uri is a base64 string
  34818. * @param uri The uri to test
  34819. * @return True if the uri is a base64 string or false otherwise
  34820. */
  34821. static IsBase64(uri: string): boolean;
  34822. /**
  34823. * Decode the given base64 uri.
  34824. * @param uri The uri to decode
  34825. * @return The decoded base64 data.
  34826. */
  34827. static DecodeBase64(uri: string): ArrayBuffer;
  34828. /**
  34829. * Gets the absolute url.
  34830. * @param url the input url
  34831. * @return the absolute url
  34832. */
  34833. static GetAbsoluteUrl(url: string): string;
  34834. /**
  34835. * No log
  34836. */
  34837. static readonly NoneLogLevel: number;
  34838. /**
  34839. * Only message logs
  34840. */
  34841. static readonly MessageLogLevel: number;
  34842. /**
  34843. * Only warning logs
  34844. */
  34845. static readonly WarningLogLevel: number;
  34846. /**
  34847. * Only error logs
  34848. */
  34849. static readonly ErrorLogLevel: number;
  34850. /**
  34851. * All logs
  34852. */
  34853. static readonly AllLogLevel: number;
  34854. /**
  34855. * Gets a value indicating the number of loading errors
  34856. * @ignorenaming
  34857. */
  34858. static get errorsCount(): number;
  34859. /**
  34860. * Callback called when a new log is added
  34861. */
  34862. static OnNewCacheEntry: (entry: string) => void;
  34863. /**
  34864. * Log a message to the console
  34865. * @param message defines the message to log
  34866. */
  34867. static Log(message: string): void;
  34868. /**
  34869. * Write a warning message to the console
  34870. * @param message defines the message to log
  34871. */
  34872. static Warn(message: string): void;
  34873. /**
  34874. * Write an error message to the console
  34875. * @param message defines the message to log
  34876. */
  34877. static Error(message: string): void;
  34878. /**
  34879. * Gets current log cache (list of logs)
  34880. */
  34881. static get LogCache(): string;
  34882. /**
  34883. * Clears the log cache
  34884. */
  34885. static ClearLogCache(): void;
  34886. /**
  34887. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34888. */
  34889. static set LogLevels(level: number);
  34890. /**
  34891. * Checks if the window object exists
  34892. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34893. */
  34894. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34895. /**
  34896. * No performance log
  34897. */
  34898. static readonly PerformanceNoneLogLevel: number;
  34899. /**
  34900. * Use user marks to log performance
  34901. */
  34902. static readonly PerformanceUserMarkLogLevel: number;
  34903. /**
  34904. * Log performance to the console
  34905. */
  34906. static readonly PerformanceConsoleLogLevel: number;
  34907. private static _performance;
  34908. /**
  34909. * Sets the current performance log level
  34910. */
  34911. static set PerformanceLogLevel(level: number);
  34912. private static _StartPerformanceCounterDisabled;
  34913. private static _EndPerformanceCounterDisabled;
  34914. private static _StartUserMark;
  34915. private static _EndUserMark;
  34916. private static _StartPerformanceConsole;
  34917. private static _EndPerformanceConsole;
  34918. /**
  34919. * Starts a performance counter
  34920. */
  34921. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34922. /**
  34923. * Ends a specific performance coutner
  34924. */
  34925. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34926. /**
  34927. * Gets either window.performance.now() if supported or Date.now() else
  34928. */
  34929. static get Now(): number;
  34930. /**
  34931. * This method will return the name of the class used to create the instance of the given object.
  34932. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34933. * @param object the object to get the class name from
  34934. * @param isType defines if the object is actually a type
  34935. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34936. */
  34937. static GetClassName(object: any, isType?: boolean): string;
  34938. /**
  34939. * Gets the first element of an array satisfying a given predicate
  34940. * @param array defines the array to browse
  34941. * @param predicate defines the predicate to use
  34942. * @returns null if not found or the element
  34943. */
  34944. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34945. /**
  34946. * This method will return the name of the full name of the class, including its owning module (if any).
  34947. * 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).
  34948. * @param object the object to get the class name from
  34949. * @param isType defines if the object is actually a type
  34950. * @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.
  34951. * @ignorenaming
  34952. */
  34953. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34954. /**
  34955. * Returns a promise that resolves after the given amount of time.
  34956. * @param delay Number of milliseconds to delay
  34957. * @returns Promise that resolves after the given amount of time
  34958. */
  34959. static DelayAsync(delay: number): Promise<void>;
  34960. /**
  34961. * Utility function to detect if the current user agent is Safari
  34962. * @returns whether or not the current user agent is safari
  34963. */
  34964. static IsSafari(): boolean;
  34965. }
  34966. /**
  34967. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34968. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34969. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34970. * @param name The name of the class, case should be preserved
  34971. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34972. */
  34973. export function className(name: string, module?: string): (target: Object) => void;
  34974. /**
  34975. * An implementation of a loop for asynchronous functions.
  34976. */
  34977. export class AsyncLoop {
  34978. /**
  34979. * Defines the number of iterations for the loop
  34980. */
  34981. iterations: number;
  34982. /**
  34983. * Defines the current index of the loop.
  34984. */
  34985. index: number;
  34986. private _done;
  34987. private _fn;
  34988. private _successCallback;
  34989. /**
  34990. * Constructor.
  34991. * @param iterations the number of iterations.
  34992. * @param func the function to run each iteration
  34993. * @param successCallback the callback that will be called upon succesful execution
  34994. * @param offset starting offset.
  34995. */
  34996. constructor(
  34997. /**
  34998. * Defines the number of iterations for the loop
  34999. */
  35000. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35001. /**
  35002. * Execute the next iteration. Must be called after the last iteration was finished.
  35003. */
  35004. executeNext(): void;
  35005. /**
  35006. * Break the loop and run the success callback.
  35007. */
  35008. breakLoop(): void;
  35009. /**
  35010. * Create and run an async loop.
  35011. * @param iterations the number of iterations.
  35012. * @param fn the function to run each iteration
  35013. * @param successCallback the callback that will be called upon succesful execution
  35014. * @param offset starting offset.
  35015. * @returns the created async loop object
  35016. */
  35017. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35018. /**
  35019. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35020. * @param iterations total number of iterations
  35021. * @param syncedIterations number of synchronous iterations in each async iteration.
  35022. * @param fn the function to call each iteration.
  35023. * @param callback a success call back that will be called when iterating stops.
  35024. * @param breakFunction a break condition (optional)
  35025. * @param timeout timeout settings for the setTimeout function. default - 0.
  35026. * @returns the created async loop object
  35027. */
  35028. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /**
  35033. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35034. * The underlying implementation relies on an associative array to ensure the best performances.
  35035. * The value can be anything including 'null' but except 'undefined'
  35036. */
  35037. export class StringDictionary<T> {
  35038. /**
  35039. * This will clear this dictionary and copy the content from the 'source' one.
  35040. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35041. * @param source the dictionary to take the content from and copy to this dictionary
  35042. */
  35043. copyFrom(source: StringDictionary<T>): void;
  35044. /**
  35045. * Get a value based from its key
  35046. * @param key the given key to get the matching value from
  35047. * @return the value if found, otherwise undefined is returned
  35048. */
  35049. get(key: string): T | undefined;
  35050. /**
  35051. * Get a value from its key or add it if it doesn't exist.
  35052. * This method will ensure you that a given key/data will be present in the dictionary.
  35053. * @param key the given key to get the matching value from
  35054. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35055. * The factory will only be invoked if there's no data for the given key.
  35056. * @return the value corresponding to the key.
  35057. */
  35058. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35059. /**
  35060. * Get a value from its key if present in the dictionary otherwise add it
  35061. * @param key the key to get the value from
  35062. * @param val if there's no such key/value pair in the dictionary add it with this value
  35063. * @return the value corresponding to the key
  35064. */
  35065. getOrAdd(key: string, val: T): T;
  35066. /**
  35067. * Check if there's a given key in the dictionary
  35068. * @param key the key to check for
  35069. * @return true if the key is present, false otherwise
  35070. */
  35071. contains(key: string): boolean;
  35072. /**
  35073. * Add a new key and its corresponding value
  35074. * @param key the key to add
  35075. * @param value the value corresponding to the key
  35076. * @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
  35077. */
  35078. add(key: string, value: T): boolean;
  35079. /**
  35080. * Update a specific value associated to a key
  35081. * @param key defines the key to use
  35082. * @param value defines the value to store
  35083. * @returns true if the value was updated (or false if the key was not found)
  35084. */
  35085. set(key: string, value: T): boolean;
  35086. /**
  35087. * Get the element of the given key and remove it from the dictionary
  35088. * @param key defines the key to search
  35089. * @returns the value associated with the key or null if not found
  35090. */
  35091. getAndRemove(key: string): Nullable<T>;
  35092. /**
  35093. * Remove a key/value from the dictionary.
  35094. * @param key the key to remove
  35095. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35096. */
  35097. remove(key: string): boolean;
  35098. /**
  35099. * Clear the whole content of the dictionary
  35100. */
  35101. clear(): void;
  35102. /**
  35103. * Gets the current count
  35104. */
  35105. get count(): number;
  35106. /**
  35107. * Execute a callback on each key/val of the dictionary.
  35108. * Note that you can remove any element in this dictionary in the callback implementation
  35109. * @param callback the callback to execute on a given key/value pair
  35110. */
  35111. forEach(callback: (key: string, val: T) => void): void;
  35112. /**
  35113. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35114. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35115. * Note that you can remove any element in this dictionary in the callback implementation
  35116. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35117. * @returns the first item
  35118. */
  35119. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35120. private _count;
  35121. private _data;
  35122. }
  35123. }
  35124. declare module BABYLON {
  35125. /** @hidden */
  35126. export interface ICollisionCoordinator {
  35127. createCollider(): Collider;
  35128. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35129. init(scene: Scene): void;
  35130. }
  35131. /** @hidden */
  35132. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35133. private _scene;
  35134. private _scaledPosition;
  35135. private _scaledVelocity;
  35136. private _finalPosition;
  35137. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35138. createCollider(): Collider;
  35139. init(scene: Scene): void;
  35140. private _collideWithWorld;
  35141. }
  35142. }
  35143. declare module BABYLON {
  35144. /**
  35145. * Class used to manage all inputs for the scene.
  35146. */
  35147. export class InputManager {
  35148. /** The distance in pixel that you have to move to prevent some events */
  35149. static DragMovementThreshold: number;
  35150. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35151. static LongPressDelay: number;
  35152. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35153. static DoubleClickDelay: number;
  35154. /** If you need to check double click without raising a single click at first click, enable this flag */
  35155. static ExclusiveDoubleClickMode: boolean;
  35156. private _wheelEventName;
  35157. private _onPointerMove;
  35158. private _onPointerDown;
  35159. private _onPointerUp;
  35160. private _initClickEvent;
  35161. private _initActionManager;
  35162. private _delayedSimpleClick;
  35163. private _delayedSimpleClickTimeout;
  35164. private _previousDelayedSimpleClickTimeout;
  35165. private _meshPickProceed;
  35166. private _previousButtonPressed;
  35167. private _currentPickResult;
  35168. private _previousPickResult;
  35169. private _totalPointersPressed;
  35170. private _doubleClickOccured;
  35171. private _pointerOverMesh;
  35172. private _pickedDownMesh;
  35173. private _pickedUpMesh;
  35174. private _pointerX;
  35175. private _pointerY;
  35176. private _unTranslatedPointerX;
  35177. private _unTranslatedPointerY;
  35178. private _startingPointerPosition;
  35179. private _previousStartingPointerPosition;
  35180. private _startingPointerTime;
  35181. private _previousStartingPointerTime;
  35182. private _pointerCaptures;
  35183. private _onKeyDown;
  35184. private _onKeyUp;
  35185. private _onCanvasFocusObserver;
  35186. private _onCanvasBlurObserver;
  35187. private _scene;
  35188. /**
  35189. * Creates a new InputManager
  35190. * @param scene defines the hosting scene
  35191. */
  35192. constructor(scene: Scene);
  35193. /**
  35194. * Gets the mesh that is currently under the pointer
  35195. */
  35196. get meshUnderPointer(): Nullable<AbstractMesh>;
  35197. /**
  35198. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35199. */
  35200. get unTranslatedPointer(): Vector2;
  35201. /**
  35202. * Gets or sets the current on-screen X position of the pointer
  35203. */
  35204. get pointerX(): number;
  35205. set pointerX(value: number);
  35206. /**
  35207. * Gets or sets the current on-screen Y position of the pointer
  35208. */
  35209. get pointerY(): number;
  35210. set pointerY(value: number);
  35211. private _updatePointerPosition;
  35212. private _processPointerMove;
  35213. private _setRayOnPointerInfo;
  35214. private _checkPrePointerObservable;
  35215. /**
  35216. * Use this method to simulate a pointer move on a mesh
  35217. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35218. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35219. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35220. */
  35221. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35222. /**
  35223. * Use this method to simulate a pointer down on a mesh
  35224. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35225. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35226. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35227. */
  35228. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35229. private _processPointerDown;
  35230. /** @hidden */
  35231. _isPointerSwiping(): boolean;
  35232. /**
  35233. * Use this method to simulate a pointer up on a mesh
  35234. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35235. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35236. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35237. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35238. */
  35239. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35240. private _processPointerUp;
  35241. /**
  35242. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35243. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35244. * @returns true if the pointer was captured
  35245. */
  35246. isPointerCaptured(pointerId?: number): boolean;
  35247. /**
  35248. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35249. * @param attachUp defines if you want to attach events to pointerup
  35250. * @param attachDown defines if you want to attach events to pointerdown
  35251. * @param attachMove defines if you want to attach events to pointermove
  35252. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35253. */
  35254. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35255. /**
  35256. * Detaches all event handlers
  35257. */
  35258. detachControl(): void;
  35259. /**
  35260. * Force the value of meshUnderPointer
  35261. * @param mesh defines the mesh to use
  35262. */
  35263. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35264. /**
  35265. * Gets the mesh under the pointer
  35266. * @returns a Mesh or null if no mesh is under the pointer
  35267. */
  35268. getPointerOverMesh(): Nullable<AbstractMesh>;
  35269. }
  35270. }
  35271. declare module BABYLON {
  35272. /**
  35273. * Helper class used to generate session unique ID
  35274. */
  35275. export class UniqueIdGenerator {
  35276. private static _UniqueIdCounter;
  35277. /**
  35278. * Gets an unique (relatively to the current scene) Id
  35279. */
  35280. static get UniqueId(): number;
  35281. }
  35282. }
  35283. declare module BABYLON {
  35284. /**
  35285. * This class defines the direct association between an animation and a target
  35286. */
  35287. export class TargetedAnimation {
  35288. /**
  35289. * Animation to perform
  35290. */
  35291. animation: Animation;
  35292. /**
  35293. * Target to animate
  35294. */
  35295. target: any;
  35296. /**
  35297. * Serialize the object
  35298. * @returns the JSON object representing the current entity
  35299. */
  35300. serialize(): any;
  35301. }
  35302. /**
  35303. * Use this class to create coordinated animations on multiple targets
  35304. */
  35305. export class AnimationGroup implements IDisposable {
  35306. /** The name of the animation group */
  35307. name: string;
  35308. private _scene;
  35309. private _targetedAnimations;
  35310. private _animatables;
  35311. private _from;
  35312. private _to;
  35313. private _isStarted;
  35314. private _isPaused;
  35315. private _speedRatio;
  35316. private _loopAnimation;
  35317. private _isAdditive;
  35318. /**
  35319. * Gets or sets the unique id of the node
  35320. */
  35321. uniqueId: number;
  35322. /**
  35323. * This observable will notify when one animation have ended
  35324. */
  35325. onAnimationEndObservable: Observable<TargetedAnimation>;
  35326. /**
  35327. * Observer raised when one animation loops
  35328. */
  35329. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35330. /**
  35331. * Observer raised when all animations have looped
  35332. */
  35333. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35334. /**
  35335. * This observable will notify when all animations have ended.
  35336. */
  35337. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35338. /**
  35339. * This observable will notify when all animations have paused.
  35340. */
  35341. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35342. /**
  35343. * This observable will notify when all animations are playing.
  35344. */
  35345. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35346. /**
  35347. * Gets the first frame
  35348. */
  35349. get from(): number;
  35350. /**
  35351. * Gets the last frame
  35352. */
  35353. get to(): number;
  35354. /**
  35355. * Define if the animations are started
  35356. */
  35357. get isStarted(): boolean;
  35358. /**
  35359. * Gets a value indicating that the current group is playing
  35360. */
  35361. get isPlaying(): boolean;
  35362. /**
  35363. * Gets or sets the speed ratio to use for all animations
  35364. */
  35365. get speedRatio(): number;
  35366. /**
  35367. * Gets or sets the speed ratio to use for all animations
  35368. */
  35369. set speedRatio(value: number);
  35370. /**
  35371. * Gets or sets if all animations should loop or not
  35372. */
  35373. get loopAnimation(): boolean;
  35374. set loopAnimation(value: boolean);
  35375. /**
  35376. * Gets or sets if all animations should be evaluated additively
  35377. */
  35378. get isAdditive(): boolean;
  35379. set isAdditive(value: boolean);
  35380. /**
  35381. * Gets the targeted animations for this animation group
  35382. */
  35383. get targetedAnimations(): Array<TargetedAnimation>;
  35384. /**
  35385. * returning the list of animatables controlled by this animation group.
  35386. */
  35387. get animatables(): Array<Animatable>;
  35388. /**
  35389. * Instantiates a new Animation Group.
  35390. * This helps managing several animations at once.
  35391. * @see http://doc.babylonjs.com/how_to/group
  35392. * @param name Defines the name of the group
  35393. * @param scene Defines the scene the group belongs to
  35394. */
  35395. constructor(
  35396. /** The name of the animation group */
  35397. name: string, scene?: Nullable<Scene>);
  35398. /**
  35399. * Add an animation (with its target) in the group
  35400. * @param animation defines the animation we want to add
  35401. * @param target defines the target of the animation
  35402. * @returns the TargetedAnimation object
  35403. */
  35404. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35405. /**
  35406. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35407. * It can add constant keys at begin or end
  35408. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35409. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35410. * @returns the animation group
  35411. */
  35412. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35413. private _animationLoopCount;
  35414. private _animationLoopFlags;
  35415. private _processLoop;
  35416. /**
  35417. * Start all animations on given targets
  35418. * @param loop defines if animations must loop
  35419. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35420. * @param from defines the from key (optional)
  35421. * @param to defines the to key (optional)
  35422. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35423. * @returns the current animation group
  35424. */
  35425. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35426. /**
  35427. * Pause all animations
  35428. * @returns the animation group
  35429. */
  35430. pause(): AnimationGroup;
  35431. /**
  35432. * Play all animations to initial state
  35433. * This function will start() the animations if they were not started or will restart() them if they were paused
  35434. * @param loop defines if animations must loop
  35435. * @returns the animation group
  35436. */
  35437. play(loop?: boolean): AnimationGroup;
  35438. /**
  35439. * Reset all animations to initial state
  35440. * @returns the animation group
  35441. */
  35442. reset(): AnimationGroup;
  35443. /**
  35444. * Restart animations from key 0
  35445. * @returns the animation group
  35446. */
  35447. restart(): AnimationGroup;
  35448. /**
  35449. * Stop all animations
  35450. * @returns the animation group
  35451. */
  35452. stop(): AnimationGroup;
  35453. /**
  35454. * Set animation weight for all animatables
  35455. * @param weight defines the weight to use
  35456. * @return the animationGroup
  35457. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35458. */
  35459. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35460. /**
  35461. * Synchronize and normalize all animatables with a source animatable
  35462. * @param root defines the root animatable to synchronize with
  35463. * @return the animationGroup
  35464. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35465. */
  35466. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35467. /**
  35468. * Goes to a specific frame in this animation group
  35469. * @param frame the frame number to go to
  35470. * @return the animationGroup
  35471. */
  35472. goToFrame(frame: number): AnimationGroup;
  35473. /**
  35474. * Dispose all associated resources
  35475. */
  35476. dispose(): void;
  35477. private _checkAnimationGroupEnded;
  35478. /**
  35479. * Clone the current animation group and returns a copy
  35480. * @param newName defines the name of the new group
  35481. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35482. * @returns the new aniamtion group
  35483. */
  35484. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35485. /**
  35486. * Serializes the animationGroup to an object
  35487. * @returns Serialized object
  35488. */
  35489. serialize(): any;
  35490. /**
  35491. * Returns a new AnimationGroup object parsed from the source provided.
  35492. * @param parsedAnimationGroup defines the source
  35493. * @param scene defines the scene that will receive the animationGroup
  35494. * @returns a new AnimationGroup
  35495. */
  35496. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35497. /**
  35498. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35499. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35500. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35501. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35502. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35503. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35504. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35505. */
  35506. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35507. /**
  35508. * Returns the string "AnimationGroup"
  35509. * @returns "AnimationGroup"
  35510. */
  35511. getClassName(): string;
  35512. /**
  35513. * Creates a detailled string about the object
  35514. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35515. * @returns a string representing the object
  35516. */
  35517. toString(fullDetails?: boolean): string;
  35518. }
  35519. }
  35520. declare module BABYLON {
  35521. /**
  35522. * Define an interface for all classes that will hold resources
  35523. */
  35524. export interface IDisposable {
  35525. /**
  35526. * Releases all held resources
  35527. */
  35528. dispose(): void;
  35529. }
  35530. /** Interface defining initialization parameters for Scene class */
  35531. export interface SceneOptions {
  35532. /**
  35533. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35534. * It will improve performance when the number of geometries becomes important.
  35535. */
  35536. useGeometryUniqueIdsMap?: boolean;
  35537. /**
  35538. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35539. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35540. */
  35541. useMaterialMeshMap?: boolean;
  35542. /**
  35543. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35544. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35545. */
  35546. useClonedMeshMap?: boolean;
  35547. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35548. virtual?: boolean;
  35549. }
  35550. /**
  35551. * Represents a scene to be rendered by the engine.
  35552. * @see http://doc.babylonjs.com/features/scene
  35553. */
  35554. export class Scene extends AbstractScene implements IAnimatable {
  35555. /** The fog is deactivated */
  35556. static readonly FOGMODE_NONE: number;
  35557. /** The fog density is following an exponential function */
  35558. static readonly FOGMODE_EXP: number;
  35559. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35560. static readonly FOGMODE_EXP2: number;
  35561. /** The fog density is following a linear function. */
  35562. static readonly FOGMODE_LINEAR: number;
  35563. /**
  35564. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35566. */
  35567. static MinDeltaTime: number;
  35568. /**
  35569. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35571. */
  35572. static MaxDeltaTime: number;
  35573. /**
  35574. * Factory used to create the default material.
  35575. * @param name The name of the material to create
  35576. * @param scene The scene to create the material for
  35577. * @returns The default material
  35578. */
  35579. static DefaultMaterialFactory(scene: Scene): Material;
  35580. /**
  35581. * Factory used to create the a collision coordinator.
  35582. * @returns The collision coordinator
  35583. */
  35584. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35585. /** @hidden */
  35586. _inputManager: InputManager;
  35587. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35588. cameraToUseForPointers: Nullable<Camera>;
  35589. /** @hidden */
  35590. readonly _isScene: boolean;
  35591. /** @hidden */
  35592. _blockEntityCollection: boolean;
  35593. /**
  35594. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35595. */
  35596. autoClear: boolean;
  35597. /**
  35598. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35599. */
  35600. autoClearDepthAndStencil: boolean;
  35601. /**
  35602. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35603. */
  35604. clearColor: Color4;
  35605. /**
  35606. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35607. */
  35608. ambientColor: Color3;
  35609. /**
  35610. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35611. * It should only be one of the following (if not the default embedded one):
  35612. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35613. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35614. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35615. * The material properties need to be setup according to the type of texture in use.
  35616. */
  35617. environmentBRDFTexture: BaseTexture;
  35618. /** @hidden */
  35619. protected _environmentTexture: Nullable<BaseTexture>;
  35620. /**
  35621. * Texture used in all pbr material as the reflection texture.
  35622. * As in the majority of the scene they are the same (exception for multi room and so on),
  35623. * this is easier to reference from here than from all the materials.
  35624. */
  35625. get environmentTexture(): Nullable<BaseTexture>;
  35626. /**
  35627. * Texture used in all pbr material as the reflection texture.
  35628. * As in the majority of the scene they are the same (exception for multi room and so on),
  35629. * this is easier to set here than in all the materials.
  35630. */
  35631. set environmentTexture(value: Nullable<BaseTexture>);
  35632. /** @hidden */
  35633. protected _environmentIntensity: number;
  35634. /**
  35635. * Intensity of the environment in all pbr material.
  35636. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35637. * As in the majority of the scene they are the same (exception for multi room and so on),
  35638. * this is easier to reference from here than from all the materials.
  35639. */
  35640. get environmentIntensity(): number;
  35641. /**
  35642. * Intensity of the environment in all pbr material.
  35643. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35644. * As in the majority of the scene they are the same (exception for multi room and so on),
  35645. * this is easier to set here than in all the materials.
  35646. */
  35647. set environmentIntensity(value: number);
  35648. /** @hidden */
  35649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35650. /**
  35651. * Default image processing configuration used either in the rendering
  35652. * Forward main pass or through the imageProcessingPostProcess if present.
  35653. * As in the majority of the scene they are the same (exception for multi camera),
  35654. * this is easier to reference from here than from all the materials and post process.
  35655. *
  35656. * No setter as we it is a shared configuration, you can set the values instead.
  35657. */
  35658. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35659. private _forceWireframe;
  35660. /**
  35661. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35662. */
  35663. set forceWireframe(value: boolean);
  35664. get forceWireframe(): boolean;
  35665. private _skipFrustumClipping;
  35666. /**
  35667. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35668. */
  35669. set skipFrustumClipping(value: boolean);
  35670. get skipFrustumClipping(): boolean;
  35671. private _forcePointsCloud;
  35672. /**
  35673. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35674. */
  35675. set forcePointsCloud(value: boolean);
  35676. get forcePointsCloud(): boolean;
  35677. /**
  35678. * Gets or sets the active clipplane 1
  35679. */
  35680. clipPlane: Nullable<Plane>;
  35681. /**
  35682. * Gets or sets the active clipplane 2
  35683. */
  35684. clipPlane2: Nullable<Plane>;
  35685. /**
  35686. * Gets or sets the active clipplane 3
  35687. */
  35688. clipPlane3: Nullable<Plane>;
  35689. /**
  35690. * Gets or sets the active clipplane 4
  35691. */
  35692. clipPlane4: Nullable<Plane>;
  35693. /**
  35694. * Gets or sets the active clipplane 5
  35695. */
  35696. clipPlane5: Nullable<Plane>;
  35697. /**
  35698. * Gets or sets the active clipplane 6
  35699. */
  35700. clipPlane6: Nullable<Plane>;
  35701. /**
  35702. * Gets or sets a boolean indicating if animations are enabled
  35703. */
  35704. animationsEnabled: boolean;
  35705. private _animationPropertiesOverride;
  35706. /**
  35707. * Gets or sets the animation properties override
  35708. */
  35709. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35710. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35711. /**
  35712. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35713. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35714. */
  35715. useConstantAnimationDeltaTime: boolean;
  35716. /**
  35717. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35718. * Please note that it requires to run a ray cast through the scene on every frame
  35719. */
  35720. constantlyUpdateMeshUnderPointer: boolean;
  35721. /**
  35722. * Defines the HTML cursor to use when hovering over interactive elements
  35723. */
  35724. hoverCursor: string;
  35725. /**
  35726. * Defines the HTML default cursor to use (empty by default)
  35727. */
  35728. defaultCursor: string;
  35729. /**
  35730. * Defines whether cursors are handled by the scene.
  35731. */
  35732. doNotHandleCursors: boolean;
  35733. /**
  35734. * This is used to call preventDefault() on pointer down
  35735. * in order to block unwanted artifacts like system double clicks
  35736. */
  35737. preventDefaultOnPointerDown: boolean;
  35738. /**
  35739. * This is used to call preventDefault() on pointer up
  35740. * in order to block unwanted artifacts like system double clicks
  35741. */
  35742. preventDefaultOnPointerUp: boolean;
  35743. /**
  35744. * Gets or sets user defined metadata
  35745. */
  35746. metadata: any;
  35747. /**
  35748. * For internal use only. Please do not use.
  35749. */
  35750. reservedDataStore: any;
  35751. /**
  35752. * Gets the name of the plugin used to load this scene (null by default)
  35753. */
  35754. loadingPluginName: string;
  35755. /**
  35756. * Use this array to add regular expressions used to disable offline support for specific urls
  35757. */
  35758. disableOfflineSupportExceptionRules: RegExp[];
  35759. /**
  35760. * An event triggered when the scene is disposed.
  35761. */
  35762. onDisposeObservable: Observable<Scene>;
  35763. private _onDisposeObserver;
  35764. /** Sets a function to be executed when this scene is disposed. */
  35765. set onDispose(callback: () => void);
  35766. /**
  35767. * An event triggered before rendering the scene (right after animations and physics)
  35768. */
  35769. onBeforeRenderObservable: Observable<Scene>;
  35770. private _onBeforeRenderObserver;
  35771. /** Sets a function to be executed before rendering this scene */
  35772. set beforeRender(callback: Nullable<() => void>);
  35773. /**
  35774. * An event triggered after rendering the scene
  35775. */
  35776. onAfterRenderObservable: Observable<Scene>;
  35777. /**
  35778. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35779. */
  35780. onAfterRenderCameraObservable: Observable<Camera>;
  35781. private _onAfterRenderObserver;
  35782. /** Sets a function to be executed after rendering this scene */
  35783. set afterRender(callback: Nullable<() => void>);
  35784. /**
  35785. * An event triggered before animating the scene
  35786. */
  35787. onBeforeAnimationsObservable: Observable<Scene>;
  35788. /**
  35789. * An event triggered after animations processing
  35790. */
  35791. onAfterAnimationsObservable: Observable<Scene>;
  35792. /**
  35793. * An event triggered before draw calls are ready to be sent
  35794. */
  35795. onBeforeDrawPhaseObservable: Observable<Scene>;
  35796. /**
  35797. * An event triggered after draw calls have been sent
  35798. */
  35799. onAfterDrawPhaseObservable: Observable<Scene>;
  35800. /**
  35801. * An event triggered when the scene is ready
  35802. */
  35803. onReadyObservable: Observable<Scene>;
  35804. /**
  35805. * An event triggered before rendering a camera
  35806. */
  35807. onBeforeCameraRenderObservable: Observable<Camera>;
  35808. private _onBeforeCameraRenderObserver;
  35809. /** Sets a function to be executed before rendering a camera*/
  35810. set beforeCameraRender(callback: () => void);
  35811. /**
  35812. * An event triggered after rendering a camera
  35813. */
  35814. onAfterCameraRenderObservable: Observable<Camera>;
  35815. private _onAfterCameraRenderObserver;
  35816. /** Sets a function to be executed after rendering a camera*/
  35817. set afterCameraRender(callback: () => void);
  35818. /**
  35819. * An event triggered when active meshes evaluation is about to start
  35820. */
  35821. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35822. /**
  35823. * An event triggered when active meshes evaluation is done
  35824. */
  35825. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35826. /**
  35827. * An event triggered when particles rendering is about to start
  35828. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35829. */
  35830. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35831. /**
  35832. * An event triggered when particles rendering is done
  35833. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35834. */
  35835. onAfterParticlesRenderingObservable: Observable<Scene>;
  35836. /**
  35837. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35838. */
  35839. onDataLoadedObservable: Observable<Scene>;
  35840. /**
  35841. * An event triggered when a camera is created
  35842. */
  35843. onNewCameraAddedObservable: Observable<Camera>;
  35844. /**
  35845. * An event triggered when a camera is removed
  35846. */
  35847. onCameraRemovedObservable: Observable<Camera>;
  35848. /**
  35849. * An event triggered when a light is created
  35850. */
  35851. onNewLightAddedObservable: Observable<Light>;
  35852. /**
  35853. * An event triggered when a light is removed
  35854. */
  35855. onLightRemovedObservable: Observable<Light>;
  35856. /**
  35857. * An event triggered when a geometry is created
  35858. */
  35859. onNewGeometryAddedObservable: Observable<Geometry>;
  35860. /**
  35861. * An event triggered when a geometry is removed
  35862. */
  35863. onGeometryRemovedObservable: Observable<Geometry>;
  35864. /**
  35865. * An event triggered when a transform node is created
  35866. */
  35867. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35868. /**
  35869. * An event triggered when a transform node is removed
  35870. */
  35871. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35872. /**
  35873. * An event triggered when a mesh is created
  35874. */
  35875. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35876. /**
  35877. * An event triggered when a mesh is removed
  35878. */
  35879. onMeshRemovedObservable: Observable<AbstractMesh>;
  35880. /**
  35881. * An event triggered when a skeleton is created
  35882. */
  35883. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35884. /**
  35885. * An event triggered when a skeleton is removed
  35886. */
  35887. onSkeletonRemovedObservable: Observable<Skeleton>;
  35888. /**
  35889. * An event triggered when a material is created
  35890. */
  35891. onNewMaterialAddedObservable: Observable<Material>;
  35892. /**
  35893. * An event triggered when a material is removed
  35894. */
  35895. onMaterialRemovedObservable: Observable<Material>;
  35896. /**
  35897. * An event triggered when a texture is created
  35898. */
  35899. onNewTextureAddedObservable: Observable<BaseTexture>;
  35900. /**
  35901. * An event triggered when a texture is removed
  35902. */
  35903. onTextureRemovedObservable: Observable<BaseTexture>;
  35904. /**
  35905. * An event triggered when render targets are about to be rendered
  35906. * Can happen multiple times per frame.
  35907. */
  35908. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35909. /**
  35910. * An event triggered when render targets were rendered.
  35911. * Can happen multiple times per frame.
  35912. */
  35913. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35914. /**
  35915. * An event triggered before calculating deterministic simulation step
  35916. */
  35917. onBeforeStepObservable: Observable<Scene>;
  35918. /**
  35919. * An event triggered after calculating deterministic simulation step
  35920. */
  35921. onAfterStepObservable: Observable<Scene>;
  35922. /**
  35923. * An event triggered when the activeCamera property is updated
  35924. */
  35925. onActiveCameraChanged: Observable<Scene>;
  35926. /**
  35927. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35928. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35929. * 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)
  35930. */
  35931. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35932. /**
  35933. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35934. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35935. * 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)
  35936. */
  35937. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35938. /**
  35939. * This Observable will when a mesh has been imported into the scene.
  35940. */
  35941. onMeshImportedObservable: Observable<AbstractMesh>;
  35942. /**
  35943. * This Observable will when an animation file has been imported into the scene.
  35944. */
  35945. onAnimationFileImportedObservable: Observable<Scene>;
  35946. /**
  35947. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35948. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35949. */
  35950. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35951. /** @hidden */
  35952. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35953. /**
  35954. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35955. */
  35956. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35957. /**
  35958. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35959. */
  35960. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35961. /**
  35962. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35963. */
  35964. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35965. /** Callback called when a pointer move is detected */
  35966. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35967. /** Callback called when a pointer down is detected */
  35968. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35969. /** Callback called when a pointer up is detected */
  35970. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35971. /** Callback called when a pointer pick is detected */
  35972. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35973. /**
  35974. * 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).
  35975. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35976. */
  35977. onPrePointerObservable: Observable<PointerInfoPre>;
  35978. /**
  35979. * Observable event triggered each time an input event is received from the rendering canvas
  35980. */
  35981. onPointerObservable: Observable<PointerInfo>;
  35982. /**
  35983. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35984. */
  35985. get unTranslatedPointer(): Vector2;
  35986. /**
  35987. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35988. */
  35989. static get DragMovementThreshold(): number;
  35990. static set DragMovementThreshold(value: number);
  35991. /**
  35992. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35993. */
  35994. static get LongPressDelay(): number;
  35995. static set LongPressDelay(value: number);
  35996. /**
  35997. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35998. */
  35999. static get DoubleClickDelay(): number;
  36000. static set DoubleClickDelay(value: number);
  36001. /** If you need to check double click without raising a single click at first click, enable this flag */
  36002. static get ExclusiveDoubleClickMode(): boolean;
  36003. static set ExclusiveDoubleClickMode(value: boolean);
  36004. /** @hidden */
  36005. _mirroredCameraPosition: Nullable<Vector3>;
  36006. /**
  36007. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36008. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36009. */
  36010. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36011. /**
  36012. * Observable event triggered each time an keyboard event is received from the hosting window
  36013. */
  36014. onKeyboardObservable: Observable<KeyboardInfo>;
  36015. private _useRightHandedSystem;
  36016. /**
  36017. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36018. */
  36019. set useRightHandedSystem(value: boolean);
  36020. get useRightHandedSystem(): boolean;
  36021. private _timeAccumulator;
  36022. private _currentStepId;
  36023. private _currentInternalStep;
  36024. /**
  36025. * Sets the step Id used by deterministic lock step
  36026. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36027. * @param newStepId defines the step Id
  36028. */
  36029. setStepId(newStepId: number): void;
  36030. /**
  36031. * Gets the step Id used by deterministic lock step
  36032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36033. * @returns the step Id
  36034. */
  36035. getStepId(): number;
  36036. /**
  36037. * Gets the internal step used by deterministic lock step
  36038. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36039. * @returns the internal step
  36040. */
  36041. getInternalStep(): number;
  36042. private _fogEnabled;
  36043. /**
  36044. * Gets or sets a boolean indicating if fog is enabled on this scene
  36045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36046. * (Default is true)
  36047. */
  36048. set fogEnabled(value: boolean);
  36049. get fogEnabled(): boolean;
  36050. private _fogMode;
  36051. /**
  36052. * Gets or sets the fog mode to use
  36053. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36054. * | mode | value |
  36055. * | --- | --- |
  36056. * | FOGMODE_NONE | 0 |
  36057. * | FOGMODE_EXP | 1 |
  36058. * | FOGMODE_EXP2 | 2 |
  36059. * | FOGMODE_LINEAR | 3 |
  36060. */
  36061. set fogMode(value: number);
  36062. get fogMode(): number;
  36063. /**
  36064. * Gets or sets the fog color to use
  36065. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36066. * (Default is Color3(0.2, 0.2, 0.3))
  36067. */
  36068. fogColor: Color3;
  36069. /**
  36070. * Gets or sets the fog density to use
  36071. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36072. * (Default is 0.1)
  36073. */
  36074. fogDensity: number;
  36075. /**
  36076. * Gets or sets the fog start distance to use
  36077. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36078. * (Default is 0)
  36079. */
  36080. fogStart: number;
  36081. /**
  36082. * Gets or sets the fog end distance to use
  36083. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36084. * (Default is 1000)
  36085. */
  36086. fogEnd: number;
  36087. private _shadowsEnabled;
  36088. /**
  36089. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36090. */
  36091. set shadowsEnabled(value: boolean);
  36092. get shadowsEnabled(): boolean;
  36093. private _lightsEnabled;
  36094. /**
  36095. * Gets or sets a boolean indicating if lights are enabled on this scene
  36096. */
  36097. set lightsEnabled(value: boolean);
  36098. get lightsEnabled(): boolean;
  36099. /** All of the active cameras added to this scene. */
  36100. activeCameras: Camera[];
  36101. /** @hidden */
  36102. _activeCamera: Nullable<Camera>;
  36103. /** Gets or sets the current active camera */
  36104. get activeCamera(): Nullable<Camera>;
  36105. set activeCamera(value: Nullable<Camera>);
  36106. private _defaultMaterial;
  36107. /** The default material used on meshes when no material is affected */
  36108. get defaultMaterial(): Material;
  36109. /** The default material used on meshes when no material is affected */
  36110. set defaultMaterial(value: Material);
  36111. private _texturesEnabled;
  36112. /**
  36113. * Gets or sets a boolean indicating if textures are enabled on this scene
  36114. */
  36115. set texturesEnabled(value: boolean);
  36116. get texturesEnabled(): boolean;
  36117. /**
  36118. * Gets or sets a boolean indicating if particles are enabled on this scene
  36119. */
  36120. particlesEnabled: boolean;
  36121. /**
  36122. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36123. */
  36124. spritesEnabled: boolean;
  36125. private _skeletonsEnabled;
  36126. /**
  36127. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36128. */
  36129. set skeletonsEnabled(value: boolean);
  36130. get skeletonsEnabled(): boolean;
  36131. /**
  36132. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36133. */
  36134. lensFlaresEnabled: boolean;
  36135. /**
  36136. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36137. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36138. */
  36139. collisionsEnabled: boolean;
  36140. private _collisionCoordinator;
  36141. /** @hidden */
  36142. get collisionCoordinator(): ICollisionCoordinator;
  36143. /**
  36144. * Defines the gravity applied to this scene (used only for collisions)
  36145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36146. */
  36147. gravity: Vector3;
  36148. /**
  36149. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36150. */
  36151. postProcessesEnabled: boolean;
  36152. /**
  36153. * The list of postprocesses added to the scene
  36154. */
  36155. postProcesses: PostProcess[];
  36156. /**
  36157. * Gets the current postprocess manager
  36158. */
  36159. postProcessManager: PostProcessManager;
  36160. /**
  36161. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36162. */
  36163. renderTargetsEnabled: boolean;
  36164. /**
  36165. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36166. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36167. */
  36168. dumpNextRenderTargets: boolean;
  36169. /**
  36170. * The list of user defined render targets added to the scene
  36171. */
  36172. customRenderTargets: RenderTargetTexture[];
  36173. /**
  36174. * Defines if texture loading must be delayed
  36175. * If true, textures will only be loaded when they need to be rendered
  36176. */
  36177. useDelayedTextureLoading: boolean;
  36178. /**
  36179. * Gets the list of meshes imported to the scene through SceneLoader
  36180. */
  36181. importedMeshesFiles: String[];
  36182. /**
  36183. * Gets or sets a boolean indicating if probes are enabled on this scene
  36184. */
  36185. probesEnabled: boolean;
  36186. /**
  36187. * Gets or sets the current offline provider to use to store scene data
  36188. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36189. */
  36190. offlineProvider: IOfflineProvider;
  36191. /**
  36192. * Gets or sets the action manager associated with the scene
  36193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36194. */
  36195. actionManager: AbstractActionManager;
  36196. private _meshesForIntersections;
  36197. /**
  36198. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36199. */
  36200. proceduralTexturesEnabled: boolean;
  36201. private _engine;
  36202. private _totalVertices;
  36203. /** @hidden */
  36204. _activeIndices: PerfCounter;
  36205. /** @hidden */
  36206. _activeParticles: PerfCounter;
  36207. /** @hidden */
  36208. _activeBones: PerfCounter;
  36209. private _animationRatio;
  36210. /** @hidden */
  36211. _animationTimeLast: number;
  36212. /** @hidden */
  36213. _animationTime: number;
  36214. /**
  36215. * Gets or sets a general scale for animation speed
  36216. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36217. */
  36218. animationTimeScale: number;
  36219. /** @hidden */
  36220. _cachedMaterial: Nullable<Material>;
  36221. /** @hidden */
  36222. _cachedEffect: Nullable<Effect>;
  36223. /** @hidden */
  36224. _cachedVisibility: Nullable<number>;
  36225. private _renderId;
  36226. private _frameId;
  36227. private _executeWhenReadyTimeoutId;
  36228. private _intermediateRendering;
  36229. private _viewUpdateFlag;
  36230. private _projectionUpdateFlag;
  36231. /** @hidden */
  36232. _toBeDisposed: Nullable<IDisposable>[];
  36233. private _activeRequests;
  36234. /** @hidden */
  36235. _pendingData: any[];
  36236. private _isDisposed;
  36237. /**
  36238. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36239. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36240. */
  36241. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36242. private _activeMeshes;
  36243. private _processedMaterials;
  36244. private _renderTargets;
  36245. /** @hidden */
  36246. _activeParticleSystems: SmartArray<IParticleSystem>;
  36247. private _activeSkeletons;
  36248. private _softwareSkinnedMeshes;
  36249. private _renderingManager;
  36250. /** @hidden */
  36251. _activeAnimatables: Animatable[];
  36252. private _transformMatrix;
  36253. private _sceneUbo;
  36254. /** @hidden */
  36255. _viewMatrix: Matrix;
  36256. private _projectionMatrix;
  36257. /** @hidden */
  36258. _forcedViewPosition: Nullable<Vector3>;
  36259. /** @hidden */
  36260. _frustumPlanes: Plane[];
  36261. /**
  36262. * Gets the list of frustum planes (built from the active camera)
  36263. */
  36264. get frustumPlanes(): Plane[];
  36265. /**
  36266. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36267. * This is useful if there are more lights that the maximum simulteanous authorized
  36268. */
  36269. requireLightSorting: boolean;
  36270. /** @hidden */
  36271. readonly useMaterialMeshMap: boolean;
  36272. /** @hidden */
  36273. readonly useClonedMeshMap: boolean;
  36274. private _externalData;
  36275. private _uid;
  36276. /**
  36277. * @hidden
  36278. * Backing store of defined scene components.
  36279. */
  36280. _components: ISceneComponent[];
  36281. /**
  36282. * @hidden
  36283. * Backing store of defined scene components.
  36284. */
  36285. _serializableComponents: ISceneSerializableComponent[];
  36286. /**
  36287. * List of components to register on the next registration step.
  36288. */
  36289. private _transientComponents;
  36290. /**
  36291. * Registers the transient components if needed.
  36292. */
  36293. private _registerTransientComponents;
  36294. /**
  36295. * @hidden
  36296. * Add a component to the scene.
  36297. * Note that the ccomponent could be registered on th next frame if this is called after
  36298. * the register component stage.
  36299. * @param component Defines the component to add to the scene
  36300. */
  36301. _addComponent(component: ISceneComponent): void;
  36302. /**
  36303. * @hidden
  36304. * Gets a component from the scene.
  36305. * @param name defines the name of the component to retrieve
  36306. * @returns the component or null if not present
  36307. */
  36308. _getComponent(name: string): Nullable<ISceneComponent>;
  36309. /**
  36310. * @hidden
  36311. * Defines the actions happening before camera updates.
  36312. */
  36313. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36314. /**
  36315. * @hidden
  36316. * Defines the actions happening before clear the canvas.
  36317. */
  36318. _beforeClearStage: Stage<SimpleStageAction>;
  36319. /**
  36320. * @hidden
  36321. * Defines the actions when collecting render targets for the frame.
  36322. */
  36323. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36324. /**
  36325. * @hidden
  36326. * Defines the actions happening for one camera in the frame.
  36327. */
  36328. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36329. /**
  36330. * @hidden
  36331. * Defines the actions happening during the per mesh ready checks.
  36332. */
  36333. _isReadyForMeshStage: Stage<MeshStageAction>;
  36334. /**
  36335. * @hidden
  36336. * Defines the actions happening before evaluate active mesh checks.
  36337. */
  36338. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36339. /**
  36340. * @hidden
  36341. * Defines the actions happening during the evaluate sub mesh checks.
  36342. */
  36343. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36344. /**
  36345. * @hidden
  36346. * Defines the actions happening during the active mesh stage.
  36347. */
  36348. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36349. /**
  36350. * @hidden
  36351. * Defines the actions happening during the per camera render target step.
  36352. */
  36353. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36354. /**
  36355. * @hidden
  36356. * Defines the actions happening just before the active camera is drawing.
  36357. */
  36358. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36359. /**
  36360. * @hidden
  36361. * Defines the actions happening just before a render target is drawing.
  36362. */
  36363. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36364. /**
  36365. * @hidden
  36366. * Defines the actions happening just before a rendering group is drawing.
  36367. */
  36368. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36369. /**
  36370. * @hidden
  36371. * Defines the actions happening just before a mesh is drawing.
  36372. */
  36373. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36374. /**
  36375. * @hidden
  36376. * Defines the actions happening just after a mesh has been drawn.
  36377. */
  36378. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36379. /**
  36380. * @hidden
  36381. * Defines the actions happening just after a rendering group has been drawn.
  36382. */
  36383. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36384. /**
  36385. * @hidden
  36386. * Defines the actions happening just after the active camera has been drawn.
  36387. */
  36388. _afterCameraDrawStage: Stage<CameraStageAction>;
  36389. /**
  36390. * @hidden
  36391. * Defines the actions happening just after a render target has been drawn.
  36392. */
  36393. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36394. /**
  36395. * @hidden
  36396. * Defines the actions happening just after rendering all cameras and computing intersections.
  36397. */
  36398. _afterRenderStage: Stage<SimpleStageAction>;
  36399. /**
  36400. * @hidden
  36401. * Defines the actions happening when a pointer move event happens.
  36402. */
  36403. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36404. /**
  36405. * @hidden
  36406. * Defines the actions happening when a pointer down event happens.
  36407. */
  36408. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36409. /**
  36410. * @hidden
  36411. * Defines the actions happening when a pointer up event happens.
  36412. */
  36413. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36414. /**
  36415. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36416. */
  36417. private geometriesByUniqueId;
  36418. /**
  36419. * Creates a new Scene
  36420. * @param engine defines the engine to use to render this scene
  36421. * @param options defines the scene options
  36422. */
  36423. constructor(engine: Engine, options?: SceneOptions);
  36424. /**
  36425. * Gets a string idenfifying the name of the class
  36426. * @returns "Scene" string
  36427. */
  36428. getClassName(): string;
  36429. private _defaultMeshCandidates;
  36430. /**
  36431. * @hidden
  36432. */
  36433. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36434. private _defaultSubMeshCandidates;
  36435. /**
  36436. * @hidden
  36437. */
  36438. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36439. /**
  36440. * Sets the default candidate providers for the scene.
  36441. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36442. * and getCollidingSubMeshCandidates to their default function
  36443. */
  36444. setDefaultCandidateProviders(): void;
  36445. /**
  36446. * Gets the mesh that is currently under the pointer
  36447. */
  36448. get meshUnderPointer(): Nullable<AbstractMesh>;
  36449. /**
  36450. * Gets or sets the current on-screen X position of the pointer
  36451. */
  36452. get pointerX(): number;
  36453. set pointerX(value: number);
  36454. /**
  36455. * Gets or sets the current on-screen Y position of the pointer
  36456. */
  36457. get pointerY(): number;
  36458. set pointerY(value: number);
  36459. /**
  36460. * Gets the cached material (ie. the latest rendered one)
  36461. * @returns the cached material
  36462. */
  36463. getCachedMaterial(): Nullable<Material>;
  36464. /**
  36465. * Gets the cached effect (ie. the latest rendered one)
  36466. * @returns the cached effect
  36467. */
  36468. getCachedEffect(): Nullable<Effect>;
  36469. /**
  36470. * Gets the cached visibility state (ie. the latest rendered one)
  36471. * @returns the cached visibility state
  36472. */
  36473. getCachedVisibility(): Nullable<number>;
  36474. /**
  36475. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36476. * @param material defines the current material
  36477. * @param effect defines the current effect
  36478. * @param visibility defines the current visibility state
  36479. * @returns true if one parameter is not cached
  36480. */
  36481. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36482. /**
  36483. * Gets the engine associated with the scene
  36484. * @returns an Engine
  36485. */
  36486. getEngine(): Engine;
  36487. /**
  36488. * Gets the total number of vertices rendered per frame
  36489. * @returns the total number of vertices rendered per frame
  36490. */
  36491. getTotalVertices(): number;
  36492. /**
  36493. * Gets the performance counter for total vertices
  36494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36495. */
  36496. get totalVerticesPerfCounter(): PerfCounter;
  36497. /**
  36498. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36499. * @returns the total number of active indices rendered per frame
  36500. */
  36501. getActiveIndices(): number;
  36502. /**
  36503. * Gets the performance counter for active indices
  36504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36505. */
  36506. get totalActiveIndicesPerfCounter(): PerfCounter;
  36507. /**
  36508. * Gets the total number of active particles rendered per frame
  36509. * @returns the total number of active particles rendered per frame
  36510. */
  36511. getActiveParticles(): number;
  36512. /**
  36513. * Gets the performance counter for active particles
  36514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36515. */
  36516. get activeParticlesPerfCounter(): PerfCounter;
  36517. /**
  36518. * Gets the total number of active bones rendered per frame
  36519. * @returns the total number of active bones rendered per frame
  36520. */
  36521. getActiveBones(): number;
  36522. /**
  36523. * Gets the performance counter for active bones
  36524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36525. */
  36526. get activeBonesPerfCounter(): PerfCounter;
  36527. /**
  36528. * Gets the array of active meshes
  36529. * @returns an array of AbstractMesh
  36530. */
  36531. getActiveMeshes(): SmartArray<AbstractMesh>;
  36532. /**
  36533. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36534. * @returns a number
  36535. */
  36536. getAnimationRatio(): number;
  36537. /**
  36538. * Gets an unique Id for the current render phase
  36539. * @returns a number
  36540. */
  36541. getRenderId(): number;
  36542. /**
  36543. * Gets an unique Id for the current frame
  36544. * @returns a number
  36545. */
  36546. getFrameId(): number;
  36547. /** Call this function if you want to manually increment the render Id*/
  36548. incrementRenderId(): void;
  36549. private _createUbo;
  36550. /**
  36551. * Use this method to simulate a pointer move on a mesh
  36552. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36553. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36554. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36555. * @returns the current scene
  36556. */
  36557. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36558. /**
  36559. * Use this method to simulate a pointer down on a mesh
  36560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36563. * @returns the current scene
  36564. */
  36565. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36566. /**
  36567. * Use this method to simulate a pointer up on a mesh
  36568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36571. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36572. * @returns the current scene
  36573. */
  36574. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36575. /**
  36576. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36577. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36578. * @returns true if the pointer was captured
  36579. */
  36580. isPointerCaptured(pointerId?: number): boolean;
  36581. /**
  36582. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36583. * @param attachUp defines if you want to attach events to pointerup
  36584. * @param attachDown defines if you want to attach events to pointerdown
  36585. * @param attachMove defines if you want to attach events to pointermove
  36586. */
  36587. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36588. /** Detaches all event handlers*/
  36589. detachControl(): void;
  36590. /**
  36591. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36592. * Delay loaded resources are not taking in account
  36593. * @return true if all required resources are ready
  36594. */
  36595. isReady(): boolean;
  36596. /** Resets all cached information relative to material (including effect and visibility) */
  36597. resetCachedMaterial(): void;
  36598. /**
  36599. * Registers a function to be called before every frame render
  36600. * @param func defines the function to register
  36601. */
  36602. registerBeforeRender(func: () => void): void;
  36603. /**
  36604. * Unregisters a function called before every frame render
  36605. * @param func defines the function to unregister
  36606. */
  36607. unregisterBeforeRender(func: () => void): void;
  36608. /**
  36609. * Registers a function to be called after every frame render
  36610. * @param func defines the function to register
  36611. */
  36612. registerAfterRender(func: () => void): void;
  36613. /**
  36614. * Unregisters a function called after every frame render
  36615. * @param func defines the function to unregister
  36616. */
  36617. unregisterAfterRender(func: () => void): void;
  36618. private _executeOnceBeforeRender;
  36619. /**
  36620. * The provided function will run before render once and will be disposed afterwards.
  36621. * A timeout delay can be provided so that the function will be executed in N ms.
  36622. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36623. * @param func The function to be executed.
  36624. * @param timeout optional delay in ms
  36625. */
  36626. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36627. /** @hidden */
  36628. _addPendingData(data: any): void;
  36629. /** @hidden */
  36630. _removePendingData(data: any): void;
  36631. /**
  36632. * Returns the number of items waiting to be loaded
  36633. * @returns the number of items waiting to be loaded
  36634. */
  36635. getWaitingItemsCount(): number;
  36636. /**
  36637. * Returns a boolean indicating if the scene is still loading data
  36638. */
  36639. get isLoading(): boolean;
  36640. /**
  36641. * Registers a function to be executed when the scene is ready
  36642. * @param {Function} func - the function to be executed
  36643. */
  36644. executeWhenReady(func: () => void): void;
  36645. /**
  36646. * Returns a promise that resolves when the scene is ready
  36647. * @returns A promise that resolves when the scene is ready
  36648. */
  36649. whenReadyAsync(): Promise<void>;
  36650. /** @hidden */
  36651. _checkIsReady(): void;
  36652. /**
  36653. * Gets all animatable attached to the scene
  36654. */
  36655. get animatables(): Animatable[];
  36656. /**
  36657. * Resets the last animation time frame.
  36658. * Useful to override when animations start running when loading a scene for the first time.
  36659. */
  36660. resetLastAnimationTimeFrame(): void;
  36661. /**
  36662. * Gets the current view matrix
  36663. * @returns a Matrix
  36664. */
  36665. getViewMatrix(): Matrix;
  36666. /**
  36667. * Gets the current projection matrix
  36668. * @returns a Matrix
  36669. */
  36670. getProjectionMatrix(): Matrix;
  36671. /**
  36672. * Gets the current transform matrix
  36673. * @returns a Matrix made of View * Projection
  36674. */
  36675. getTransformMatrix(): Matrix;
  36676. /**
  36677. * Sets the current transform matrix
  36678. * @param viewL defines the View matrix to use
  36679. * @param projectionL defines the Projection matrix to use
  36680. * @param viewR defines the right View matrix to use (if provided)
  36681. * @param projectionR defines the right Projection matrix to use (if provided)
  36682. */
  36683. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36684. /**
  36685. * Gets the uniform buffer used to store scene data
  36686. * @returns a UniformBuffer
  36687. */
  36688. getSceneUniformBuffer(): UniformBuffer;
  36689. /**
  36690. * Gets an unique (relatively to the current scene) Id
  36691. * @returns an unique number for the scene
  36692. */
  36693. getUniqueId(): number;
  36694. /**
  36695. * Add a mesh to the list of scene's meshes
  36696. * @param newMesh defines the mesh to add
  36697. * @param recursive if all child meshes should also be added to the scene
  36698. */
  36699. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36700. /**
  36701. * Remove a mesh for the list of scene's meshes
  36702. * @param toRemove defines the mesh to remove
  36703. * @param recursive if all child meshes should also be removed from the scene
  36704. * @returns the index where the mesh was in the mesh list
  36705. */
  36706. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36707. /**
  36708. * Add a transform node to the list of scene's transform nodes
  36709. * @param newTransformNode defines the transform node to add
  36710. */
  36711. addTransformNode(newTransformNode: TransformNode): void;
  36712. /**
  36713. * Remove a transform node for the list of scene's transform nodes
  36714. * @param toRemove defines the transform node to remove
  36715. * @returns the index where the transform node was in the transform node list
  36716. */
  36717. removeTransformNode(toRemove: TransformNode): number;
  36718. /**
  36719. * Remove a skeleton for the list of scene's skeletons
  36720. * @param toRemove defines the skeleton to remove
  36721. * @returns the index where the skeleton was in the skeleton list
  36722. */
  36723. removeSkeleton(toRemove: Skeleton): number;
  36724. /**
  36725. * Remove a morph target for the list of scene's morph targets
  36726. * @param toRemove defines the morph target to remove
  36727. * @returns the index where the morph target was in the morph target list
  36728. */
  36729. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36730. /**
  36731. * Remove a light for the list of scene's lights
  36732. * @param toRemove defines the light to remove
  36733. * @returns the index where the light was in the light list
  36734. */
  36735. removeLight(toRemove: Light): number;
  36736. /**
  36737. * Remove a camera for the list of scene's cameras
  36738. * @param toRemove defines the camera to remove
  36739. * @returns the index where the camera was in the camera list
  36740. */
  36741. removeCamera(toRemove: Camera): number;
  36742. /**
  36743. * Remove a particle system for the list of scene's particle systems
  36744. * @param toRemove defines the particle system to remove
  36745. * @returns the index where the particle system was in the particle system list
  36746. */
  36747. removeParticleSystem(toRemove: IParticleSystem): number;
  36748. /**
  36749. * Remove a animation for the list of scene's animations
  36750. * @param toRemove defines the animation to remove
  36751. * @returns the index where the animation was in the animation list
  36752. */
  36753. removeAnimation(toRemove: Animation): number;
  36754. /**
  36755. * Will stop the animation of the given target
  36756. * @param target - the target
  36757. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36758. * @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)
  36759. */
  36760. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36761. /**
  36762. * Removes the given animation group from this scene.
  36763. * @param toRemove The animation group to remove
  36764. * @returns The index of the removed animation group
  36765. */
  36766. removeAnimationGroup(toRemove: AnimationGroup): number;
  36767. /**
  36768. * Removes the given multi-material from this scene.
  36769. * @param toRemove The multi-material to remove
  36770. * @returns The index of the removed multi-material
  36771. */
  36772. removeMultiMaterial(toRemove: MultiMaterial): number;
  36773. /**
  36774. * Removes the given material from this scene.
  36775. * @param toRemove The material to remove
  36776. * @returns The index of the removed material
  36777. */
  36778. removeMaterial(toRemove: Material): number;
  36779. /**
  36780. * Removes the given action manager from this scene.
  36781. * @param toRemove The action manager to remove
  36782. * @returns The index of the removed action manager
  36783. */
  36784. removeActionManager(toRemove: AbstractActionManager): number;
  36785. /**
  36786. * Removes the given texture from this scene.
  36787. * @param toRemove The texture to remove
  36788. * @returns The index of the removed texture
  36789. */
  36790. removeTexture(toRemove: BaseTexture): number;
  36791. /**
  36792. * Adds the given light to this scene
  36793. * @param newLight The light to add
  36794. */
  36795. addLight(newLight: Light): void;
  36796. /**
  36797. * Sorts the list list based on light priorities
  36798. */
  36799. sortLightsByPriority(): void;
  36800. /**
  36801. * Adds the given camera to this scene
  36802. * @param newCamera The camera to add
  36803. */
  36804. addCamera(newCamera: Camera): void;
  36805. /**
  36806. * Adds the given skeleton to this scene
  36807. * @param newSkeleton The skeleton to add
  36808. */
  36809. addSkeleton(newSkeleton: Skeleton): void;
  36810. /**
  36811. * Adds the given particle system to this scene
  36812. * @param newParticleSystem The particle system to add
  36813. */
  36814. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36815. /**
  36816. * Adds the given animation to this scene
  36817. * @param newAnimation The animation to add
  36818. */
  36819. addAnimation(newAnimation: Animation): void;
  36820. /**
  36821. * Adds the given animation group to this scene.
  36822. * @param newAnimationGroup The animation group to add
  36823. */
  36824. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36825. /**
  36826. * Adds the given multi-material to this scene
  36827. * @param newMultiMaterial The multi-material to add
  36828. */
  36829. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36830. /**
  36831. * Adds the given material to this scene
  36832. * @param newMaterial The material to add
  36833. */
  36834. addMaterial(newMaterial: Material): void;
  36835. /**
  36836. * Adds the given morph target to this scene
  36837. * @param newMorphTargetManager The morph target to add
  36838. */
  36839. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36840. /**
  36841. * Adds the given geometry to this scene
  36842. * @param newGeometry The geometry to add
  36843. */
  36844. addGeometry(newGeometry: Geometry): void;
  36845. /**
  36846. * Adds the given action manager to this scene
  36847. * @param newActionManager The action manager to add
  36848. */
  36849. addActionManager(newActionManager: AbstractActionManager): void;
  36850. /**
  36851. * Adds the given texture to this scene.
  36852. * @param newTexture The texture to add
  36853. */
  36854. addTexture(newTexture: BaseTexture): void;
  36855. /**
  36856. * Switch active camera
  36857. * @param newCamera defines the new active camera
  36858. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36859. */
  36860. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36861. /**
  36862. * sets the active camera of the scene using its ID
  36863. * @param id defines the camera's ID
  36864. * @return the new active camera or null if none found.
  36865. */
  36866. setActiveCameraByID(id: string): Nullable<Camera>;
  36867. /**
  36868. * sets the active camera of the scene using its name
  36869. * @param name defines the camera's name
  36870. * @returns the new active camera or null if none found.
  36871. */
  36872. setActiveCameraByName(name: string): Nullable<Camera>;
  36873. /**
  36874. * get an animation group using its name
  36875. * @param name defines the material's name
  36876. * @return the animation group or null if none found.
  36877. */
  36878. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36879. /**
  36880. * Get a material using its unique id
  36881. * @param uniqueId defines the material's unique id
  36882. * @return the material or null if none found.
  36883. */
  36884. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36885. /**
  36886. * get a material using its id
  36887. * @param id defines the material's ID
  36888. * @return the material or null if none found.
  36889. */
  36890. getMaterialByID(id: string): Nullable<Material>;
  36891. /**
  36892. * Gets a the last added material using a given id
  36893. * @param id defines the material's ID
  36894. * @return the last material with the given id or null if none found.
  36895. */
  36896. getLastMaterialByID(id: string): Nullable<Material>;
  36897. /**
  36898. * Gets a material using its name
  36899. * @param name defines the material's name
  36900. * @return the material or null if none found.
  36901. */
  36902. getMaterialByName(name: string): Nullable<Material>;
  36903. /**
  36904. * Get a texture using its unique id
  36905. * @param uniqueId defines the texture's unique id
  36906. * @return the texture or null if none found.
  36907. */
  36908. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36909. /**
  36910. * Gets a camera using its id
  36911. * @param id defines the id to look for
  36912. * @returns the camera or null if not found
  36913. */
  36914. getCameraByID(id: string): Nullable<Camera>;
  36915. /**
  36916. * Gets a camera using its unique id
  36917. * @param uniqueId defines the unique id to look for
  36918. * @returns the camera or null if not found
  36919. */
  36920. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36921. /**
  36922. * Gets a camera using its name
  36923. * @param name defines the camera's name
  36924. * @return the camera or null if none found.
  36925. */
  36926. getCameraByName(name: string): Nullable<Camera>;
  36927. /**
  36928. * Gets a bone using its id
  36929. * @param id defines the bone's id
  36930. * @return the bone or null if not found
  36931. */
  36932. getBoneByID(id: string): Nullable<Bone>;
  36933. /**
  36934. * Gets a bone using its id
  36935. * @param name defines the bone's name
  36936. * @return the bone or null if not found
  36937. */
  36938. getBoneByName(name: string): Nullable<Bone>;
  36939. /**
  36940. * Gets a light node using its name
  36941. * @param name defines the the light's name
  36942. * @return the light or null if none found.
  36943. */
  36944. getLightByName(name: string): Nullable<Light>;
  36945. /**
  36946. * Gets a light node using its id
  36947. * @param id defines the light's id
  36948. * @return the light or null if none found.
  36949. */
  36950. getLightByID(id: string): Nullable<Light>;
  36951. /**
  36952. * Gets a light node using its scene-generated unique ID
  36953. * @param uniqueId defines the light's unique id
  36954. * @return the light or null if none found.
  36955. */
  36956. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36957. /**
  36958. * Gets a particle system by id
  36959. * @param id defines the particle system id
  36960. * @return the corresponding system or null if none found
  36961. */
  36962. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36963. /**
  36964. * Gets a geometry using its ID
  36965. * @param id defines the geometry's id
  36966. * @return the geometry or null if none found.
  36967. */
  36968. getGeometryByID(id: string): Nullable<Geometry>;
  36969. private _getGeometryByUniqueID;
  36970. /**
  36971. * Add a new geometry to this scene
  36972. * @param geometry defines the geometry to be added to the scene.
  36973. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36974. * @return a boolean defining if the geometry was added or not
  36975. */
  36976. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36977. /**
  36978. * Removes an existing geometry
  36979. * @param geometry defines the geometry to be removed from the scene
  36980. * @return a boolean defining if the geometry was removed or not
  36981. */
  36982. removeGeometry(geometry: Geometry): boolean;
  36983. /**
  36984. * Gets the list of geometries attached to the scene
  36985. * @returns an array of Geometry
  36986. */
  36987. getGeometries(): Geometry[];
  36988. /**
  36989. * Gets the first added mesh found of a given ID
  36990. * @param id defines the id to search for
  36991. * @return the mesh found or null if not found at all
  36992. */
  36993. getMeshByID(id: string): Nullable<AbstractMesh>;
  36994. /**
  36995. * Gets a list of meshes using their id
  36996. * @param id defines the id to search for
  36997. * @returns a list of meshes
  36998. */
  36999. getMeshesByID(id: string): Array<AbstractMesh>;
  37000. /**
  37001. * Gets the first added transform node found of a given ID
  37002. * @param id defines the id to search for
  37003. * @return the found transform node or null if not found at all.
  37004. */
  37005. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37006. /**
  37007. * Gets a transform node with its auto-generated unique id
  37008. * @param uniqueId efines the unique id to search for
  37009. * @return the found transform node or null if not found at all.
  37010. */
  37011. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37012. /**
  37013. * Gets a list of transform nodes using their id
  37014. * @param id defines the id to search for
  37015. * @returns a list of transform nodes
  37016. */
  37017. getTransformNodesByID(id: string): Array<TransformNode>;
  37018. /**
  37019. * Gets a mesh with its auto-generated unique id
  37020. * @param uniqueId defines the unique id to search for
  37021. * @return the found mesh or null if not found at all.
  37022. */
  37023. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37024. /**
  37025. * Gets a the last added mesh using a given id
  37026. * @param id defines the id to search for
  37027. * @return the found mesh or null if not found at all.
  37028. */
  37029. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37030. /**
  37031. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37032. * @param id defines the id to search for
  37033. * @return the found node or null if not found at all
  37034. */
  37035. getLastEntryByID(id: string): Nullable<Node>;
  37036. /**
  37037. * Gets a node (Mesh, Camera, Light) using a given id
  37038. * @param id defines the id to search for
  37039. * @return the found node or null if not found at all
  37040. */
  37041. getNodeByID(id: string): Nullable<Node>;
  37042. /**
  37043. * Gets a node (Mesh, Camera, Light) using a given name
  37044. * @param name defines the name to search for
  37045. * @return the found node or null if not found at all.
  37046. */
  37047. getNodeByName(name: string): Nullable<Node>;
  37048. /**
  37049. * Gets a mesh using a given name
  37050. * @param name defines the name to search for
  37051. * @return the found mesh or null if not found at all.
  37052. */
  37053. getMeshByName(name: string): Nullable<AbstractMesh>;
  37054. /**
  37055. * Gets a transform node using a given name
  37056. * @param name defines the name to search for
  37057. * @return the found transform node or null if not found at all.
  37058. */
  37059. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37060. /**
  37061. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37062. * @param id defines the id to search for
  37063. * @return the found skeleton or null if not found at all.
  37064. */
  37065. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37066. /**
  37067. * Gets a skeleton using a given auto generated unique id
  37068. * @param uniqueId defines the unique id to search for
  37069. * @return the found skeleton or null if not found at all.
  37070. */
  37071. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37072. /**
  37073. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37074. * @param id defines the id to search for
  37075. * @return the found skeleton or null if not found at all.
  37076. */
  37077. getSkeletonById(id: string): Nullable<Skeleton>;
  37078. /**
  37079. * Gets a skeleton using a given name
  37080. * @param name defines the name to search for
  37081. * @return the found skeleton or null if not found at all.
  37082. */
  37083. getSkeletonByName(name: string): Nullable<Skeleton>;
  37084. /**
  37085. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37086. * @param id defines the id to search for
  37087. * @return the found morph target manager or null if not found at all.
  37088. */
  37089. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37090. /**
  37091. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37092. * @param id defines the id to search for
  37093. * @return the found morph target or null if not found at all.
  37094. */
  37095. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37096. /**
  37097. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37098. * @param name defines the name to search for
  37099. * @return the found morph target or null if not found at all.
  37100. */
  37101. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37102. /**
  37103. * Gets a boolean indicating if the given mesh is active
  37104. * @param mesh defines the mesh to look for
  37105. * @returns true if the mesh is in the active list
  37106. */
  37107. isActiveMesh(mesh: AbstractMesh): boolean;
  37108. /**
  37109. * Return a unique id as a string which can serve as an identifier for the scene
  37110. */
  37111. get uid(): string;
  37112. /**
  37113. * Add an externaly attached data from its key.
  37114. * This method call will fail and return false, if such key already exists.
  37115. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37116. * @param key the unique key that identifies the data
  37117. * @param data the data object to associate to the key for this Engine instance
  37118. * @return true if no such key were already present and the data was added successfully, false otherwise
  37119. */
  37120. addExternalData<T>(key: string, data: T): boolean;
  37121. /**
  37122. * Get an externaly attached data from its key
  37123. * @param key the unique key that identifies the data
  37124. * @return the associated data, if present (can be null), or undefined if not present
  37125. */
  37126. getExternalData<T>(key: string): Nullable<T>;
  37127. /**
  37128. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37129. * @param key the unique key that identifies the data
  37130. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37131. * @return the associated data, can be null if the factory returned null.
  37132. */
  37133. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37134. /**
  37135. * Remove an externaly attached data from the Engine instance
  37136. * @param key the unique key that identifies the data
  37137. * @return true if the data was successfully removed, false if it doesn't exist
  37138. */
  37139. removeExternalData(key: string): boolean;
  37140. private _evaluateSubMesh;
  37141. /**
  37142. * Clear the processed materials smart array preventing retention point in material dispose.
  37143. */
  37144. freeProcessedMaterials(): void;
  37145. private _preventFreeActiveMeshesAndRenderingGroups;
  37146. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37147. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37148. * when disposing several meshes in a row or a hierarchy of meshes.
  37149. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37150. */
  37151. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37152. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37153. /**
  37154. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37155. */
  37156. freeActiveMeshes(): void;
  37157. /**
  37158. * Clear the info related to rendering groups preventing retention points during dispose.
  37159. */
  37160. freeRenderingGroups(): void;
  37161. /** @hidden */
  37162. _isInIntermediateRendering(): boolean;
  37163. /**
  37164. * Lambda returning the list of potentially active meshes.
  37165. */
  37166. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37167. /**
  37168. * Lambda returning the list of potentially active sub meshes.
  37169. */
  37170. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37171. /**
  37172. * Lambda returning the list of potentially intersecting sub meshes.
  37173. */
  37174. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37175. /**
  37176. * Lambda returning the list of potentially colliding sub meshes.
  37177. */
  37178. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37179. private _activeMeshesFrozen;
  37180. private _skipEvaluateActiveMeshesCompletely;
  37181. /**
  37182. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37183. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37184. * @returns the current scene
  37185. */
  37186. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37187. /**
  37188. * Use this function to restart evaluating active meshes on every frame
  37189. * @returns the current scene
  37190. */
  37191. unfreezeActiveMeshes(): Scene;
  37192. private _evaluateActiveMeshes;
  37193. private _activeMesh;
  37194. /**
  37195. * Update the transform matrix to update from the current active camera
  37196. * @param force defines a boolean used to force the update even if cache is up to date
  37197. */
  37198. updateTransformMatrix(force?: boolean): void;
  37199. private _bindFrameBuffer;
  37200. /** @hidden */
  37201. _allowPostProcessClearColor: boolean;
  37202. /** @hidden */
  37203. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37204. private _processSubCameras;
  37205. private _checkIntersections;
  37206. /** @hidden */
  37207. _advancePhysicsEngineStep(step: number): void;
  37208. /**
  37209. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37210. */
  37211. getDeterministicFrameTime: () => number;
  37212. /** @hidden */
  37213. _animate(): void;
  37214. /** Execute all animations (for a frame) */
  37215. animate(): void;
  37216. /**
  37217. * Render the scene
  37218. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37219. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37220. */
  37221. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37222. /**
  37223. * Freeze all materials
  37224. * A frozen material will not be updatable but should be faster to render
  37225. */
  37226. freezeMaterials(): void;
  37227. /**
  37228. * Unfreeze all materials
  37229. * A frozen material will not be updatable but should be faster to render
  37230. */
  37231. unfreezeMaterials(): void;
  37232. /**
  37233. * Releases all held ressources
  37234. */
  37235. dispose(): void;
  37236. /**
  37237. * Gets if the scene is already disposed
  37238. */
  37239. get isDisposed(): boolean;
  37240. /**
  37241. * Call this function to reduce memory footprint of the scene.
  37242. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37243. */
  37244. clearCachedVertexData(): void;
  37245. /**
  37246. * This function will remove the local cached buffer data from texture.
  37247. * It will save memory but will prevent the texture from being rebuilt
  37248. */
  37249. cleanCachedTextureBuffer(): void;
  37250. /**
  37251. * Get the world extend vectors with an optional filter
  37252. *
  37253. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37254. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37255. */
  37256. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37257. min: Vector3;
  37258. max: Vector3;
  37259. };
  37260. /**
  37261. * Creates a ray that can be used to pick in the scene
  37262. * @param x defines the x coordinate of the origin (on-screen)
  37263. * @param y defines the y coordinate of the origin (on-screen)
  37264. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37265. * @param camera defines the camera to use for the picking
  37266. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37267. * @returns a Ray
  37268. */
  37269. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37270. /**
  37271. * Creates a ray that can be used to pick in the scene
  37272. * @param x defines the x coordinate of the origin (on-screen)
  37273. * @param y defines the y coordinate of the origin (on-screen)
  37274. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37275. * @param result defines the ray where to store the picking ray
  37276. * @param camera defines the camera to use for the picking
  37277. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37278. * @returns the current scene
  37279. */
  37280. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37281. /**
  37282. * Creates a ray that can be used to pick in the scene
  37283. * @param x defines the x coordinate of the origin (on-screen)
  37284. * @param y defines the y coordinate of the origin (on-screen)
  37285. * @param camera defines the camera to use for the picking
  37286. * @returns a Ray
  37287. */
  37288. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37289. /**
  37290. * Creates a ray that can be used to pick in the scene
  37291. * @param x defines the x coordinate of the origin (on-screen)
  37292. * @param y defines the y coordinate of the origin (on-screen)
  37293. * @param result defines the ray where to store the picking ray
  37294. * @param camera defines the camera to use for the picking
  37295. * @returns the current scene
  37296. */
  37297. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37298. /** Launch a ray to try to pick a mesh in the scene
  37299. * @param x position on screen
  37300. * @param y position on screen
  37301. * @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
  37302. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37303. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37304. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37305. * @returns a PickingInfo
  37306. */
  37307. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37308. /** Use the given ray to pick a mesh in the scene
  37309. * @param ray The ray to use to pick meshes
  37310. * @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
  37311. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37313. * @returns a PickingInfo
  37314. */
  37315. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37316. /**
  37317. * Launch a ray to try to pick a mesh in the scene
  37318. * @param x X position on screen
  37319. * @param y Y position on screen
  37320. * @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
  37321. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37322. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37323. * @returns an array of PickingInfo
  37324. */
  37325. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37326. /**
  37327. * Launch a ray to try to pick a mesh in the scene
  37328. * @param ray Ray to use
  37329. * @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
  37330. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37331. * @returns an array of PickingInfo
  37332. */
  37333. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37334. /**
  37335. * Force the value of meshUnderPointer
  37336. * @param mesh defines the mesh to use
  37337. */
  37338. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37339. /**
  37340. * Gets the mesh under the pointer
  37341. * @returns a Mesh or null if no mesh is under the pointer
  37342. */
  37343. getPointerOverMesh(): Nullable<AbstractMesh>;
  37344. /** @hidden */
  37345. _rebuildGeometries(): void;
  37346. /** @hidden */
  37347. _rebuildTextures(): void;
  37348. private _getByTags;
  37349. /**
  37350. * Get a list of meshes by tags
  37351. * @param tagsQuery defines the tags query to use
  37352. * @param forEach defines a predicate used to filter results
  37353. * @returns an array of Mesh
  37354. */
  37355. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37356. /**
  37357. * Get a list of cameras by tags
  37358. * @param tagsQuery defines the tags query to use
  37359. * @param forEach defines a predicate used to filter results
  37360. * @returns an array of Camera
  37361. */
  37362. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37363. /**
  37364. * Get a list of lights by tags
  37365. * @param tagsQuery defines the tags query to use
  37366. * @param forEach defines a predicate used to filter results
  37367. * @returns an array of Light
  37368. */
  37369. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37370. /**
  37371. * Get a list of materials by tags
  37372. * @param tagsQuery defines the tags query to use
  37373. * @param forEach defines a predicate used to filter results
  37374. * @returns an array of Material
  37375. */
  37376. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37377. /**
  37378. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37379. * This allowed control for front to back rendering or reversly depending of the special needs.
  37380. *
  37381. * @param renderingGroupId The rendering group id corresponding to its index
  37382. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37383. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37384. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37385. */
  37386. 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;
  37387. /**
  37388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37389. *
  37390. * @param renderingGroupId The rendering group id corresponding to its index
  37391. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37392. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37393. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37394. */
  37395. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37396. /**
  37397. * Gets the current auto clear configuration for one rendering group of the rendering
  37398. * manager.
  37399. * @param index the rendering group index to get the information for
  37400. * @returns The auto clear setup for the requested rendering group
  37401. */
  37402. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37403. private _blockMaterialDirtyMechanism;
  37404. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37405. get blockMaterialDirtyMechanism(): boolean;
  37406. set blockMaterialDirtyMechanism(value: boolean);
  37407. /**
  37408. * Will flag all materials as dirty to trigger new shader compilation
  37409. * @param flag defines the flag used to specify which material part must be marked as dirty
  37410. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37411. */
  37412. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37413. /** @hidden */
  37414. _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;
  37415. /** @hidden */
  37416. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37417. /** @hidden */
  37418. _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;
  37419. /** @hidden */
  37420. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37421. /** @hidden */
  37422. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37423. /** @hidden */
  37424. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37425. }
  37426. }
  37427. declare module BABYLON {
  37428. /**
  37429. * Set of assets to keep when moving a scene into an asset container.
  37430. */
  37431. export class KeepAssets extends AbstractScene {
  37432. }
  37433. /**
  37434. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37435. */
  37436. export class InstantiatedEntries {
  37437. /**
  37438. * List of new root nodes (eg. nodes with no parent)
  37439. */
  37440. rootNodes: TransformNode[];
  37441. /**
  37442. * List of new skeletons
  37443. */
  37444. skeletons: Skeleton[];
  37445. /**
  37446. * List of new animation groups
  37447. */
  37448. animationGroups: AnimationGroup[];
  37449. }
  37450. /**
  37451. * Container with a set of assets that can be added or removed from a scene.
  37452. */
  37453. export class AssetContainer extends AbstractScene {
  37454. private _wasAddedToScene;
  37455. /**
  37456. * The scene the AssetContainer belongs to.
  37457. */
  37458. scene: Scene;
  37459. /**
  37460. * Instantiates an AssetContainer.
  37461. * @param scene The scene the AssetContainer belongs to.
  37462. */
  37463. constructor(scene: Scene);
  37464. /**
  37465. * Instantiate or clone all meshes and add the new ones to the scene.
  37466. * Skeletons and animation groups will all be cloned
  37467. * @param nameFunction defines an optional function used to get new names for clones
  37468. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37469. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37470. */
  37471. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37472. /**
  37473. * Adds all the assets from the container to the scene.
  37474. */
  37475. addAllToScene(): void;
  37476. /**
  37477. * Removes all the assets in the container from the scene
  37478. */
  37479. removeAllFromScene(): void;
  37480. /**
  37481. * Disposes all the assets in the container
  37482. */
  37483. dispose(): void;
  37484. private _moveAssets;
  37485. /**
  37486. * Removes all the assets contained in the scene and adds them to the container.
  37487. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37488. */
  37489. moveAllFromScene(keepAssets?: KeepAssets): void;
  37490. /**
  37491. * 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.
  37492. * @returns the root mesh
  37493. */
  37494. createRootMesh(): Mesh;
  37495. /**
  37496. * Merge animations from this asset container into a scene
  37497. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37498. * @param animatables set of animatables to retarget to a node from the scene
  37499. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37500. */
  37501. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37502. }
  37503. }
  37504. declare module BABYLON {
  37505. /**
  37506. * Defines how the parser contract is defined.
  37507. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37508. */
  37509. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37510. /**
  37511. * Defines how the individual parser contract is defined.
  37512. * These parser can parse an individual asset
  37513. */
  37514. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37515. /**
  37516. * Base class of the scene acting as a container for the different elements composing a scene.
  37517. * This class is dynamically extended by the different components of the scene increasing
  37518. * flexibility and reducing coupling
  37519. */
  37520. export abstract class AbstractScene {
  37521. /**
  37522. * Stores the list of available parsers in the application.
  37523. */
  37524. private static _BabylonFileParsers;
  37525. /**
  37526. * Stores the list of available individual parsers in the application.
  37527. */
  37528. private static _IndividualBabylonFileParsers;
  37529. /**
  37530. * Adds a parser in the list of available ones
  37531. * @param name Defines the name of the parser
  37532. * @param parser Defines the parser to add
  37533. */
  37534. static AddParser(name: string, parser: BabylonFileParser): void;
  37535. /**
  37536. * Gets a general parser from the list of avaialble ones
  37537. * @param name Defines the name of the parser
  37538. * @returns the requested parser or null
  37539. */
  37540. static GetParser(name: string): Nullable<BabylonFileParser>;
  37541. /**
  37542. * Adds n individual parser in the list of available ones
  37543. * @param name Defines the name of the parser
  37544. * @param parser Defines the parser to add
  37545. */
  37546. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37547. /**
  37548. * Gets an individual parser from the list of avaialble ones
  37549. * @param name Defines the name of the parser
  37550. * @returns the requested parser or null
  37551. */
  37552. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37553. /**
  37554. * Parser json data and populate both a scene and its associated container object
  37555. * @param jsonData Defines the data to parse
  37556. * @param scene Defines the scene to parse the data for
  37557. * @param container Defines the container attached to the parsing sequence
  37558. * @param rootUrl Defines the root url of the data
  37559. */
  37560. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37561. /**
  37562. * Gets the list of root nodes (ie. nodes with no parent)
  37563. */
  37564. rootNodes: Node[];
  37565. /** All of the cameras added to this scene
  37566. * @see http://doc.babylonjs.com/babylon101/cameras
  37567. */
  37568. cameras: Camera[];
  37569. /**
  37570. * All of the lights added to this scene
  37571. * @see http://doc.babylonjs.com/babylon101/lights
  37572. */
  37573. lights: Light[];
  37574. /**
  37575. * All of the (abstract) meshes added to this scene
  37576. */
  37577. meshes: AbstractMesh[];
  37578. /**
  37579. * The list of skeletons added to the scene
  37580. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37581. */
  37582. skeletons: Skeleton[];
  37583. /**
  37584. * All of the particle systems added to this scene
  37585. * @see http://doc.babylonjs.com/babylon101/particles
  37586. */
  37587. particleSystems: IParticleSystem[];
  37588. /**
  37589. * Gets a list of Animations associated with the scene
  37590. */
  37591. animations: Animation[];
  37592. /**
  37593. * All of the animation groups added to this scene
  37594. * @see http://doc.babylonjs.com/how_to/group
  37595. */
  37596. animationGroups: AnimationGroup[];
  37597. /**
  37598. * All of the multi-materials added to this scene
  37599. * @see http://doc.babylonjs.com/how_to/multi_materials
  37600. */
  37601. multiMaterials: MultiMaterial[];
  37602. /**
  37603. * All of the materials added to this scene
  37604. * In the context of a Scene, it is not supposed to be modified manually.
  37605. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37606. * Note also that the order of the Material within the array is not significant and might change.
  37607. * @see http://doc.babylonjs.com/babylon101/materials
  37608. */
  37609. materials: Material[];
  37610. /**
  37611. * The list of morph target managers added to the scene
  37612. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37613. */
  37614. morphTargetManagers: MorphTargetManager[];
  37615. /**
  37616. * The list of geometries used in the scene.
  37617. */
  37618. geometries: Geometry[];
  37619. /**
  37620. * All of the tranform nodes added to this scene
  37621. * In the context of a Scene, it is not supposed to be modified manually.
  37622. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37623. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37624. * @see http://doc.babylonjs.com/how_to/transformnode
  37625. */
  37626. transformNodes: TransformNode[];
  37627. /**
  37628. * ActionManagers available on the scene.
  37629. */
  37630. actionManagers: AbstractActionManager[];
  37631. /**
  37632. * Textures to keep.
  37633. */
  37634. textures: BaseTexture[];
  37635. /**
  37636. * Environment texture for the scene
  37637. */
  37638. environmentTexture: Nullable<BaseTexture>;
  37639. /**
  37640. * @returns all meshes, lights, cameras, transformNodes and bones
  37641. */
  37642. getNodes(): Array<Node>;
  37643. }
  37644. }
  37645. declare module BABYLON {
  37646. /**
  37647. * Interface used to define options for Sound class
  37648. */
  37649. export interface ISoundOptions {
  37650. /**
  37651. * Does the sound autoplay once loaded.
  37652. */
  37653. autoplay?: boolean;
  37654. /**
  37655. * Does the sound loop after it finishes playing once.
  37656. */
  37657. loop?: boolean;
  37658. /**
  37659. * Sound's volume
  37660. */
  37661. volume?: number;
  37662. /**
  37663. * Is it a spatial sound?
  37664. */
  37665. spatialSound?: boolean;
  37666. /**
  37667. * Maximum distance to hear that sound
  37668. */
  37669. maxDistance?: number;
  37670. /**
  37671. * Uses user defined attenuation function
  37672. */
  37673. useCustomAttenuation?: boolean;
  37674. /**
  37675. * Define the roll off factor of spatial sounds.
  37676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37677. */
  37678. rolloffFactor?: number;
  37679. /**
  37680. * Define the reference distance the sound should be heard perfectly.
  37681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37682. */
  37683. refDistance?: number;
  37684. /**
  37685. * Define the distance attenuation model the sound will follow.
  37686. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37687. */
  37688. distanceModel?: string;
  37689. /**
  37690. * Defines the playback speed (1 by default)
  37691. */
  37692. playbackRate?: number;
  37693. /**
  37694. * Defines if the sound is from a streaming source
  37695. */
  37696. streaming?: boolean;
  37697. /**
  37698. * Defines an optional length (in seconds) inside the sound file
  37699. */
  37700. length?: number;
  37701. /**
  37702. * Defines an optional offset (in seconds) inside the sound file
  37703. */
  37704. offset?: number;
  37705. /**
  37706. * If true, URLs will not be required to state the audio file codec to use.
  37707. */
  37708. skipCodecCheck?: boolean;
  37709. }
  37710. /**
  37711. * Defines a sound that can be played in the application.
  37712. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37714. */
  37715. export class Sound {
  37716. /**
  37717. * The name of the sound in the scene.
  37718. */
  37719. name: string;
  37720. /**
  37721. * Does the sound autoplay once loaded.
  37722. */
  37723. autoplay: boolean;
  37724. /**
  37725. * Does the sound loop after it finishes playing once.
  37726. */
  37727. loop: boolean;
  37728. /**
  37729. * Does the sound use a custom attenuation curve to simulate the falloff
  37730. * happening when the source gets further away from the camera.
  37731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37732. */
  37733. useCustomAttenuation: boolean;
  37734. /**
  37735. * The sound track id this sound belongs to.
  37736. */
  37737. soundTrackId: number;
  37738. /**
  37739. * Is this sound currently played.
  37740. */
  37741. isPlaying: boolean;
  37742. /**
  37743. * Is this sound currently paused.
  37744. */
  37745. isPaused: boolean;
  37746. /**
  37747. * Does this sound enables spatial sound.
  37748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37749. */
  37750. spatialSound: boolean;
  37751. /**
  37752. * Define the reference distance the sound should be heard perfectly.
  37753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37754. */
  37755. refDistance: number;
  37756. /**
  37757. * Define the roll off factor of spatial sounds.
  37758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37759. */
  37760. rolloffFactor: number;
  37761. /**
  37762. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37764. */
  37765. maxDistance: number;
  37766. /**
  37767. * Define the distance attenuation model the sound will follow.
  37768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37769. */
  37770. distanceModel: string;
  37771. /**
  37772. * @hidden
  37773. * Back Compat
  37774. **/
  37775. onended: () => any;
  37776. /**
  37777. * Observable event when the current playing sound finishes.
  37778. */
  37779. onEndedObservable: Observable<Sound>;
  37780. private _panningModel;
  37781. private _playbackRate;
  37782. private _streaming;
  37783. private _startTime;
  37784. private _startOffset;
  37785. private _position;
  37786. /** @hidden */
  37787. _positionInEmitterSpace: boolean;
  37788. private _localDirection;
  37789. private _volume;
  37790. private _isReadyToPlay;
  37791. private _isDirectional;
  37792. private _readyToPlayCallback;
  37793. private _audioBuffer;
  37794. private _soundSource;
  37795. private _streamingSource;
  37796. private _soundPanner;
  37797. private _soundGain;
  37798. private _inputAudioNode;
  37799. private _outputAudioNode;
  37800. private _coneInnerAngle;
  37801. private _coneOuterAngle;
  37802. private _coneOuterGain;
  37803. private _scene;
  37804. private _connectedTransformNode;
  37805. private _customAttenuationFunction;
  37806. private _registerFunc;
  37807. private _isOutputConnected;
  37808. private _htmlAudioElement;
  37809. private _urlType;
  37810. private _length?;
  37811. private _offset?;
  37812. /** @hidden */
  37813. static _SceneComponentInitialization: (scene: Scene) => void;
  37814. /**
  37815. * Create a sound and attach it to a scene
  37816. * @param name Name of your sound
  37817. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37818. * @param scene defines the scene the sound belongs to
  37819. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37820. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37821. */
  37822. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37823. /**
  37824. * Release the sound and its associated resources
  37825. */
  37826. dispose(): void;
  37827. /**
  37828. * Gets if the sounds is ready to be played or not.
  37829. * @returns true if ready, otherwise false
  37830. */
  37831. isReady(): boolean;
  37832. private _soundLoaded;
  37833. /**
  37834. * Sets the data of the sound from an audiobuffer
  37835. * @param audioBuffer The audioBuffer containing the data
  37836. */
  37837. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37838. /**
  37839. * Updates the current sounds options such as maxdistance, loop...
  37840. * @param options A JSON object containing values named as the object properties
  37841. */
  37842. updateOptions(options: ISoundOptions): void;
  37843. private _createSpatialParameters;
  37844. private _updateSpatialParameters;
  37845. /**
  37846. * Switch the panning model to HRTF:
  37847. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37849. */
  37850. switchPanningModelToHRTF(): void;
  37851. /**
  37852. * Switch the panning model to Equal Power:
  37853. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37855. */
  37856. switchPanningModelToEqualPower(): void;
  37857. private _switchPanningModel;
  37858. /**
  37859. * Connect this sound to a sound track audio node like gain...
  37860. * @param soundTrackAudioNode the sound track audio node to connect to
  37861. */
  37862. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37863. /**
  37864. * Transform this sound into a directional source
  37865. * @param coneInnerAngle Size of the inner cone in degree
  37866. * @param coneOuterAngle Size of the outer cone in degree
  37867. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37868. */
  37869. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37870. /**
  37871. * Gets or sets the inner angle for the directional cone.
  37872. */
  37873. get directionalConeInnerAngle(): number;
  37874. /**
  37875. * Gets or sets the inner angle for the directional cone.
  37876. */
  37877. set directionalConeInnerAngle(value: number);
  37878. /**
  37879. * Gets or sets the outer angle for the directional cone.
  37880. */
  37881. get directionalConeOuterAngle(): number;
  37882. /**
  37883. * Gets or sets the outer angle for the directional cone.
  37884. */
  37885. set directionalConeOuterAngle(value: number);
  37886. /**
  37887. * Sets the position of the emitter if spatial sound is enabled
  37888. * @param newPosition Defines the new posisiton
  37889. */
  37890. setPosition(newPosition: Vector3): void;
  37891. /**
  37892. * Sets the local direction of the emitter if spatial sound is enabled
  37893. * @param newLocalDirection Defines the new local direction
  37894. */
  37895. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37896. private _updateDirection;
  37897. /** @hidden */
  37898. updateDistanceFromListener(): void;
  37899. /**
  37900. * Sets a new custom attenuation function for the sound.
  37901. * @param callback Defines the function used for the attenuation
  37902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37903. */
  37904. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37905. /**
  37906. * Play the sound
  37907. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37908. * @param offset (optional) Start the sound at a specific time in seconds
  37909. * @param length (optional) Sound duration (in seconds)
  37910. */
  37911. play(time?: number, offset?: number, length?: number): void;
  37912. private _onended;
  37913. /**
  37914. * Stop the sound
  37915. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37916. */
  37917. stop(time?: number): void;
  37918. /**
  37919. * Put the sound in pause
  37920. */
  37921. pause(): void;
  37922. /**
  37923. * Sets a dedicated volume for this sounds
  37924. * @param newVolume Define the new volume of the sound
  37925. * @param time Define time for gradual change to new volume
  37926. */
  37927. setVolume(newVolume: number, time?: number): void;
  37928. /**
  37929. * Set the sound play back rate
  37930. * @param newPlaybackRate Define the playback rate the sound should be played at
  37931. */
  37932. setPlaybackRate(newPlaybackRate: number): void;
  37933. /**
  37934. * Gets the volume of the sound.
  37935. * @returns the volume of the sound
  37936. */
  37937. getVolume(): number;
  37938. /**
  37939. * Attach the sound to a dedicated mesh
  37940. * @param transformNode The transform node to connect the sound with
  37941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37942. */
  37943. attachToMesh(transformNode: TransformNode): void;
  37944. /**
  37945. * Detach the sound from the previously attached mesh
  37946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37947. */
  37948. detachFromMesh(): void;
  37949. private _onRegisterAfterWorldMatrixUpdate;
  37950. /**
  37951. * Clone the current sound in the scene.
  37952. * @returns the new sound clone
  37953. */
  37954. clone(): Nullable<Sound>;
  37955. /**
  37956. * Gets the current underlying audio buffer containing the data
  37957. * @returns the audio buffer
  37958. */
  37959. getAudioBuffer(): Nullable<AudioBuffer>;
  37960. /**
  37961. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37962. * @returns the source node
  37963. */
  37964. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37965. /**
  37966. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37967. * @returns the gain node
  37968. */
  37969. getSoundGain(): Nullable<GainNode>;
  37970. /**
  37971. * Serializes the Sound in a JSON representation
  37972. * @returns the JSON representation of the sound
  37973. */
  37974. serialize(): any;
  37975. /**
  37976. * Parse a JSON representation of a sound to innstantiate in a given scene
  37977. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37978. * @param scene Define the scene the new parsed sound should be created in
  37979. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37980. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37981. * @returns the newly parsed sound
  37982. */
  37983. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37984. }
  37985. }
  37986. declare module BABYLON {
  37987. /**
  37988. * This defines an action helpful to play a defined sound on a triggered action.
  37989. */
  37990. export class PlaySoundAction extends Action {
  37991. private _sound;
  37992. /**
  37993. * Instantiate the action
  37994. * @param triggerOptions defines the trigger options
  37995. * @param sound defines the sound to play
  37996. * @param condition defines the trigger related conditions
  37997. */
  37998. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37999. /** @hidden */
  38000. _prepare(): void;
  38001. /**
  38002. * Execute the action and play the sound.
  38003. */
  38004. execute(): void;
  38005. /**
  38006. * Serializes the actions and its related information.
  38007. * @param parent defines the object to serialize in
  38008. * @returns the serialized object
  38009. */
  38010. serialize(parent: any): any;
  38011. }
  38012. /**
  38013. * This defines an action helpful to stop a defined sound on a triggered action.
  38014. */
  38015. export class StopSoundAction extends Action {
  38016. private _sound;
  38017. /**
  38018. * Instantiate the action
  38019. * @param triggerOptions defines the trigger options
  38020. * @param sound defines the sound to stop
  38021. * @param condition defines the trigger related conditions
  38022. */
  38023. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38024. /** @hidden */
  38025. _prepare(): void;
  38026. /**
  38027. * Execute the action and stop the sound.
  38028. */
  38029. execute(): void;
  38030. /**
  38031. * Serializes the actions and its related information.
  38032. * @param parent defines the object to serialize in
  38033. * @returns the serialized object
  38034. */
  38035. serialize(parent: any): any;
  38036. }
  38037. }
  38038. declare module BABYLON {
  38039. /**
  38040. * This defines an action responsible to change the value of a property
  38041. * by interpolating between its current value and the newly set one once triggered.
  38042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38043. */
  38044. export class InterpolateValueAction extends Action {
  38045. /**
  38046. * Defines the path of the property where the value should be interpolated
  38047. */
  38048. propertyPath: string;
  38049. /**
  38050. * Defines the target value at the end of the interpolation.
  38051. */
  38052. value: any;
  38053. /**
  38054. * Defines the time it will take for the property to interpolate to the value.
  38055. */
  38056. duration: number;
  38057. /**
  38058. * Defines if the other scene animations should be stopped when the action has been triggered
  38059. */
  38060. stopOtherAnimations?: boolean;
  38061. /**
  38062. * Defines a callback raised once the interpolation animation has been done.
  38063. */
  38064. onInterpolationDone?: () => void;
  38065. /**
  38066. * Observable triggered once the interpolation animation has been done.
  38067. */
  38068. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38069. private _target;
  38070. private _effectiveTarget;
  38071. private _property;
  38072. /**
  38073. * Instantiate the action
  38074. * @param triggerOptions defines the trigger options
  38075. * @param target defines the object containing the value to interpolate
  38076. * @param propertyPath defines the path to the property in the target object
  38077. * @param value defines the target value at the end of the interpolation
  38078. * @param duration deines the time it will take for the property to interpolate to the value.
  38079. * @param condition defines the trigger related conditions
  38080. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38081. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38082. */
  38083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38084. /** @hidden */
  38085. _prepare(): void;
  38086. /**
  38087. * Execute the action starts the value interpolation.
  38088. */
  38089. execute(): void;
  38090. /**
  38091. * Serializes the actions and its related information.
  38092. * @param parent defines the object to serialize in
  38093. * @returns the serialized object
  38094. */
  38095. serialize(parent: any): any;
  38096. }
  38097. }
  38098. declare module BABYLON {
  38099. /**
  38100. * Options allowed during the creation of a sound track.
  38101. */
  38102. export interface ISoundTrackOptions {
  38103. /**
  38104. * The volume the sound track should take during creation
  38105. */
  38106. volume?: number;
  38107. /**
  38108. * Define if the sound track is the main sound track of the scene
  38109. */
  38110. mainTrack?: boolean;
  38111. }
  38112. /**
  38113. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38114. * It will be also used in a future release to apply effects on a specific track.
  38115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38116. */
  38117. export class SoundTrack {
  38118. /**
  38119. * The unique identifier of the sound track in the scene.
  38120. */
  38121. id: number;
  38122. /**
  38123. * The list of sounds included in the sound track.
  38124. */
  38125. soundCollection: Array<Sound>;
  38126. private _outputAudioNode;
  38127. private _scene;
  38128. private _connectedAnalyser;
  38129. private _options;
  38130. private _isInitialized;
  38131. /**
  38132. * Creates a new sound track.
  38133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38134. * @param scene Define the scene the sound track belongs to
  38135. * @param options
  38136. */
  38137. constructor(scene: Scene, options?: ISoundTrackOptions);
  38138. private _initializeSoundTrackAudioGraph;
  38139. /**
  38140. * Release the sound track and its associated resources
  38141. */
  38142. dispose(): void;
  38143. /**
  38144. * Adds a sound to this sound track
  38145. * @param sound define the cound to add
  38146. * @ignoreNaming
  38147. */
  38148. AddSound(sound: Sound): void;
  38149. /**
  38150. * Removes a sound to this sound track
  38151. * @param sound define the cound to remove
  38152. * @ignoreNaming
  38153. */
  38154. RemoveSound(sound: Sound): void;
  38155. /**
  38156. * Set a global volume for the full sound track.
  38157. * @param newVolume Define the new volume of the sound track
  38158. */
  38159. setVolume(newVolume: number): void;
  38160. /**
  38161. * Switch the panning model to HRTF:
  38162. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38164. */
  38165. switchPanningModelToHRTF(): void;
  38166. /**
  38167. * Switch the panning model to Equal Power:
  38168. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38170. */
  38171. switchPanningModelToEqualPower(): void;
  38172. /**
  38173. * Connect the sound track to an audio analyser allowing some amazing
  38174. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38176. * @param analyser The analyser to connect to the engine
  38177. */
  38178. connectToAnalyser(analyser: Analyser): void;
  38179. }
  38180. }
  38181. declare module BABYLON {
  38182. interface AbstractScene {
  38183. /**
  38184. * The list of sounds used in the scene.
  38185. */
  38186. sounds: Nullable<Array<Sound>>;
  38187. }
  38188. interface Scene {
  38189. /**
  38190. * @hidden
  38191. * Backing field
  38192. */
  38193. _mainSoundTrack: SoundTrack;
  38194. /**
  38195. * The main sound track played by the scene.
  38196. * It cotains your primary collection of sounds.
  38197. */
  38198. mainSoundTrack: SoundTrack;
  38199. /**
  38200. * The list of sound tracks added to the scene
  38201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38202. */
  38203. soundTracks: Nullable<Array<SoundTrack>>;
  38204. /**
  38205. * Gets a sound using a given name
  38206. * @param name defines the name to search for
  38207. * @return the found sound or null if not found at all.
  38208. */
  38209. getSoundByName(name: string): Nullable<Sound>;
  38210. /**
  38211. * Gets or sets if audio support is enabled
  38212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38213. */
  38214. audioEnabled: boolean;
  38215. /**
  38216. * Gets or sets if audio will be output to headphones
  38217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38218. */
  38219. headphone: boolean;
  38220. /**
  38221. * Gets or sets custom audio listener position provider
  38222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38223. */
  38224. audioListenerPositionProvider: Nullable<() => Vector3>;
  38225. /**
  38226. * Gets or sets a refresh rate when using 3D audio positioning
  38227. */
  38228. audioPositioningRefreshRate: number;
  38229. }
  38230. /**
  38231. * Defines the sound scene component responsible to manage any sounds
  38232. * in a given scene.
  38233. */
  38234. export class AudioSceneComponent implements ISceneSerializableComponent {
  38235. /**
  38236. * The component name helpfull to identify the component in the list of scene components.
  38237. */
  38238. readonly name: string;
  38239. /**
  38240. * The scene the component belongs to.
  38241. */
  38242. scene: Scene;
  38243. private _audioEnabled;
  38244. /**
  38245. * Gets whether audio is enabled or not.
  38246. * Please use related enable/disable method to switch state.
  38247. */
  38248. get audioEnabled(): boolean;
  38249. private _headphone;
  38250. /**
  38251. * Gets whether audio is outputing to headphone or not.
  38252. * Please use the according Switch methods to change output.
  38253. */
  38254. get headphone(): boolean;
  38255. /**
  38256. * Gets or sets a refresh rate when using 3D audio positioning
  38257. */
  38258. audioPositioningRefreshRate: number;
  38259. private _audioListenerPositionProvider;
  38260. /**
  38261. * Gets the current audio listener position provider
  38262. */
  38263. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38264. /**
  38265. * Sets a custom listener position for all sounds in the scene
  38266. * By default, this is the position of the first active camera
  38267. */
  38268. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38269. /**
  38270. * Creates a new instance of the component for the given scene
  38271. * @param scene Defines the scene to register the component in
  38272. */
  38273. constructor(scene: Scene);
  38274. /**
  38275. * Registers the component in a given scene
  38276. */
  38277. register(): void;
  38278. /**
  38279. * Rebuilds the elements related to this component in case of
  38280. * context lost for instance.
  38281. */
  38282. rebuild(): void;
  38283. /**
  38284. * Serializes the component data to the specified json object
  38285. * @param serializationObject The object to serialize to
  38286. */
  38287. serialize(serializationObject: any): void;
  38288. /**
  38289. * Adds all the elements from the container to the scene
  38290. * @param container the container holding the elements
  38291. */
  38292. addFromContainer(container: AbstractScene): void;
  38293. /**
  38294. * Removes all the elements in the container from the scene
  38295. * @param container contains the elements to remove
  38296. * @param dispose if the removed element should be disposed (default: false)
  38297. */
  38298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38299. /**
  38300. * Disposes the component and the associated ressources.
  38301. */
  38302. dispose(): void;
  38303. /**
  38304. * Disables audio in the associated scene.
  38305. */
  38306. disableAudio(): void;
  38307. /**
  38308. * Enables audio in the associated scene.
  38309. */
  38310. enableAudio(): void;
  38311. /**
  38312. * Switch audio to headphone output.
  38313. */
  38314. switchAudioModeForHeadphones(): void;
  38315. /**
  38316. * Switch audio to normal speakers.
  38317. */
  38318. switchAudioModeForNormalSpeakers(): void;
  38319. private _cachedCameraDirection;
  38320. private _cachedCameraPosition;
  38321. private _lastCheck;
  38322. private _afterRender;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /**
  38327. * Wraps one or more Sound objects and selects one with random weight for playback.
  38328. */
  38329. export class WeightedSound {
  38330. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38331. loop: boolean;
  38332. private _coneInnerAngle;
  38333. private _coneOuterAngle;
  38334. private _volume;
  38335. /** A Sound is currently playing. */
  38336. isPlaying: boolean;
  38337. /** A Sound is currently paused. */
  38338. isPaused: boolean;
  38339. private _sounds;
  38340. private _weights;
  38341. private _currentIndex?;
  38342. /**
  38343. * Creates a new WeightedSound from the list of sounds given.
  38344. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38345. * @param sounds Array of Sounds that will be selected from.
  38346. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38347. */
  38348. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38349. /**
  38350. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38351. */
  38352. get directionalConeInnerAngle(): number;
  38353. /**
  38354. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38355. */
  38356. set directionalConeInnerAngle(value: number);
  38357. /**
  38358. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38359. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38360. */
  38361. get directionalConeOuterAngle(): number;
  38362. /**
  38363. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38364. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38365. */
  38366. set directionalConeOuterAngle(value: number);
  38367. /**
  38368. * Playback volume.
  38369. */
  38370. get volume(): number;
  38371. /**
  38372. * Playback volume.
  38373. */
  38374. set volume(value: number);
  38375. private _onended;
  38376. /**
  38377. * Suspend playback
  38378. */
  38379. pause(): void;
  38380. /**
  38381. * Stop playback
  38382. */
  38383. stop(): void;
  38384. /**
  38385. * Start playback.
  38386. * @param startOffset Position the clip head at a specific time in seconds.
  38387. */
  38388. play(startOffset?: number): void;
  38389. }
  38390. }
  38391. declare module BABYLON {
  38392. /**
  38393. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38394. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38395. */
  38396. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38397. /**
  38398. * Gets the name of the behavior.
  38399. */
  38400. get name(): string;
  38401. /**
  38402. * The easing function used by animations
  38403. */
  38404. static EasingFunction: BackEase;
  38405. /**
  38406. * The easing mode used by animations
  38407. */
  38408. static EasingMode: number;
  38409. /**
  38410. * The duration of the animation, in milliseconds
  38411. */
  38412. transitionDuration: number;
  38413. /**
  38414. * Length of the distance animated by the transition when lower radius is reached
  38415. */
  38416. lowerRadiusTransitionRange: number;
  38417. /**
  38418. * Length of the distance animated by the transition when upper radius is reached
  38419. */
  38420. upperRadiusTransitionRange: number;
  38421. private _autoTransitionRange;
  38422. /**
  38423. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38424. */
  38425. get autoTransitionRange(): boolean;
  38426. /**
  38427. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38428. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38429. */
  38430. set autoTransitionRange(value: boolean);
  38431. private _attachedCamera;
  38432. private _onAfterCheckInputsObserver;
  38433. private _onMeshTargetChangedObserver;
  38434. /**
  38435. * Initializes the behavior.
  38436. */
  38437. init(): void;
  38438. /**
  38439. * Attaches the behavior to its arc rotate camera.
  38440. * @param camera Defines the camera to attach the behavior to
  38441. */
  38442. attach(camera: ArcRotateCamera): void;
  38443. /**
  38444. * Detaches the behavior from its current arc rotate camera.
  38445. */
  38446. detach(): void;
  38447. private _radiusIsAnimating;
  38448. private _radiusBounceTransition;
  38449. private _animatables;
  38450. private _cachedWheelPrecision;
  38451. /**
  38452. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38453. * @param radiusLimit The limit to check against.
  38454. * @return Bool to indicate if at limit.
  38455. */
  38456. private _isRadiusAtLimit;
  38457. /**
  38458. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38459. * @param radiusDelta The delta by which to animate to. Can be negative.
  38460. */
  38461. private _applyBoundRadiusAnimation;
  38462. /**
  38463. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38464. */
  38465. protected _clearAnimationLocks(): void;
  38466. /**
  38467. * Stops and removes all animations that have been applied to the camera
  38468. */
  38469. stopAllAnimations(): void;
  38470. }
  38471. }
  38472. declare module BABYLON {
  38473. /**
  38474. * 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.
  38475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38476. */
  38477. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38478. /**
  38479. * Gets the name of the behavior.
  38480. */
  38481. get name(): string;
  38482. private _mode;
  38483. private _radiusScale;
  38484. private _positionScale;
  38485. private _defaultElevation;
  38486. private _elevationReturnTime;
  38487. private _elevationReturnWaitTime;
  38488. private _zoomStopsAnimation;
  38489. private _framingTime;
  38490. /**
  38491. * The easing function used by animations
  38492. */
  38493. static EasingFunction: ExponentialEase;
  38494. /**
  38495. * The easing mode used by animations
  38496. */
  38497. static EasingMode: number;
  38498. /**
  38499. * Sets the current mode used by the behavior
  38500. */
  38501. set mode(mode: number);
  38502. /**
  38503. * Gets current mode used by the behavior.
  38504. */
  38505. get mode(): number;
  38506. /**
  38507. * Sets the scale applied to the radius (1 by default)
  38508. */
  38509. set radiusScale(radius: number);
  38510. /**
  38511. * Gets the scale applied to the radius
  38512. */
  38513. get radiusScale(): number;
  38514. /**
  38515. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38516. */
  38517. set positionScale(scale: number);
  38518. /**
  38519. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38520. */
  38521. get positionScale(): number;
  38522. /**
  38523. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38524. * behaviour is triggered, in radians.
  38525. */
  38526. set defaultElevation(elevation: number);
  38527. /**
  38528. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38529. * behaviour is triggered, in radians.
  38530. */
  38531. get defaultElevation(): number;
  38532. /**
  38533. * Sets the time (in milliseconds) taken to return to the default beta position.
  38534. * Negative value indicates camera should not return to default.
  38535. */
  38536. set elevationReturnTime(speed: number);
  38537. /**
  38538. * Gets the time (in milliseconds) taken to return to the default beta position.
  38539. * Negative value indicates camera should not return to default.
  38540. */
  38541. get elevationReturnTime(): number;
  38542. /**
  38543. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38544. */
  38545. set elevationReturnWaitTime(time: number);
  38546. /**
  38547. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38548. */
  38549. get elevationReturnWaitTime(): number;
  38550. /**
  38551. * Sets the flag that indicates if user zooming should stop animation.
  38552. */
  38553. set zoomStopsAnimation(flag: boolean);
  38554. /**
  38555. * Gets the flag that indicates if user zooming should stop animation.
  38556. */
  38557. get zoomStopsAnimation(): boolean;
  38558. /**
  38559. * Sets the transition time when framing the mesh, in milliseconds
  38560. */
  38561. set framingTime(time: number);
  38562. /**
  38563. * Gets the transition time when framing the mesh, in milliseconds
  38564. */
  38565. get framingTime(): number;
  38566. /**
  38567. * Define if the behavior should automatically change the configured
  38568. * camera limits and sensibilities.
  38569. */
  38570. autoCorrectCameraLimitsAndSensibility: boolean;
  38571. private _onPrePointerObservableObserver;
  38572. private _onAfterCheckInputsObserver;
  38573. private _onMeshTargetChangedObserver;
  38574. private _attachedCamera;
  38575. private _isPointerDown;
  38576. private _lastInteractionTime;
  38577. /**
  38578. * Initializes the behavior.
  38579. */
  38580. init(): void;
  38581. /**
  38582. * Attaches the behavior to its arc rotate camera.
  38583. * @param camera Defines the camera to attach the behavior to
  38584. */
  38585. attach(camera: ArcRotateCamera): void;
  38586. /**
  38587. * Detaches the behavior from its current arc rotate camera.
  38588. */
  38589. detach(): void;
  38590. private _animatables;
  38591. private _betaIsAnimating;
  38592. private _betaTransition;
  38593. private _radiusTransition;
  38594. private _vectorTransition;
  38595. /**
  38596. * Targets the given mesh and updates zoom level accordingly.
  38597. * @param mesh The mesh to target.
  38598. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38599. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38600. */
  38601. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38602. /**
  38603. * Targets the given mesh with its children and updates zoom level accordingly.
  38604. * @param mesh The mesh to target.
  38605. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38606. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38607. */
  38608. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38609. /**
  38610. * Targets the given meshes with their children and updates zoom level accordingly.
  38611. * @param meshes The mesh to target.
  38612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38614. */
  38615. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38616. /**
  38617. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38618. * @param minimumWorld Determines the smaller position of the bounding box extend
  38619. * @param maximumWorld Determines the bigger position of the bounding box extend
  38620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38622. */
  38623. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38624. /**
  38625. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38626. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38627. * frustum width.
  38628. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38629. * to fully enclose the mesh in the viewing frustum.
  38630. */
  38631. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38632. /**
  38633. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38634. * is automatically returned to its default position (expected to be above ground plane).
  38635. */
  38636. private _maintainCameraAboveGround;
  38637. /**
  38638. * Returns the frustum slope based on the canvas ratio and camera FOV
  38639. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38640. */
  38641. private _getFrustumSlope;
  38642. /**
  38643. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38644. */
  38645. private _clearAnimationLocks;
  38646. /**
  38647. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38648. */
  38649. private _applyUserInteraction;
  38650. /**
  38651. * Stops and removes all animations that have been applied to the camera
  38652. */
  38653. stopAllAnimations(): void;
  38654. /**
  38655. * Gets a value indicating if the user is moving the camera
  38656. */
  38657. get isUserIsMoving(): boolean;
  38658. /**
  38659. * The camera can move all the way towards the mesh.
  38660. */
  38661. static IgnoreBoundsSizeMode: number;
  38662. /**
  38663. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38664. */
  38665. static FitFrustumSidesMode: number;
  38666. }
  38667. }
  38668. declare module BABYLON {
  38669. /**
  38670. * Base class for Camera Pointer Inputs.
  38671. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38672. * for example usage.
  38673. */
  38674. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38675. /**
  38676. * Defines the camera the input is attached to.
  38677. */
  38678. abstract camera: Camera;
  38679. /**
  38680. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38681. */
  38682. protected _altKey: boolean;
  38683. protected _ctrlKey: boolean;
  38684. protected _metaKey: boolean;
  38685. protected _shiftKey: boolean;
  38686. /**
  38687. * Which mouse buttons were pressed at time of last mouse event.
  38688. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38689. */
  38690. protected _buttonsPressed: number;
  38691. /**
  38692. * Defines the buttons associated with the input to handle camera move.
  38693. */
  38694. buttons: number[];
  38695. /**
  38696. * Attach the input controls to a specific dom element to get the input from.
  38697. * @param element Defines the element the controls should be listened from
  38698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38699. */
  38700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38701. /**
  38702. * Detach the current controls from the specified dom element.
  38703. * @param element Defines the element to stop listening the inputs from
  38704. */
  38705. detachControl(element: Nullable<HTMLElement>): void;
  38706. /**
  38707. * Gets the class name of the current input.
  38708. * @returns the class name
  38709. */
  38710. getClassName(): string;
  38711. /**
  38712. * Get the friendly name associated with the input class.
  38713. * @returns the input friendly name
  38714. */
  38715. getSimpleName(): string;
  38716. /**
  38717. * Called on pointer POINTERDOUBLETAP event.
  38718. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38719. */
  38720. protected onDoubleTap(type: string): void;
  38721. /**
  38722. * Called on pointer POINTERMOVE event if only a single touch is active.
  38723. * Override this method to provide functionality.
  38724. */
  38725. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38726. /**
  38727. * Called on pointer POINTERMOVE event if multiple touches are active.
  38728. * Override this method to provide functionality.
  38729. */
  38730. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38731. /**
  38732. * Called on JS contextmenu event.
  38733. * Override this method to provide functionality.
  38734. */
  38735. protected onContextMenu(evt: PointerEvent): void;
  38736. /**
  38737. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38738. * press.
  38739. * Override this method to provide functionality.
  38740. */
  38741. protected onButtonDown(evt: PointerEvent): void;
  38742. /**
  38743. * Called each time a new POINTERUP event occurs. Ie, for each button
  38744. * release.
  38745. * Override this method to provide functionality.
  38746. */
  38747. protected onButtonUp(evt: PointerEvent): void;
  38748. /**
  38749. * Called when window becomes inactive.
  38750. * Override this method to provide functionality.
  38751. */
  38752. protected onLostFocus(): void;
  38753. private _pointerInput;
  38754. private _observer;
  38755. private _onLostFocus;
  38756. private pointA;
  38757. private pointB;
  38758. }
  38759. }
  38760. declare module BABYLON {
  38761. /**
  38762. * Manage the pointers inputs to control an arc rotate camera.
  38763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38764. */
  38765. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38766. /**
  38767. * Defines the camera the input is attached to.
  38768. */
  38769. camera: ArcRotateCamera;
  38770. /**
  38771. * Gets the class name of the current input.
  38772. * @returns the class name
  38773. */
  38774. getClassName(): string;
  38775. /**
  38776. * Defines the buttons associated with the input to handle camera move.
  38777. */
  38778. buttons: number[];
  38779. /**
  38780. * Defines the pointer angular sensibility along the X axis or how fast is
  38781. * the camera rotating.
  38782. */
  38783. angularSensibilityX: number;
  38784. /**
  38785. * Defines the pointer angular sensibility along the Y axis or how fast is
  38786. * the camera rotating.
  38787. */
  38788. angularSensibilityY: number;
  38789. /**
  38790. * Defines the pointer pinch precision or how fast is the camera zooming.
  38791. */
  38792. pinchPrecision: number;
  38793. /**
  38794. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38795. * from 0.
  38796. * It defines the percentage of current camera.radius to use as delta when
  38797. * pinch zoom is used.
  38798. */
  38799. pinchDeltaPercentage: number;
  38800. /**
  38801. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38802. * that any object in the plane at the camera's target point will scale
  38803. * perfectly with finger motion.
  38804. * Overrides pinchDeltaPercentage and pinchPrecision.
  38805. */
  38806. useNaturalPinchZoom: boolean;
  38807. /**
  38808. * Defines the pointer panning sensibility or how fast is the camera moving.
  38809. */
  38810. panningSensibility: number;
  38811. /**
  38812. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38813. */
  38814. multiTouchPanning: boolean;
  38815. /**
  38816. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38817. * zoom (pinch) through multitouch.
  38818. */
  38819. multiTouchPanAndZoom: boolean;
  38820. /**
  38821. * Revers pinch action direction.
  38822. */
  38823. pinchInwards: boolean;
  38824. private _isPanClick;
  38825. private _twoFingerActivityCount;
  38826. private _isPinching;
  38827. /**
  38828. * Called on pointer POINTERMOVE event if only a single touch is active.
  38829. */
  38830. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38831. /**
  38832. * Called on pointer POINTERDOUBLETAP event.
  38833. */
  38834. protected onDoubleTap(type: string): void;
  38835. /**
  38836. * Called on pointer POINTERMOVE event if multiple touches are active.
  38837. */
  38838. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38839. /**
  38840. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38841. * press.
  38842. */
  38843. protected onButtonDown(evt: PointerEvent): void;
  38844. /**
  38845. * Called each time a new POINTERUP event occurs. Ie, for each button
  38846. * release.
  38847. */
  38848. protected onButtonUp(evt: PointerEvent): void;
  38849. /**
  38850. * Called when window becomes inactive.
  38851. */
  38852. protected onLostFocus(): void;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38859. */
  38860. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38861. /**
  38862. * Defines the camera the input is attached to.
  38863. */
  38864. camera: ArcRotateCamera;
  38865. /**
  38866. * Defines the list of key codes associated with the up action (increase alpha)
  38867. */
  38868. keysUp: number[];
  38869. /**
  38870. * Defines the list of key codes associated with the down action (decrease alpha)
  38871. */
  38872. keysDown: number[];
  38873. /**
  38874. * Defines the list of key codes associated with the left action (increase beta)
  38875. */
  38876. keysLeft: number[];
  38877. /**
  38878. * Defines the list of key codes associated with the right action (decrease beta)
  38879. */
  38880. keysRight: number[];
  38881. /**
  38882. * Defines the list of key codes associated with the reset action.
  38883. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38884. */
  38885. keysReset: number[];
  38886. /**
  38887. * Defines the panning sensibility of the inputs.
  38888. * (How fast is the camera panning)
  38889. */
  38890. panningSensibility: number;
  38891. /**
  38892. * Defines the zooming sensibility of the inputs.
  38893. * (How fast is the camera zooming)
  38894. */
  38895. zoomingSensibility: number;
  38896. /**
  38897. * Defines whether maintaining the alt key down switch the movement mode from
  38898. * orientation to zoom.
  38899. */
  38900. useAltToZoom: boolean;
  38901. /**
  38902. * Rotation speed of the camera
  38903. */
  38904. angularSpeed: number;
  38905. private _keys;
  38906. private _ctrlPressed;
  38907. private _altPressed;
  38908. private _onCanvasBlurObserver;
  38909. private _onKeyboardObserver;
  38910. private _engine;
  38911. private _scene;
  38912. /**
  38913. * Attach the input controls to a specific dom element to get the input from.
  38914. * @param element Defines the element the controls should be listened from
  38915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38916. */
  38917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38918. /**
  38919. * Detach the current controls from the specified dom element.
  38920. * @param element Defines the element to stop listening the inputs from
  38921. */
  38922. detachControl(element: Nullable<HTMLElement>): void;
  38923. /**
  38924. * Update the current camera state depending on the inputs that have been used this frame.
  38925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38926. */
  38927. checkInputs(): void;
  38928. /**
  38929. * Gets the class name of the current intput.
  38930. * @returns the class name
  38931. */
  38932. getClassName(): string;
  38933. /**
  38934. * Get the friendly name associated with the input class.
  38935. * @returns the input friendly name
  38936. */
  38937. getSimpleName(): string;
  38938. }
  38939. }
  38940. declare module BABYLON {
  38941. /**
  38942. * Manage the mouse wheel inputs to control an arc rotate camera.
  38943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38944. */
  38945. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38946. /**
  38947. * Defines the camera the input is attached to.
  38948. */
  38949. camera: ArcRotateCamera;
  38950. /**
  38951. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38952. */
  38953. wheelPrecision: number;
  38954. /**
  38955. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38956. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38957. */
  38958. wheelDeltaPercentage: number;
  38959. private _wheel;
  38960. private _observer;
  38961. private computeDeltaFromMouseWheelLegacyEvent;
  38962. /**
  38963. * Attach the input controls to a specific dom element to get the input from.
  38964. * @param element Defines the element the controls should be listened from
  38965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38966. */
  38967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38968. /**
  38969. * Detach the current controls from the specified dom element.
  38970. * @param element Defines the element to stop listening the inputs from
  38971. */
  38972. detachControl(element: Nullable<HTMLElement>): void;
  38973. /**
  38974. * Gets the class name of the current intput.
  38975. * @returns the class name
  38976. */
  38977. getClassName(): string;
  38978. /**
  38979. * Get the friendly name associated with the input class.
  38980. * @returns the input friendly name
  38981. */
  38982. getSimpleName(): string;
  38983. }
  38984. }
  38985. declare module BABYLON {
  38986. /**
  38987. * Default Inputs manager for the ArcRotateCamera.
  38988. * It groups all the default supported inputs for ease of use.
  38989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38990. */
  38991. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38992. /**
  38993. * Instantiates a new ArcRotateCameraInputsManager.
  38994. * @param camera Defines the camera the inputs belong to
  38995. */
  38996. constructor(camera: ArcRotateCamera);
  38997. /**
  38998. * Add mouse wheel input support to the input manager.
  38999. * @returns the current input manager
  39000. */
  39001. addMouseWheel(): ArcRotateCameraInputsManager;
  39002. /**
  39003. * Add pointers input support to the input manager.
  39004. * @returns the current input manager
  39005. */
  39006. addPointers(): ArcRotateCameraInputsManager;
  39007. /**
  39008. * Add keyboard input support to the input manager.
  39009. * @returns the current input manager
  39010. */
  39011. addKeyboard(): ArcRotateCameraInputsManager;
  39012. }
  39013. }
  39014. declare module BABYLON {
  39015. /**
  39016. * This represents an orbital type of camera.
  39017. *
  39018. * 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.
  39019. * 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.
  39020. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39021. */
  39022. export class ArcRotateCamera extends TargetCamera {
  39023. /**
  39024. * Defines the rotation angle of the camera along the longitudinal axis.
  39025. */
  39026. alpha: number;
  39027. /**
  39028. * Defines the rotation angle of the camera along the latitudinal axis.
  39029. */
  39030. beta: number;
  39031. /**
  39032. * Defines the radius of the camera from it s target point.
  39033. */
  39034. radius: number;
  39035. protected _target: Vector3;
  39036. protected _targetHost: Nullable<AbstractMesh>;
  39037. /**
  39038. * Defines the target point of the camera.
  39039. * The camera looks towards it form the radius distance.
  39040. */
  39041. get target(): Vector3;
  39042. set target(value: Vector3);
  39043. /**
  39044. * Define the current local position of the camera in the scene
  39045. */
  39046. get position(): Vector3;
  39047. set position(newPosition: Vector3);
  39048. protected _upVector: Vector3;
  39049. protected _upToYMatrix: Matrix;
  39050. protected _YToUpMatrix: Matrix;
  39051. /**
  39052. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39053. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39054. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39055. */
  39056. set upVector(vec: Vector3);
  39057. get upVector(): Vector3;
  39058. /**
  39059. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39060. */
  39061. setMatUp(): void;
  39062. /**
  39063. * Current inertia value on the longitudinal axis.
  39064. * The bigger this number the longer it will take for the camera to stop.
  39065. */
  39066. inertialAlphaOffset: number;
  39067. /**
  39068. * Current inertia value on the latitudinal axis.
  39069. * The bigger this number the longer it will take for the camera to stop.
  39070. */
  39071. inertialBetaOffset: number;
  39072. /**
  39073. * Current inertia value on the radius axis.
  39074. * The bigger this number the longer it will take for the camera to stop.
  39075. */
  39076. inertialRadiusOffset: number;
  39077. /**
  39078. * Minimum allowed angle on the longitudinal axis.
  39079. * This can help limiting how the Camera is able to move in the scene.
  39080. */
  39081. lowerAlphaLimit: Nullable<number>;
  39082. /**
  39083. * Maximum allowed angle on the longitudinal axis.
  39084. * This can help limiting how the Camera is able to move in the scene.
  39085. */
  39086. upperAlphaLimit: Nullable<number>;
  39087. /**
  39088. * Minimum allowed angle on the latitudinal axis.
  39089. * This can help limiting how the Camera is able to move in the scene.
  39090. */
  39091. lowerBetaLimit: number;
  39092. /**
  39093. * Maximum allowed angle on the latitudinal axis.
  39094. * This can help limiting how the Camera is able to move in the scene.
  39095. */
  39096. upperBetaLimit: number;
  39097. /**
  39098. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39099. * This can help limiting how the Camera is able to move in the scene.
  39100. */
  39101. lowerRadiusLimit: Nullable<number>;
  39102. /**
  39103. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39104. * This can help limiting how the Camera is able to move in the scene.
  39105. */
  39106. upperRadiusLimit: Nullable<number>;
  39107. /**
  39108. * Defines the current inertia value used during panning of the camera along the X axis.
  39109. */
  39110. inertialPanningX: number;
  39111. /**
  39112. * Defines the current inertia value used during panning of the camera along the Y axis.
  39113. */
  39114. inertialPanningY: number;
  39115. /**
  39116. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39117. * Basically if your fingers moves away from more than this distance you will be considered
  39118. * in pinch mode.
  39119. */
  39120. pinchToPanMaxDistance: number;
  39121. /**
  39122. * Defines the maximum distance the camera can pan.
  39123. * This could help keeping the cammera always in your scene.
  39124. */
  39125. panningDistanceLimit: Nullable<number>;
  39126. /**
  39127. * Defines the target of the camera before paning.
  39128. */
  39129. panningOriginTarget: Vector3;
  39130. /**
  39131. * Defines the value of the inertia used during panning.
  39132. * 0 would mean stop inertia and one would mean no decelleration at all.
  39133. */
  39134. panningInertia: number;
  39135. /**
  39136. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39137. */
  39138. get angularSensibilityX(): number;
  39139. set angularSensibilityX(value: number);
  39140. /**
  39141. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39142. */
  39143. get angularSensibilityY(): number;
  39144. set angularSensibilityY(value: number);
  39145. /**
  39146. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39147. */
  39148. get pinchPrecision(): number;
  39149. set pinchPrecision(value: number);
  39150. /**
  39151. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39152. * It will be used instead of pinchDeltaPrecision if different from 0.
  39153. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39154. */
  39155. get pinchDeltaPercentage(): number;
  39156. set pinchDeltaPercentage(value: number);
  39157. /**
  39158. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39159. * and pinch delta percentage.
  39160. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39161. * that any object in the plane at the camera's target point will scale
  39162. * perfectly with finger motion.
  39163. */
  39164. get useNaturalPinchZoom(): boolean;
  39165. set useNaturalPinchZoom(value: boolean);
  39166. /**
  39167. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39168. */
  39169. get panningSensibility(): number;
  39170. set panningSensibility(value: number);
  39171. /**
  39172. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39173. */
  39174. get keysUp(): number[];
  39175. set keysUp(value: number[]);
  39176. /**
  39177. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39178. */
  39179. get keysDown(): number[];
  39180. set keysDown(value: number[]);
  39181. /**
  39182. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39183. */
  39184. get keysLeft(): number[];
  39185. set keysLeft(value: number[]);
  39186. /**
  39187. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39188. */
  39189. get keysRight(): number[];
  39190. set keysRight(value: number[]);
  39191. /**
  39192. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39193. */
  39194. get wheelPrecision(): number;
  39195. set wheelPrecision(value: number);
  39196. /**
  39197. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39198. * It will be used instead of pinchDeltaPrecision if different from 0.
  39199. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39200. */
  39201. get wheelDeltaPercentage(): number;
  39202. set wheelDeltaPercentage(value: number);
  39203. /**
  39204. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39205. */
  39206. zoomOnFactor: number;
  39207. /**
  39208. * Defines a screen offset for the camera position.
  39209. */
  39210. targetScreenOffset: Vector2;
  39211. /**
  39212. * Allows the camera to be completely reversed.
  39213. * If false the camera can not arrive upside down.
  39214. */
  39215. allowUpsideDown: boolean;
  39216. /**
  39217. * Define if double tap/click is used to restore the previously saved state of the camera.
  39218. */
  39219. useInputToRestoreState: boolean;
  39220. /** @hidden */
  39221. _viewMatrix: Matrix;
  39222. /** @hidden */
  39223. _useCtrlForPanning: boolean;
  39224. /** @hidden */
  39225. _panningMouseButton: number;
  39226. /**
  39227. * Defines the input associated to the camera.
  39228. */
  39229. inputs: ArcRotateCameraInputsManager;
  39230. /** @hidden */
  39231. _reset: () => void;
  39232. /**
  39233. * Defines the allowed panning axis.
  39234. */
  39235. panningAxis: Vector3;
  39236. protected _localDirection: Vector3;
  39237. protected _transformedDirection: Vector3;
  39238. private _bouncingBehavior;
  39239. /**
  39240. * Gets the bouncing behavior of the camera if it has been enabled.
  39241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39242. */
  39243. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39244. /**
  39245. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39247. */
  39248. get useBouncingBehavior(): boolean;
  39249. set useBouncingBehavior(value: boolean);
  39250. private _framingBehavior;
  39251. /**
  39252. * Gets the framing behavior of the camera if it has been enabled.
  39253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39254. */
  39255. get framingBehavior(): Nullable<FramingBehavior>;
  39256. /**
  39257. * Defines if the framing behavior of the camera is enabled on the camera.
  39258. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39259. */
  39260. get useFramingBehavior(): boolean;
  39261. set useFramingBehavior(value: boolean);
  39262. private _autoRotationBehavior;
  39263. /**
  39264. * Gets the auto rotation behavior of the camera if it has been enabled.
  39265. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39266. */
  39267. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39268. /**
  39269. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39270. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39271. */
  39272. get useAutoRotationBehavior(): boolean;
  39273. set useAutoRotationBehavior(value: boolean);
  39274. /**
  39275. * Observable triggered when the mesh target has been changed on the camera.
  39276. */
  39277. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39278. /**
  39279. * Event raised when the camera is colliding with a mesh.
  39280. */
  39281. onCollide: (collidedMesh: AbstractMesh) => void;
  39282. /**
  39283. * Defines whether the camera should check collision with the objects oh the scene.
  39284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39285. */
  39286. checkCollisions: boolean;
  39287. /**
  39288. * Defines the collision radius of the camera.
  39289. * This simulates a sphere around the camera.
  39290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39291. */
  39292. collisionRadius: Vector3;
  39293. protected _collider: Collider;
  39294. protected _previousPosition: Vector3;
  39295. protected _collisionVelocity: Vector3;
  39296. protected _newPosition: Vector3;
  39297. protected _previousAlpha: number;
  39298. protected _previousBeta: number;
  39299. protected _previousRadius: number;
  39300. protected _collisionTriggered: boolean;
  39301. protected _targetBoundingCenter: Nullable<Vector3>;
  39302. private _computationVector;
  39303. /**
  39304. * Instantiates a new ArcRotateCamera in a given scene
  39305. * @param name Defines the name of the camera
  39306. * @param alpha Defines the camera rotation along the logitudinal axis
  39307. * @param beta Defines the camera rotation along the latitudinal axis
  39308. * @param radius Defines the camera distance from its target
  39309. * @param target Defines the camera target
  39310. * @param scene Defines the scene the camera belongs to
  39311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39312. */
  39313. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39314. /** @hidden */
  39315. _initCache(): void;
  39316. /** @hidden */
  39317. _updateCache(ignoreParentClass?: boolean): void;
  39318. protected _getTargetPosition(): Vector3;
  39319. private _storedAlpha;
  39320. private _storedBeta;
  39321. private _storedRadius;
  39322. private _storedTarget;
  39323. private _storedTargetScreenOffset;
  39324. /**
  39325. * Stores the current state of the camera (alpha, beta, radius and target)
  39326. * @returns the camera itself
  39327. */
  39328. storeState(): Camera;
  39329. /**
  39330. * @hidden
  39331. * Restored camera state. You must call storeState() first
  39332. */
  39333. _restoreStateValues(): boolean;
  39334. /** @hidden */
  39335. _isSynchronizedViewMatrix(): boolean;
  39336. /**
  39337. * Attached controls to the current camera.
  39338. * @param element Defines the element the controls should be listened from
  39339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39340. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39341. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39342. */
  39343. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39344. /**
  39345. * Detach the current controls from the camera.
  39346. * The camera will stop reacting to inputs.
  39347. * @param element Defines the element to stop listening the inputs from
  39348. */
  39349. detachControl(element: HTMLElement): void;
  39350. /** @hidden */
  39351. _checkInputs(): void;
  39352. protected _checkLimits(): void;
  39353. /**
  39354. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39355. */
  39356. rebuildAnglesAndRadius(): void;
  39357. /**
  39358. * Use a position to define the current camera related information like alpha, beta and radius
  39359. * @param position Defines the position to set the camera at
  39360. */
  39361. setPosition(position: Vector3): void;
  39362. /**
  39363. * Defines the target the camera should look at.
  39364. * This will automatically adapt alpha beta and radius to fit within the new target.
  39365. * @param target Defines the new target as a Vector or a mesh
  39366. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39367. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39368. */
  39369. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39370. /** @hidden */
  39371. _getViewMatrix(): Matrix;
  39372. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39373. /**
  39374. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39375. * @param meshes Defines the mesh to zoom on
  39376. * @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)
  39377. */
  39378. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39379. /**
  39380. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39381. * The target will be changed but the radius
  39382. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39383. * @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)
  39384. */
  39385. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39386. min: Vector3;
  39387. max: Vector3;
  39388. distance: number;
  39389. }, doNotUpdateMaxZ?: boolean): void;
  39390. /**
  39391. * @override
  39392. * Override Camera.createRigCamera
  39393. */
  39394. createRigCamera(name: string, cameraIndex: number): Camera;
  39395. /**
  39396. * @hidden
  39397. * @override
  39398. * Override Camera._updateRigCameras
  39399. */
  39400. _updateRigCameras(): void;
  39401. /**
  39402. * Destroy the camera and release the current resources hold by it.
  39403. */
  39404. dispose(): void;
  39405. /**
  39406. * Gets the current object class name.
  39407. * @return the class name
  39408. */
  39409. getClassName(): string;
  39410. }
  39411. }
  39412. declare module BABYLON {
  39413. /**
  39414. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39415. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39416. */
  39417. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39418. /**
  39419. * Gets the name of the behavior.
  39420. */
  39421. get name(): string;
  39422. private _zoomStopsAnimation;
  39423. private _idleRotationSpeed;
  39424. private _idleRotationWaitTime;
  39425. private _idleRotationSpinupTime;
  39426. /**
  39427. * Sets the flag that indicates if user zooming should stop animation.
  39428. */
  39429. set zoomStopsAnimation(flag: boolean);
  39430. /**
  39431. * Gets the flag that indicates if user zooming should stop animation.
  39432. */
  39433. get zoomStopsAnimation(): boolean;
  39434. /**
  39435. * Sets the default speed at which the camera rotates around the model.
  39436. */
  39437. set idleRotationSpeed(speed: number);
  39438. /**
  39439. * Gets the default speed at which the camera rotates around the model.
  39440. */
  39441. get idleRotationSpeed(): number;
  39442. /**
  39443. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39444. */
  39445. set idleRotationWaitTime(time: number);
  39446. /**
  39447. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39448. */
  39449. get idleRotationWaitTime(): number;
  39450. /**
  39451. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39452. */
  39453. set idleRotationSpinupTime(time: number);
  39454. /**
  39455. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39456. */
  39457. get idleRotationSpinupTime(): number;
  39458. /**
  39459. * Gets a value indicating if the camera is currently rotating because of this behavior
  39460. */
  39461. get rotationInProgress(): boolean;
  39462. private _onPrePointerObservableObserver;
  39463. private _onAfterCheckInputsObserver;
  39464. private _attachedCamera;
  39465. private _isPointerDown;
  39466. private _lastFrameTime;
  39467. private _lastInteractionTime;
  39468. private _cameraRotationSpeed;
  39469. /**
  39470. * Initializes the behavior.
  39471. */
  39472. init(): void;
  39473. /**
  39474. * Attaches the behavior to its arc rotate camera.
  39475. * @param camera Defines the camera to attach the behavior to
  39476. */
  39477. attach(camera: ArcRotateCamera): void;
  39478. /**
  39479. * Detaches the behavior from its current arc rotate camera.
  39480. */
  39481. detach(): void;
  39482. /**
  39483. * Returns true if user is scrolling.
  39484. * @return true if user is scrolling.
  39485. */
  39486. private _userIsZooming;
  39487. private _lastFrameRadius;
  39488. private _shouldAnimationStopForInteraction;
  39489. /**
  39490. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39491. */
  39492. private _applyUserInteraction;
  39493. private _userIsMoving;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39499. */
  39500. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39501. private ui;
  39502. /**
  39503. * The name of the behavior
  39504. */
  39505. name: string;
  39506. /**
  39507. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39508. */
  39509. distanceAwayFromFace: number;
  39510. /**
  39511. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39512. */
  39513. distanceAwayFromBottomOfFace: number;
  39514. private _faceVectors;
  39515. private _target;
  39516. private _scene;
  39517. private _onRenderObserver;
  39518. private _tmpMatrix;
  39519. private _tmpVector;
  39520. /**
  39521. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39522. * @param ui The transform node that should be attched to the mesh
  39523. */
  39524. constructor(ui: TransformNode);
  39525. /**
  39526. * Initializes the behavior
  39527. */
  39528. init(): void;
  39529. private _closestFace;
  39530. private _zeroVector;
  39531. private _lookAtTmpMatrix;
  39532. private _lookAtToRef;
  39533. /**
  39534. * Attaches the AttachToBoxBehavior to the passed in mesh
  39535. * @param target The mesh that the specified node will be attached to
  39536. */
  39537. attach(target: Mesh): void;
  39538. /**
  39539. * Detaches the behavior from the mesh
  39540. */
  39541. detach(): void;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /**
  39546. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39547. */
  39548. export class FadeInOutBehavior implements Behavior<Mesh> {
  39549. /**
  39550. * Time in milliseconds to delay before fading in (Default: 0)
  39551. */
  39552. delay: number;
  39553. /**
  39554. * Time in milliseconds for the mesh to fade in (Default: 300)
  39555. */
  39556. fadeInTime: number;
  39557. private _millisecondsPerFrame;
  39558. private _hovered;
  39559. private _hoverValue;
  39560. private _ownerNode;
  39561. /**
  39562. * Instatiates the FadeInOutBehavior
  39563. */
  39564. constructor();
  39565. /**
  39566. * The name of the behavior
  39567. */
  39568. get name(): string;
  39569. /**
  39570. * Initializes the behavior
  39571. */
  39572. init(): void;
  39573. /**
  39574. * Attaches the fade behavior on the passed in mesh
  39575. * @param ownerNode The mesh that will be faded in/out once attached
  39576. */
  39577. attach(ownerNode: Mesh): void;
  39578. /**
  39579. * Detaches the behavior from the mesh
  39580. */
  39581. detach(): void;
  39582. /**
  39583. * Triggers the mesh to begin fading in or out
  39584. * @param value if the object should fade in or out (true to fade in)
  39585. */
  39586. fadeIn(value: boolean): void;
  39587. private _update;
  39588. private _setAllVisibility;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * Class containing a set of static utilities functions for managing Pivots
  39594. * @hidden
  39595. */
  39596. export class PivotTools {
  39597. private static _PivotCached;
  39598. private static _OldPivotPoint;
  39599. private static _PivotTranslation;
  39600. private static _PivotTmpVector;
  39601. /** @hidden */
  39602. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39603. /** @hidden */
  39604. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39605. }
  39606. }
  39607. declare module BABYLON {
  39608. /**
  39609. * Class containing static functions to help procedurally build meshes
  39610. */
  39611. export class PlaneBuilder {
  39612. /**
  39613. * Creates a plane mesh
  39614. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39615. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39616. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39618. * * 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
  39619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39620. * @param name defines the name of the mesh
  39621. * @param options defines the options used to create the mesh
  39622. * @param scene defines the hosting scene
  39623. * @returns the plane mesh
  39624. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39625. */
  39626. static CreatePlane(name: string, options: {
  39627. size?: number;
  39628. width?: number;
  39629. height?: number;
  39630. sideOrientation?: number;
  39631. frontUVs?: Vector4;
  39632. backUVs?: Vector4;
  39633. updatable?: boolean;
  39634. sourcePlane?: Plane;
  39635. }, scene?: Nullable<Scene>): Mesh;
  39636. }
  39637. }
  39638. declare module BABYLON {
  39639. /**
  39640. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39641. */
  39642. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39643. private static _AnyMouseID;
  39644. /**
  39645. * Abstract mesh the behavior is set on
  39646. */
  39647. attachedNode: AbstractMesh;
  39648. private _dragPlane;
  39649. private _scene;
  39650. private _pointerObserver;
  39651. private _beforeRenderObserver;
  39652. private static _planeScene;
  39653. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39654. /**
  39655. * 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)
  39656. */
  39657. maxDragAngle: number;
  39658. /**
  39659. * @hidden
  39660. */
  39661. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39662. /**
  39663. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39664. */
  39665. currentDraggingPointerID: number;
  39666. /**
  39667. * The last position where the pointer hit the drag plane in world space
  39668. */
  39669. lastDragPosition: Vector3;
  39670. /**
  39671. * If the behavior is currently in a dragging state
  39672. */
  39673. dragging: boolean;
  39674. /**
  39675. * 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)
  39676. */
  39677. dragDeltaRatio: number;
  39678. /**
  39679. * If the drag plane orientation should be updated during the dragging (Default: true)
  39680. */
  39681. updateDragPlane: boolean;
  39682. private _debugMode;
  39683. private _moving;
  39684. /**
  39685. * Fires each time the attached mesh is dragged with the pointer
  39686. * * delta between last drag position and current drag position in world space
  39687. * * dragDistance along the drag axis
  39688. * * dragPlaneNormal normal of the current drag plane used during the drag
  39689. * * dragPlanePoint in world space where the drag intersects the drag plane
  39690. */
  39691. onDragObservable: Observable<{
  39692. delta: Vector3;
  39693. dragPlanePoint: Vector3;
  39694. dragPlaneNormal: Vector3;
  39695. dragDistance: number;
  39696. pointerId: number;
  39697. }>;
  39698. /**
  39699. * Fires each time a drag begins (eg. mouse down on mesh)
  39700. */
  39701. onDragStartObservable: Observable<{
  39702. dragPlanePoint: Vector3;
  39703. pointerId: number;
  39704. }>;
  39705. /**
  39706. * Fires each time a drag ends (eg. mouse release after drag)
  39707. */
  39708. onDragEndObservable: Observable<{
  39709. dragPlanePoint: Vector3;
  39710. pointerId: number;
  39711. }>;
  39712. /**
  39713. * If the attached mesh should be moved when dragged
  39714. */
  39715. moveAttached: boolean;
  39716. /**
  39717. * If the drag behavior will react to drag events (Default: true)
  39718. */
  39719. enabled: boolean;
  39720. /**
  39721. * If pointer events should start and release the drag (Default: true)
  39722. */
  39723. startAndReleaseDragOnPointerEvents: boolean;
  39724. /**
  39725. * If camera controls should be detached during the drag
  39726. */
  39727. detachCameraControls: boolean;
  39728. /**
  39729. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39730. */
  39731. useObjectOrientationForDragging: boolean;
  39732. private _options;
  39733. /**
  39734. * Gets the options used by the behavior
  39735. */
  39736. get options(): {
  39737. dragAxis?: Vector3;
  39738. dragPlaneNormal?: Vector3;
  39739. };
  39740. /**
  39741. * Sets the options used by the behavior
  39742. */
  39743. set options(options: {
  39744. dragAxis?: Vector3;
  39745. dragPlaneNormal?: Vector3;
  39746. });
  39747. /**
  39748. * Creates a pointer drag behavior that can be attached to a mesh
  39749. * @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)
  39750. */
  39751. constructor(options?: {
  39752. dragAxis?: Vector3;
  39753. dragPlaneNormal?: Vector3;
  39754. });
  39755. /**
  39756. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39757. */
  39758. validateDrag: (targetPosition: Vector3) => boolean;
  39759. /**
  39760. * The name of the behavior
  39761. */
  39762. get name(): string;
  39763. /**
  39764. * Initializes the behavior
  39765. */
  39766. init(): void;
  39767. private _tmpVector;
  39768. private _alternatePickedPoint;
  39769. private _worldDragAxis;
  39770. private _targetPosition;
  39771. private _attachedElement;
  39772. /**
  39773. * Attaches the drag behavior the passed in mesh
  39774. * @param ownerNode The mesh that will be dragged around once attached
  39775. * @param predicate Predicate to use for pick filtering
  39776. */
  39777. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39778. /**
  39779. * Force relase the drag action by code.
  39780. */
  39781. releaseDrag(): void;
  39782. private _startDragRay;
  39783. private _lastPointerRay;
  39784. /**
  39785. * Simulates the start of a pointer drag event on the behavior
  39786. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39787. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39788. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39789. */
  39790. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39791. private _startDrag;
  39792. private _dragDelta;
  39793. private _moveDrag;
  39794. private _pickWithRayOnDragPlane;
  39795. private _pointA;
  39796. private _pointB;
  39797. private _pointC;
  39798. private _lineA;
  39799. private _lineB;
  39800. private _localAxis;
  39801. private _lookAt;
  39802. private _updateDragPlanePosition;
  39803. /**
  39804. * Detaches the behavior from the mesh
  39805. */
  39806. detach(): void;
  39807. }
  39808. }
  39809. declare module BABYLON {
  39810. /**
  39811. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39812. */
  39813. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39814. private _dragBehaviorA;
  39815. private _dragBehaviorB;
  39816. private _startDistance;
  39817. private _initialScale;
  39818. private _targetScale;
  39819. private _ownerNode;
  39820. private _sceneRenderObserver;
  39821. /**
  39822. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39823. */
  39824. constructor();
  39825. /**
  39826. * The name of the behavior
  39827. */
  39828. get name(): string;
  39829. /**
  39830. * Initializes the behavior
  39831. */
  39832. init(): void;
  39833. private _getCurrentDistance;
  39834. /**
  39835. * Attaches the scale behavior the passed in mesh
  39836. * @param ownerNode The mesh that will be scaled around once attached
  39837. */
  39838. attach(ownerNode: Mesh): void;
  39839. /**
  39840. * Detaches the behavior from the mesh
  39841. */
  39842. detach(): void;
  39843. }
  39844. }
  39845. declare module BABYLON {
  39846. /**
  39847. * 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
  39848. */
  39849. export class SixDofDragBehavior implements Behavior<Mesh> {
  39850. private static _virtualScene;
  39851. private _ownerNode;
  39852. private _sceneRenderObserver;
  39853. private _scene;
  39854. private _targetPosition;
  39855. private _virtualOriginMesh;
  39856. private _virtualDragMesh;
  39857. private _pointerObserver;
  39858. private _moving;
  39859. private _startingOrientation;
  39860. private _attachedElement;
  39861. /**
  39862. * 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)
  39863. */
  39864. private zDragFactor;
  39865. /**
  39866. * If the object should rotate to face the drag origin
  39867. */
  39868. rotateDraggedObject: boolean;
  39869. /**
  39870. * If the behavior is currently in a dragging state
  39871. */
  39872. dragging: boolean;
  39873. /**
  39874. * 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)
  39875. */
  39876. dragDeltaRatio: number;
  39877. /**
  39878. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39879. */
  39880. currentDraggingPointerID: number;
  39881. /**
  39882. * If camera controls should be detached during the drag
  39883. */
  39884. detachCameraControls: boolean;
  39885. /**
  39886. * Fires each time a drag starts
  39887. */
  39888. onDragStartObservable: Observable<{}>;
  39889. /**
  39890. * Fires each time a drag ends (eg. mouse release after drag)
  39891. */
  39892. onDragEndObservable: Observable<{}>;
  39893. /**
  39894. * 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
  39895. */
  39896. constructor();
  39897. /**
  39898. * The name of the behavior
  39899. */
  39900. get name(): string;
  39901. /**
  39902. * Initializes the behavior
  39903. */
  39904. init(): void;
  39905. /**
  39906. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39907. */
  39908. private get _pointerCamera();
  39909. /**
  39910. * Attaches the scale behavior the passed in mesh
  39911. * @param ownerNode The mesh that will be scaled around once attached
  39912. */
  39913. attach(ownerNode: Mesh): void;
  39914. /**
  39915. * Detaches the behavior from the mesh
  39916. */
  39917. detach(): void;
  39918. }
  39919. }
  39920. declare module BABYLON {
  39921. /**
  39922. * Class used to apply inverse kinematics to bones
  39923. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39924. */
  39925. export class BoneIKController {
  39926. private static _tmpVecs;
  39927. private static _tmpQuat;
  39928. private static _tmpMats;
  39929. /**
  39930. * Gets or sets the target mesh
  39931. */
  39932. targetMesh: AbstractMesh;
  39933. /** Gets or sets the mesh used as pole */
  39934. poleTargetMesh: AbstractMesh;
  39935. /**
  39936. * Gets or sets the bone used as pole
  39937. */
  39938. poleTargetBone: Nullable<Bone>;
  39939. /**
  39940. * Gets or sets the target position
  39941. */
  39942. targetPosition: Vector3;
  39943. /**
  39944. * Gets or sets the pole target position
  39945. */
  39946. poleTargetPosition: Vector3;
  39947. /**
  39948. * Gets or sets the pole target local offset
  39949. */
  39950. poleTargetLocalOffset: Vector3;
  39951. /**
  39952. * Gets or sets the pole angle
  39953. */
  39954. poleAngle: number;
  39955. /**
  39956. * Gets or sets the mesh associated with the controller
  39957. */
  39958. mesh: AbstractMesh;
  39959. /**
  39960. * 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)
  39961. */
  39962. slerpAmount: number;
  39963. private _bone1Quat;
  39964. private _bone1Mat;
  39965. private _bone2Ang;
  39966. private _bone1;
  39967. private _bone2;
  39968. private _bone1Length;
  39969. private _bone2Length;
  39970. private _maxAngle;
  39971. private _maxReach;
  39972. private _rightHandedSystem;
  39973. private _bendAxis;
  39974. private _slerping;
  39975. private _adjustRoll;
  39976. /**
  39977. * Gets or sets maximum allowed angle
  39978. */
  39979. get maxAngle(): number;
  39980. set maxAngle(value: number);
  39981. /**
  39982. * Creates a new BoneIKController
  39983. * @param mesh defines the mesh to control
  39984. * @param bone defines the bone to control
  39985. * @param options defines options to set up the controller
  39986. */
  39987. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39988. targetMesh?: AbstractMesh;
  39989. poleTargetMesh?: AbstractMesh;
  39990. poleTargetBone?: Bone;
  39991. poleTargetLocalOffset?: Vector3;
  39992. poleAngle?: number;
  39993. bendAxis?: Vector3;
  39994. maxAngle?: number;
  39995. slerpAmount?: number;
  39996. });
  39997. private _setMaxAngle;
  39998. /**
  39999. * Force the controller to update the bones
  40000. */
  40001. update(): void;
  40002. }
  40003. }
  40004. declare module BABYLON {
  40005. /**
  40006. * Class used to make a bone look toward a point in space
  40007. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40008. */
  40009. export class BoneLookController {
  40010. private static _tmpVecs;
  40011. private static _tmpQuat;
  40012. private static _tmpMats;
  40013. /**
  40014. * The target Vector3 that the bone will look at
  40015. */
  40016. target: Vector3;
  40017. /**
  40018. * The mesh that the bone is attached to
  40019. */
  40020. mesh: AbstractMesh;
  40021. /**
  40022. * The bone that will be looking to the target
  40023. */
  40024. bone: Bone;
  40025. /**
  40026. * The up axis of the coordinate system that is used when the bone is rotated
  40027. */
  40028. upAxis: Vector3;
  40029. /**
  40030. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40031. */
  40032. upAxisSpace: Space;
  40033. /**
  40034. * Used to make an adjustment to the yaw of the bone
  40035. */
  40036. adjustYaw: number;
  40037. /**
  40038. * Used to make an adjustment to the pitch of the bone
  40039. */
  40040. adjustPitch: number;
  40041. /**
  40042. * Used to make an adjustment to the roll of the bone
  40043. */
  40044. adjustRoll: number;
  40045. /**
  40046. * 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)
  40047. */
  40048. slerpAmount: number;
  40049. private _minYaw;
  40050. private _maxYaw;
  40051. private _minPitch;
  40052. private _maxPitch;
  40053. private _minYawSin;
  40054. private _minYawCos;
  40055. private _maxYawSin;
  40056. private _maxYawCos;
  40057. private _midYawConstraint;
  40058. private _minPitchTan;
  40059. private _maxPitchTan;
  40060. private _boneQuat;
  40061. private _slerping;
  40062. private _transformYawPitch;
  40063. private _transformYawPitchInv;
  40064. private _firstFrameSkipped;
  40065. private _yawRange;
  40066. private _fowardAxis;
  40067. /**
  40068. * Gets or sets the minimum yaw angle that the bone can look to
  40069. */
  40070. get minYaw(): number;
  40071. set minYaw(value: number);
  40072. /**
  40073. * Gets or sets the maximum yaw angle that the bone can look to
  40074. */
  40075. get maxYaw(): number;
  40076. set maxYaw(value: number);
  40077. /**
  40078. * Gets or sets the minimum pitch angle that the bone can look to
  40079. */
  40080. get minPitch(): number;
  40081. set minPitch(value: number);
  40082. /**
  40083. * Gets or sets the maximum pitch angle that the bone can look to
  40084. */
  40085. get maxPitch(): number;
  40086. set maxPitch(value: number);
  40087. /**
  40088. * Create a BoneLookController
  40089. * @param mesh the mesh that the bone belongs to
  40090. * @param bone the bone that will be looking to the target
  40091. * @param target the target Vector3 to look at
  40092. * @param options optional settings:
  40093. * * maxYaw: the maximum angle the bone will yaw to
  40094. * * minYaw: the minimum angle the bone will yaw to
  40095. * * maxPitch: the maximum angle the bone will pitch to
  40096. * * minPitch: the minimum angle the bone will yaw to
  40097. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40098. * * upAxis: the up axis of the coordinate system
  40099. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40100. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40101. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40102. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40103. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40104. * * adjustRoll: used to make an adjustment to the roll of the bone
  40105. **/
  40106. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40107. maxYaw?: number;
  40108. minYaw?: number;
  40109. maxPitch?: number;
  40110. minPitch?: number;
  40111. slerpAmount?: number;
  40112. upAxis?: Vector3;
  40113. upAxisSpace?: Space;
  40114. yawAxis?: Vector3;
  40115. pitchAxis?: Vector3;
  40116. adjustYaw?: number;
  40117. adjustPitch?: number;
  40118. adjustRoll?: number;
  40119. });
  40120. /**
  40121. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40122. */
  40123. update(): void;
  40124. private _getAngleDiff;
  40125. private _getAngleBetween;
  40126. private _isAngleBetween;
  40127. }
  40128. }
  40129. declare module BABYLON {
  40130. /**
  40131. * Manage the gamepad inputs to control an arc rotate camera.
  40132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40133. */
  40134. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40135. /**
  40136. * Defines the camera the input is attached to.
  40137. */
  40138. camera: ArcRotateCamera;
  40139. /**
  40140. * Defines the gamepad the input is gathering event from.
  40141. */
  40142. gamepad: Nullable<Gamepad>;
  40143. /**
  40144. * Defines the gamepad rotation sensiblity.
  40145. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40146. */
  40147. gamepadRotationSensibility: number;
  40148. /**
  40149. * Defines the gamepad move sensiblity.
  40150. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40151. */
  40152. gamepadMoveSensibility: number;
  40153. private _yAxisScale;
  40154. /**
  40155. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40156. */
  40157. get invertYAxis(): boolean;
  40158. set invertYAxis(value: boolean);
  40159. private _onGamepadConnectedObserver;
  40160. private _onGamepadDisconnectedObserver;
  40161. /**
  40162. * Attach the input controls to a specific dom element to get the input from.
  40163. * @param element Defines the element the controls should be listened from
  40164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40165. */
  40166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40167. /**
  40168. * Detach the current controls from the specified dom element.
  40169. * @param element Defines the element to stop listening the inputs from
  40170. */
  40171. detachControl(element: Nullable<HTMLElement>): void;
  40172. /**
  40173. * Update the current camera state depending on the inputs that have been used this frame.
  40174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40175. */
  40176. checkInputs(): void;
  40177. /**
  40178. * Gets the class name of the current intput.
  40179. * @returns the class name
  40180. */
  40181. getClassName(): string;
  40182. /**
  40183. * Get the friendly name associated with the input class.
  40184. * @returns the input friendly name
  40185. */
  40186. getSimpleName(): string;
  40187. }
  40188. }
  40189. declare module BABYLON {
  40190. interface ArcRotateCameraInputsManager {
  40191. /**
  40192. * Add orientation input support to the input manager.
  40193. * @returns the current input manager
  40194. */
  40195. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40196. }
  40197. /**
  40198. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40200. */
  40201. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40202. /**
  40203. * Defines the camera the input is attached to.
  40204. */
  40205. camera: ArcRotateCamera;
  40206. /**
  40207. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40208. */
  40209. alphaCorrection: number;
  40210. /**
  40211. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40212. */
  40213. gammaCorrection: number;
  40214. private _alpha;
  40215. private _gamma;
  40216. private _dirty;
  40217. private _deviceOrientationHandler;
  40218. /**
  40219. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40220. */
  40221. constructor();
  40222. /**
  40223. * Attach the input controls to a specific dom element to get the input from.
  40224. * @param element Defines the element the controls should be listened from
  40225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40226. */
  40227. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40228. /** @hidden */
  40229. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40230. /**
  40231. * Update the current camera state depending on the inputs that have been used this frame.
  40232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40233. */
  40234. checkInputs(): void;
  40235. /**
  40236. * Detach the current controls from the specified dom element.
  40237. * @param element Defines the element to stop listening the inputs from
  40238. */
  40239. detachControl(element: Nullable<HTMLElement>): void;
  40240. /**
  40241. * Gets the class name of the current intput.
  40242. * @returns the class name
  40243. */
  40244. getClassName(): string;
  40245. /**
  40246. * Get the friendly name associated with the input class.
  40247. * @returns the input friendly name
  40248. */
  40249. getSimpleName(): string;
  40250. }
  40251. }
  40252. declare module BABYLON {
  40253. /**
  40254. * Listen to mouse events to control the camera.
  40255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40256. */
  40257. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40258. /**
  40259. * Defines the camera the input is attached to.
  40260. */
  40261. camera: FlyCamera;
  40262. /**
  40263. * Defines if touch is enabled. (Default is true.)
  40264. */
  40265. touchEnabled: boolean;
  40266. /**
  40267. * Defines the buttons associated with the input to handle camera rotation.
  40268. */
  40269. buttons: number[];
  40270. /**
  40271. * Assign buttons for Yaw control.
  40272. */
  40273. buttonsYaw: number[];
  40274. /**
  40275. * Assign buttons for Pitch control.
  40276. */
  40277. buttonsPitch: number[];
  40278. /**
  40279. * Assign buttons for Roll control.
  40280. */
  40281. buttonsRoll: number[];
  40282. /**
  40283. * Detect if any button is being pressed while mouse is moved.
  40284. * -1 = Mouse locked.
  40285. * 0 = Left button.
  40286. * 1 = Middle Button.
  40287. * 2 = Right Button.
  40288. */
  40289. activeButton: number;
  40290. /**
  40291. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40292. * Higher values reduce its sensitivity.
  40293. */
  40294. angularSensibility: number;
  40295. private _mousemoveCallback;
  40296. private _observer;
  40297. private _rollObserver;
  40298. private previousPosition;
  40299. private noPreventDefault;
  40300. private element;
  40301. /**
  40302. * Listen to mouse events to control the camera.
  40303. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40305. */
  40306. constructor(touchEnabled?: boolean);
  40307. /**
  40308. * Attach the mouse control to the HTML DOM element.
  40309. * @param element Defines the element that listens to the input events.
  40310. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40311. */
  40312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40313. /**
  40314. * Detach the current controls from the specified dom element.
  40315. * @param element Defines the element to stop listening the inputs from
  40316. */
  40317. detachControl(element: Nullable<HTMLElement>): void;
  40318. /**
  40319. * Gets the class name of the current input.
  40320. * @returns the class name.
  40321. */
  40322. getClassName(): string;
  40323. /**
  40324. * Get the friendly name associated with the input class.
  40325. * @returns the input's friendly name.
  40326. */
  40327. getSimpleName(): string;
  40328. private _pointerInput;
  40329. private _onMouseMove;
  40330. /**
  40331. * Rotate camera by mouse offset.
  40332. */
  40333. private rotateCamera;
  40334. }
  40335. }
  40336. declare module BABYLON {
  40337. /**
  40338. * Default Inputs manager for the FlyCamera.
  40339. * It groups all the default supported inputs for ease of use.
  40340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40341. */
  40342. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40343. /**
  40344. * Instantiates a new FlyCameraInputsManager.
  40345. * @param camera Defines the camera the inputs belong to.
  40346. */
  40347. constructor(camera: FlyCamera);
  40348. /**
  40349. * Add keyboard input support to the input manager.
  40350. * @returns the new FlyCameraKeyboardMoveInput().
  40351. */
  40352. addKeyboard(): FlyCameraInputsManager;
  40353. /**
  40354. * Add mouse input support to the input manager.
  40355. * @param touchEnabled Enable touch screen support.
  40356. * @returns the new FlyCameraMouseInput().
  40357. */
  40358. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40359. }
  40360. }
  40361. declare module BABYLON {
  40362. /**
  40363. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40364. * such as in a 3D Space Shooter or a Flight Simulator.
  40365. */
  40366. export class FlyCamera extends TargetCamera {
  40367. /**
  40368. * Define the collision ellipsoid of the camera.
  40369. * This is helpful for simulating a camera body, like a player's body.
  40370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40371. */
  40372. ellipsoid: Vector3;
  40373. /**
  40374. * Define an offset for the position of the ellipsoid around the camera.
  40375. * This can be helpful if the camera is attached away from the player's body center,
  40376. * such as at its head.
  40377. */
  40378. ellipsoidOffset: Vector3;
  40379. /**
  40380. * Enable or disable collisions of the camera with the rest of the scene objects.
  40381. */
  40382. checkCollisions: boolean;
  40383. /**
  40384. * Enable or disable gravity on the camera.
  40385. */
  40386. applyGravity: boolean;
  40387. /**
  40388. * Define the current direction the camera is moving to.
  40389. */
  40390. cameraDirection: Vector3;
  40391. /**
  40392. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40393. * This overrides and empties cameraRotation.
  40394. */
  40395. rotationQuaternion: Quaternion;
  40396. /**
  40397. * Track Roll to maintain the wanted Rolling when looking around.
  40398. */
  40399. _trackRoll: number;
  40400. /**
  40401. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40402. */
  40403. rollCorrect: number;
  40404. /**
  40405. * Mimic a banked turn, Rolling the camera when Yawing.
  40406. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40407. */
  40408. bankedTurn: boolean;
  40409. /**
  40410. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40411. */
  40412. bankedTurnLimit: number;
  40413. /**
  40414. * Value of 0 disables the banked Roll.
  40415. * Value of 1 is equal to the Yaw angle in radians.
  40416. */
  40417. bankedTurnMultiplier: number;
  40418. /**
  40419. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40420. */
  40421. inputs: FlyCameraInputsManager;
  40422. /**
  40423. * Gets the input sensibility for mouse input.
  40424. * Higher values reduce sensitivity.
  40425. */
  40426. get angularSensibility(): number;
  40427. /**
  40428. * Sets the input sensibility for a mouse input.
  40429. * Higher values reduce sensitivity.
  40430. */
  40431. set angularSensibility(value: number);
  40432. /**
  40433. * Get the keys for camera movement forward.
  40434. */
  40435. get keysForward(): number[];
  40436. /**
  40437. * Set the keys for camera movement forward.
  40438. */
  40439. set keysForward(value: number[]);
  40440. /**
  40441. * Get the keys for camera movement backward.
  40442. */
  40443. get keysBackward(): number[];
  40444. set keysBackward(value: number[]);
  40445. /**
  40446. * Get the keys for camera movement up.
  40447. */
  40448. get keysUp(): number[];
  40449. /**
  40450. * Set the keys for camera movement up.
  40451. */
  40452. set keysUp(value: number[]);
  40453. /**
  40454. * Get the keys for camera movement down.
  40455. */
  40456. get keysDown(): number[];
  40457. /**
  40458. * Set the keys for camera movement down.
  40459. */
  40460. set keysDown(value: number[]);
  40461. /**
  40462. * Get the keys for camera movement left.
  40463. */
  40464. get keysLeft(): number[];
  40465. /**
  40466. * Set the keys for camera movement left.
  40467. */
  40468. set keysLeft(value: number[]);
  40469. /**
  40470. * Set the keys for camera movement right.
  40471. */
  40472. get keysRight(): number[];
  40473. /**
  40474. * Set the keys for camera movement right.
  40475. */
  40476. set keysRight(value: number[]);
  40477. /**
  40478. * Event raised when the camera collides with a mesh in the scene.
  40479. */
  40480. onCollide: (collidedMesh: AbstractMesh) => void;
  40481. private _collider;
  40482. private _needMoveForGravity;
  40483. private _oldPosition;
  40484. private _diffPosition;
  40485. private _newPosition;
  40486. /** @hidden */
  40487. _localDirection: Vector3;
  40488. /** @hidden */
  40489. _transformedDirection: Vector3;
  40490. /**
  40491. * Instantiates a FlyCamera.
  40492. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40493. * such as in a 3D Space Shooter or a Flight Simulator.
  40494. * @param name Define the name of the camera in the scene.
  40495. * @param position Define the starting position of the camera in the scene.
  40496. * @param scene Define the scene the camera belongs to.
  40497. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40498. */
  40499. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40500. /**
  40501. * Attach a control to the HTML DOM element.
  40502. * @param element Defines the element that listens to the input events.
  40503. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40504. */
  40505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40506. /**
  40507. * Detach a control from the HTML DOM element.
  40508. * The camera will stop reacting to that input.
  40509. * @param element Defines the element that listens to the input events.
  40510. */
  40511. detachControl(element: HTMLElement): void;
  40512. private _collisionMask;
  40513. /**
  40514. * Get the mask that the camera ignores in collision events.
  40515. */
  40516. get collisionMask(): number;
  40517. /**
  40518. * Set the mask that the camera ignores in collision events.
  40519. */
  40520. set collisionMask(mask: number);
  40521. /** @hidden */
  40522. _collideWithWorld(displacement: Vector3): void;
  40523. /** @hidden */
  40524. private _onCollisionPositionChange;
  40525. /** @hidden */
  40526. _checkInputs(): void;
  40527. /** @hidden */
  40528. _decideIfNeedsToMove(): boolean;
  40529. /** @hidden */
  40530. _updatePosition(): void;
  40531. /**
  40532. * Restore the Roll to its target value at the rate specified.
  40533. * @param rate - Higher means slower restoring.
  40534. * @hidden
  40535. */
  40536. restoreRoll(rate: number): void;
  40537. /**
  40538. * Destroy the camera and release the current resources held by it.
  40539. */
  40540. dispose(): void;
  40541. /**
  40542. * Get the current object class name.
  40543. * @returns the class name.
  40544. */
  40545. getClassName(): string;
  40546. }
  40547. }
  40548. declare module BABYLON {
  40549. /**
  40550. * Listen to keyboard events to control the camera.
  40551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40552. */
  40553. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40554. /**
  40555. * Defines the camera the input is attached to.
  40556. */
  40557. camera: FlyCamera;
  40558. /**
  40559. * The list of keyboard keys used to control the forward move of the camera.
  40560. */
  40561. keysForward: number[];
  40562. /**
  40563. * The list of keyboard keys used to control the backward move of the camera.
  40564. */
  40565. keysBackward: number[];
  40566. /**
  40567. * The list of keyboard keys used to control the forward move of the camera.
  40568. */
  40569. keysUp: number[];
  40570. /**
  40571. * The list of keyboard keys used to control the backward move of the camera.
  40572. */
  40573. keysDown: number[];
  40574. /**
  40575. * The list of keyboard keys used to control the right strafe move of the camera.
  40576. */
  40577. keysRight: number[];
  40578. /**
  40579. * The list of keyboard keys used to control the left strafe move of the camera.
  40580. */
  40581. keysLeft: number[];
  40582. private _keys;
  40583. private _onCanvasBlurObserver;
  40584. private _onKeyboardObserver;
  40585. private _engine;
  40586. private _scene;
  40587. /**
  40588. * Attach the input controls to a specific dom element to get the input from.
  40589. * @param element Defines the element the controls should be listened from
  40590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40591. */
  40592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40593. /**
  40594. * Detach the current controls from the specified dom element.
  40595. * @param element Defines the element to stop listening the inputs from
  40596. */
  40597. detachControl(element: Nullable<HTMLElement>): void;
  40598. /**
  40599. * Gets the class name of the current intput.
  40600. * @returns the class name
  40601. */
  40602. getClassName(): string;
  40603. /** @hidden */
  40604. _onLostFocus(e: FocusEvent): void;
  40605. /**
  40606. * Get the friendly name associated with the input class.
  40607. * @returns the input friendly name
  40608. */
  40609. getSimpleName(): string;
  40610. /**
  40611. * Update the current camera state depending on the inputs that have been used this frame.
  40612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40613. */
  40614. checkInputs(): void;
  40615. }
  40616. }
  40617. declare module BABYLON {
  40618. /**
  40619. * Manage the mouse wheel inputs to control a follow camera.
  40620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40621. */
  40622. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40623. /**
  40624. * Defines the camera the input is attached to.
  40625. */
  40626. camera: FollowCamera;
  40627. /**
  40628. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40629. */
  40630. axisControlRadius: boolean;
  40631. /**
  40632. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40633. */
  40634. axisControlHeight: boolean;
  40635. /**
  40636. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40637. */
  40638. axisControlRotation: boolean;
  40639. /**
  40640. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40641. * relation to mouseWheel events.
  40642. */
  40643. wheelPrecision: number;
  40644. /**
  40645. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40646. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40647. */
  40648. wheelDeltaPercentage: number;
  40649. private _wheel;
  40650. private _observer;
  40651. /**
  40652. * Attach the input controls to a specific dom element to get the input from.
  40653. * @param element Defines the element the controls should be listened from
  40654. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40655. */
  40656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40657. /**
  40658. * Detach the current controls from the specified dom element.
  40659. * @param element Defines the element to stop listening the inputs from
  40660. */
  40661. detachControl(element: Nullable<HTMLElement>): void;
  40662. /**
  40663. * Gets the class name of the current intput.
  40664. * @returns the class name
  40665. */
  40666. getClassName(): string;
  40667. /**
  40668. * Get the friendly name associated with the input class.
  40669. * @returns the input friendly name
  40670. */
  40671. getSimpleName(): string;
  40672. }
  40673. }
  40674. declare module BABYLON {
  40675. /**
  40676. * Manage the pointers inputs to control an follow camera.
  40677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40678. */
  40679. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40680. /**
  40681. * Defines the camera the input is attached to.
  40682. */
  40683. camera: FollowCamera;
  40684. /**
  40685. * Gets the class name of the current input.
  40686. * @returns the class name
  40687. */
  40688. getClassName(): string;
  40689. /**
  40690. * Defines the pointer angular sensibility along the X axis or how fast is
  40691. * the camera rotating.
  40692. * A negative number will reverse the axis direction.
  40693. */
  40694. angularSensibilityX: number;
  40695. /**
  40696. * Defines the pointer angular sensibility along the Y axis or how fast is
  40697. * the camera rotating.
  40698. * A negative number will reverse the axis direction.
  40699. */
  40700. angularSensibilityY: number;
  40701. /**
  40702. * Defines the pointer pinch precision or how fast is the camera zooming.
  40703. * A negative number will reverse the axis direction.
  40704. */
  40705. pinchPrecision: number;
  40706. /**
  40707. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40708. * from 0.
  40709. * It defines the percentage of current camera.radius to use as delta when
  40710. * pinch zoom is used.
  40711. */
  40712. pinchDeltaPercentage: number;
  40713. /**
  40714. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40715. */
  40716. axisXControlRadius: boolean;
  40717. /**
  40718. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40719. */
  40720. axisXControlHeight: boolean;
  40721. /**
  40722. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40723. */
  40724. axisXControlRotation: boolean;
  40725. /**
  40726. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40727. */
  40728. axisYControlRadius: boolean;
  40729. /**
  40730. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40731. */
  40732. axisYControlHeight: boolean;
  40733. /**
  40734. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40735. */
  40736. axisYControlRotation: boolean;
  40737. /**
  40738. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40739. */
  40740. axisPinchControlRadius: boolean;
  40741. /**
  40742. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40743. */
  40744. axisPinchControlHeight: boolean;
  40745. /**
  40746. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40747. */
  40748. axisPinchControlRotation: boolean;
  40749. /**
  40750. * Log error messages if basic misconfiguration has occurred.
  40751. */
  40752. warningEnable: boolean;
  40753. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40754. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40755. private _warningCounter;
  40756. private _warning;
  40757. }
  40758. }
  40759. declare module BABYLON {
  40760. /**
  40761. * Default Inputs manager for the FollowCamera.
  40762. * It groups all the default supported inputs for ease of use.
  40763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40764. */
  40765. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40766. /**
  40767. * Instantiates a new FollowCameraInputsManager.
  40768. * @param camera Defines the camera the inputs belong to
  40769. */
  40770. constructor(camera: FollowCamera);
  40771. /**
  40772. * Add keyboard input support to the input manager.
  40773. * @returns the current input manager
  40774. */
  40775. addKeyboard(): FollowCameraInputsManager;
  40776. /**
  40777. * Add mouse wheel input support to the input manager.
  40778. * @returns the current input manager
  40779. */
  40780. addMouseWheel(): FollowCameraInputsManager;
  40781. /**
  40782. * Add pointers input support to the input manager.
  40783. * @returns the current input manager
  40784. */
  40785. addPointers(): FollowCameraInputsManager;
  40786. /**
  40787. * Add orientation input support to the input manager.
  40788. * @returns the current input manager
  40789. */
  40790. addVRDeviceOrientation(): FollowCameraInputsManager;
  40791. }
  40792. }
  40793. declare module BABYLON {
  40794. /**
  40795. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40796. * an arc rotate version arcFollowCamera are available.
  40797. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40798. */
  40799. export class FollowCamera extends TargetCamera {
  40800. /**
  40801. * Distance the follow camera should follow an object at
  40802. */
  40803. radius: number;
  40804. /**
  40805. * Minimum allowed distance of the camera to the axis of rotation
  40806. * (The camera can not get closer).
  40807. * This can help limiting how the Camera is able to move in the scene.
  40808. */
  40809. lowerRadiusLimit: Nullable<number>;
  40810. /**
  40811. * Maximum allowed distance of the camera to the axis of rotation
  40812. * (The camera can not get further).
  40813. * This can help limiting how the Camera is able to move in the scene.
  40814. */
  40815. upperRadiusLimit: Nullable<number>;
  40816. /**
  40817. * Define a rotation offset between the camera and the object it follows
  40818. */
  40819. rotationOffset: number;
  40820. /**
  40821. * Minimum allowed angle to camera position relative to target object.
  40822. * This can help limiting how the Camera is able to move in the scene.
  40823. */
  40824. lowerRotationOffsetLimit: Nullable<number>;
  40825. /**
  40826. * Maximum allowed angle to camera position relative to target object.
  40827. * This can help limiting how the Camera is able to move in the scene.
  40828. */
  40829. upperRotationOffsetLimit: Nullable<number>;
  40830. /**
  40831. * Define a height offset between the camera and the object it follows.
  40832. * It can help following an object from the top (like a car chaing a plane)
  40833. */
  40834. heightOffset: number;
  40835. /**
  40836. * Minimum allowed height of camera position relative to target object.
  40837. * This can help limiting how the Camera is able to move in the scene.
  40838. */
  40839. lowerHeightOffsetLimit: Nullable<number>;
  40840. /**
  40841. * Maximum allowed height of camera position relative to target object.
  40842. * This can help limiting how the Camera is able to move in the scene.
  40843. */
  40844. upperHeightOffsetLimit: Nullable<number>;
  40845. /**
  40846. * Define how fast the camera can accelerate to follow it s target.
  40847. */
  40848. cameraAcceleration: number;
  40849. /**
  40850. * Define the speed limit of the camera following an object.
  40851. */
  40852. maxCameraSpeed: number;
  40853. /**
  40854. * Define the target of the camera.
  40855. */
  40856. lockedTarget: Nullable<AbstractMesh>;
  40857. /**
  40858. * Defines the input associated with the camera.
  40859. */
  40860. inputs: FollowCameraInputsManager;
  40861. /**
  40862. * Instantiates the follow camera.
  40863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40864. * @param name Define the name of the camera in the scene
  40865. * @param position Define the position of the camera
  40866. * @param scene Define the scene the camera belong to
  40867. * @param lockedTarget Define the target of the camera
  40868. */
  40869. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40870. private _follow;
  40871. /**
  40872. * Attached controls to the current camera.
  40873. * @param element Defines the element the controls should be listened from
  40874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40875. */
  40876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40877. /**
  40878. * Detach the current controls from the camera.
  40879. * The camera will stop reacting to inputs.
  40880. * @param element Defines the element to stop listening the inputs from
  40881. */
  40882. detachControl(element: HTMLElement): void;
  40883. /** @hidden */
  40884. _checkInputs(): void;
  40885. private _checkLimits;
  40886. /**
  40887. * Gets the camera class name.
  40888. * @returns the class name
  40889. */
  40890. getClassName(): string;
  40891. }
  40892. /**
  40893. * Arc Rotate version of the follow camera.
  40894. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40895. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40896. */
  40897. export class ArcFollowCamera extends TargetCamera {
  40898. /** The longitudinal angle of the camera */
  40899. alpha: number;
  40900. /** The latitudinal angle of the camera */
  40901. beta: number;
  40902. /** The radius of the camera from its target */
  40903. radius: number;
  40904. /** Define the camera target (the messh it should follow) */
  40905. target: Nullable<AbstractMesh>;
  40906. private _cartesianCoordinates;
  40907. /**
  40908. * Instantiates a new ArcFollowCamera
  40909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40910. * @param name Define the name of the camera
  40911. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40912. * @param beta Define the rotation angle of the camera around the elevation axis
  40913. * @param radius Define the radius of the camera from its target point
  40914. * @param target Define the target of the camera
  40915. * @param scene Define the scene the camera belongs to
  40916. */
  40917. constructor(name: string,
  40918. /** The longitudinal angle of the camera */
  40919. alpha: number,
  40920. /** The latitudinal angle of the camera */
  40921. beta: number,
  40922. /** The radius of the camera from its target */
  40923. radius: number,
  40924. /** Define the camera target (the messh it should follow) */
  40925. target: Nullable<AbstractMesh>, scene: Scene);
  40926. private _follow;
  40927. /** @hidden */
  40928. _checkInputs(): void;
  40929. /**
  40930. * Returns the class name of the object.
  40931. * It is mostly used internally for serialization purposes.
  40932. */
  40933. getClassName(): string;
  40934. }
  40935. }
  40936. declare module BABYLON {
  40937. /**
  40938. * Manage the keyboard inputs to control the movement of a follow camera.
  40939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40940. */
  40941. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40942. /**
  40943. * Defines the camera the input is attached to.
  40944. */
  40945. camera: FollowCamera;
  40946. /**
  40947. * Defines the list of key codes associated with the up action (increase heightOffset)
  40948. */
  40949. keysHeightOffsetIncr: number[];
  40950. /**
  40951. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40952. */
  40953. keysHeightOffsetDecr: number[];
  40954. /**
  40955. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40956. */
  40957. keysHeightOffsetModifierAlt: boolean;
  40958. /**
  40959. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40960. */
  40961. keysHeightOffsetModifierCtrl: boolean;
  40962. /**
  40963. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40964. */
  40965. keysHeightOffsetModifierShift: boolean;
  40966. /**
  40967. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40968. */
  40969. keysRotationOffsetIncr: number[];
  40970. /**
  40971. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40972. */
  40973. keysRotationOffsetDecr: number[];
  40974. /**
  40975. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40976. */
  40977. keysRotationOffsetModifierAlt: boolean;
  40978. /**
  40979. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40980. */
  40981. keysRotationOffsetModifierCtrl: boolean;
  40982. /**
  40983. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40984. */
  40985. keysRotationOffsetModifierShift: boolean;
  40986. /**
  40987. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40988. */
  40989. keysRadiusIncr: number[];
  40990. /**
  40991. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40992. */
  40993. keysRadiusDecr: number[];
  40994. /**
  40995. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40996. */
  40997. keysRadiusModifierAlt: boolean;
  40998. /**
  40999. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41000. */
  41001. keysRadiusModifierCtrl: boolean;
  41002. /**
  41003. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41004. */
  41005. keysRadiusModifierShift: boolean;
  41006. /**
  41007. * Defines the rate of change of heightOffset.
  41008. */
  41009. heightSensibility: number;
  41010. /**
  41011. * Defines the rate of change of rotationOffset.
  41012. */
  41013. rotationSensibility: number;
  41014. /**
  41015. * Defines the rate of change of radius.
  41016. */
  41017. radiusSensibility: number;
  41018. private _keys;
  41019. private _ctrlPressed;
  41020. private _altPressed;
  41021. private _shiftPressed;
  41022. private _onCanvasBlurObserver;
  41023. private _onKeyboardObserver;
  41024. private _engine;
  41025. private _scene;
  41026. /**
  41027. * Attach the input controls to a specific dom element to get the input from.
  41028. * @param element Defines the element the controls should be listened from
  41029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41030. */
  41031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41032. /**
  41033. * Detach the current controls from the specified dom element.
  41034. * @param element Defines the element to stop listening the inputs from
  41035. */
  41036. detachControl(element: Nullable<HTMLElement>): void;
  41037. /**
  41038. * Update the current camera state depending on the inputs that have been used this frame.
  41039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41040. */
  41041. checkInputs(): void;
  41042. /**
  41043. * Gets the class name of the current input.
  41044. * @returns the class name
  41045. */
  41046. getClassName(): string;
  41047. /**
  41048. * Get the friendly name associated with the input class.
  41049. * @returns the input friendly name
  41050. */
  41051. getSimpleName(): string;
  41052. /**
  41053. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41054. * allow modification of the heightOffset value.
  41055. */
  41056. private _modifierHeightOffset;
  41057. /**
  41058. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41059. * allow modification of the rotationOffset value.
  41060. */
  41061. private _modifierRotationOffset;
  41062. /**
  41063. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41064. * allow modification of the radius value.
  41065. */
  41066. private _modifierRadius;
  41067. }
  41068. }
  41069. declare module BABYLON {
  41070. interface FreeCameraInputsManager {
  41071. /**
  41072. * @hidden
  41073. */
  41074. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41075. /**
  41076. * Add orientation input support to the input manager.
  41077. * @returns the current input manager
  41078. */
  41079. addDeviceOrientation(): FreeCameraInputsManager;
  41080. }
  41081. /**
  41082. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41083. * Screen rotation is taken into account.
  41084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41085. */
  41086. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41087. private _camera;
  41088. private _screenOrientationAngle;
  41089. private _constantTranform;
  41090. private _screenQuaternion;
  41091. private _alpha;
  41092. private _beta;
  41093. private _gamma;
  41094. /**
  41095. * Can be used to detect if a device orientation sensor is available on a device
  41096. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41097. * @returns a promise that will resolve on orientation change
  41098. */
  41099. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41100. /**
  41101. * @hidden
  41102. */
  41103. _onDeviceOrientationChangedObservable: Observable<void>;
  41104. /**
  41105. * Instantiates a new input
  41106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41107. */
  41108. constructor();
  41109. /**
  41110. * Define the camera controlled by the input.
  41111. */
  41112. get camera(): FreeCamera;
  41113. set camera(camera: FreeCamera);
  41114. /**
  41115. * Attach the input controls to a specific dom element to get the input from.
  41116. * @param element Defines the element the controls should be listened from
  41117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41118. */
  41119. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41120. private _orientationChanged;
  41121. private _deviceOrientation;
  41122. /**
  41123. * Detach the current controls from the specified dom element.
  41124. * @param element Defines the element to stop listening the inputs from
  41125. */
  41126. detachControl(element: Nullable<HTMLElement>): void;
  41127. /**
  41128. * Update the current camera state depending on the inputs that have been used this frame.
  41129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41130. */
  41131. checkInputs(): void;
  41132. /**
  41133. * Gets the class name of the current intput.
  41134. * @returns the class name
  41135. */
  41136. getClassName(): string;
  41137. /**
  41138. * Get the friendly name associated with the input class.
  41139. * @returns the input friendly name
  41140. */
  41141. getSimpleName(): string;
  41142. }
  41143. }
  41144. declare module BABYLON {
  41145. /**
  41146. * Manage the gamepad inputs to control a free camera.
  41147. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41148. */
  41149. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41150. /**
  41151. * Define the camera the input is attached to.
  41152. */
  41153. camera: FreeCamera;
  41154. /**
  41155. * Define the Gamepad controlling the input
  41156. */
  41157. gamepad: Nullable<Gamepad>;
  41158. /**
  41159. * Defines the gamepad rotation sensiblity.
  41160. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41161. */
  41162. gamepadAngularSensibility: number;
  41163. /**
  41164. * Defines the gamepad move sensiblity.
  41165. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41166. */
  41167. gamepadMoveSensibility: number;
  41168. private _yAxisScale;
  41169. /**
  41170. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41171. */
  41172. get invertYAxis(): boolean;
  41173. set invertYAxis(value: boolean);
  41174. private _onGamepadConnectedObserver;
  41175. private _onGamepadDisconnectedObserver;
  41176. private _cameraTransform;
  41177. private _deltaTransform;
  41178. private _vector3;
  41179. private _vector2;
  41180. /**
  41181. * Attach the input controls to a specific dom element to get the input from.
  41182. * @param element Defines the element the controls should be listened from
  41183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41184. */
  41185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41186. /**
  41187. * Detach the current controls from the specified dom element.
  41188. * @param element Defines the element to stop listening the inputs from
  41189. */
  41190. detachControl(element: Nullable<HTMLElement>): void;
  41191. /**
  41192. * Update the current camera state depending on the inputs that have been used this frame.
  41193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41194. */
  41195. checkInputs(): void;
  41196. /**
  41197. * Gets the class name of the current intput.
  41198. * @returns the class name
  41199. */
  41200. getClassName(): string;
  41201. /**
  41202. * Get the friendly name associated with the input class.
  41203. * @returns the input friendly name
  41204. */
  41205. getSimpleName(): string;
  41206. }
  41207. }
  41208. declare module BABYLON {
  41209. /**
  41210. * Defines the potential axis of a Joystick
  41211. */
  41212. export enum JoystickAxis {
  41213. /** X axis */
  41214. X = 0,
  41215. /** Y axis */
  41216. Y = 1,
  41217. /** Z axis */
  41218. Z = 2
  41219. }
  41220. /**
  41221. * Class used to define virtual joystick (used in touch mode)
  41222. */
  41223. export class VirtualJoystick {
  41224. /**
  41225. * Gets or sets a boolean indicating that left and right values must be inverted
  41226. */
  41227. reverseLeftRight: boolean;
  41228. /**
  41229. * Gets or sets a boolean indicating that up and down values must be inverted
  41230. */
  41231. reverseUpDown: boolean;
  41232. /**
  41233. * Gets the offset value for the position (ie. the change of the position value)
  41234. */
  41235. deltaPosition: Vector3;
  41236. /**
  41237. * Gets a boolean indicating if the virtual joystick was pressed
  41238. */
  41239. pressed: boolean;
  41240. /**
  41241. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41242. */
  41243. static Canvas: Nullable<HTMLCanvasElement>;
  41244. private static _globalJoystickIndex;
  41245. private static vjCanvasContext;
  41246. private static vjCanvasWidth;
  41247. private static vjCanvasHeight;
  41248. private static halfWidth;
  41249. private _action;
  41250. private _axisTargetedByLeftAndRight;
  41251. private _axisTargetedByUpAndDown;
  41252. private _joystickSensibility;
  41253. private _inversedSensibility;
  41254. private _joystickPointerID;
  41255. private _joystickColor;
  41256. private _joystickPointerPos;
  41257. private _joystickPreviousPointerPos;
  41258. private _joystickPointerStartPos;
  41259. private _deltaJoystickVector;
  41260. private _leftJoystick;
  41261. private _touches;
  41262. private _onPointerDownHandlerRef;
  41263. private _onPointerMoveHandlerRef;
  41264. private _onPointerUpHandlerRef;
  41265. private _onResize;
  41266. /**
  41267. * Creates a new virtual joystick
  41268. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41269. */
  41270. constructor(leftJoystick?: boolean);
  41271. /**
  41272. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41273. * @param newJoystickSensibility defines the new sensibility
  41274. */
  41275. setJoystickSensibility(newJoystickSensibility: number): void;
  41276. private _onPointerDown;
  41277. private _onPointerMove;
  41278. private _onPointerUp;
  41279. /**
  41280. * Change the color of the virtual joystick
  41281. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41282. */
  41283. setJoystickColor(newColor: string): void;
  41284. /**
  41285. * Defines a callback to call when the joystick is touched
  41286. * @param action defines the callback
  41287. */
  41288. setActionOnTouch(action: () => any): void;
  41289. /**
  41290. * Defines which axis you'd like to control for left & right
  41291. * @param axis defines the axis to use
  41292. */
  41293. setAxisForLeftRight(axis: JoystickAxis): void;
  41294. /**
  41295. * Defines which axis you'd like to control for up & down
  41296. * @param axis defines the axis to use
  41297. */
  41298. setAxisForUpDown(axis: JoystickAxis): void;
  41299. private _drawVirtualJoystick;
  41300. /**
  41301. * Release internal HTML canvas
  41302. */
  41303. releaseCanvas(): void;
  41304. }
  41305. }
  41306. declare module BABYLON {
  41307. interface FreeCameraInputsManager {
  41308. /**
  41309. * Add virtual joystick input support to the input manager.
  41310. * @returns the current input manager
  41311. */
  41312. addVirtualJoystick(): FreeCameraInputsManager;
  41313. }
  41314. /**
  41315. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41317. */
  41318. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41319. /**
  41320. * Defines the camera the input is attached to.
  41321. */
  41322. camera: FreeCamera;
  41323. private _leftjoystick;
  41324. private _rightjoystick;
  41325. /**
  41326. * Gets the left stick of the virtual joystick.
  41327. * @returns The virtual Joystick
  41328. */
  41329. getLeftJoystick(): VirtualJoystick;
  41330. /**
  41331. * Gets the right stick of the virtual joystick.
  41332. * @returns The virtual Joystick
  41333. */
  41334. getRightJoystick(): VirtualJoystick;
  41335. /**
  41336. * Update the current camera state depending on the inputs that have been used this frame.
  41337. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41338. */
  41339. checkInputs(): void;
  41340. /**
  41341. * Attach the input controls to a specific dom element to get the input from.
  41342. * @param element Defines the element the controls should be listened from
  41343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41344. */
  41345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41346. /**
  41347. * Detach the current controls from the specified dom element.
  41348. * @param element Defines the element to stop listening the inputs from
  41349. */
  41350. detachControl(element: Nullable<HTMLElement>): void;
  41351. /**
  41352. * Gets the class name of the current intput.
  41353. * @returns the class name
  41354. */
  41355. getClassName(): string;
  41356. /**
  41357. * Get the friendly name associated with the input class.
  41358. * @returns the input friendly name
  41359. */
  41360. getSimpleName(): string;
  41361. }
  41362. }
  41363. declare module BABYLON {
  41364. /**
  41365. * This represents a FPS type of camera controlled by touch.
  41366. * This is like a universal camera minus the Gamepad controls.
  41367. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41368. */
  41369. export class TouchCamera extends FreeCamera {
  41370. /**
  41371. * Defines the touch sensibility for rotation.
  41372. * The higher the faster.
  41373. */
  41374. get touchAngularSensibility(): number;
  41375. set touchAngularSensibility(value: number);
  41376. /**
  41377. * Defines the touch sensibility for move.
  41378. * The higher the faster.
  41379. */
  41380. get touchMoveSensibility(): number;
  41381. set touchMoveSensibility(value: number);
  41382. /**
  41383. * Instantiates a new touch camera.
  41384. * This represents a FPS type of camera controlled by touch.
  41385. * This is like a universal camera minus the Gamepad controls.
  41386. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41387. * @param name Define the name of the camera in the scene
  41388. * @param position Define the start position of the camera in the scene
  41389. * @param scene Define the scene the camera belongs to
  41390. */
  41391. constructor(name: string, position: Vector3, scene: Scene);
  41392. /**
  41393. * Gets the current object class name.
  41394. * @return the class name
  41395. */
  41396. getClassName(): string;
  41397. /** @hidden */
  41398. _setupInputs(): void;
  41399. }
  41400. }
  41401. declare module BABYLON {
  41402. /**
  41403. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41404. * being tilted forward or back and left or right.
  41405. */
  41406. export class DeviceOrientationCamera extends FreeCamera {
  41407. private _initialQuaternion;
  41408. private _quaternionCache;
  41409. private _tmpDragQuaternion;
  41410. private _disablePointerInputWhenUsingDeviceOrientation;
  41411. /**
  41412. * Creates a new device orientation camera
  41413. * @param name The name of the camera
  41414. * @param position The start position camera
  41415. * @param scene The scene the camera belongs to
  41416. */
  41417. constructor(name: string, position: Vector3, scene: Scene);
  41418. /**
  41419. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41420. */
  41421. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41422. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41423. private _dragFactor;
  41424. /**
  41425. * Enabled turning on the y axis when the orientation sensor is active
  41426. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41427. */
  41428. enableHorizontalDragging(dragFactor?: number): void;
  41429. /**
  41430. * Gets the current instance class name ("DeviceOrientationCamera").
  41431. * This helps avoiding instanceof at run time.
  41432. * @returns the class name
  41433. */
  41434. getClassName(): string;
  41435. /**
  41436. * @hidden
  41437. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41438. */
  41439. _checkInputs(): void;
  41440. /**
  41441. * Reset the camera to its default orientation on the specified axis only.
  41442. * @param axis The axis to reset
  41443. */
  41444. resetToCurrentRotation(axis?: Axis): void;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * Defines supported buttons for XBox360 compatible gamepads
  41450. */
  41451. export enum Xbox360Button {
  41452. /** A */
  41453. A = 0,
  41454. /** B */
  41455. B = 1,
  41456. /** X */
  41457. X = 2,
  41458. /** Y */
  41459. Y = 3,
  41460. /** Left button */
  41461. LB = 4,
  41462. /** Right button */
  41463. RB = 5,
  41464. /** Back */
  41465. Back = 8,
  41466. /** Start */
  41467. Start = 9,
  41468. /** Left stick */
  41469. LeftStick = 10,
  41470. /** Right stick */
  41471. RightStick = 11
  41472. }
  41473. /** Defines values for XBox360 DPad */
  41474. export enum Xbox360Dpad {
  41475. /** Up */
  41476. Up = 12,
  41477. /** Down */
  41478. Down = 13,
  41479. /** Left */
  41480. Left = 14,
  41481. /** Right */
  41482. Right = 15
  41483. }
  41484. /**
  41485. * Defines a XBox360 gamepad
  41486. */
  41487. export class Xbox360Pad extends Gamepad {
  41488. private _leftTrigger;
  41489. private _rightTrigger;
  41490. private _onlefttriggerchanged;
  41491. private _onrighttriggerchanged;
  41492. private _onbuttondown;
  41493. private _onbuttonup;
  41494. private _ondpaddown;
  41495. private _ondpadup;
  41496. /** Observable raised when a button is pressed */
  41497. onButtonDownObservable: Observable<Xbox360Button>;
  41498. /** Observable raised when a button is released */
  41499. onButtonUpObservable: Observable<Xbox360Button>;
  41500. /** Observable raised when a pad is pressed */
  41501. onPadDownObservable: Observable<Xbox360Dpad>;
  41502. /** Observable raised when a pad is released */
  41503. onPadUpObservable: Observable<Xbox360Dpad>;
  41504. private _buttonA;
  41505. private _buttonB;
  41506. private _buttonX;
  41507. private _buttonY;
  41508. private _buttonBack;
  41509. private _buttonStart;
  41510. private _buttonLB;
  41511. private _buttonRB;
  41512. private _buttonLeftStick;
  41513. private _buttonRightStick;
  41514. private _dPadUp;
  41515. private _dPadDown;
  41516. private _dPadLeft;
  41517. private _dPadRight;
  41518. private _isXboxOnePad;
  41519. /**
  41520. * Creates a new XBox360 gamepad object
  41521. * @param id defines the id of this gamepad
  41522. * @param index defines its index
  41523. * @param gamepad defines the internal HTML gamepad object
  41524. * @param xboxOne defines if it is a XBox One gamepad
  41525. */
  41526. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41527. /**
  41528. * Defines the callback to call when left trigger is pressed
  41529. * @param callback defines the callback to use
  41530. */
  41531. onlefttriggerchanged(callback: (value: number) => void): void;
  41532. /**
  41533. * Defines the callback to call when right trigger is pressed
  41534. * @param callback defines the callback to use
  41535. */
  41536. onrighttriggerchanged(callback: (value: number) => void): void;
  41537. /**
  41538. * Gets the left trigger value
  41539. */
  41540. get leftTrigger(): number;
  41541. /**
  41542. * Sets the left trigger value
  41543. */
  41544. set leftTrigger(newValue: number);
  41545. /**
  41546. * Gets the right trigger value
  41547. */
  41548. get rightTrigger(): number;
  41549. /**
  41550. * Sets the right trigger value
  41551. */
  41552. set rightTrigger(newValue: number);
  41553. /**
  41554. * Defines the callback to call when a button is pressed
  41555. * @param callback defines the callback to use
  41556. */
  41557. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41558. /**
  41559. * Defines the callback to call when a button is released
  41560. * @param callback defines the callback to use
  41561. */
  41562. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41563. /**
  41564. * Defines the callback to call when a pad is pressed
  41565. * @param callback defines the callback to use
  41566. */
  41567. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41568. /**
  41569. * Defines the callback to call when a pad is released
  41570. * @param callback defines the callback to use
  41571. */
  41572. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41573. private _setButtonValue;
  41574. private _setDPadValue;
  41575. /**
  41576. * Gets the value of the `A` button
  41577. */
  41578. get buttonA(): number;
  41579. /**
  41580. * Sets the value of the `A` button
  41581. */
  41582. set buttonA(value: number);
  41583. /**
  41584. * Gets the value of the `B` button
  41585. */
  41586. get buttonB(): number;
  41587. /**
  41588. * Sets the value of the `B` button
  41589. */
  41590. set buttonB(value: number);
  41591. /**
  41592. * Gets the value of the `X` button
  41593. */
  41594. get buttonX(): number;
  41595. /**
  41596. * Sets the value of the `X` button
  41597. */
  41598. set buttonX(value: number);
  41599. /**
  41600. * Gets the value of the `Y` button
  41601. */
  41602. get buttonY(): number;
  41603. /**
  41604. * Sets the value of the `Y` button
  41605. */
  41606. set buttonY(value: number);
  41607. /**
  41608. * Gets the value of the `Start` button
  41609. */
  41610. get buttonStart(): number;
  41611. /**
  41612. * Sets the value of the `Start` button
  41613. */
  41614. set buttonStart(value: number);
  41615. /**
  41616. * Gets the value of the `Back` button
  41617. */
  41618. get buttonBack(): number;
  41619. /**
  41620. * Sets the value of the `Back` button
  41621. */
  41622. set buttonBack(value: number);
  41623. /**
  41624. * Gets the value of the `Left` button
  41625. */
  41626. get buttonLB(): number;
  41627. /**
  41628. * Sets the value of the `Left` button
  41629. */
  41630. set buttonLB(value: number);
  41631. /**
  41632. * Gets the value of the `Right` button
  41633. */
  41634. get buttonRB(): number;
  41635. /**
  41636. * Sets the value of the `Right` button
  41637. */
  41638. set buttonRB(value: number);
  41639. /**
  41640. * Gets the value of the Left joystick
  41641. */
  41642. get buttonLeftStick(): number;
  41643. /**
  41644. * Sets the value of the Left joystick
  41645. */
  41646. set buttonLeftStick(value: number);
  41647. /**
  41648. * Gets the value of the Right joystick
  41649. */
  41650. get buttonRightStick(): number;
  41651. /**
  41652. * Sets the value of the Right joystick
  41653. */
  41654. set buttonRightStick(value: number);
  41655. /**
  41656. * Gets the value of D-pad up
  41657. */
  41658. get dPadUp(): number;
  41659. /**
  41660. * Sets the value of D-pad up
  41661. */
  41662. set dPadUp(value: number);
  41663. /**
  41664. * Gets the value of D-pad down
  41665. */
  41666. get dPadDown(): number;
  41667. /**
  41668. * Sets the value of D-pad down
  41669. */
  41670. set dPadDown(value: number);
  41671. /**
  41672. * Gets the value of D-pad left
  41673. */
  41674. get dPadLeft(): number;
  41675. /**
  41676. * Sets the value of D-pad left
  41677. */
  41678. set dPadLeft(value: number);
  41679. /**
  41680. * Gets the value of D-pad right
  41681. */
  41682. get dPadRight(): number;
  41683. /**
  41684. * Sets the value of D-pad right
  41685. */
  41686. set dPadRight(value: number);
  41687. /**
  41688. * Force the gamepad to synchronize with device values
  41689. */
  41690. update(): void;
  41691. /**
  41692. * Disposes the gamepad
  41693. */
  41694. dispose(): void;
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. /**
  41699. * Defines supported buttons for DualShock compatible gamepads
  41700. */
  41701. export enum DualShockButton {
  41702. /** Cross */
  41703. Cross = 0,
  41704. /** Circle */
  41705. Circle = 1,
  41706. /** Square */
  41707. Square = 2,
  41708. /** Triangle */
  41709. Triangle = 3,
  41710. /** L1 */
  41711. L1 = 4,
  41712. /** R1 */
  41713. R1 = 5,
  41714. /** Share */
  41715. Share = 8,
  41716. /** Options */
  41717. Options = 9,
  41718. /** Left stick */
  41719. LeftStick = 10,
  41720. /** Right stick */
  41721. RightStick = 11
  41722. }
  41723. /** Defines values for DualShock DPad */
  41724. export enum DualShockDpad {
  41725. /** Up */
  41726. Up = 12,
  41727. /** Down */
  41728. Down = 13,
  41729. /** Left */
  41730. Left = 14,
  41731. /** Right */
  41732. Right = 15
  41733. }
  41734. /**
  41735. * Defines a DualShock gamepad
  41736. */
  41737. export class DualShockPad extends Gamepad {
  41738. private _leftTrigger;
  41739. private _rightTrigger;
  41740. private _onlefttriggerchanged;
  41741. private _onrighttriggerchanged;
  41742. private _onbuttondown;
  41743. private _onbuttonup;
  41744. private _ondpaddown;
  41745. private _ondpadup;
  41746. /** Observable raised when a button is pressed */
  41747. onButtonDownObservable: Observable<DualShockButton>;
  41748. /** Observable raised when a button is released */
  41749. onButtonUpObservable: Observable<DualShockButton>;
  41750. /** Observable raised when a pad is pressed */
  41751. onPadDownObservable: Observable<DualShockDpad>;
  41752. /** Observable raised when a pad is released */
  41753. onPadUpObservable: Observable<DualShockDpad>;
  41754. private _buttonCross;
  41755. private _buttonCircle;
  41756. private _buttonSquare;
  41757. private _buttonTriangle;
  41758. private _buttonShare;
  41759. private _buttonOptions;
  41760. private _buttonL1;
  41761. private _buttonR1;
  41762. private _buttonLeftStick;
  41763. private _buttonRightStick;
  41764. private _dPadUp;
  41765. private _dPadDown;
  41766. private _dPadLeft;
  41767. private _dPadRight;
  41768. /**
  41769. * Creates a new DualShock gamepad object
  41770. * @param id defines the id of this gamepad
  41771. * @param index defines its index
  41772. * @param gamepad defines the internal HTML gamepad object
  41773. */
  41774. constructor(id: string, index: number, gamepad: any);
  41775. /**
  41776. * Defines the callback to call when left trigger is pressed
  41777. * @param callback defines the callback to use
  41778. */
  41779. onlefttriggerchanged(callback: (value: number) => void): void;
  41780. /**
  41781. * Defines the callback to call when right trigger is pressed
  41782. * @param callback defines the callback to use
  41783. */
  41784. onrighttriggerchanged(callback: (value: number) => void): void;
  41785. /**
  41786. * Gets the left trigger value
  41787. */
  41788. get leftTrigger(): number;
  41789. /**
  41790. * Sets the left trigger value
  41791. */
  41792. set leftTrigger(newValue: number);
  41793. /**
  41794. * Gets the right trigger value
  41795. */
  41796. get rightTrigger(): number;
  41797. /**
  41798. * Sets the right trigger value
  41799. */
  41800. set rightTrigger(newValue: number);
  41801. /**
  41802. * Defines the callback to call when a button is pressed
  41803. * @param callback defines the callback to use
  41804. */
  41805. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41806. /**
  41807. * Defines the callback to call when a button is released
  41808. * @param callback defines the callback to use
  41809. */
  41810. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41811. /**
  41812. * Defines the callback to call when a pad is pressed
  41813. * @param callback defines the callback to use
  41814. */
  41815. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41816. /**
  41817. * Defines the callback to call when a pad is released
  41818. * @param callback defines the callback to use
  41819. */
  41820. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41821. private _setButtonValue;
  41822. private _setDPadValue;
  41823. /**
  41824. * Gets the value of the `Cross` button
  41825. */
  41826. get buttonCross(): number;
  41827. /**
  41828. * Sets the value of the `Cross` button
  41829. */
  41830. set buttonCross(value: number);
  41831. /**
  41832. * Gets the value of the `Circle` button
  41833. */
  41834. get buttonCircle(): number;
  41835. /**
  41836. * Sets the value of the `Circle` button
  41837. */
  41838. set buttonCircle(value: number);
  41839. /**
  41840. * Gets the value of the `Square` button
  41841. */
  41842. get buttonSquare(): number;
  41843. /**
  41844. * Sets the value of the `Square` button
  41845. */
  41846. set buttonSquare(value: number);
  41847. /**
  41848. * Gets the value of the `Triangle` button
  41849. */
  41850. get buttonTriangle(): number;
  41851. /**
  41852. * Sets the value of the `Triangle` button
  41853. */
  41854. set buttonTriangle(value: number);
  41855. /**
  41856. * Gets the value of the `Options` button
  41857. */
  41858. get buttonOptions(): number;
  41859. /**
  41860. * Sets the value of the `Options` button
  41861. */
  41862. set buttonOptions(value: number);
  41863. /**
  41864. * Gets the value of the `Share` button
  41865. */
  41866. get buttonShare(): number;
  41867. /**
  41868. * Sets the value of the `Share` button
  41869. */
  41870. set buttonShare(value: number);
  41871. /**
  41872. * Gets the value of the `L1` button
  41873. */
  41874. get buttonL1(): number;
  41875. /**
  41876. * Sets the value of the `L1` button
  41877. */
  41878. set buttonL1(value: number);
  41879. /**
  41880. * Gets the value of the `R1` button
  41881. */
  41882. get buttonR1(): number;
  41883. /**
  41884. * Sets the value of the `R1` button
  41885. */
  41886. set buttonR1(value: number);
  41887. /**
  41888. * Gets the value of the Left joystick
  41889. */
  41890. get buttonLeftStick(): number;
  41891. /**
  41892. * Sets the value of the Left joystick
  41893. */
  41894. set buttonLeftStick(value: number);
  41895. /**
  41896. * Gets the value of the Right joystick
  41897. */
  41898. get buttonRightStick(): number;
  41899. /**
  41900. * Sets the value of the Right joystick
  41901. */
  41902. set buttonRightStick(value: number);
  41903. /**
  41904. * Gets the value of D-pad up
  41905. */
  41906. get dPadUp(): number;
  41907. /**
  41908. * Sets the value of D-pad up
  41909. */
  41910. set dPadUp(value: number);
  41911. /**
  41912. * Gets the value of D-pad down
  41913. */
  41914. get dPadDown(): number;
  41915. /**
  41916. * Sets the value of D-pad down
  41917. */
  41918. set dPadDown(value: number);
  41919. /**
  41920. * Gets the value of D-pad left
  41921. */
  41922. get dPadLeft(): number;
  41923. /**
  41924. * Sets the value of D-pad left
  41925. */
  41926. set dPadLeft(value: number);
  41927. /**
  41928. * Gets the value of D-pad right
  41929. */
  41930. get dPadRight(): number;
  41931. /**
  41932. * Sets the value of D-pad right
  41933. */
  41934. set dPadRight(value: number);
  41935. /**
  41936. * Force the gamepad to synchronize with device values
  41937. */
  41938. update(): void;
  41939. /**
  41940. * Disposes the gamepad
  41941. */
  41942. dispose(): void;
  41943. }
  41944. }
  41945. declare module BABYLON {
  41946. /**
  41947. * Manager for handling gamepads
  41948. */
  41949. export class GamepadManager {
  41950. private _scene?;
  41951. private _babylonGamepads;
  41952. private _oneGamepadConnected;
  41953. /** @hidden */
  41954. _isMonitoring: boolean;
  41955. private _gamepadEventSupported;
  41956. private _gamepadSupport?;
  41957. /**
  41958. * observable to be triggered when the gamepad controller has been connected
  41959. */
  41960. onGamepadConnectedObservable: Observable<Gamepad>;
  41961. /**
  41962. * observable to be triggered when the gamepad controller has been disconnected
  41963. */
  41964. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41965. private _onGamepadConnectedEvent;
  41966. private _onGamepadDisconnectedEvent;
  41967. /**
  41968. * Initializes the gamepad manager
  41969. * @param _scene BabylonJS scene
  41970. */
  41971. constructor(_scene?: Scene | undefined);
  41972. /**
  41973. * The gamepads in the game pad manager
  41974. */
  41975. get gamepads(): Gamepad[];
  41976. /**
  41977. * Get the gamepad controllers based on type
  41978. * @param type The type of gamepad controller
  41979. * @returns Nullable gamepad
  41980. */
  41981. getGamepadByType(type?: number): Nullable<Gamepad>;
  41982. /**
  41983. * Disposes the gamepad manager
  41984. */
  41985. dispose(): void;
  41986. private _addNewGamepad;
  41987. private _startMonitoringGamepads;
  41988. private _stopMonitoringGamepads;
  41989. /** @hidden */
  41990. _checkGamepadsStatus(): void;
  41991. private _updateGamepadObjects;
  41992. }
  41993. }
  41994. declare module BABYLON {
  41995. interface Scene {
  41996. /** @hidden */
  41997. _gamepadManager: Nullable<GamepadManager>;
  41998. /**
  41999. * Gets the gamepad manager associated with the scene
  42000. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42001. */
  42002. gamepadManager: GamepadManager;
  42003. }
  42004. /**
  42005. * Interface representing a free camera inputs manager
  42006. */
  42007. interface FreeCameraInputsManager {
  42008. /**
  42009. * Adds gamepad input support to the FreeCameraInputsManager.
  42010. * @returns the FreeCameraInputsManager
  42011. */
  42012. addGamepad(): FreeCameraInputsManager;
  42013. }
  42014. /**
  42015. * Interface representing an arc rotate camera inputs manager
  42016. */
  42017. interface ArcRotateCameraInputsManager {
  42018. /**
  42019. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42020. * @returns the camera inputs manager
  42021. */
  42022. addGamepad(): ArcRotateCameraInputsManager;
  42023. }
  42024. /**
  42025. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42026. */
  42027. export class GamepadSystemSceneComponent implements ISceneComponent {
  42028. /**
  42029. * The component name helpfull to identify the component in the list of scene components.
  42030. */
  42031. readonly name: string;
  42032. /**
  42033. * The scene the component belongs to.
  42034. */
  42035. scene: Scene;
  42036. /**
  42037. * Creates a new instance of the component for the given scene
  42038. * @param scene Defines the scene to register the component in
  42039. */
  42040. constructor(scene: Scene);
  42041. /**
  42042. * Registers the component in a given scene
  42043. */
  42044. register(): void;
  42045. /**
  42046. * Rebuilds the elements related to this component in case of
  42047. * context lost for instance.
  42048. */
  42049. rebuild(): void;
  42050. /**
  42051. * Disposes the component and the associated ressources
  42052. */
  42053. dispose(): void;
  42054. private _beforeCameraUpdate;
  42055. }
  42056. }
  42057. declare module BABYLON {
  42058. /**
  42059. * 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,
  42060. * which still works and will still be found in many Playgrounds.
  42061. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42062. */
  42063. export class UniversalCamera extends TouchCamera {
  42064. /**
  42065. * Defines the gamepad rotation sensiblity.
  42066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42067. */
  42068. get gamepadAngularSensibility(): number;
  42069. set gamepadAngularSensibility(value: number);
  42070. /**
  42071. * Defines the gamepad move sensiblity.
  42072. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42073. */
  42074. get gamepadMoveSensibility(): number;
  42075. set gamepadMoveSensibility(value: number);
  42076. /**
  42077. * 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,
  42078. * which still works and will still be found in many Playgrounds.
  42079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42080. * @param name Define the name of the camera in the scene
  42081. * @param position Define the start position of the camera in the scene
  42082. * @param scene Define the scene the camera belongs to
  42083. */
  42084. constructor(name: string, position: Vector3, scene: Scene);
  42085. /**
  42086. * Gets the current object class name.
  42087. * @return the class name
  42088. */
  42089. getClassName(): string;
  42090. }
  42091. }
  42092. declare module BABYLON {
  42093. /**
  42094. * This represents a FPS type of camera. This is only here for back compat purpose.
  42095. * Please use the UniversalCamera instead as both are identical.
  42096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42097. */
  42098. export class GamepadCamera extends UniversalCamera {
  42099. /**
  42100. * Instantiates a new Gamepad Camera
  42101. * This represents a FPS type of camera. This is only here for back compat purpose.
  42102. * Please use the UniversalCamera instead as both are identical.
  42103. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42104. * @param name Define the name of the camera in the scene
  42105. * @param position Define the start position of the camera in the scene
  42106. * @param scene Define the scene the camera belongs to
  42107. */
  42108. constructor(name: string, position: Vector3, scene: Scene);
  42109. /**
  42110. * Gets the current object class name.
  42111. * @return the class name
  42112. */
  42113. getClassName(): string;
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. /** @hidden */
  42118. export var passPixelShader: {
  42119. name: string;
  42120. shader: string;
  42121. };
  42122. }
  42123. declare module BABYLON {
  42124. /** @hidden */
  42125. export var passCubePixelShader: {
  42126. name: string;
  42127. shader: string;
  42128. };
  42129. }
  42130. declare module BABYLON {
  42131. /**
  42132. * PassPostProcess which produces an output the same as it's input
  42133. */
  42134. export class PassPostProcess extends PostProcess {
  42135. /**
  42136. * Creates the PassPostProcess
  42137. * @param name The name of the effect.
  42138. * @param options The required width/height ratio to downsize to before computing the render pass.
  42139. * @param camera The camera to apply the render pass to.
  42140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42141. * @param engine The engine which the post process will be applied. (default: current engine)
  42142. * @param reusable If the post process can be reused on the same frame. (default: false)
  42143. * @param textureType The type of texture to be used when performing the post processing.
  42144. * @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)
  42145. */
  42146. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42147. }
  42148. /**
  42149. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42150. */
  42151. export class PassCubePostProcess extends PostProcess {
  42152. private _face;
  42153. /**
  42154. * Gets or sets the cube face to display.
  42155. * * 0 is +X
  42156. * * 1 is -X
  42157. * * 2 is +Y
  42158. * * 3 is -Y
  42159. * * 4 is +Z
  42160. * * 5 is -Z
  42161. */
  42162. get face(): number;
  42163. set face(value: number);
  42164. /**
  42165. * Creates the PassCubePostProcess
  42166. * @param name The name of the effect.
  42167. * @param options The required width/height ratio to downsize to before computing the render pass.
  42168. * @param camera The camera to apply the render pass to.
  42169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42170. * @param engine The engine which the post process will be applied. (default: current engine)
  42171. * @param reusable If the post process can be reused on the same frame. (default: false)
  42172. * @param textureType The type of texture to be used when performing the post processing.
  42173. * @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)
  42174. */
  42175. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42176. }
  42177. }
  42178. declare module BABYLON {
  42179. /** @hidden */
  42180. export var anaglyphPixelShader: {
  42181. name: string;
  42182. shader: string;
  42183. };
  42184. }
  42185. declare module BABYLON {
  42186. /**
  42187. * Postprocess used to generate anaglyphic rendering
  42188. */
  42189. export class AnaglyphPostProcess extends PostProcess {
  42190. private _passedProcess;
  42191. /**
  42192. * Creates a new AnaglyphPostProcess
  42193. * @param name defines postprocess name
  42194. * @param options defines creation options or target ratio scale
  42195. * @param rigCameras defines cameras using this postprocess
  42196. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42197. * @param engine defines hosting engine
  42198. * @param reusable defines if the postprocess will be reused multiple times per frame
  42199. */
  42200. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42201. }
  42202. }
  42203. declare module BABYLON {
  42204. /**
  42205. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42207. */
  42208. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42209. /**
  42210. * Creates a new AnaglyphArcRotateCamera
  42211. * @param name defines camera name
  42212. * @param alpha defines alpha angle (in radians)
  42213. * @param beta defines beta angle (in radians)
  42214. * @param radius defines radius
  42215. * @param target defines camera target
  42216. * @param interaxialDistance defines distance between each color axis
  42217. * @param scene defines the hosting scene
  42218. */
  42219. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42220. /**
  42221. * Gets camera class name
  42222. * @returns AnaglyphArcRotateCamera
  42223. */
  42224. getClassName(): string;
  42225. }
  42226. }
  42227. declare module BABYLON {
  42228. /**
  42229. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42230. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42231. */
  42232. export class AnaglyphFreeCamera extends FreeCamera {
  42233. /**
  42234. * Creates a new AnaglyphFreeCamera
  42235. * @param name defines camera name
  42236. * @param position defines initial position
  42237. * @param interaxialDistance defines distance between each color axis
  42238. * @param scene defines the hosting scene
  42239. */
  42240. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42241. /**
  42242. * Gets camera class name
  42243. * @returns AnaglyphFreeCamera
  42244. */
  42245. getClassName(): string;
  42246. }
  42247. }
  42248. declare module BABYLON {
  42249. /**
  42250. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42251. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42252. */
  42253. export class AnaglyphGamepadCamera extends GamepadCamera {
  42254. /**
  42255. * Creates a new AnaglyphGamepadCamera
  42256. * @param name defines camera name
  42257. * @param position defines initial position
  42258. * @param interaxialDistance defines distance between each color axis
  42259. * @param scene defines the hosting scene
  42260. */
  42261. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42262. /**
  42263. * Gets camera class name
  42264. * @returns AnaglyphGamepadCamera
  42265. */
  42266. getClassName(): string;
  42267. }
  42268. }
  42269. declare module BABYLON {
  42270. /**
  42271. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42272. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42273. */
  42274. export class AnaglyphUniversalCamera extends UniversalCamera {
  42275. /**
  42276. * Creates a new AnaglyphUniversalCamera
  42277. * @param name defines camera name
  42278. * @param position defines initial position
  42279. * @param interaxialDistance defines distance between each color axis
  42280. * @param scene defines the hosting scene
  42281. */
  42282. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42283. /**
  42284. * Gets camera class name
  42285. * @returns AnaglyphUniversalCamera
  42286. */
  42287. getClassName(): string;
  42288. }
  42289. }
  42290. declare module BABYLON {
  42291. /** @hidden */
  42292. export var stereoscopicInterlacePixelShader: {
  42293. name: string;
  42294. shader: string;
  42295. };
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42300. */
  42301. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42302. private _stepSize;
  42303. private _passedProcess;
  42304. /**
  42305. * Initializes a StereoscopicInterlacePostProcessI
  42306. * @param name The name of the effect.
  42307. * @param rigCameras The rig cameras to be appled to the post process
  42308. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42309. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42311. * @param engine The engine which the post process will be applied. (default: current engine)
  42312. * @param reusable If the post process can be reused on the same frame. (default: false)
  42313. */
  42314. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42315. }
  42316. /**
  42317. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42318. */
  42319. export class StereoscopicInterlacePostProcess extends PostProcess {
  42320. private _stepSize;
  42321. private _passedProcess;
  42322. /**
  42323. * Initializes a StereoscopicInterlacePostProcess
  42324. * @param name The name of the effect.
  42325. * @param rigCameras The rig cameras to be appled to the post process
  42326. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42328. * @param engine The engine which the post process will be applied. (default: current engine)
  42329. * @param reusable If the post process can be reused on the same frame. (default: false)
  42330. */
  42331. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42332. }
  42333. }
  42334. declare module BABYLON {
  42335. /**
  42336. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42337. * @see http://doc.babylonjs.com/features/cameras
  42338. */
  42339. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42340. /**
  42341. * Creates a new StereoscopicArcRotateCamera
  42342. * @param name defines camera name
  42343. * @param alpha defines alpha angle (in radians)
  42344. * @param beta defines beta angle (in radians)
  42345. * @param radius defines radius
  42346. * @param target defines camera target
  42347. * @param interaxialDistance defines distance between each color axis
  42348. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42349. * @param scene defines the hosting scene
  42350. */
  42351. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42352. /**
  42353. * Gets camera class name
  42354. * @returns StereoscopicArcRotateCamera
  42355. */
  42356. getClassName(): string;
  42357. }
  42358. }
  42359. declare module BABYLON {
  42360. /**
  42361. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42362. * @see http://doc.babylonjs.com/features/cameras
  42363. */
  42364. export class StereoscopicFreeCamera extends FreeCamera {
  42365. /**
  42366. * Creates a new StereoscopicFreeCamera
  42367. * @param name defines camera name
  42368. * @param position defines initial position
  42369. * @param interaxialDistance defines distance between each color axis
  42370. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42371. * @param scene defines the hosting scene
  42372. */
  42373. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42374. /**
  42375. * Gets camera class name
  42376. * @returns StereoscopicFreeCamera
  42377. */
  42378. getClassName(): string;
  42379. }
  42380. }
  42381. declare module BABYLON {
  42382. /**
  42383. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42384. * @see http://doc.babylonjs.com/features/cameras
  42385. */
  42386. export class StereoscopicGamepadCamera extends GamepadCamera {
  42387. /**
  42388. * Creates a new StereoscopicGamepadCamera
  42389. * @param name defines camera name
  42390. * @param position defines initial position
  42391. * @param interaxialDistance defines distance between each color axis
  42392. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42393. * @param scene defines the hosting scene
  42394. */
  42395. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42396. /**
  42397. * Gets camera class name
  42398. * @returns StereoscopicGamepadCamera
  42399. */
  42400. getClassName(): string;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42406. * @see http://doc.babylonjs.com/features/cameras
  42407. */
  42408. export class StereoscopicUniversalCamera extends UniversalCamera {
  42409. /**
  42410. * Creates a new StereoscopicUniversalCamera
  42411. * @param name defines camera name
  42412. * @param position defines initial position
  42413. * @param interaxialDistance defines distance between each color axis
  42414. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42415. * @param scene defines the hosting scene
  42416. */
  42417. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42418. /**
  42419. * Gets camera class name
  42420. * @returns StereoscopicUniversalCamera
  42421. */
  42422. getClassName(): string;
  42423. }
  42424. }
  42425. declare module BABYLON {
  42426. /**
  42427. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42428. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42429. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42430. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42431. */
  42432. export class VirtualJoysticksCamera extends FreeCamera {
  42433. /**
  42434. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42435. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42436. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42437. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42438. * @param name Define the name of the camera in the scene
  42439. * @param position Define the start position of the camera in the scene
  42440. * @param scene Define the scene the camera belongs to
  42441. */
  42442. constructor(name: string, position: Vector3, scene: Scene);
  42443. /**
  42444. * Gets the current object class name.
  42445. * @return the class name
  42446. */
  42447. getClassName(): string;
  42448. }
  42449. }
  42450. declare module BABYLON {
  42451. /**
  42452. * This represents all the required metrics to create a VR camera.
  42453. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42454. */
  42455. export class VRCameraMetrics {
  42456. /**
  42457. * Define the horizontal resolution off the screen.
  42458. */
  42459. hResolution: number;
  42460. /**
  42461. * Define the vertical resolution off the screen.
  42462. */
  42463. vResolution: number;
  42464. /**
  42465. * Define the horizontal screen size.
  42466. */
  42467. hScreenSize: number;
  42468. /**
  42469. * Define the vertical screen size.
  42470. */
  42471. vScreenSize: number;
  42472. /**
  42473. * Define the vertical screen center position.
  42474. */
  42475. vScreenCenter: number;
  42476. /**
  42477. * Define the distance of the eyes to the screen.
  42478. */
  42479. eyeToScreenDistance: number;
  42480. /**
  42481. * Define the distance between both lenses
  42482. */
  42483. lensSeparationDistance: number;
  42484. /**
  42485. * Define the distance between both viewer's eyes.
  42486. */
  42487. interpupillaryDistance: number;
  42488. /**
  42489. * Define the distortion factor of the VR postprocess.
  42490. * Please, touch with care.
  42491. */
  42492. distortionK: number[];
  42493. /**
  42494. * Define the chromatic aberration correction factors for the VR post process.
  42495. */
  42496. chromaAbCorrection: number[];
  42497. /**
  42498. * Define the scale factor of the post process.
  42499. * The smaller the better but the slower.
  42500. */
  42501. postProcessScaleFactor: number;
  42502. /**
  42503. * Define an offset for the lens center.
  42504. */
  42505. lensCenterOffset: number;
  42506. /**
  42507. * Define if the current vr camera should compensate the distortion of the lense or not.
  42508. */
  42509. compensateDistortion: boolean;
  42510. /**
  42511. * Defines if multiview should be enabled when rendering (Default: false)
  42512. */
  42513. multiviewEnabled: boolean;
  42514. /**
  42515. * Gets the rendering aspect ratio based on the provided resolutions.
  42516. */
  42517. get aspectRatio(): number;
  42518. /**
  42519. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42520. */
  42521. get aspectRatioFov(): number;
  42522. /**
  42523. * @hidden
  42524. */
  42525. get leftHMatrix(): Matrix;
  42526. /**
  42527. * @hidden
  42528. */
  42529. get rightHMatrix(): Matrix;
  42530. /**
  42531. * @hidden
  42532. */
  42533. get leftPreViewMatrix(): Matrix;
  42534. /**
  42535. * @hidden
  42536. */
  42537. get rightPreViewMatrix(): Matrix;
  42538. /**
  42539. * Get the default VRMetrics based on the most generic setup.
  42540. * @returns the default vr metrics
  42541. */
  42542. static GetDefault(): VRCameraMetrics;
  42543. }
  42544. }
  42545. declare module BABYLON {
  42546. /** @hidden */
  42547. export var vrDistortionCorrectionPixelShader: {
  42548. name: string;
  42549. shader: string;
  42550. };
  42551. }
  42552. declare module BABYLON {
  42553. /**
  42554. * VRDistortionCorrectionPostProcess used for mobile VR
  42555. */
  42556. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42557. private _isRightEye;
  42558. private _distortionFactors;
  42559. private _postProcessScaleFactor;
  42560. private _lensCenterOffset;
  42561. private _scaleIn;
  42562. private _scaleFactor;
  42563. private _lensCenter;
  42564. /**
  42565. * Initializes the VRDistortionCorrectionPostProcess
  42566. * @param name The name of the effect.
  42567. * @param camera The camera to apply the render pass to.
  42568. * @param isRightEye If this is for the right eye distortion
  42569. * @param vrMetrics All the required metrics for the VR camera
  42570. */
  42571. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42572. }
  42573. }
  42574. declare module BABYLON {
  42575. /**
  42576. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42577. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42578. */
  42579. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42580. /**
  42581. * Creates a new VRDeviceOrientationArcRotateCamera
  42582. * @param name defines camera name
  42583. * @param alpha defines the camera rotation along the logitudinal axis
  42584. * @param beta defines the camera rotation along the latitudinal axis
  42585. * @param radius defines the camera distance from its target
  42586. * @param target defines the camera target
  42587. * @param scene defines the scene the camera belongs to
  42588. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42589. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42590. */
  42591. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42592. /**
  42593. * Gets camera class name
  42594. * @returns VRDeviceOrientationArcRotateCamera
  42595. */
  42596. getClassName(): string;
  42597. }
  42598. }
  42599. declare module BABYLON {
  42600. /**
  42601. * Camera used to simulate VR rendering (based on FreeCamera)
  42602. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42603. */
  42604. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42605. /**
  42606. * Creates a new VRDeviceOrientationFreeCamera
  42607. * @param name defines camera name
  42608. * @param position defines the start position of the camera
  42609. * @param scene defines the scene the camera belongs to
  42610. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42611. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42612. */
  42613. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42614. /**
  42615. * Gets camera class name
  42616. * @returns VRDeviceOrientationFreeCamera
  42617. */
  42618. getClassName(): string;
  42619. }
  42620. }
  42621. declare module BABYLON {
  42622. /**
  42623. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42624. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42625. */
  42626. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42627. /**
  42628. * Creates a new VRDeviceOrientationGamepadCamera
  42629. * @param name defines camera name
  42630. * @param position defines the start position of the camera
  42631. * @param scene defines the scene the camera belongs to
  42632. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42633. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42634. */
  42635. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42636. /**
  42637. * Gets camera class name
  42638. * @returns VRDeviceOrientationGamepadCamera
  42639. */
  42640. getClassName(): string;
  42641. }
  42642. }
  42643. declare module BABYLON {
  42644. /** @hidden */
  42645. export var imageProcessingPixelShader: {
  42646. name: string;
  42647. shader: string;
  42648. };
  42649. }
  42650. declare module BABYLON {
  42651. /**
  42652. * ImageProcessingPostProcess
  42653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42654. */
  42655. export class ImageProcessingPostProcess extends PostProcess {
  42656. /**
  42657. * Default configuration related to image processing available in the PBR Material.
  42658. */
  42659. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42660. /**
  42661. * Gets the image processing configuration used either in this material.
  42662. */
  42663. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42664. /**
  42665. * Sets the Default image processing configuration used either in the this material.
  42666. *
  42667. * If sets to null, the scene one is in use.
  42668. */
  42669. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42670. /**
  42671. * Keep track of the image processing observer to allow dispose and replace.
  42672. */
  42673. private _imageProcessingObserver;
  42674. /**
  42675. * Attaches a new image processing configuration to the PBR Material.
  42676. * @param configuration
  42677. */
  42678. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42679. /**
  42680. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42681. */
  42682. get colorCurves(): Nullable<ColorCurves>;
  42683. /**
  42684. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42685. */
  42686. set colorCurves(value: Nullable<ColorCurves>);
  42687. /**
  42688. * Gets wether the color curves effect is enabled.
  42689. */
  42690. get colorCurvesEnabled(): boolean;
  42691. /**
  42692. * Sets wether the color curves effect is enabled.
  42693. */
  42694. set colorCurvesEnabled(value: boolean);
  42695. /**
  42696. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42697. */
  42698. get colorGradingTexture(): Nullable<BaseTexture>;
  42699. /**
  42700. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42701. */
  42702. set colorGradingTexture(value: Nullable<BaseTexture>);
  42703. /**
  42704. * Gets wether the color grading effect is enabled.
  42705. */
  42706. get colorGradingEnabled(): boolean;
  42707. /**
  42708. * Gets wether the color grading effect is enabled.
  42709. */
  42710. set colorGradingEnabled(value: boolean);
  42711. /**
  42712. * Gets exposure used in the effect.
  42713. */
  42714. get exposure(): number;
  42715. /**
  42716. * Sets exposure used in the effect.
  42717. */
  42718. set exposure(value: number);
  42719. /**
  42720. * Gets wether tonemapping is enabled or not.
  42721. */
  42722. get toneMappingEnabled(): boolean;
  42723. /**
  42724. * Sets wether tonemapping is enabled or not
  42725. */
  42726. set toneMappingEnabled(value: boolean);
  42727. /**
  42728. * Gets the type of tone mapping effect.
  42729. */
  42730. get toneMappingType(): number;
  42731. /**
  42732. * Sets the type of tone mapping effect.
  42733. */
  42734. set toneMappingType(value: number);
  42735. /**
  42736. * Gets contrast used in the effect.
  42737. */
  42738. get contrast(): number;
  42739. /**
  42740. * Sets contrast used in the effect.
  42741. */
  42742. set contrast(value: number);
  42743. /**
  42744. * Gets Vignette stretch size.
  42745. */
  42746. get vignetteStretch(): number;
  42747. /**
  42748. * Sets Vignette stretch size.
  42749. */
  42750. set vignetteStretch(value: number);
  42751. /**
  42752. * Gets Vignette centre X Offset.
  42753. */
  42754. get vignetteCentreX(): number;
  42755. /**
  42756. * Sets Vignette centre X Offset.
  42757. */
  42758. set vignetteCentreX(value: number);
  42759. /**
  42760. * Gets Vignette centre Y Offset.
  42761. */
  42762. get vignetteCentreY(): number;
  42763. /**
  42764. * Sets Vignette centre Y Offset.
  42765. */
  42766. set vignetteCentreY(value: number);
  42767. /**
  42768. * Gets Vignette weight or intensity of the vignette effect.
  42769. */
  42770. get vignetteWeight(): number;
  42771. /**
  42772. * Sets Vignette weight or intensity of the vignette effect.
  42773. */
  42774. set vignetteWeight(value: number);
  42775. /**
  42776. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42777. * if vignetteEnabled is set to true.
  42778. */
  42779. get vignetteColor(): Color4;
  42780. /**
  42781. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42782. * if vignetteEnabled is set to true.
  42783. */
  42784. set vignetteColor(value: Color4);
  42785. /**
  42786. * Gets Camera field of view used by the Vignette effect.
  42787. */
  42788. get vignetteCameraFov(): number;
  42789. /**
  42790. * Sets Camera field of view used by the Vignette effect.
  42791. */
  42792. set vignetteCameraFov(value: number);
  42793. /**
  42794. * Gets the vignette blend mode allowing different kind of effect.
  42795. */
  42796. get vignetteBlendMode(): number;
  42797. /**
  42798. * Sets the vignette blend mode allowing different kind of effect.
  42799. */
  42800. set vignetteBlendMode(value: number);
  42801. /**
  42802. * Gets wether the vignette effect is enabled.
  42803. */
  42804. get vignetteEnabled(): boolean;
  42805. /**
  42806. * Sets wether the vignette effect is enabled.
  42807. */
  42808. set vignetteEnabled(value: boolean);
  42809. private _fromLinearSpace;
  42810. /**
  42811. * Gets wether the input of the processing is in Gamma or Linear Space.
  42812. */
  42813. get fromLinearSpace(): boolean;
  42814. /**
  42815. * Sets wether the input of the processing is in Gamma or Linear Space.
  42816. */
  42817. set fromLinearSpace(value: boolean);
  42818. /**
  42819. * Defines cache preventing GC.
  42820. */
  42821. private _defines;
  42822. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42823. /**
  42824. * "ImageProcessingPostProcess"
  42825. * @returns "ImageProcessingPostProcess"
  42826. */
  42827. getClassName(): string;
  42828. protected _updateParameters(): void;
  42829. dispose(camera?: Camera): void;
  42830. }
  42831. }
  42832. declare module BABYLON {
  42833. /**
  42834. * Class containing static functions to help procedurally build meshes
  42835. */
  42836. export class GroundBuilder {
  42837. /**
  42838. * Creates a ground mesh
  42839. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42840. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42842. * @param name defines the name of the mesh
  42843. * @param options defines the options used to create the mesh
  42844. * @param scene defines the hosting scene
  42845. * @returns the ground mesh
  42846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42847. */
  42848. static CreateGround(name: string, options: {
  42849. width?: number;
  42850. height?: number;
  42851. subdivisions?: number;
  42852. subdivisionsX?: number;
  42853. subdivisionsY?: number;
  42854. updatable?: boolean;
  42855. }, scene: any): Mesh;
  42856. /**
  42857. * Creates a tiled ground mesh
  42858. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42859. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42860. * * 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
  42861. * * 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
  42862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42863. * @param name defines the name of the mesh
  42864. * @param options defines the options used to create the mesh
  42865. * @param scene defines the hosting scene
  42866. * @returns the tiled ground mesh
  42867. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42868. */
  42869. static CreateTiledGround(name: string, options: {
  42870. xmin: number;
  42871. zmin: number;
  42872. xmax: number;
  42873. zmax: number;
  42874. subdivisions?: {
  42875. w: number;
  42876. h: number;
  42877. };
  42878. precision?: {
  42879. w: number;
  42880. h: number;
  42881. };
  42882. updatable?: boolean;
  42883. }, scene?: Nullable<Scene>): Mesh;
  42884. /**
  42885. * Creates a ground mesh from a height map
  42886. * * The parameter `url` sets the URL of the height map image resource.
  42887. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42888. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42889. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42890. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42891. * * 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.
  42892. * * 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).
  42893. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42895. * @param name defines the name of the mesh
  42896. * @param url defines the url to the height map
  42897. * @param options defines the options used to create the mesh
  42898. * @param scene defines the hosting scene
  42899. * @returns the ground mesh
  42900. * @see https://doc.babylonjs.com/babylon101/height_map
  42901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42902. */
  42903. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42904. width?: number;
  42905. height?: number;
  42906. subdivisions?: number;
  42907. minHeight?: number;
  42908. maxHeight?: number;
  42909. colorFilter?: Color3;
  42910. alphaFilter?: number;
  42911. updatable?: boolean;
  42912. onReady?: (mesh: GroundMesh) => void;
  42913. }, scene?: Nullable<Scene>): GroundMesh;
  42914. }
  42915. }
  42916. declare module BABYLON {
  42917. /**
  42918. * Class containing static functions to help procedurally build meshes
  42919. */
  42920. export class TorusBuilder {
  42921. /**
  42922. * Creates a torus mesh
  42923. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42924. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42925. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42927. * * 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
  42928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42929. * @param name defines the name of the mesh
  42930. * @param options defines the options used to create the mesh
  42931. * @param scene defines the hosting scene
  42932. * @returns the torus mesh
  42933. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42934. */
  42935. static CreateTorus(name: string, options: {
  42936. diameter?: number;
  42937. thickness?: number;
  42938. tessellation?: number;
  42939. updatable?: boolean;
  42940. sideOrientation?: number;
  42941. frontUVs?: Vector4;
  42942. backUVs?: Vector4;
  42943. }, scene: any): Mesh;
  42944. }
  42945. }
  42946. declare module BABYLON {
  42947. /**
  42948. * Class containing static functions to help procedurally build meshes
  42949. */
  42950. export class CylinderBuilder {
  42951. /**
  42952. * Creates a cylinder or a cone mesh
  42953. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42954. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42955. * * 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.
  42956. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42957. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42958. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42959. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42960. * * 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).
  42961. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42962. * * 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).
  42963. * * 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
  42964. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42965. * * 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
  42966. * * 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.
  42967. * * If `enclose` is false, a ring surface is one element.
  42968. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42969. * * 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
  42970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42971. * * 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
  42972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42973. * @param name defines the name of the mesh
  42974. * @param options defines the options used to create the mesh
  42975. * @param scene defines the hosting scene
  42976. * @returns the cylinder mesh
  42977. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42978. */
  42979. static CreateCylinder(name: string, options: {
  42980. height?: number;
  42981. diameterTop?: number;
  42982. diameterBottom?: number;
  42983. diameter?: number;
  42984. tessellation?: number;
  42985. subdivisions?: number;
  42986. arc?: number;
  42987. faceColors?: Color4[];
  42988. faceUV?: Vector4[];
  42989. updatable?: boolean;
  42990. hasRings?: boolean;
  42991. enclose?: boolean;
  42992. cap?: number;
  42993. sideOrientation?: number;
  42994. frontUVs?: Vector4;
  42995. backUVs?: Vector4;
  42996. }, scene: any): Mesh;
  42997. }
  42998. }
  42999. declare module BABYLON {
  43000. /**
  43001. * States of the webXR experience
  43002. */
  43003. export enum WebXRState {
  43004. /**
  43005. * Transitioning to being in XR mode
  43006. */
  43007. ENTERING_XR = 0,
  43008. /**
  43009. * Transitioning to non XR mode
  43010. */
  43011. EXITING_XR = 1,
  43012. /**
  43013. * In XR mode and presenting
  43014. */
  43015. IN_XR = 2,
  43016. /**
  43017. * Not entered XR mode
  43018. */
  43019. NOT_IN_XR = 3
  43020. }
  43021. /**
  43022. * Abstraction of the XR render target
  43023. */
  43024. export interface WebXRRenderTarget extends IDisposable {
  43025. /**
  43026. * xrpresent context of the canvas which can be used to display/mirror xr content
  43027. */
  43028. canvasContext: WebGLRenderingContext;
  43029. /**
  43030. * xr layer for the canvas
  43031. */
  43032. xrLayer: Nullable<XRWebGLLayer>;
  43033. /**
  43034. * Initializes the xr layer for the session
  43035. * @param xrSession xr session
  43036. * @returns a promise that will resolve once the XR Layer has been created
  43037. */
  43038. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43039. }
  43040. }
  43041. declare module BABYLON {
  43042. /**
  43043. * COnfiguration object for WebXR output canvas
  43044. */
  43045. export class WebXRManagedOutputCanvasOptions {
  43046. /**
  43047. * An optional canvas in case you wish to create it yourself and provide it here.
  43048. * If not provided, a new canvas will be created
  43049. */
  43050. canvasElement?: HTMLCanvasElement;
  43051. /**
  43052. * Options for this XR Layer output
  43053. */
  43054. canvasOptions?: XRWebGLLayerOptions;
  43055. /**
  43056. * CSS styling for a newly created canvas (if not provided)
  43057. */
  43058. newCanvasCssStyle?: string;
  43059. /**
  43060. * Get the default values of the configuration object
  43061. * @returns default values of this configuration object
  43062. */
  43063. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43064. }
  43065. /**
  43066. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43067. */
  43068. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43069. private _options;
  43070. private _canvas;
  43071. private _engine;
  43072. /**
  43073. * Rendering context of the canvas which can be used to display/mirror xr content
  43074. */
  43075. canvasContext: WebGLRenderingContext;
  43076. /**
  43077. * xr layer for the canvas
  43078. */
  43079. xrLayer: Nullable<XRWebGLLayer>;
  43080. /**
  43081. * Initializes the canvas to be added/removed upon entering/exiting xr
  43082. * @param _xrSessionManager The XR Session manager
  43083. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43084. */
  43085. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43086. /**
  43087. * Disposes of the object
  43088. */
  43089. dispose(): void;
  43090. /**
  43091. * Initializes the xr layer for the session
  43092. * @param xrSession xr session
  43093. * @returns a promise that will resolve once the XR Layer has been created
  43094. */
  43095. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43096. private _addCanvas;
  43097. private _removeCanvas;
  43098. private _setManagedOutputCanvas;
  43099. }
  43100. }
  43101. declare module BABYLON {
  43102. /**
  43103. * Manages an XRSession to work with Babylon's engine
  43104. * @see https://doc.babylonjs.com/how_to/webxr
  43105. */
  43106. export class WebXRSessionManager implements IDisposable {
  43107. /** The scene which the session should be created for */
  43108. scene: Scene;
  43109. private _referenceSpace;
  43110. private _rttProvider;
  43111. private _sessionEnded;
  43112. private _xrNavigator;
  43113. private baseLayer;
  43114. /**
  43115. * The base reference space from which the session started. good if you want to reset your
  43116. * reference space
  43117. */
  43118. baseReferenceSpace: XRReferenceSpace;
  43119. /**
  43120. * Current XR frame
  43121. */
  43122. currentFrame: Nullable<XRFrame>;
  43123. /** WebXR timestamp updated every frame */
  43124. currentTimestamp: number;
  43125. /**
  43126. * Used just in case of a failure to initialize an immersive session.
  43127. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43128. */
  43129. defaultHeightCompensation: number;
  43130. /**
  43131. * Fires every time a new xrFrame arrives which can be used to update the camera
  43132. */
  43133. onXRFrameObservable: Observable<XRFrame>;
  43134. /**
  43135. * Fires when the reference space changed
  43136. */
  43137. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43138. /**
  43139. * Fires when the xr session is ended either by the device or manually done
  43140. */
  43141. onXRSessionEnded: Observable<any>;
  43142. /**
  43143. * Fires when the xr session is ended either by the device or manually done
  43144. */
  43145. onXRSessionInit: Observable<XRSession>;
  43146. /**
  43147. * Underlying xr session
  43148. */
  43149. session: XRSession;
  43150. /**
  43151. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43152. * or get the offset the player is currently at.
  43153. */
  43154. viewerReferenceSpace: XRReferenceSpace;
  43155. /**
  43156. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43157. * @param scene The scene which the session should be created for
  43158. */
  43159. constructor(
  43160. /** The scene which the session should be created for */
  43161. scene: Scene);
  43162. /**
  43163. * The current reference space used in this session. This reference space can constantly change!
  43164. * It is mainly used to offset the camera's position.
  43165. */
  43166. get referenceSpace(): XRReferenceSpace;
  43167. /**
  43168. * Set a new reference space and triggers the observable
  43169. */
  43170. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43171. /**
  43172. * Disposes of the session manager
  43173. */
  43174. dispose(): void;
  43175. /**
  43176. * Stops the xrSession and restores the render loop
  43177. * @returns Promise which resolves after it exits XR
  43178. */
  43179. exitXRAsync(): Promise<void>;
  43180. /**
  43181. * Gets the correct render target texture to be rendered this frame for this eye
  43182. * @param eye the eye for which to get the render target
  43183. * @returns the render target for the specified eye
  43184. */
  43185. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43186. /**
  43187. * Creates a WebXRRenderTarget object for the XR session
  43188. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43189. * @param options optional options to provide when creating a new render target
  43190. * @returns a WebXR render target to which the session can render
  43191. */
  43192. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43193. /**
  43194. * Initializes the manager
  43195. * After initialization enterXR can be called to start an XR session
  43196. * @returns Promise which resolves after it is initialized
  43197. */
  43198. initializeAsync(): Promise<void>;
  43199. /**
  43200. * Initializes an xr session
  43201. * @param xrSessionMode mode to initialize
  43202. * @param xrSessionInit defines optional and required values to pass to the session builder
  43203. * @returns a promise which will resolve once the session has been initialized
  43204. */
  43205. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43206. /**
  43207. * Checks if a session would be supported for the creation options specified
  43208. * @param sessionMode session mode to check if supported eg. immersive-vr
  43209. * @returns A Promise that resolves to true if supported and false if not
  43210. */
  43211. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43212. /**
  43213. * Resets the reference space to the one started the session
  43214. */
  43215. resetReferenceSpace(): void;
  43216. /**
  43217. * Starts rendering to the xr layer
  43218. */
  43219. runXRRenderLoop(): void;
  43220. /**
  43221. * Sets the reference space on the xr session
  43222. * @param referenceSpaceType space to set
  43223. * @returns a promise that will resolve once the reference space has been set
  43224. */
  43225. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43226. /**
  43227. * Updates the render state of the session
  43228. * @param state state to set
  43229. * @returns a promise that resolves once the render state has been updated
  43230. */
  43231. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43232. /**
  43233. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43234. * @param sessionMode defines the session to test
  43235. * @returns a promise with boolean as final value
  43236. */
  43237. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43238. private _createRenderTargetTexture;
  43239. }
  43240. }
  43241. declare module BABYLON {
  43242. /**
  43243. * WebXR Camera which holds the views for the xrSession
  43244. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43245. */
  43246. export class WebXRCamera extends FreeCamera {
  43247. private _xrSessionManager;
  43248. private _firstFrame;
  43249. private _referenceQuaternion;
  43250. private _referencedPosition;
  43251. private _xrInvPositionCache;
  43252. private _xrInvQuaternionCache;
  43253. /**
  43254. * Should position compensation execute on first frame.
  43255. * This is used when copying the position from a native (non XR) camera
  43256. */
  43257. compensateOnFirstFrame: boolean;
  43258. /**
  43259. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43260. * @param name the name of the camera
  43261. * @param scene the scene to add the camera to
  43262. * @param _xrSessionManager a constructed xr session manager
  43263. */
  43264. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43265. /**
  43266. * Return the user's height, unrelated to the current ground.
  43267. * This will be the y position of this camera, when ground level is 0.
  43268. */
  43269. get realWorldHeight(): number;
  43270. /** @hidden */
  43271. _updateForDualEyeDebugging(): void;
  43272. /**
  43273. * Sets this camera's transformation based on a non-vr camera
  43274. * @param otherCamera the non-vr camera to copy the transformation from
  43275. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43276. */
  43277. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43278. /**
  43279. * Gets the current instance class name ("WebXRCamera").
  43280. * @returns the class name
  43281. */
  43282. getClassName(): string;
  43283. private _updateFromXRSession;
  43284. private _updateNumberOfRigCameras;
  43285. private _updateReferenceSpace;
  43286. private _updateReferenceSpaceOffset;
  43287. }
  43288. }
  43289. declare module BABYLON {
  43290. /**
  43291. * Defining the interface required for a (webxr) feature
  43292. */
  43293. export interface IWebXRFeature extends IDisposable {
  43294. /**
  43295. * Is this feature attached
  43296. */
  43297. attached: boolean;
  43298. /**
  43299. * Should auto-attach be disabled?
  43300. */
  43301. disableAutoAttach: boolean;
  43302. /**
  43303. * Attach the feature to the session
  43304. * Will usually be called by the features manager
  43305. *
  43306. * @param force should attachment be forced (even when already attached)
  43307. * @returns true if successful.
  43308. */
  43309. attach(force?: boolean): boolean;
  43310. /**
  43311. * Detach the feature from the session
  43312. * Will usually be called by the features manager
  43313. *
  43314. * @returns true if successful.
  43315. */
  43316. detach(): boolean;
  43317. }
  43318. /**
  43319. * A list of the currently available features without referencing them
  43320. */
  43321. export class WebXRFeatureName {
  43322. /**
  43323. * The name of the anchor system feature
  43324. */
  43325. static ANCHOR_SYSTEM: string;
  43326. /**
  43327. * The name of the background remover feature
  43328. */
  43329. static BACKGROUND_REMOVER: string;
  43330. /**
  43331. * The name of the hit test feature
  43332. */
  43333. static HIT_TEST: string;
  43334. /**
  43335. * physics impostors for xr controllers feature
  43336. */
  43337. static PHYSICS_CONTROLLERS: string;
  43338. /**
  43339. * The name of the plane detection feature
  43340. */
  43341. static PLANE_DETECTION: string;
  43342. /**
  43343. * The name of the pointer selection feature
  43344. */
  43345. static POINTER_SELECTION: string;
  43346. /**
  43347. * The name of the teleportation feature
  43348. */
  43349. static TELEPORTATION: string;
  43350. }
  43351. /**
  43352. * Defining the constructor of a feature. Used to register the modules.
  43353. */
  43354. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43355. /**
  43356. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43357. * It is mainly used in AR sessions.
  43358. *
  43359. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43360. */
  43361. export class WebXRFeaturesManager implements IDisposable {
  43362. private _xrSessionManager;
  43363. private static readonly _AvailableFeatures;
  43364. private _features;
  43365. /**
  43366. * constructs a new features manages.
  43367. *
  43368. * @param _xrSessionManager an instance of WebXRSessionManager
  43369. */
  43370. constructor(_xrSessionManager: WebXRSessionManager);
  43371. /**
  43372. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43373. * Mainly used internally.
  43374. *
  43375. * @param featureName the name of the feature to register
  43376. * @param constructorFunction the function used to construct the module
  43377. * @param version the (babylon) version of the module
  43378. * @param stable is that a stable version of this module
  43379. */
  43380. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43381. /**
  43382. * Returns a constructor of a specific feature.
  43383. *
  43384. * @param featureName the name of the feature to construct
  43385. * @param version the version of the feature to load
  43386. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43387. * @param options optional options provided to the module.
  43388. * @returns a function that, when called, will return a new instance of this feature
  43389. */
  43390. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43391. /**
  43392. * Can be used to return the list of features currently registered
  43393. *
  43394. * @returns an Array of available features
  43395. */
  43396. static GetAvailableFeatures(): string[];
  43397. /**
  43398. * Gets the versions available for a specific feature
  43399. * @param featureName the name of the feature
  43400. * @returns an array with the available versions
  43401. */
  43402. static GetAvailableVersions(featureName: string): string[];
  43403. /**
  43404. * Return the latest unstable version of this feature
  43405. * @param featureName the name of the feature to search
  43406. * @returns the version number. if not found will return -1
  43407. */
  43408. static GetLatestVersionOfFeature(featureName: string): number;
  43409. /**
  43410. * Return the latest stable version of this feature
  43411. * @param featureName the name of the feature to search
  43412. * @returns the version number. if not found will return -1
  43413. */
  43414. static GetStableVersionOfFeature(featureName: string): number;
  43415. /**
  43416. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43417. * Can be used during a session to start a feature
  43418. * @param featureName the name of feature to attach
  43419. */
  43420. attachFeature(featureName: string): void;
  43421. /**
  43422. * Can be used inside a session or when the session ends to detach a specific feature
  43423. * @param featureName the name of the feature to detach
  43424. */
  43425. detachFeature(featureName: string): void;
  43426. /**
  43427. * Used to disable an already-enabled feature
  43428. * The feature will be disposed and will be recreated once enabled.
  43429. * @param featureName the feature to disable
  43430. * @returns true if disable was successful
  43431. */
  43432. disableFeature(featureName: string | {
  43433. Name: string;
  43434. }): boolean;
  43435. /**
  43436. * dispose this features manager
  43437. */
  43438. dispose(): void;
  43439. /**
  43440. * 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.
  43441. * 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.
  43442. *
  43443. * @param featureName the name of the feature to load or the class of the feature
  43444. * @param version optional version to load. if not provided the latest version will be enabled
  43445. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43446. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43447. * @returns a new constructed feature or throws an error if feature not found.
  43448. */
  43449. enableFeature(featureName: string | {
  43450. Name: string;
  43451. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43452. /**
  43453. * get the implementation of an enabled feature.
  43454. * @param featureName the name of the feature to load
  43455. * @returns the feature class, if found
  43456. */
  43457. getEnabledFeature(featureName: string): IWebXRFeature;
  43458. /**
  43459. * Get the list of enabled features
  43460. * @returns an array of enabled features
  43461. */
  43462. getEnabledFeatures(): string[];
  43463. }
  43464. }
  43465. declare module BABYLON {
  43466. /**
  43467. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43468. * @see https://doc.babylonjs.com/how_to/webxr
  43469. */
  43470. export class WebXRExperienceHelper implements IDisposable {
  43471. private scene;
  43472. private _nonVRCamera;
  43473. private _originalSceneAutoClear;
  43474. private _supported;
  43475. /**
  43476. * Camera used to render xr content
  43477. */
  43478. camera: WebXRCamera;
  43479. /** A features manager for this xr session */
  43480. featuresManager: WebXRFeaturesManager;
  43481. /**
  43482. * Observers registered here will be triggered after the camera's initial transformation is set
  43483. * This can be used to set a different ground level or an extra rotation.
  43484. *
  43485. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43486. * to the position set after this observable is done executing.
  43487. */
  43488. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43489. /**
  43490. * Fires when the state of the experience helper has changed
  43491. */
  43492. onStateChangedObservable: Observable<WebXRState>;
  43493. /** Session manager used to keep track of xr session */
  43494. sessionManager: WebXRSessionManager;
  43495. /**
  43496. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43497. */
  43498. state: WebXRState;
  43499. /**
  43500. * Creates a WebXRExperienceHelper
  43501. * @param scene The scene the helper should be created in
  43502. */
  43503. private constructor();
  43504. /**
  43505. * Creates the experience helper
  43506. * @param scene the scene to attach the experience helper to
  43507. * @returns a promise for the experience helper
  43508. */
  43509. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43510. /**
  43511. * Disposes of the experience helper
  43512. */
  43513. dispose(): void;
  43514. /**
  43515. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43516. * @param sessionMode options for the XR session
  43517. * @param referenceSpaceType frame of reference of the XR session
  43518. * @param renderTarget the output canvas that will be used to enter XR mode
  43519. * @returns promise that resolves after xr mode has entered
  43520. */
  43521. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43522. /**
  43523. * Exits XR mode and returns the scene to its original state
  43524. * @returns promise that resolves after xr mode has exited
  43525. */
  43526. exitXRAsync(): Promise<void>;
  43527. private _nonXRToXRCamera;
  43528. private _setState;
  43529. }
  43530. }
  43531. declare module BABYLON {
  43532. /**
  43533. * X-Y values for axes in WebXR
  43534. */
  43535. export interface IWebXRMotionControllerAxesValue {
  43536. /**
  43537. * The value of the x axis
  43538. */
  43539. x: number;
  43540. /**
  43541. * The value of the y-axis
  43542. */
  43543. y: number;
  43544. }
  43545. /**
  43546. * changed / previous values for the values of this component
  43547. */
  43548. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43549. /**
  43550. * current (this frame) value
  43551. */
  43552. current: T;
  43553. /**
  43554. * previous (last change) value
  43555. */
  43556. previous: T;
  43557. }
  43558. /**
  43559. * Represents changes in the component between current frame and last values recorded
  43560. */
  43561. export interface IWebXRMotionControllerComponentChanges {
  43562. /**
  43563. * will be populated with previous and current values if axes changed
  43564. */
  43565. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43566. /**
  43567. * will be populated with previous and current values if pressed changed
  43568. */
  43569. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43570. /**
  43571. * will be populated with previous and current values if touched changed
  43572. */
  43573. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43574. /**
  43575. * will be populated with previous and current values if value changed
  43576. */
  43577. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43578. }
  43579. /**
  43580. * This class represents a single component (for example button or thumbstick) of a motion controller
  43581. */
  43582. export class WebXRControllerComponent implements IDisposable {
  43583. /**
  43584. * the id of this component
  43585. */
  43586. id: string;
  43587. /**
  43588. * the type of the component
  43589. */
  43590. type: MotionControllerComponentType;
  43591. private _buttonIndex;
  43592. private _axesIndices;
  43593. private _axes;
  43594. private _changes;
  43595. private _currentValue;
  43596. private _hasChanges;
  43597. private _pressed;
  43598. private _touched;
  43599. /**
  43600. * button component type
  43601. */
  43602. static BUTTON_TYPE: MotionControllerComponentType;
  43603. /**
  43604. * squeeze component type
  43605. */
  43606. static SQUEEZE_TYPE: MotionControllerComponentType;
  43607. /**
  43608. * Thumbstick component type
  43609. */
  43610. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43611. /**
  43612. * Touchpad component type
  43613. */
  43614. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43615. /**
  43616. * trigger component type
  43617. */
  43618. static TRIGGER_TYPE: MotionControllerComponentType;
  43619. /**
  43620. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43621. * the axes data changes
  43622. */
  43623. onAxisValueChangedObservable: Observable<{
  43624. x: number;
  43625. y: number;
  43626. }>;
  43627. /**
  43628. * Observers registered here will be triggered when the state of a button changes
  43629. * State change is either pressed / touched / value
  43630. */
  43631. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43632. /**
  43633. * Creates a new component for a motion controller.
  43634. * It is created by the motion controller itself
  43635. *
  43636. * @param id the id of this component
  43637. * @param type the type of the component
  43638. * @param _buttonIndex index in the buttons array of the gamepad
  43639. * @param _axesIndices indices of the values in the axes array of the gamepad
  43640. */
  43641. constructor(
  43642. /**
  43643. * the id of this component
  43644. */
  43645. id: string,
  43646. /**
  43647. * the type of the component
  43648. */
  43649. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43650. /**
  43651. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43652. */
  43653. get axes(): IWebXRMotionControllerAxesValue;
  43654. /**
  43655. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43656. */
  43657. get changes(): IWebXRMotionControllerComponentChanges;
  43658. /**
  43659. * Return whether or not the component changed the last frame
  43660. */
  43661. get hasChanges(): boolean;
  43662. /**
  43663. * is the button currently pressed
  43664. */
  43665. get pressed(): boolean;
  43666. /**
  43667. * is the button currently touched
  43668. */
  43669. get touched(): boolean;
  43670. /**
  43671. * Get the current value of this component
  43672. */
  43673. get value(): number;
  43674. /**
  43675. * Dispose this component
  43676. */
  43677. dispose(): void;
  43678. /**
  43679. * Are there axes correlating to this component
  43680. * @return true is axes data is available
  43681. */
  43682. isAxes(): boolean;
  43683. /**
  43684. * Is this component a button (hence - pressable)
  43685. * @returns true if can be pressed
  43686. */
  43687. isButton(): boolean;
  43688. /**
  43689. * update this component using the gamepad object it is in. Called on every frame
  43690. * @param nativeController the native gamepad controller object
  43691. */
  43692. update(nativeController: IMinimalMotionControllerObject): void;
  43693. }
  43694. }
  43695. declare module BABYLON {
  43696. /**
  43697. * Class used to represent data loading progression
  43698. */
  43699. export class SceneLoaderProgressEvent {
  43700. /** defines if data length to load can be evaluated */
  43701. readonly lengthComputable: boolean;
  43702. /** defines the loaded data length */
  43703. readonly loaded: number;
  43704. /** defines the data length to load */
  43705. readonly total: number;
  43706. /**
  43707. * Create a new progress event
  43708. * @param lengthComputable defines if data length to load can be evaluated
  43709. * @param loaded defines the loaded data length
  43710. * @param total defines the data length to load
  43711. */
  43712. constructor(
  43713. /** defines if data length to load can be evaluated */
  43714. lengthComputable: boolean,
  43715. /** defines the loaded data length */
  43716. loaded: number,
  43717. /** defines the data length to load */
  43718. total: number);
  43719. /**
  43720. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43721. * @param event defines the source event
  43722. * @returns a new SceneLoaderProgressEvent
  43723. */
  43724. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43725. }
  43726. /**
  43727. * Interface used by SceneLoader plugins to define supported file extensions
  43728. */
  43729. export interface ISceneLoaderPluginExtensions {
  43730. /**
  43731. * Defines the list of supported extensions
  43732. */
  43733. [extension: string]: {
  43734. isBinary: boolean;
  43735. };
  43736. }
  43737. /**
  43738. * Interface used by SceneLoader plugin factory
  43739. */
  43740. export interface ISceneLoaderPluginFactory {
  43741. /**
  43742. * Defines the name of the factory
  43743. */
  43744. name: string;
  43745. /**
  43746. * Function called to create a new plugin
  43747. * @return the new plugin
  43748. */
  43749. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43750. /**
  43751. * The callback that returns true if the data can be directly loaded.
  43752. * @param data string containing the file data
  43753. * @returns if the data can be loaded directly
  43754. */
  43755. canDirectLoad?(data: string): boolean;
  43756. }
  43757. /**
  43758. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43759. */
  43760. export interface ISceneLoaderPluginBase {
  43761. /**
  43762. * The friendly name of this plugin.
  43763. */
  43764. name: string;
  43765. /**
  43766. * The file extensions supported by this plugin.
  43767. */
  43768. extensions: string | ISceneLoaderPluginExtensions;
  43769. /**
  43770. * The callback called when loading from a url.
  43771. * @param scene scene loading this url
  43772. * @param url url to load
  43773. * @param onSuccess callback called when the file successfully loads
  43774. * @param onProgress callback called while file is loading (if the server supports this mode)
  43775. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43776. * @param onError callback called when the file fails to load
  43777. * @returns a file request object
  43778. */
  43779. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43780. /**
  43781. * The callback called when loading from a file object.
  43782. * @param scene scene loading this file
  43783. * @param file defines the file to load
  43784. * @param onSuccess defines the callback to call when data is loaded
  43785. * @param onProgress defines the callback to call during loading process
  43786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43787. * @param onError defines the callback to call when an error occurs
  43788. * @returns a file request object
  43789. */
  43790. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43791. /**
  43792. * The callback that returns true if the data can be directly loaded.
  43793. * @param data string containing the file data
  43794. * @returns if the data can be loaded directly
  43795. */
  43796. canDirectLoad?(data: string): boolean;
  43797. /**
  43798. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43799. * @param scene scene loading this data
  43800. * @param data string containing the data
  43801. * @returns data to pass to the plugin
  43802. */
  43803. directLoad?(scene: Scene, data: string): any;
  43804. /**
  43805. * The callback that allows custom handling of the root url based on the response url.
  43806. * @param rootUrl the original root url
  43807. * @param responseURL the response url if available
  43808. * @returns the new root url
  43809. */
  43810. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43811. }
  43812. /**
  43813. * Interface used to define a SceneLoader plugin
  43814. */
  43815. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43816. /**
  43817. * Import meshes into a scene.
  43818. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43819. * @param scene The scene to import into
  43820. * @param data The data to import
  43821. * @param rootUrl The root url for scene and resources
  43822. * @param meshes The meshes array to import into
  43823. * @param particleSystems The particle systems array to import into
  43824. * @param skeletons The skeletons array to import into
  43825. * @param onError The callback when import fails
  43826. * @returns True if successful or false otherwise
  43827. */
  43828. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43829. /**
  43830. * Load into a scene.
  43831. * @param scene The scene to load into
  43832. * @param data The data to import
  43833. * @param rootUrl The root url for scene and resources
  43834. * @param onError The callback when import fails
  43835. * @returns True if successful or false otherwise
  43836. */
  43837. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43838. /**
  43839. * Load into an asset container.
  43840. * @param scene The scene to load into
  43841. * @param data The data to import
  43842. * @param rootUrl The root url for scene and resources
  43843. * @param onError The callback when import fails
  43844. * @returns The loaded asset container
  43845. */
  43846. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43847. }
  43848. /**
  43849. * Interface used to define an async SceneLoader plugin
  43850. */
  43851. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43852. /**
  43853. * Import meshes into a scene.
  43854. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43855. * @param scene The scene to import into
  43856. * @param data The data to import
  43857. * @param rootUrl The root url for scene and resources
  43858. * @param onProgress The callback when the load progresses
  43859. * @param fileName Defines the name of the file to load
  43860. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43861. */
  43862. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43863. meshes: AbstractMesh[];
  43864. particleSystems: IParticleSystem[];
  43865. skeletons: Skeleton[];
  43866. animationGroups: AnimationGroup[];
  43867. }>;
  43868. /**
  43869. * Load into a scene.
  43870. * @param scene The scene to load into
  43871. * @param data The data to import
  43872. * @param rootUrl The root url for scene and resources
  43873. * @param onProgress The callback when the load progresses
  43874. * @param fileName Defines the name of the file to load
  43875. * @returns Nothing
  43876. */
  43877. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43878. /**
  43879. * Load into an asset container.
  43880. * @param scene The scene to load into
  43881. * @param data The data to import
  43882. * @param rootUrl The root url for scene and resources
  43883. * @param onProgress The callback when the load progresses
  43884. * @param fileName Defines the name of the file to load
  43885. * @returns The loaded asset container
  43886. */
  43887. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43888. }
  43889. /**
  43890. * Mode that determines how to handle old animation groups before loading new ones.
  43891. */
  43892. export enum SceneLoaderAnimationGroupLoadingMode {
  43893. /**
  43894. * Reset all old animations to initial state then dispose them.
  43895. */
  43896. Clean = 0,
  43897. /**
  43898. * Stop all old animations.
  43899. */
  43900. Stop = 1,
  43901. /**
  43902. * Restart old animations from first frame.
  43903. */
  43904. Sync = 2,
  43905. /**
  43906. * Old animations remains untouched.
  43907. */
  43908. NoSync = 3
  43909. }
  43910. /**
  43911. * Class used to load scene from various file formats using registered plugins
  43912. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43913. */
  43914. export class SceneLoader {
  43915. /**
  43916. * No logging while loading
  43917. */
  43918. static readonly NO_LOGGING: number;
  43919. /**
  43920. * Minimal logging while loading
  43921. */
  43922. static readonly MINIMAL_LOGGING: number;
  43923. /**
  43924. * Summary logging while loading
  43925. */
  43926. static readonly SUMMARY_LOGGING: number;
  43927. /**
  43928. * Detailled logging while loading
  43929. */
  43930. static readonly DETAILED_LOGGING: number;
  43931. /**
  43932. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43933. */
  43934. static get ForceFullSceneLoadingForIncremental(): boolean;
  43935. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43936. /**
  43937. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43938. */
  43939. static get ShowLoadingScreen(): boolean;
  43940. static set ShowLoadingScreen(value: boolean);
  43941. /**
  43942. * Defines the current logging level (while loading the scene)
  43943. * @ignorenaming
  43944. */
  43945. static get loggingLevel(): number;
  43946. static set loggingLevel(value: number);
  43947. /**
  43948. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43949. */
  43950. static get CleanBoneMatrixWeights(): boolean;
  43951. static set CleanBoneMatrixWeights(value: boolean);
  43952. /**
  43953. * Event raised when a plugin is used to load a scene
  43954. */
  43955. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43956. private static _registeredPlugins;
  43957. private static _getDefaultPlugin;
  43958. private static _getPluginForExtension;
  43959. private static _getPluginForDirectLoad;
  43960. private static _getPluginForFilename;
  43961. private static _getDirectLoad;
  43962. private static _loadData;
  43963. private static _getFileInfo;
  43964. /**
  43965. * Gets a plugin that can load the given extension
  43966. * @param extension defines the extension to load
  43967. * @returns a plugin or null if none works
  43968. */
  43969. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43970. /**
  43971. * Gets a boolean indicating that the given extension can be loaded
  43972. * @param extension defines the extension to load
  43973. * @returns true if the extension is supported
  43974. */
  43975. static IsPluginForExtensionAvailable(extension: string): boolean;
  43976. /**
  43977. * Adds a new plugin to the list of registered plugins
  43978. * @param plugin defines the plugin to add
  43979. */
  43980. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43981. /**
  43982. * Import meshes into a scene
  43983. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43984. * @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)
  43985. * @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)
  43986. * @param scene the instance of BABYLON.Scene to append to
  43987. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43988. * @param onProgress a callback with a progress event for each file being loaded
  43989. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43990. * @param pluginExtension the extension used to determine the plugin
  43991. * @returns The loaded plugin
  43992. */
  43993. 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>;
  43994. /**
  43995. * Import meshes into a scene
  43996. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43997. * @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)
  43998. * @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)
  43999. * @param scene the instance of BABYLON.Scene to append to
  44000. * @param onProgress a callback with a progress event for each file being loaded
  44001. * @param pluginExtension the extension used to determine the plugin
  44002. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44003. */
  44004. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44005. meshes: AbstractMesh[];
  44006. particleSystems: IParticleSystem[];
  44007. skeletons: Skeleton[];
  44008. animationGroups: AnimationGroup[];
  44009. }>;
  44010. /**
  44011. * Load a scene
  44012. * @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)
  44013. * @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)
  44014. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44015. * @param onSuccess a callback with the scene when import succeeds
  44016. * @param onProgress a callback with a progress event for each file being loaded
  44017. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44018. * @param pluginExtension the extension used to determine the plugin
  44019. * @returns The loaded plugin
  44020. */
  44021. 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>;
  44022. /**
  44023. * Load a scene
  44024. * @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)
  44025. * @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)
  44026. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44027. * @param onProgress a callback with a progress event for each file being loaded
  44028. * @param pluginExtension the extension used to determine the plugin
  44029. * @returns The loaded scene
  44030. */
  44031. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44032. /**
  44033. * Append a scene
  44034. * @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)
  44035. * @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)
  44036. * @param scene is the instance of BABYLON.Scene to append to
  44037. * @param onSuccess a callback with the scene when import succeeds
  44038. * @param onProgress a callback with a progress event for each file being loaded
  44039. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44040. * @param pluginExtension the extension used to determine the plugin
  44041. * @returns The loaded plugin
  44042. */
  44043. 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>;
  44044. /**
  44045. * Append a scene
  44046. * @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)
  44047. * @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)
  44048. * @param scene is the instance of BABYLON.Scene to append to
  44049. * @param onProgress a callback with a progress event for each file being loaded
  44050. * @param pluginExtension the extension used to determine the plugin
  44051. * @returns The given scene
  44052. */
  44053. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44054. /**
  44055. * Load a scene into an asset container
  44056. * @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)
  44057. * @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)
  44058. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44059. * @param onSuccess a callback with the scene when import succeeds
  44060. * @param onProgress a callback with a progress event for each file being loaded
  44061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44062. * @param pluginExtension the extension used to determine the plugin
  44063. * @returns The loaded plugin
  44064. */
  44065. 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>;
  44066. /**
  44067. * Load a scene into an asset container
  44068. * @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)
  44069. * @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)
  44070. * @param scene is the instance of Scene to append to
  44071. * @param onProgress a callback with a progress event for each file being loaded
  44072. * @param pluginExtension the extension used to determine the plugin
  44073. * @returns The loaded asset container
  44074. */
  44075. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44076. /**
  44077. * Import animations from a file into a scene
  44078. * @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)
  44079. * @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)
  44080. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44081. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44082. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44083. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44084. * @param onSuccess a callback with the scene when import succeeds
  44085. * @param onProgress a callback with a progress event for each file being loaded
  44086. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44087. */
  44088. 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;
  44089. /**
  44090. * Import animations from a file into a scene
  44091. * @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)
  44092. * @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)
  44093. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44094. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44095. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44096. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44097. * @param onSuccess a callback with the scene when import succeeds
  44098. * @param onProgress a callback with a progress event for each file being loaded
  44099. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44100. * @returns the updated scene with imported animations
  44101. */
  44102. 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>;
  44103. }
  44104. }
  44105. declare module BABYLON {
  44106. /**
  44107. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44108. */
  44109. export type MotionControllerHandness = "none" | "left" | "right";
  44110. /**
  44111. * The type of components available in motion controllers.
  44112. * This is not the name of the component.
  44113. */
  44114. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44115. /**
  44116. * The state of a controller component
  44117. */
  44118. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44119. /**
  44120. * The schema of motion controller layout.
  44121. * No object will be initialized using this interface
  44122. * This is used just to define the profile.
  44123. */
  44124. export interface IMotionControllerLayout {
  44125. /**
  44126. * Path to load the assets. Usually relative to the base path
  44127. */
  44128. assetPath: string;
  44129. /**
  44130. * Available components (unsorted)
  44131. */
  44132. components: {
  44133. /**
  44134. * A map of component Ids
  44135. */
  44136. [componentId: string]: {
  44137. /**
  44138. * The type of input the component outputs
  44139. */
  44140. type: MotionControllerComponentType;
  44141. /**
  44142. * The indices of this component in the gamepad object
  44143. */
  44144. gamepadIndices: {
  44145. /**
  44146. * Index of button
  44147. */
  44148. button?: number;
  44149. /**
  44150. * If available, index of x-axis
  44151. */
  44152. xAxis?: number;
  44153. /**
  44154. * If available, index of y-axis
  44155. */
  44156. yAxis?: number;
  44157. };
  44158. /**
  44159. * The mesh's root node name
  44160. */
  44161. rootNodeName: string;
  44162. /**
  44163. * Animation definitions for this model
  44164. */
  44165. visualResponses: {
  44166. [stateKey: string]: {
  44167. /**
  44168. * What property will be animated
  44169. */
  44170. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44171. /**
  44172. * What states influence this visual response
  44173. */
  44174. states: MotionControllerComponentStateType[];
  44175. /**
  44176. * Type of animation - movement or visibility
  44177. */
  44178. valueNodeProperty: "transform" | "visibility";
  44179. /**
  44180. * Base node name to move. Its position will be calculated according to the min and max nodes
  44181. */
  44182. valueNodeName?: string;
  44183. /**
  44184. * Minimum movement node
  44185. */
  44186. minNodeName?: string;
  44187. /**
  44188. * Max movement node
  44189. */
  44190. maxNodeName?: string;
  44191. };
  44192. };
  44193. /**
  44194. * If touch enabled, what is the name of node to display user feedback
  44195. */
  44196. touchPointNodeName?: string;
  44197. };
  44198. };
  44199. /**
  44200. * Is it xr standard mapping or not
  44201. */
  44202. gamepadMapping: "" | "xr-standard";
  44203. /**
  44204. * Base root node of this entire model
  44205. */
  44206. rootNodeName: string;
  44207. /**
  44208. * Defines the main button component id
  44209. */
  44210. selectComponentId: string;
  44211. }
  44212. /**
  44213. * A definition for the layout map in the input profile
  44214. */
  44215. export interface IMotionControllerLayoutMap {
  44216. /**
  44217. * Layouts with handness type as a key
  44218. */
  44219. [handness: string]: IMotionControllerLayout;
  44220. }
  44221. /**
  44222. * The XR Input profile schema
  44223. * Profiles can be found here:
  44224. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44225. */
  44226. export interface IMotionControllerProfile {
  44227. /**
  44228. * fallback profiles for this profileId
  44229. */
  44230. fallbackProfileIds: string[];
  44231. /**
  44232. * The layout map, with handness as key
  44233. */
  44234. layouts: IMotionControllerLayoutMap;
  44235. /**
  44236. * The id of this profile
  44237. * correlates to the profile(s) in the xrInput.profiles array
  44238. */
  44239. profileId: string;
  44240. }
  44241. /**
  44242. * A helper-interface for the 3 meshes needed for controller button animation
  44243. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44244. */
  44245. export interface IMotionControllerButtonMeshMap {
  44246. /**
  44247. * the mesh that defines the pressed value mesh position.
  44248. * This is used to find the max-position of this button
  44249. */
  44250. pressedMesh: AbstractMesh;
  44251. /**
  44252. * the mesh that defines the unpressed value mesh position.
  44253. * This is used to find the min (or initial) position of this button
  44254. */
  44255. unpressedMesh: AbstractMesh;
  44256. /**
  44257. * The mesh that will be changed when value changes
  44258. */
  44259. valueMesh: AbstractMesh;
  44260. }
  44261. /**
  44262. * A helper-interface for the 3 meshes needed for controller axis animation.
  44263. * This will be expanded when touchpad animations are fully supported
  44264. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44265. */
  44266. export interface IMotionControllerMeshMap {
  44267. /**
  44268. * the mesh that defines the maximum value mesh position.
  44269. */
  44270. maxMesh?: AbstractMesh;
  44271. /**
  44272. * the mesh that defines the minimum value mesh position.
  44273. */
  44274. minMesh?: AbstractMesh;
  44275. /**
  44276. * The mesh that will be changed when axis value changes
  44277. */
  44278. valueMesh: AbstractMesh;
  44279. }
  44280. /**
  44281. * The elements needed for change-detection of the gamepad objects in motion controllers
  44282. */
  44283. export interface IMinimalMotionControllerObject {
  44284. /**
  44285. * Available axes of this controller
  44286. */
  44287. axes: number[];
  44288. /**
  44289. * An array of available buttons
  44290. */
  44291. buttons: Array<{
  44292. /**
  44293. * Value of the button/trigger
  44294. */
  44295. value: number;
  44296. /**
  44297. * If the button/trigger is currently touched
  44298. */
  44299. touched: boolean;
  44300. /**
  44301. * If the button/trigger is currently pressed
  44302. */
  44303. pressed: boolean;
  44304. }>;
  44305. }
  44306. /**
  44307. * An Abstract Motion controller
  44308. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44309. * Each component has an observable to check for changes in value and state
  44310. */
  44311. export abstract class WebXRAbstractMotionController implements IDisposable {
  44312. protected scene: Scene;
  44313. protected layout: IMotionControllerLayout;
  44314. /**
  44315. * The gamepad object correlating to this controller
  44316. */
  44317. gamepadObject: IMinimalMotionControllerObject;
  44318. /**
  44319. * handness (left/right/none) of this controller
  44320. */
  44321. handness: MotionControllerHandness;
  44322. private _initComponent;
  44323. private _modelReady;
  44324. /**
  44325. * A map of components (WebXRControllerComponent) in this motion controller
  44326. * Components have a ComponentType and can also have both button and axis definitions
  44327. */
  44328. readonly components: {
  44329. [id: string]: WebXRControllerComponent;
  44330. };
  44331. /**
  44332. * Disable the model's animation. Can be set at any time.
  44333. */
  44334. disableAnimation: boolean;
  44335. /**
  44336. * Observers registered here will be triggered when the model of this controller is done loading
  44337. */
  44338. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44339. /**
  44340. * The profile id of this motion controller
  44341. */
  44342. abstract profileId: string;
  44343. /**
  44344. * The root mesh of the model. It is null if the model was not yet initialized
  44345. */
  44346. rootMesh: Nullable<AbstractMesh>;
  44347. /**
  44348. * constructs a new abstract motion controller
  44349. * @param scene the scene to which the model of the controller will be added
  44350. * @param layout The profile layout to load
  44351. * @param gamepadObject The gamepad object correlating to this controller
  44352. * @param handness handness (left/right/none) of this controller
  44353. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44354. */
  44355. constructor(scene: Scene, layout: IMotionControllerLayout,
  44356. /**
  44357. * The gamepad object correlating to this controller
  44358. */
  44359. gamepadObject: IMinimalMotionControllerObject,
  44360. /**
  44361. * handness (left/right/none) of this controller
  44362. */
  44363. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44364. /**
  44365. * Dispose this controller, the model mesh and all its components
  44366. */
  44367. dispose(): void;
  44368. /**
  44369. * Returns all components of specific type
  44370. * @param type the type to search for
  44371. * @return an array of components with this type
  44372. */
  44373. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44374. /**
  44375. * get a component based an its component id as defined in layout.components
  44376. * @param id the id of the component
  44377. * @returns the component correlates to the id or undefined if not found
  44378. */
  44379. getComponent(id: string): WebXRControllerComponent;
  44380. /**
  44381. * Get the list of components available in this motion controller
  44382. * @returns an array of strings correlating to available components
  44383. */
  44384. getComponentIds(): string[];
  44385. /**
  44386. * Get the first component of specific type
  44387. * @param type type of component to find
  44388. * @return a controller component or null if not found
  44389. */
  44390. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44391. /**
  44392. * Get the main (Select) component of this controller as defined in the layout
  44393. * @returns the main component of this controller
  44394. */
  44395. getMainComponent(): WebXRControllerComponent;
  44396. /**
  44397. * Loads the model correlating to this controller
  44398. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44399. * @returns A promise fulfilled with the result of the model loading
  44400. */
  44401. loadModel(): Promise<boolean>;
  44402. /**
  44403. * Update this model using the current XRFrame
  44404. * @param xrFrame the current xr frame to use and update the model
  44405. */
  44406. updateFromXRFrame(xrFrame: XRFrame): void;
  44407. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44408. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44409. /**
  44410. * Moves the axis on the controller mesh based on its current state
  44411. * @param axis the index of the axis
  44412. * @param axisValue the value of the axis which determines the meshes new position
  44413. * @hidden
  44414. */
  44415. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44416. /**
  44417. * Update the model itself with the current frame data
  44418. * @param xrFrame the frame to use for updating the model mesh
  44419. */
  44420. protected updateModel(xrFrame: XRFrame): void;
  44421. /**
  44422. * Get the filename and path for this controller's model
  44423. * @returns a map of filename and path
  44424. */
  44425. protected abstract _getFilenameAndPath(): {
  44426. filename: string;
  44427. path: string;
  44428. };
  44429. /**
  44430. * This function is called before the mesh is loaded. It checks for loading constraints.
  44431. * For example, this function can check if the GLB loader is available
  44432. * If this function returns false, the generic controller will be loaded instead
  44433. * @returns Is the client ready to load the mesh
  44434. */
  44435. protected abstract _getModelLoadingConstraints(): boolean;
  44436. /**
  44437. * This function will be called after the model was successfully loaded and can be used
  44438. * for mesh transformations before it is available for the user
  44439. * @param meshes the loaded meshes
  44440. */
  44441. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44442. /**
  44443. * Set the root mesh for this controller. Important for the WebXR controller class
  44444. * @param meshes the loaded meshes
  44445. */
  44446. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44447. /**
  44448. * A function executed each frame that updates the mesh (if needed)
  44449. * @param xrFrame the current xrFrame
  44450. */
  44451. protected abstract _updateModel(xrFrame: XRFrame): void;
  44452. private _getGenericFilenameAndPath;
  44453. private _getGenericParentMesh;
  44454. }
  44455. }
  44456. declare module BABYLON {
  44457. /**
  44458. * A generic trigger-only motion controller for WebXR
  44459. */
  44460. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44461. /**
  44462. * Static version of the profile id of this controller
  44463. */
  44464. static ProfileId: string;
  44465. profileId: string;
  44466. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44467. protected _getFilenameAndPath(): {
  44468. filename: string;
  44469. path: string;
  44470. };
  44471. protected _getModelLoadingConstraints(): boolean;
  44472. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44473. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44474. protected _updateModel(): void;
  44475. }
  44476. }
  44477. declare module BABYLON {
  44478. /**
  44479. * Class containing static functions to help procedurally build meshes
  44480. */
  44481. export class SphereBuilder {
  44482. /**
  44483. * Creates a sphere mesh
  44484. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44485. * * 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`)
  44486. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44487. * * 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
  44488. * * 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)
  44489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44490. * * 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
  44491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44492. * @param name defines the name of the mesh
  44493. * @param options defines the options used to create the mesh
  44494. * @param scene defines the hosting scene
  44495. * @returns the sphere mesh
  44496. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44497. */
  44498. static CreateSphere(name: string, options: {
  44499. segments?: number;
  44500. diameter?: number;
  44501. diameterX?: number;
  44502. diameterY?: number;
  44503. diameterZ?: number;
  44504. arc?: number;
  44505. slice?: number;
  44506. sideOrientation?: number;
  44507. frontUVs?: Vector4;
  44508. backUVs?: Vector4;
  44509. updatable?: boolean;
  44510. }, scene?: Nullable<Scene>): Mesh;
  44511. }
  44512. }
  44513. declare module BABYLON {
  44514. /**
  44515. * A profiled motion controller has its profile loaded from an online repository.
  44516. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44517. */
  44518. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44519. private _repositoryUrl;
  44520. private _buttonMeshMapping;
  44521. private _touchDots;
  44522. /**
  44523. * The profile ID of this controller. Will be populated when the controller initializes.
  44524. */
  44525. profileId: string;
  44526. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44527. dispose(): void;
  44528. protected _getFilenameAndPath(): {
  44529. filename: string;
  44530. path: string;
  44531. };
  44532. protected _getModelLoadingConstraints(): boolean;
  44533. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44534. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44535. protected _updateModel(_xrFrame: XRFrame): void;
  44536. }
  44537. }
  44538. declare module BABYLON {
  44539. /**
  44540. * A construction function type to create a new controller based on an xrInput object
  44541. */
  44542. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44543. /**
  44544. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44545. *
  44546. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44547. * it should be replaced with auto-loaded controllers.
  44548. *
  44549. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44550. */
  44551. export class WebXRMotionControllerManager {
  44552. private static _AvailableControllers;
  44553. private static _Fallbacks;
  44554. private static _ProfileLoadingPromises;
  44555. private static _ProfilesList;
  44556. /**
  44557. * The base URL of the online controller repository. Can be changed at any time.
  44558. */
  44559. static BaseRepositoryUrl: string;
  44560. /**
  44561. * Which repository gets priority - local or online
  44562. */
  44563. static PrioritizeOnlineRepository: boolean;
  44564. /**
  44565. * Use the online repository, or use only locally-defined controllers
  44566. */
  44567. static UseOnlineRepository: boolean;
  44568. /**
  44569. * Clear the cache used for profile loading and reload when requested again
  44570. */
  44571. static ClearProfilesCache(): void;
  44572. /**
  44573. * Register the default fallbacks.
  44574. * This function is called automatically when this file is imported.
  44575. */
  44576. static DefaultFallbacks(): void;
  44577. /**
  44578. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44579. * @param profileId the profile to which a fallback needs to be found
  44580. * @return an array with corresponding fallback profiles
  44581. */
  44582. static FindFallbackWithProfileId(profileId: string): string[];
  44583. /**
  44584. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44585. * The order of search:
  44586. *
  44587. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44588. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44589. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44590. * 4) return the generic trigger controller if none were found
  44591. *
  44592. * @param xrInput the xrInput to which a new controller is initialized
  44593. * @param scene the scene to which the model will be added
  44594. * @param forceProfile force a certain profile for this controller
  44595. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44596. */
  44597. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44598. /**
  44599. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44600. *
  44601. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44602. *
  44603. * @param type the profile type to register
  44604. * @param constructFunction the function to be called when loading this profile
  44605. */
  44606. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44607. /**
  44608. * Register a fallback to a specific profile.
  44609. * @param profileId the profileId that will receive the fallbacks
  44610. * @param fallbacks A list of fallback profiles
  44611. */
  44612. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44613. /**
  44614. * Will update the list of profiles available in the repository
  44615. * @return a promise that resolves to a map of profiles available online
  44616. */
  44617. static UpdateProfilesList(): Promise<{
  44618. [profile: string]: string;
  44619. }>;
  44620. private static _LoadProfileFromRepository;
  44621. private static _LoadProfilesFromAvailableControllers;
  44622. }
  44623. }
  44624. declare module BABYLON {
  44625. /**
  44626. * Configuration options for the WebXR controller creation
  44627. */
  44628. export interface IWebXRControllerOptions {
  44629. /**
  44630. * Should the controller mesh be animated when a user interacts with it
  44631. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44632. */
  44633. disableMotionControllerAnimation?: boolean;
  44634. /**
  44635. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44636. */
  44637. doNotLoadControllerMesh?: boolean;
  44638. /**
  44639. * Force a specific controller type for this controller.
  44640. * This can be used when creating your own profile or when testing different controllers
  44641. */
  44642. forceControllerProfile?: string;
  44643. }
  44644. /**
  44645. * Represents an XR controller
  44646. */
  44647. export class WebXRInputSource {
  44648. private _scene;
  44649. /** The underlying input source for the controller */
  44650. inputSource: XRInputSource;
  44651. private _options;
  44652. private _tmpQuaternion;
  44653. private _tmpVector;
  44654. private _uniqueId;
  44655. /**
  44656. * 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
  44657. */
  44658. grip?: AbstractMesh;
  44659. /**
  44660. * If available, this is the gamepad object related to this controller.
  44661. * Using this object it is possible to get click events and trackpad changes of the
  44662. * webxr controller that is currently being used.
  44663. */
  44664. motionController?: WebXRAbstractMotionController;
  44665. /**
  44666. * Event that fires when the controller is removed/disposed.
  44667. * The object provided as event data is this controller, after associated assets were disposed.
  44668. * uniqueId is still available.
  44669. */
  44670. onDisposeObservable: Observable<WebXRInputSource>;
  44671. /**
  44672. * Will be triggered when the mesh associated with the motion controller is done loading.
  44673. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44674. * A shortened version of controller -> motion controller -> on mesh loaded.
  44675. */
  44676. onMeshLoadedObservable: Observable<AbstractMesh>;
  44677. /**
  44678. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44679. */
  44680. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44681. /**
  44682. * Pointer which can be used to select objects or attach a visible laser to
  44683. */
  44684. pointer: AbstractMesh;
  44685. /**
  44686. * Creates the controller
  44687. * @see https://doc.babylonjs.com/how_to/webxr
  44688. * @param _scene the scene which the controller should be associated to
  44689. * @param inputSource the underlying input source for the controller
  44690. * @param _options options for this controller creation
  44691. */
  44692. constructor(_scene: Scene,
  44693. /** The underlying input source for the controller */
  44694. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44695. /**
  44696. * Get this controllers unique id
  44697. */
  44698. get uniqueId(): string;
  44699. /**
  44700. * Disposes of the object
  44701. */
  44702. dispose(): void;
  44703. /**
  44704. * Gets a world space ray coming from the pointer or grip
  44705. * @param result the resulting ray
  44706. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44707. */
  44708. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44709. /**
  44710. * Updates the controller pose based on the given XRFrame
  44711. * @param xrFrame xr frame to update the pose with
  44712. * @param referenceSpace reference space to use
  44713. */
  44714. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44715. }
  44716. }
  44717. declare module BABYLON {
  44718. /**
  44719. * The schema for initialization options of the XR Input class
  44720. */
  44721. export interface IWebXRInputOptions {
  44722. /**
  44723. * If set to true no model will be automatically loaded
  44724. */
  44725. doNotLoadControllerMeshes?: boolean;
  44726. /**
  44727. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44728. * If not found, the xr input profile data will be used.
  44729. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44730. */
  44731. forceInputProfile?: string;
  44732. /**
  44733. * Do not send a request to the controller repository to load the profile.
  44734. *
  44735. * Instead, use the controllers available in babylon itself.
  44736. */
  44737. disableOnlineControllerRepository?: boolean;
  44738. /**
  44739. * A custom URL for the controllers repository
  44740. */
  44741. customControllersRepositoryURL?: string;
  44742. /**
  44743. * Should the controller model's components not move according to the user input
  44744. */
  44745. disableControllerAnimation?: boolean;
  44746. }
  44747. /**
  44748. * XR input used to track XR inputs such as controllers/rays
  44749. */
  44750. export class WebXRInput implements IDisposable {
  44751. /**
  44752. * the xr session manager for this session
  44753. */
  44754. xrSessionManager: WebXRSessionManager;
  44755. /**
  44756. * the WebXR camera for this session. Mainly used for teleportation
  44757. */
  44758. xrCamera: WebXRCamera;
  44759. private readonly options;
  44760. /**
  44761. * XR controllers being tracked
  44762. */
  44763. controllers: Array<WebXRInputSource>;
  44764. private _frameObserver;
  44765. private _sessionEndedObserver;
  44766. private _sessionInitObserver;
  44767. /**
  44768. * Event when a controller has been connected/added
  44769. */
  44770. onControllerAddedObservable: Observable<WebXRInputSource>;
  44771. /**
  44772. * Event when a controller has been removed/disconnected
  44773. */
  44774. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44775. /**
  44776. * Initializes the WebXRInput
  44777. * @param xrSessionManager the xr session manager for this session
  44778. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44779. * @param options = initialization options for this xr input
  44780. */
  44781. constructor(
  44782. /**
  44783. * the xr session manager for this session
  44784. */
  44785. xrSessionManager: WebXRSessionManager,
  44786. /**
  44787. * the WebXR camera for this session. Mainly used for teleportation
  44788. */
  44789. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44790. private _onInputSourcesChange;
  44791. private _addAndRemoveControllers;
  44792. /**
  44793. * Disposes of the object
  44794. */
  44795. dispose(): void;
  44796. }
  44797. }
  44798. declare module BABYLON {
  44799. /**
  44800. * This is the base class for all WebXR features.
  44801. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44802. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44803. */
  44804. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44805. protected _xrSessionManager: WebXRSessionManager;
  44806. private _attached;
  44807. private _removeOnDetach;
  44808. /**
  44809. * Should auto-attach be disabled?
  44810. */
  44811. disableAutoAttach: boolean;
  44812. /**
  44813. * Construct a new (abstract) WebXR feature
  44814. * @param _xrSessionManager the xr session manager for this feature
  44815. */
  44816. constructor(_xrSessionManager: WebXRSessionManager);
  44817. /**
  44818. * Is this feature attached
  44819. */
  44820. get attached(): boolean;
  44821. /**
  44822. * attach this feature
  44823. *
  44824. * @param force should attachment be forced (even when already attached)
  44825. * @returns true if successful, false is failed or already attached
  44826. */
  44827. attach(force?: boolean): boolean;
  44828. /**
  44829. * detach this feature.
  44830. *
  44831. * @returns true if successful, false if failed or already detached
  44832. */
  44833. detach(): boolean;
  44834. /**
  44835. * Dispose this feature and all of the resources attached
  44836. */
  44837. dispose(): void;
  44838. /**
  44839. * This is used to register callbacks that will automatically be removed when detach is called.
  44840. * @param observable the observable to which the observer will be attached
  44841. * @param callback the callback to register
  44842. */
  44843. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44844. /**
  44845. * Code in this function will be executed on each xrFrame received from the browser.
  44846. * This function will not execute after the feature is detached.
  44847. * @param _xrFrame the current frame
  44848. */
  44849. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44850. }
  44851. }
  44852. declare module BABYLON {
  44853. /**
  44854. * Renders a layer on top of an existing scene
  44855. */
  44856. export class UtilityLayerRenderer implements IDisposable {
  44857. /** the original scene that will be rendered on top of */
  44858. originalScene: Scene;
  44859. private _pointerCaptures;
  44860. private _lastPointerEvents;
  44861. private static _DefaultUtilityLayer;
  44862. private static _DefaultKeepDepthUtilityLayer;
  44863. private _sharedGizmoLight;
  44864. private _renderCamera;
  44865. /**
  44866. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44867. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44868. * @returns the camera that is used when rendering the utility layer
  44869. */
  44870. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44871. /**
  44872. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44873. * @param cam the camera that should be used when rendering the utility layer
  44874. */
  44875. setRenderCamera(cam: Nullable<Camera>): void;
  44876. /**
  44877. * @hidden
  44878. * Light which used by gizmos to get light shading
  44879. */
  44880. _getSharedGizmoLight(): HemisphericLight;
  44881. /**
  44882. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44883. */
  44884. pickUtilitySceneFirst: boolean;
  44885. /**
  44886. * 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)
  44887. */
  44888. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44889. /**
  44890. * 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)
  44891. */
  44892. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44893. /**
  44894. * The scene that is rendered on top of the original scene
  44895. */
  44896. utilityLayerScene: Scene;
  44897. /**
  44898. * If the utility layer should automatically be rendered on top of existing scene
  44899. */
  44900. shouldRender: boolean;
  44901. /**
  44902. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44903. */
  44904. onlyCheckPointerDownEvents: boolean;
  44905. /**
  44906. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44907. */
  44908. processAllEvents: boolean;
  44909. /**
  44910. * Observable raised when the pointer move from the utility layer scene to the main scene
  44911. */
  44912. onPointerOutObservable: Observable<number>;
  44913. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44914. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44915. private _afterRenderObserver;
  44916. private _sceneDisposeObserver;
  44917. private _originalPointerObserver;
  44918. /**
  44919. * Instantiates a UtilityLayerRenderer
  44920. * @param originalScene the original scene that will be rendered on top of
  44921. * @param handleEvents boolean indicating if the utility layer should handle events
  44922. */
  44923. constructor(
  44924. /** the original scene that will be rendered on top of */
  44925. originalScene: Scene, handleEvents?: boolean);
  44926. private _notifyObservers;
  44927. /**
  44928. * Renders the utility layers scene on top of the original scene
  44929. */
  44930. render(): void;
  44931. /**
  44932. * Disposes of the renderer
  44933. */
  44934. dispose(): void;
  44935. private _updateCamera;
  44936. }
  44937. }
  44938. declare module BABYLON {
  44939. /**
  44940. * Options interface for the pointer selection module
  44941. */
  44942. export interface IWebXRControllerPointerSelectionOptions {
  44943. /**
  44944. * if provided, this scene will be used to render meshes.
  44945. */
  44946. customUtilityLayerScene?: Scene;
  44947. /**
  44948. * 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)
  44949. * If not disabled, the last picked point will be used to execute a pointer up event
  44950. * If disabled, pointer up event will be triggered right after the pointer down event.
  44951. * Used in screen and gaze target ray mode only
  44952. */
  44953. disablePointerUpOnTouchOut: boolean;
  44954. /**
  44955. * For gaze mode (time to select instead of press)
  44956. */
  44957. forceGazeMode: boolean;
  44958. /**
  44959. * 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
  44960. * to start a new countdown to the pointer down event.
  44961. * Defaults to 1.
  44962. */
  44963. gazeModePointerMovedFactor?: number;
  44964. /**
  44965. * Different button type to use instead of the main component
  44966. */
  44967. overrideButtonId?: string;
  44968. /**
  44969. * use this rendering group id for the meshes (optional)
  44970. */
  44971. renderingGroupId?: number;
  44972. /**
  44973. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44974. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44975. * 3000 means 3 seconds between pointing at something and selecting it
  44976. */
  44977. timeToSelect?: number;
  44978. /**
  44979. * Should meshes created here be added to a utility layer or the main scene
  44980. */
  44981. useUtilityLayer?: boolean;
  44982. /**
  44983. * the xr input to use with this pointer selection
  44984. */
  44985. xrInput: WebXRInput;
  44986. }
  44987. /**
  44988. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44989. */
  44990. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44991. private readonly _options;
  44992. private static _idCounter;
  44993. private _attachController;
  44994. private _controllers;
  44995. private _scene;
  44996. private _tmpVectorForPickCompare;
  44997. /**
  44998. * The module's name
  44999. */
  45000. static readonly Name: string;
  45001. /**
  45002. * The (Babylon) version of this module.
  45003. * This is an integer representing the implementation version.
  45004. * This number does not correspond to the WebXR specs version
  45005. */
  45006. static readonly Version: number;
  45007. /**
  45008. * Disable lighting on the laser pointer (so it will always be visible)
  45009. */
  45010. disablePointerLighting: boolean;
  45011. /**
  45012. * Disable lighting on the selection mesh (so it will always be visible)
  45013. */
  45014. disableSelectionMeshLighting: boolean;
  45015. /**
  45016. * Should the laser pointer be displayed
  45017. */
  45018. displayLaserPointer: boolean;
  45019. /**
  45020. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45021. */
  45022. displaySelectionMesh: boolean;
  45023. /**
  45024. * This color will be set to the laser pointer when selection is triggered
  45025. */
  45026. laserPointerPickedColor: Color3;
  45027. /**
  45028. * Default color of the laser pointer
  45029. */
  45030. lasterPointerDefaultColor: Color3;
  45031. /**
  45032. * default color of the selection ring
  45033. */
  45034. selectionMeshDefaultColor: Color3;
  45035. /**
  45036. * This color will be applied to the selection ring when selection is triggered
  45037. */
  45038. selectionMeshPickedColor: Color3;
  45039. /**
  45040. * Optional filter to be used for ray selection. This predicate shares behavior with
  45041. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45042. */
  45043. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45044. /**
  45045. * constructs a new background remover module
  45046. * @param _xrSessionManager the session manager for this module
  45047. * @param _options read-only options to be used in this module
  45048. */
  45049. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45050. /**
  45051. * attach this feature
  45052. * Will usually be called by the features manager
  45053. *
  45054. * @returns true if successful.
  45055. */
  45056. attach(): boolean;
  45057. /**
  45058. * detach this feature.
  45059. * Will usually be called by the features manager
  45060. *
  45061. * @returns true if successful.
  45062. */
  45063. detach(): boolean;
  45064. /**
  45065. * Will get the mesh under a specific pointer.
  45066. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45067. * @param controllerId the controllerId to check
  45068. * @returns The mesh under pointer or null if no mesh is under the pointer
  45069. */
  45070. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45071. /**
  45072. * Get the xr controller that correlates to the pointer id in the pointer event
  45073. *
  45074. * @param id the pointer id to search for
  45075. * @returns the controller that correlates to this id or null if not found
  45076. */
  45077. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45078. protected _onXRFrame(_xrFrame: XRFrame): void;
  45079. private _attachGazeMode;
  45080. private _attachScreenRayMode;
  45081. private _attachTrackedPointerRayMode;
  45082. private _convertNormalToDirectionOfRay;
  45083. private _detachController;
  45084. private _generateNewMeshPair;
  45085. private _pickingMoved;
  45086. private _updatePointerDistance;
  45087. }
  45088. }
  45089. declare module BABYLON {
  45090. /**
  45091. * Button which can be used to enter a different mode of XR
  45092. */
  45093. export class WebXREnterExitUIButton {
  45094. /** button element */
  45095. element: HTMLElement;
  45096. /** XR initialization options for the button */
  45097. sessionMode: XRSessionMode;
  45098. /** Reference space type */
  45099. referenceSpaceType: XRReferenceSpaceType;
  45100. /**
  45101. * Creates a WebXREnterExitUIButton
  45102. * @param element button element
  45103. * @param sessionMode XR initialization session mode
  45104. * @param referenceSpaceType the type of reference space to be used
  45105. */
  45106. constructor(
  45107. /** button element */
  45108. element: HTMLElement,
  45109. /** XR initialization options for the button */
  45110. sessionMode: XRSessionMode,
  45111. /** Reference space type */
  45112. referenceSpaceType: XRReferenceSpaceType);
  45113. /**
  45114. * Extendable function which can be used to update the button's visuals when the state changes
  45115. * @param activeButton the current active button in the UI
  45116. */
  45117. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45118. }
  45119. /**
  45120. * Options to create the webXR UI
  45121. */
  45122. export class WebXREnterExitUIOptions {
  45123. /**
  45124. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45125. */
  45126. customButtons?: Array<WebXREnterExitUIButton>;
  45127. /**
  45128. * A reference space type to use when creating the default button.
  45129. * Default is local-floor
  45130. */
  45131. referenceSpaceType?: XRReferenceSpaceType;
  45132. /**
  45133. * Context to enter xr with
  45134. */
  45135. renderTarget?: Nullable<WebXRRenderTarget>;
  45136. /**
  45137. * A session mode to use when creating the default button.
  45138. * Default is immersive-vr
  45139. */
  45140. sessionMode?: XRSessionMode;
  45141. }
  45142. /**
  45143. * UI to allow the user to enter/exit XR mode
  45144. */
  45145. export class WebXREnterExitUI implements IDisposable {
  45146. private scene;
  45147. /** version of the options passed to this UI */
  45148. options: WebXREnterExitUIOptions;
  45149. private _activeButton;
  45150. private _buttons;
  45151. private _overlay;
  45152. /**
  45153. * Fired every time the active button is changed.
  45154. *
  45155. * When xr is entered via a button that launches xr that button will be the callback parameter
  45156. *
  45157. * When exiting xr the callback parameter will be null)
  45158. */
  45159. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45160. /**
  45161. *
  45162. * @param scene babylon scene object to use
  45163. * @param options (read-only) version of the options passed to this UI
  45164. */
  45165. private constructor();
  45166. /**
  45167. * Creates UI to allow the user to enter/exit XR mode
  45168. * @param scene the scene to add the ui to
  45169. * @param helper the xr experience helper to enter/exit xr with
  45170. * @param options options to configure the UI
  45171. * @returns the created ui
  45172. */
  45173. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45174. /**
  45175. * Disposes of the XR UI component
  45176. */
  45177. dispose(): void;
  45178. private _updateButtons;
  45179. }
  45180. }
  45181. declare module BABYLON {
  45182. /**
  45183. * Class containing static functions to help procedurally build meshes
  45184. */
  45185. export class LinesBuilder {
  45186. /**
  45187. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45188. * * 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
  45189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45190. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45191. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45192. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45193. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45194. * * 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
  45195. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45198. * @param name defines the name of the new line system
  45199. * @param options defines the options used to create the line system
  45200. * @param scene defines the hosting scene
  45201. * @returns a new line system mesh
  45202. */
  45203. static CreateLineSystem(name: string, options: {
  45204. lines: Vector3[][];
  45205. updatable?: boolean;
  45206. instance?: Nullable<LinesMesh>;
  45207. colors?: Nullable<Color4[][]>;
  45208. useVertexAlpha?: boolean;
  45209. }, scene: Nullable<Scene>): LinesMesh;
  45210. /**
  45211. * Creates a line mesh
  45212. * 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
  45213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45214. * * The parameter `points` is an array successive Vector3
  45215. * * 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
  45216. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45218. * * When updating an instance, remember that only point positions can change, not the number of points
  45219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45221. * @param name defines the name of the new line system
  45222. * @param options defines the options used to create the line system
  45223. * @param scene defines the hosting scene
  45224. * @returns a new line mesh
  45225. */
  45226. static CreateLines(name: string, options: {
  45227. points: Vector3[];
  45228. updatable?: boolean;
  45229. instance?: Nullable<LinesMesh>;
  45230. colors?: Color4[];
  45231. useVertexAlpha?: boolean;
  45232. }, scene?: Nullable<Scene>): LinesMesh;
  45233. /**
  45234. * Creates a dashed line mesh
  45235. * * 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
  45236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45237. * * The parameter `points` is an array successive Vector3
  45238. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45239. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45240. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45241. * * 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
  45242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45243. * * When updating an instance, remember that only point positions can change, not the number of points
  45244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45245. * @param name defines the name of the mesh
  45246. * @param options defines the options used to create the mesh
  45247. * @param scene defines the hosting scene
  45248. * @returns the dashed line mesh
  45249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45250. */
  45251. static CreateDashedLines(name: string, options: {
  45252. points: Vector3[];
  45253. dashSize?: number;
  45254. gapSize?: number;
  45255. dashNb?: number;
  45256. updatable?: boolean;
  45257. instance?: LinesMesh;
  45258. useVertexAlpha?: boolean;
  45259. }, scene?: Nullable<Scene>): LinesMesh;
  45260. }
  45261. }
  45262. declare module BABYLON {
  45263. /**
  45264. * The options container for the teleportation module
  45265. */
  45266. export interface IWebXRTeleportationOptions {
  45267. /**
  45268. * if provided, this scene will be used to render meshes.
  45269. */
  45270. customUtilityLayerScene?: Scene;
  45271. /**
  45272. * Values to configure the default target mesh
  45273. */
  45274. defaultTargetMeshOptions?: {
  45275. /**
  45276. * Fill color of the teleportation area
  45277. */
  45278. teleportationFillColor?: string;
  45279. /**
  45280. * Border color for the teleportation area
  45281. */
  45282. teleportationBorderColor?: string;
  45283. /**
  45284. * Disable the mesh's animation sequence
  45285. */
  45286. disableAnimation?: boolean;
  45287. /**
  45288. * Disable lighting on the material or the ring and arrow
  45289. */
  45290. disableLighting?: boolean;
  45291. /**
  45292. * Override the default material of the torus and arrow
  45293. */
  45294. torusArrowMaterial?: Material;
  45295. };
  45296. /**
  45297. * A list of meshes to use as floor meshes.
  45298. * Meshes can be added and removed after initializing the feature using the
  45299. * addFloorMesh and removeFloorMesh functions
  45300. * If empty, rotation will still work
  45301. */
  45302. floorMeshes?: AbstractMesh[];
  45303. /**
  45304. * use this rendering group id for the meshes (optional)
  45305. */
  45306. renderingGroupId?: number;
  45307. /**
  45308. * Should teleportation move only to snap points
  45309. */
  45310. snapPointsOnly?: boolean;
  45311. /**
  45312. * An array of points to which the teleportation will snap to.
  45313. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45314. */
  45315. snapPositions?: Vector3[];
  45316. /**
  45317. * How close should the teleportation ray be in order to snap to position.
  45318. * Default to 0.8 units (meters)
  45319. */
  45320. snapToPositionRadius?: number;
  45321. /**
  45322. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45323. * If you want to support rotation, make sure your mesh has a direction indicator.
  45324. *
  45325. * When left untouched, the default mesh will be initialized.
  45326. */
  45327. teleportationTargetMesh?: AbstractMesh;
  45328. /**
  45329. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45330. */
  45331. timeToTeleport?: number;
  45332. /**
  45333. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45334. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45335. */
  45336. useMainComponentOnly?: boolean;
  45337. /**
  45338. * Should meshes created here be added to a utility layer or the main scene
  45339. */
  45340. useUtilityLayer?: boolean;
  45341. /**
  45342. * Babylon XR Input class for controller
  45343. */
  45344. xrInput: WebXRInput;
  45345. }
  45346. /**
  45347. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45348. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45349. * the input of the attached controllers.
  45350. */
  45351. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45352. private _options;
  45353. private _controllers;
  45354. private _currentTeleportationControllerId;
  45355. private _floorMeshes;
  45356. private _quadraticBezierCurve;
  45357. private _selectionFeature;
  45358. private _snapToPositions;
  45359. private _snappedToPoint;
  45360. private _teleportationRingMaterial?;
  45361. private _tmpRay;
  45362. private _tmpVector;
  45363. /**
  45364. * The module's name
  45365. */
  45366. static readonly Name: string;
  45367. /**
  45368. * The (Babylon) version of this module.
  45369. * This is an integer representing the implementation version.
  45370. * This number does not correspond to the webxr specs version
  45371. */
  45372. static readonly Version: number;
  45373. /**
  45374. * Is movement backwards enabled
  45375. */
  45376. backwardsMovementEnabled: boolean;
  45377. /**
  45378. * Distance to travel when moving backwards
  45379. */
  45380. backwardsTeleportationDistance: number;
  45381. /**
  45382. * The distance from the user to the inspection point in the direction of the controller
  45383. * A higher number will allow the user to move further
  45384. * defaults to 5 (meters, in xr units)
  45385. */
  45386. parabolicCheckRadius: number;
  45387. /**
  45388. * Should the module support parabolic ray on top of direct ray
  45389. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45390. * Very helpful when moving between floors / different heights
  45391. */
  45392. parabolicRayEnabled: boolean;
  45393. /**
  45394. * How much rotation should be applied when rotating right and left
  45395. */
  45396. rotationAngle: number;
  45397. /**
  45398. * Is rotation enabled when moving forward?
  45399. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45400. */
  45401. rotationEnabled: boolean;
  45402. /**
  45403. * constructs a new anchor system
  45404. * @param _xrSessionManager an instance of WebXRSessionManager
  45405. * @param _options configuration object for this feature
  45406. */
  45407. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45408. /**
  45409. * Get the snapPointsOnly flag
  45410. */
  45411. get snapPointsOnly(): boolean;
  45412. /**
  45413. * Sets the snapPointsOnly flag
  45414. * @param snapToPoints should teleportation be exclusively to snap points
  45415. */
  45416. set snapPointsOnly(snapToPoints: boolean);
  45417. /**
  45418. * Add a new mesh to the floor meshes array
  45419. * @param mesh the mesh to use as floor mesh
  45420. */
  45421. addFloorMesh(mesh: AbstractMesh): void;
  45422. /**
  45423. * Add a new snap-to point to fix teleportation to this position
  45424. * @param newSnapPoint The new Snap-To point
  45425. */
  45426. addSnapPoint(newSnapPoint: Vector3): void;
  45427. attach(): boolean;
  45428. detach(): boolean;
  45429. dispose(): void;
  45430. /**
  45431. * Remove a mesh from the floor meshes array
  45432. * @param mesh the mesh to remove
  45433. */
  45434. removeFloorMesh(mesh: AbstractMesh): void;
  45435. /**
  45436. * Remove a mesh from the floor meshes array using its name
  45437. * @param name the mesh name to remove
  45438. */
  45439. removeFloorMeshByName(name: string): void;
  45440. /**
  45441. * 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
  45442. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45443. * @returns was the point found and removed or not
  45444. */
  45445. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45446. /**
  45447. * This function sets a selection feature that will be disabled when
  45448. * the forward ray is shown and will be reattached when hidden.
  45449. * This is used to remove the selection rays when moving.
  45450. * @param selectionFeature the feature to disable when forward movement is enabled
  45451. */
  45452. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45453. protected _onXRFrame(_xrFrame: XRFrame): void;
  45454. private _attachController;
  45455. private _createDefaultTargetMesh;
  45456. private _detachController;
  45457. private _findClosestSnapPointWithRadius;
  45458. private _setTargetMeshPosition;
  45459. private _setTargetMeshVisibility;
  45460. private _showParabolicPath;
  45461. private _teleportForward;
  45462. }
  45463. }
  45464. declare module BABYLON {
  45465. /**
  45466. * Options for the default xr helper
  45467. */
  45468. export class WebXRDefaultExperienceOptions {
  45469. /**
  45470. * Enable or disable default UI to enter XR
  45471. */
  45472. disableDefaultUI?: boolean;
  45473. /**
  45474. * Should teleportation not initialize. defaults to false.
  45475. */
  45476. disableTeleportation?: boolean;
  45477. /**
  45478. * Floor meshes that will be used for teleport
  45479. */
  45480. floorMeshes?: Array<AbstractMesh>;
  45481. /**
  45482. * If set to true, the first frame will not be used to reset position
  45483. * The first frame is mainly used when copying transformation from the old camera
  45484. * Mainly used in AR
  45485. */
  45486. ignoreNativeCameraTransformation?: boolean;
  45487. /**
  45488. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45489. */
  45490. inputOptions?: IWebXRInputOptions;
  45491. /**
  45492. * optional configuration for the output canvas
  45493. */
  45494. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45495. /**
  45496. * optional UI options. This can be used among other to change session mode and reference space type
  45497. */
  45498. uiOptions?: WebXREnterExitUIOptions;
  45499. /**
  45500. * When loading teleportation and pointer select, use stable versions instead of latest.
  45501. */
  45502. useStablePlugins?: boolean;
  45503. }
  45504. /**
  45505. * Default experience which provides a similar setup to the previous webVRExperience
  45506. */
  45507. export class WebXRDefaultExperience {
  45508. /**
  45509. * Base experience
  45510. */
  45511. baseExperience: WebXRExperienceHelper;
  45512. /**
  45513. * Enables ui for entering/exiting xr
  45514. */
  45515. enterExitUI: WebXREnterExitUI;
  45516. /**
  45517. * Input experience extension
  45518. */
  45519. input: WebXRInput;
  45520. /**
  45521. * Enables laser pointer and selection
  45522. */
  45523. pointerSelection: WebXRControllerPointerSelection;
  45524. /**
  45525. * Default target xr should render to
  45526. */
  45527. renderTarget: WebXRRenderTarget;
  45528. /**
  45529. * Enables teleportation
  45530. */
  45531. teleportation: WebXRMotionControllerTeleportation;
  45532. private constructor();
  45533. /**
  45534. * Creates the default xr experience
  45535. * @param scene scene
  45536. * @param options options for basic configuration
  45537. * @returns resulting WebXRDefaultExperience
  45538. */
  45539. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45540. /**
  45541. * DIsposes of the experience helper
  45542. */
  45543. dispose(): void;
  45544. }
  45545. }
  45546. declare module BABYLON {
  45547. /**
  45548. * Options to modify the vr teleportation behavior.
  45549. */
  45550. export interface VRTeleportationOptions {
  45551. /**
  45552. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45553. */
  45554. floorMeshName?: string;
  45555. /**
  45556. * A list of meshes to be used as the teleportation floor. (default: empty)
  45557. */
  45558. floorMeshes?: Mesh[];
  45559. /**
  45560. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45561. */
  45562. teleportationMode?: number;
  45563. /**
  45564. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45565. */
  45566. teleportationTime?: number;
  45567. /**
  45568. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45569. */
  45570. teleportationSpeed?: number;
  45571. /**
  45572. * The easing function used in the animation or null for Linear. (default CircleEase)
  45573. */
  45574. easingFunction?: EasingFunction;
  45575. }
  45576. /**
  45577. * Options to modify the vr experience helper's behavior.
  45578. */
  45579. export interface VRExperienceHelperOptions extends WebVROptions {
  45580. /**
  45581. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45582. */
  45583. createDeviceOrientationCamera?: boolean;
  45584. /**
  45585. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45586. */
  45587. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45588. /**
  45589. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45590. */
  45591. laserToggle?: boolean;
  45592. /**
  45593. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45594. */
  45595. floorMeshes?: Mesh[];
  45596. /**
  45597. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45598. */
  45599. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45600. /**
  45601. * Defines if WebXR should be used instead of WebVR (if available)
  45602. */
  45603. useXR?: boolean;
  45604. }
  45605. /**
  45606. * Event containing information after VR has been entered
  45607. */
  45608. export class OnAfterEnteringVRObservableEvent {
  45609. /**
  45610. * If entering vr was successful
  45611. */
  45612. success: boolean;
  45613. }
  45614. /**
  45615. * Helps to quickly add VR support to an existing scene.
  45616. * See http://doc.babylonjs.com/how_to/webvr_helper
  45617. */
  45618. export class VRExperienceHelper {
  45619. /** Options to modify the vr experience helper's behavior. */
  45620. webVROptions: VRExperienceHelperOptions;
  45621. private _scene;
  45622. private _position;
  45623. private _btnVR;
  45624. private _btnVRDisplayed;
  45625. private _webVRsupported;
  45626. private _webVRready;
  45627. private _webVRrequesting;
  45628. private _webVRpresenting;
  45629. private _hasEnteredVR;
  45630. private _fullscreenVRpresenting;
  45631. private _inputElement;
  45632. private _webVRCamera;
  45633. private _vrDeviceOrientationCamera;
  45634. private _deviceOrientationCamera;
  45635. private _existingCamera;
  45636. private _onKeyDown;
  45637. private _onVrDisplayPresentChange;
  45638. private _onVRDisplayChanged;
  45639. private _onVRRequestPresentStart;
  45640. private _onVRRequestPresentComplete;
  45641. /**
  45642. * 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)
  45643. */
  45644. enableGazeEvenWhenNoPointerLock: boolean;
  45645. /**
  45646. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45647. */
  45648. exitVROnDoubleTap: boolean;
  45649. /**
  45650. * Observable raised right before entering VR.
  45651. */
  45652. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45653. /**
  45654. * Observable raised when entering VR has completed.
  45655. */
  45656. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45657. /**
  45658. * Observable raised when exiting VR.
  45659. */
  45660. onExitingVRObservable: Observable<VRExperienceHelper>;
  45661. /**
  45662. * Observable raised when controller mesh is loaded.
  45663. */
  45664. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45665. /** Return this.onEnteringVRObservable
  45666. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45667. */
  45668. get onEnteringVR(): Observable<VRExperienceHelper>;
  45669. /** Return this.onExitingVRObservable
  45670. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45671. */
  45672. get onExitingVR(): Observable<VRExperienceHelper>;
  45673. /** Return this.onControllerMeshLoadedObservable
  45674. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45675. */
  45676. get onControllerMeshLoaded(): Observable<WebVRController>;
  45677. private _rayLength;
  45678. private _useCustomVRButton;
  45679. private _teleportationRequested;
  45680. private _teleportActive;
  45681. private _floorMeshName;
  45682. private _floorMeshesCollection;
  45683. private _teleportationMode;
  45684. private _teleportationTime;
  45685. private _teleportationSpeed;
  45686. private _teleportationEasing;
  45687. private _rotationAllowed;
  45688. private _teleportBackwardsVector;
  45689. private _teleportationTarget;
  45690. private _isDefaultTeleportationTarget;
  45691. private _postProcessMove;
  45692. private _teleportationFillColor;
  45693. private _teleportationBorderColor;
  45694. private _rotationAngle;
  45695. private _haloCenter;
  45696. private _cameraGazer;
  45697. private _padSensibilityUp;
  45698. private _padSensibilityDown;
  45699. private _leftController;
  45700. private _rightController;
  45701. private _gazeColor;
  45702. private _laserColor;
  45703. private _pickedLaserColor;
  45704. private _pickedGazeColor;
  45705. /**
  45706. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45707. */
  45708. onNewMeshSelected: Observable<AbstractMesh>;
  45709. /**
  45710. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45711. * This observable will provide the mesh and the controller used to select the mesh
  45712. */
  45713. onMeshSelectedWithController: Observable<{
  45714. mesh: AbstractMesh;
  45715. controller: WebVRController;
  45716. }>;
  45717. /**
  45718. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45719. */
  45720. onNewMeshPicked: Observable<PickingInfo>;
  45721. private _circleEase;
  45722. /**
  45723. * Observable raised before camera teleportation
  45724. */
  45725. onBeforeCameraTeleport: Observable<Vector3>;
  45726. /**
  45727. * Observable raised after camera teleportation
  45728. */
  45729. onAfterCameraTeleport: Observable<Vector3>;
  45730. /**
  45731. * Observable raised when current selected mesh gets unselected
  45732. */
  45733. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45734. private _raySelectionPredicate;
  45735. /**
  45736. * To be optionaly changed by user to define custom ray selection
  45737. */
  45738. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45739. /**
  45740. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45741. */
  45742. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45743. /**
  45744. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45745. */
  45746. teleportationEnabled: boolean;
  45747. private _defaultHeight;
  45748. private _teleportationInitialized;
  45749. private _interactionsEnabled;
  45750. private _interactionsRequested;
  45751. private _displayGaze;
  45752. private _displayLaserPointer;
  45753. /**
  45754. * The mesh used to display where the user is going to teleport.
  45755. */
  45756. get teleportationTarget(): Mesh;
  45757. /**
  45758. * Sets the mesh to be used to display where the user is going to teleport.
  45759. */
  45760. set teleportationTarget(value: Mesh);
  45761. /**
  45762. * 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
  45763. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45764. * See http://doc.babylonjs.com/resources/baking_transformations
  45765. */
  45766. get gazeTrackerMesh(): Mesh;
  45767. set gazeTrackerMesh(value: Mesh);
  45768. /**
  45769. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45770. */
  45771. updateGazeTrackerScale: boolean;
  45772. /**
  45773. * If the gaze trackers color should be updated when selecting meshes
  45774. */
  45775. updateGazeTrackerColor: boolean;
  45776. /**
  45777. * If the controller laser color should be updated when selecting meshes
  45778. */
  45779. updateControllerLaserColor: boolean;
  45780. /**
  45781. * The gaze tracking mesh corresponding to the left controller
  45782. */
  45783. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45784. /**
  45785. * The gaze tracking mesh corresponding to the right controller
  45786. */
  45787. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45788. /**
  45789. * If the ray of the gaze should be displayed.
  45790. */
  45791. get displayGaze(): boolean;
  45792. /**
  45793. * Sets if the ray of the gaze should be displayed.
  45794. */
  45795. set displayGaze(value: boolean);
  45796. /**
  45797. * If the ray of the LaserPointer should be displayed.
  45798. */
  45799. get displayLaserPointer(): boolean;
  45800. /**
  45801. * Sets if the ray of the LaserPointer should be displayed.
  45802. */
  45803. set displayLaserPointer(value: boolean);
  45804. /**
  45805. * The deviceOrientationCamera used as the camera when not in VR.
  45806. */
  45807. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45808. /**
  45809. * Based on the current WebVR support, returns the current VR camera used.
  45810. */
  45811. get currentVRCamera(): Nullable<Camera>;
  45812. /**
  45813. * The webVRCamera which is used when in VR.
  45814. */
  45815. get webVRCamera(): WebVRFreeCamera;
  45816. /**
  45817. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45818. */
  45819. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45820. /**
  45821. * The html button that is used to trigger entering into VR.
  45822. */
  45823. get vrButton(): Nullable<HTMLButtonElement>;
  45824. private get _teleportationRequestInitiated();
  45825. /**
  45826. * Defines whether or not Pointer lock should be requested when switching to
  45827. * full screen.
  45828. */
  45829. requestPointerLockOnFullScreen: boolean;
  45830. /**
  45831. * If asking to force XR, this will be populated with the default xr experience
  45832. */
  45833. xr: WebXRDefaultExperience;
  45834. /**
  45835. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45836. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45837. */
  45838. xrTestDone: boolean;
  45839. /**
  45840. * Instantiates a VRExperienceHelper.
  45841. * Helps to quickly add VR support to an existing scene.
  45842. * @param scene The scene the VRExperienceHelper belongs to.
  45843. * @param webVROptions Options to modify the vr experience helper's behavior.
  45844. */
  45845. constructor(scene: Scene,
  45846. /** Options to modify the vr experience helper's behavior. */
  45847. webVROptions?: VRExperienceHelperOptions);
  45848. private completeVRInit;
  45849. private _onDefaultMeshLoaded;
  45850. private _onResize;
  45851. private _onFullscreenChange;
  45852. /**
  45853. * Gets a value indicating if we are currently in VR mode.
  45854. */
  45855. get isInVRMode(): boolean;
  45856. private onVrDisplayPresentChange;
  45857. private onVRDisplayChanged;
  45858. private moveButtonToBottomRight;
  45859. private displayVRButton;
  45860. private updateButtonVisibility;
  45861. private _cachedAngularSensibility;
  45862. /**
  45863. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45864. * Otherwise, will use the fullscreen API.
  45865. */
  45866. enterVR(): void;
  45867. /**
  45868. * Attempt to exit VR, or fullscreen.
  45869. */
  45870. exitVR(): void;
  45871. /**
  45872. * The position of the vr experience helper.
  45873. */
  45874. get position(): Vector3;
  45875. /**
  45876. * Sets the position of the vr experience helper.
  45877. */
  45878. set position(value: Vector3);
  45879. /**
  45880. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45881. */
  45882. enableInteractions(): void;
  45883. private get _noControllerIsActive();
  45884. private beforeRender;
  45885. private _isTeleportationFloor;
  45886. /**
  45887. * Adds a floor mesh to be used for teleportation.
  45888. * @param floorMesh the mesh to be used for teleportation.
  45889. */
  45890. addFloorMesh(floorMesh: Mesh): void;
  45891. /**
  45892. * Removes a floor mesh from being used for teleportation.
  45893. * @param floorMesh the mesh to be removed.
  45894. */
  45895. removeFloorMesh(floorMesh: Mesh): void;
  45896. /**
  45897. * Enables interactions and teleportation using the VR controllers and gaze.
  45898. * @param vrTeleportationOptions options to modify teleportation behavior.
  45899. */
  45900. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45901. private _onNewGamepadConnected;
  45902. private _tryEnableInteractionOnController;
  45903. private _onNewGamepadDisconnected;
  45904. private _enableInteractionOnController;
  45905. private _checkTeleportWithRay;
  45906. private _checkRotate;
  45907. private _checkTeleportBackwards;
  45908. private _enableTeleportationOnController;
  45909. private _createTeleportationCircles;
  45910. private _displayTeleportationTarget;
  45911. private _hideTeleportationTarget;
  45912. private _rotateCamera;
  45913. private _moveTeleportationSelectorTo;
  45914. private _workingVector;
  45915. private _workingQuaternion;
  45916. private _workingMatrix;
  45917. /**
  45918. * Time Constant Teleportation Mode
  45919. */
  45920. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45921. /**
  45922. * Speed Constant Teleportation Mode
  45923. */
  45924. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45925. /**
  45926. * Teleports the users feet to the desired location
  45927. * @param location The location where the user's feet should be placed
  45928. */
  45929. teleportCamera(location: Vector3): void;
  45930. private _convertNormalToDirectionOfRay;
  45931. private _castRayAndSelectObject;
  45932. private _notifySelectedMeshUnselected;
  45933. /**
  45934. * Permanently set new colors for the laser pointer
  45935. * @param color the new laser color
  45936. * @param pickedColor the new laser color when picked mesh detected
  45937. */
  45938. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45939. /**
  45940. * Set lighting enabled / disabled on the laser pointer of both controllers
  45941. * @param enabled should the lighting be enabled on the laser pointer
  45942. */
  45943. setLaserLightingState(enabled?: boolean): void;
  45944. /**
  45945. * Permanently set new colors for the gaze pointer
  45946. * @param color the new gaze color
  45947. * @param pickedColor the new gaze color when picked mesh detected
  45948. */
  45949. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45950. /**
  45951. * Sets the color of the laser ray from the vr controllers.
  45952. * @param color new color for the ray.
  45953. */
  45954. changeLaserColor(color: Color3): void;
  45955. /**
  45956. * Sets the color of the ray from the vr headsets gaze.
  45957. * @param color new color for the ray.
  45958. */
  45959. changeGazeColor(color: Color3): void;
  45960. /**
  45961. * Exits VR and disposes of the vr experience helper
  45962. */
  45963. dispose(): void;
  45964. /**
  45965. * Gets the name of the VRExperienceHelper class
  45966. * @returns "VRExperienceHelper"
  45967. */
  45968. getClassName(): string;
  45969. }
  45970. }
  45971. declare module BABYLON {
  45972. /**
  45973. * Contains an array of blocks representing the octree
  45974. */
  45975. export interface IOctreeContainer<T> {
  45976. /**
  45977. * Blocks within the octree
  45978. */
  45979. blocks: Array<OctreeBlock<T>>;
  45980. }
  45981. /**
  45982. * Class used to store a cell in an octree
  45983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45984. */
  45985. export class OctreeBlock<T> {
  45986. /**
  45987. * Gets the content of the current block
  45988. */
  45989. entries: T[];
  45990. /**
  45991. * Gets the list of block children
  45992. */
  45993. blocks: Array<OctreeBlock<T>>;
  45994. private _depth;
  45995. private _maxDepth;
  45996. private _capacity;
  45997. private _minPoint;
  45998. private _maxPoint;
  45999. private _boundingVectors;
  46000. private _creationFunc;
  46001. /**
  46002. * Creates a new block
  46003. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46004. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46005. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46006. * @param depth defines the current depth of this block in the octree
  46007. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46008. * @param creationFunc defines a callback to call when an element is added to the block
  46009. */
  46010. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46011. /**
  46012. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46013. */
  46014. get capacity(): number;
  46015. /**
  46016. * Gets the minimum vector (in world space) of the block's bounding box
  46017. */
  46018. get minPoint(): Vector3;
  46019. /**
  46020. * Gets the maximum vector (in world space) of the block's bounding box
  46021. */
  46022. get maxPoint(): Vector3;
  46023. /**
  46024. * Add a new element to this block
  46025. * @param entry defines the element to add
  46026. */
  46027. addEntry(entry: T): void;
  46028. /**
  46029. * Remove an element from this block
  46030. * @param entry defines the element to remove
  46031. */
  46032. removeEntry(entry: T): void;
  46033. /**
  46034. * Add an array of elements to this block
  46035. * @param entries defines the array of elements to add
  46036. */
  46037. addEntries(entries: T[]): void;
  46038. /**
  46039. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46040. * @param frustumPlanes defines the frustum planes to test
  46041. * @param selection defines the array to store current content if selection is positive
  46042. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46043. */
  46044. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46045. /**
  46046. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46047. * @param sphereCenter defines the bounding sphere center
  46048. * @param sphereRadius defines the bounding sphere radius
  46049. * @param selection defines the array to store current content if selection is positive
  46050. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46051. */
  46052. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46053. /**
  46054. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46055. * @param ray defines the ray to test with
  46056. * @param selection defines the array to store current content if selection is positive
  46057. */
  46058. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46059. /**
  46060. * Subdivide the content into child blocks (this block will then be empty)
  46061. */
  46062. createInnerBlocks(): void;
  46063. /**
  46064. * @hidden
  46065. */
  46066. 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;
  46067. }
  46068. }
  46069. declare module BABYLON {
  46070. /**
  46071. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46072. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46073. */
  46074. export class Octree<T> {
  46075. /** 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.) */
  46076. maxDepth: number;
  46077. /**
  46078. * Blocks within the octree containing objects
  46079. */
  46080. blocks: Array<OctreeBlock<T>>;
  46081. /**
  46082. * Content stored in the octree
  46083. */
  46084. dynamicContent: T[];
  46085. private _maxBlockCapacity;
  46086. private _selectionContent;
  46087. private _creationFunc;
  46088. /**
  46089. * Creates a octree
  46090. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46091. * @param creationFunc function to be used to instatiate the octree
  46092. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46093. * @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.)
  46094. */
  46095. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46096. /** 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.) */
  46097. maxDepth?: number);
  46098. /**
  46099. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46100. * @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);
  46101. * @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);
  46102. * @param entries meshes to be added to the octree blocks
  46103. */
  46104. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46105. /**
  46106. * Adds a mesh to the octree
  46107. * @param entry Mesh to add to the octree
  46108. */
  46109. addMesh(entry: T): void;
  46110. /**
  46111. * Remove an element from the octree
  46112. * @param entry defines the element to remove
  46113. */
  46114. removeMesh(entry: T): void;
  46115. /**
  46116. * Selects an array of meshes within the frustum
  46117. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46118. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46119. * @returns array of meshes within the frustum
  46120. */
  46121. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46122. /**
  46123. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46124. * @param sphereCenter defines the bounding sphere center
  46125. * @param sphereRadius defines the bounding sphere radius
  46126. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46127. * @returns an array of objects that intersect the sphere
  46128. */
  46129. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46130. /**
  46131. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46132. * @param ray defines the ray to test with
  46133. * @returns array of intersected objects
  46134. */
  46135. intersectsRay(ray: Ray): SmartArray<T>;
  46136. /**
  46137. * Adds a mesh into the octree block if it intersects the block
  46138. */
  46139. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46140. /**
  46141. * Adds a submesh into the octree block if it intersects the block
  46142. */
  46143. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46144. }
  46145. }
  46146. declare module BABYLON {
  46147. interface Scene {
  46148. /**
  46149. * @hidden
  46150. * Backing Filed
  46151. */
  46152. _selectionOctree: Octree<AbstractMesh>;
  46153. /**
  46154. * Gets the octree used to boost mesh selection (picking)
  46155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46156. */
  46157. selectionOctree: Octree<AbstractMesh>;
  46158. /**
  46159. * Creates or updates the octree used to boost selection (picking)
  46160. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46161. * @param maxCapacity defines the maximum capacity per leaf
  46162. * @param maxDepth defines the maximum depth of the octree
  46163. * @returns an octree of AbstractMesh
  46164. */
  46165. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46166. }
  46167. interface AbstractMesh {
  46168. /**
  46169. * @hidden
  46170. * Backing Field
  46171. */
  46172. _submeshesOctree: Octree<SubMesh>;
  46173. /**
  46174. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46175. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46176. * @param maxCapacity defines the maximum size of each block (64 by default)
  46177. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46178. * @returns the new octree
  46179. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46181. */
  46182. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46183. }
  46184. /**
  46185. * Defines the octree scene component responsible to manage any octrees
  46186. * in a given scene.
  46187. */
  46188. export class OctreeSceneComponent {
  46189. /**
  46190. * The component name help to identify the component in the list of scene components.
  46191. */
  46192. readonly name: string;
  46193. /**
  46194. * The scene the component belongs to.
  46195. */
  46196. scene: Scene;
  46197. /**
  46198. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46199. */
  46200. readonly checksIsEnabled: boolean;
  46201. /**
  46202. * Creates a new instance of the component for the given scene
  46203. * @param scene Defines the scene to register the component in
  46204. */
  46205. constructor(scene: Scene);
  46206. /**
  46207. * Registers the component in a given scene
  46208. */
  46209. register(): void;
  46210. /**
  46211. * Return the list of active meshes
  46212. * @returns the list of active meshes
  46213. */
  46214. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46215. /**
  46216. * Return the list of active sub meshes
  46217. * @param mesh The mesh to get the candidates sub meshes from
  46218. * @returns the list of active sub meshes
  46219. */
  46220. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46221. private _tempRay;
  46222. /**
  46223. * Return the list of sub meshes intersecting with a given local ray
  46224. * @param mesh defines the mesh to find the submesh for
  46225. * @param localRay defines the ray in local space
  46226. * @returns the list of intersecting sub meshes
  46227. */
  46228. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46229. /**
  46230. * Return the list of sub meshes colliding with a collider
  46231. * @param mesh defines the mesh to find the submesh for
  46232. * @param collider defines the collider to evaluate the collision against
  46233. * @returns the list of colliding sub meshes
  46234. */
  46235. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46236. /**
  46237. * Rebuilds the elements related to this component in case of
  46238. * context lost for instance.
  46239. */
  46240. rebuild(): void;
  46241. /**
  46242. * Disposes the component and the associated ressources.
  46243. */
  46244. dispose(): void;
  46245. }
  46246. }
  46247. declare module BABYLON {
  46248. /**
  46249. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46250. */
  46251. export class Gizmo implements IDisposable {
  46252. /** The utility layer the gizmo will be added to */
  46253. gizmoLayer: UtilityLayerRenderer;
  46254. /**
  46255. * The root mesh of the gizmo
  46256. */
  46257. _rootMesh: Mesh;
  46258. private _attachedMesh;
  46259. /**
  46260. * Ratio for the scale of the gizmo (Default: 1)
  46261. */
  46262. scaleRatio: number;
  46263. /**
  46264. * If a custom mesh has been set (Default: false)
  46265. */
  46266. protected _customMeshSet: boolean;
  46267. /**
  46268. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46269. * * When set, interactions will be enabled
  46270. */
  46271. get attachedMesh(): Nullable<AbstractMesh>;
  46272. set attachedMesh(value: Nullable<AbstractMesh>);
  46273. /**
  46274. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46275. * @param mesh The mesh to replace the default mesh of the gizmo
  46276. */
  46277. setCustomMesh(mesh: Mesh): void;
  46278. /**
  46279. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46280. */
  46281. updateGizmoRotationToMatchAttachedMesh: boolean;
  46282. /**
  46283. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46284. */
  46285. updateGizmoPositionToMatchAttachedMesh: boolean;
  46286. /**
  46287. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46288. */
  46289. updateScale: boolean;
  46290. protected _interactionsEnabled: boolean;
  46291. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46292. private _beforeRenderObserver;
  46293. private _tempVector;
  46294. /**
  46295. * Creates a gizmo
  46296. * @param gizmoLayer The utility layer the gizmo will be added to
  46297. */
  46298. constructor(
  46299. /** The utility layer the gizmo will be added to */
  46300. gizmoLayer?: UtilityLayerRenderer);
  46301. /**
  46302. * Updates the gizmo to match the attached mesh's position/rotation
  46303. */
  46304. protected _update(): void;
  46305. /**
  46306. * Disposes of the gizmo
  46307. */
  46308. dispose(): void;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /**
  46313. * Single plane drag gizmo
  46314. */
  46315. export class PlaneDragGizmo extends Gizmo {
  46316. /**
  46317. * Drag behavior responsible for the gizmos dragging interactions
  46318. */
  46319. dragBehavior: PointerDragBehavior;
  46320. private _pointerObserver;
  46321. /**
  46322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46323. */
  46324. snapDistance: number;
  46325. /**
  46326. * Event that fires each time the gizmo snaps to a new location.
  46327. * * snapDistance is the the change in distance
  46328. */
  46329. onSnapObservable: Observable<{
  46330. snapDistance: number;
  46331. }>;
  46332. private _plane;
  46333. private _coloredMaterial;
  46334. private _hoverMaterial;
  46335. private _isEnabled;
  46336. private _parent;
  46337. /** @hidden */
  46338. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46339. /** @hidden */
  46340. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46341. /**
  46342. * Creates a PlaneDragGizmo
  46343. * @param gizmoLayer The utility layer the gizmo will be added to
  46344. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46345. * @param color The color of the gizmo
  46346. */
  46347. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46348. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46349. /**
  46350. * If the gizmo is enabled
  46351. */
  46352. set isEnabled(value: boolean);
  46353. get isEnabled(): boolean;
  46354. /**
  46355. * Disposes of the gizmo
  46356. */
  46357. dispose(): void;
  46358. }
  46359. }
  46360. declare module BABYLON {
  46361. /**
  46362. * Gizmo that enables dragging a mesh along 3 axis
  46363. */
  46364. export class PositionGizmo extends Gizmo {
  46365. /**
  46366. * Internal gizmo used for interactions on the x axis
  46367. */
  46368. xGizmo: AxisDragGizmo;
  46369. /**
  46370. * Internal gizmo used for interactions on the y axis
  46371. */
  46372. yGizmo: AxisDragGizmo;
  46373. /**
  46374. * Internal gizmo used for interactions on the z axis
  46375. */
  46376. zGizmo: AxisDragGizmo;
  46377. /**
  46378. * Internal gizmo used for interactions on the yz plane
  46379. */
  46380. xPlaneGizmo: PlaneDragGizmo;
  46381. /**
  46382. * Internal gizmo used for interactions on the xz plane
  46383. */
  46384. yPlaneGizmo: PlaneDragGizmo;
  46385. /**
  46386. * Internal gizmo used for interactions on the xy plane
  46387. */
  46388. zPlaneGizmo: PlaneDragGizmo;
  46389. /**
  46390. * private variables
  46391. */
  46392. private _meshAttached;
  46393. private _updateGizmoRotationToMatchAttachedMesh;
  46394. private _snapDistance;
  46395. private _scaleRatio;
  46396. /** Fires an event when any of it's sub gizmos are dragged */
  46397. onDragStartObservable: Observable<unknown>;
  46398. /** Fires an event when any of it's sub gizmos are released from dragging */
  46399. onDragEndObservable: Observable<unknown>;
  46400. /**
  46401. * If set to true, planar drag is enabled
  46402. */
  46403. private _planarGizmoEnabled;
  46404. get attachedMesh(): Nullable<AbstractMesh>;
  46405. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46406. /**
  46407. * Creates a PositionGizmo
  46408. * @param gizmoLayer The utility layer the gizmo will be added to
  46409. */
  46410. constructor(gizmoLayer?: UtilityLayerRenderer);
  46411. /**
  46412. * If the planar drag gizmo is enabled
  46413. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46414. */
  46415. set planarGizmoEnabled(value: boolean);
  46416. get planarGizmoEnabled(): boolean;
  46417. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46418. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46419. /**
  46420. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46421. */
  46422. set snapDistance(value: number);
  46423. get snapDistance(): number;
  46424. /**
  46425. * Ratio for the scale of the gizmo (Default: 1)
  46426. */
  46427. set scaleRatio(value: number);
  46428. get scaleRatio(): number;
  46429. /**
  46430. * Disposes of the gizmo
  46431. */
  46432. dispose(): void;
  46433. /**
  46434. * CustomMeshes are not supported by this gizmo
  46435. * @param mesh The mesh to replace the default mesh of the gizmo
  46436. */
  46437. setCustomMesh(mesh: Mesh): void;
  46438. }
  46439. }
  46440. declare module BABYLON {
  46441. /**
  46442. * Single axis drag gizmo
  46443. */
  46444. export class AxisDragGizmo extends Gizmo {
  46445. /**
  46446. * Drag behavior responsible for the gizmos dragging interactions
  46447. */
  46448. dragBehavior: PointerDragBehavior;
  46449. private _pointerObserver;
  46450. /**
  46451. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46452. */
  46453. snapDistance: number;
  46454. /**
  46455. * Event that fires each time the gizmo snaps to a new location.
  46456. * * snapDistance is the the change in distance
  46457. */
  46458. onSnapObservable: Observable<{
  46459. snapDistance: number;
  46460. }>;
  46461. private _isEnabled;
  46462. private _parent;
  46463. private _arrow;
  46464. private _coloredMaterial;
  46465. private _hoverMaterial;
  46466. /** @hidden */
  46467. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46468. /** @hidden */
  46469. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46470. /**
  46471. * Creates an AxisDragGizmo
  46472. * @param gizmoLayer The utility layer the gizmo will be added to
  46473. * @param dragAxis The axis which the gizmo will be able to drag on
  46474. * @param color The color of the gizmo
  46475. */
  46476. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46477. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46478. /**
  46479. * If the gizmo is enabled
  46480. */
  46481. set isEnabled(value: boolean);
  46482. get isEnabled(): boolean;
  46483. /**
  46484. * Disposes of the gizmo
  46485. */
  46486. dispose(): void;
  46487. }
  46488. }
  46489. declare module BABYLON.Debug {
  46490. /**
  46491. * The Axes viewer will show 3 axes in a specific point in space
  46492. */
  46493. export class AxesViewer {
  46494. private _xAxis;
  46495. private _yAxis;
  46496. private _zAxis;
  46497. private _scaleLinesFactor;
  46498. private _instanced;
  46499. /**
  46500. * Gets the hosting scene
  46501. */
  46502. scene: Scene;
  46503. /**
  46504. * Gets or sets a number used to scale line length
  46505. */
  46506. scaleLines: number;
  46507. /** Gets the node hierarchy used to render x-axis */
  46508. get xAxis(): TransformNode;
  46509. /** Gets the node hierarchy used to render y-axis */
  46510. get yAxis(): TransformNode;
  46511. /** Gets the node hierarchy used to render z-axis */
  46512. get zAxis(): TransformNode;
  46513. /**
  46514. * Creates a new AxesViewer
  46515. * @param scene defines the hosting scene
  46516. * @param scaleLines defines a number used to scale line length (1 by default)
  46517. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46518. * @param xAxis defines the node hierarchy used to render the x-axis
  46519. * @param yAxis defines the node hierarchy used to render the y-axis
  46520. * @param zAxis defines the node hierarchy used to render the z-axis
  46521. */
  46522. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46523. /**
  46524. * Force the viewer to update
  46525. * @param position defines the position of the viewer
  46526. * @param xaxis defines the x axis of the viewer
  46527. * @param yaxis defines the y axis of the viewer
  46528. * @param zaxis defines the z axis of the viewer
  46529. */
  46530. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46531. /**
  46532. * Creates an instance of this axes viewer.
  46533. * @returns a new axes viewer with instanced meshes
  46534. */
  46535. createInstance(): AxesViewer;
  46536. /** Releases resources */
  46537. dispose(): void;
  46538. private static _SetRenderingGroupId;
  46539. }
  46540. }
  46541. declare module BABYLON.Debug {
  46542. /**
  46543. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46544. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46545. */
  46546. export class BoneAxesViewer extends AxesViewer {
  46547. /**
  46548. * Gets or sets the target mesh where to display the axes viewer
  46549. */
  46550. mesh: Nullable<Mesh>;
  46551. /**
  46552. * Gets or sets the target bone where to display the axes viewer
  46553. */
  46554. bone: Nullable<Bone>;
  46555. /** Gets current position */
  46556. pos: Vector3;
  46557. /** Gets direction of X axis */
  46558. xaxis: Vector3;
  46559. /** Gets direction of Y axis */
  46560. yaxis: Vector3;
  46561. /** Gets direction of Z axis */
  46562. zaxis: Vector3;
  46563. /**
  46564. * Creates a new BoneAxesViewer
  46565. * @param scene defines the hosting scene
  46566. * @param bone defines the target bone
  46567. * @param mesh defines the target mesh
  46568. * @param scaleLines defines a scaling factor for line length (1 by default)
  46569. */
  46570. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46571. /**
  46572. * Force the viewer to update
  46573. */
  46574. update(): void;
  46575. /** Releases resources */
  46576. dispose(): void;
  46577. }
  46578. }
  46579. declare module BABYLON {
  46580. /**
  46581. * Interface used to define scene explorer extensibility option
  46582. */
  46583. export interface IExplorerExtensibilityOption {
  46584. /**
  46585. * Define the option label
  46586. */
  46587. label: string;
  46588. /**
  46589. * Defines the action to execute on click
  46590. */
  46591. action: (entity: any) => void;
  46592. }
  46593. /**
  46594. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46595. */
  46596. export interface IExplorerExtensibilityGroup {
  46597. /**
  46598. * Defines a predicate to test if a given type mut be extended
  46599. */
  46600. predicate: (entity: any) => boolean;
  46601. /**
  46602. * Gets the list of options added to a type
  46603. */
  46604. entries: IExplorerExtensibilityOption[];
  46605. }
  46606. /**
  46607. * Interface used to define the options to use to create the Inspector
  46608. */
  46609. export interface IInspectorOptions {
  46610. /**
  46611. * Display in overlay mode (default: false)
  46612. */
  46613. overlay?: boolean;
  46614. /**
  46615. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46616. */
  46617. globalRoot?: HTMLElement;
  46618. /**
  46619. * Display the Scene explorer
  46620. */
  46621. showExplorer?: boolean;
  46622. /**
  46623. * Display the property inspector
  46624. */
  46625. showInspector?: boolean;
  46626. /**
  46627. * Display in embed mode (both panes on the right)
  46628. */
  46629. embedMode?: boolean;
  46630. /**
  46631. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46632. */
  46633. handleResize?: boolean;
  46634. /**
  46635. * Allow the panes to popup (default: true)
  46636. */
  46637. enablePopup?: boolean;
  46638. /**
  46639. * Allow the panes to be closed by users (default: true)
  46640. */
  46641. enableClose?: boolean;
  46642. /**
  46643. * Optional list of extensibility entries
  46644. */
  46645. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46646. /**
  46647. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46648. */
  46649. inspectorURL?: string;
  46650. /**
  46651. * Optional initial tab (default to DebugLayerTab.Properties)
  46652. */
  46653. initialTab?: DebugLayerTab;
  46654. }
  46655. interface Scene {
  46656. /**
  46657. * @hidden
  46658. * Backing field
  46659. */
  46660. _debugLayer: DebugLayer;
  46661. /**
  46662. * Gets the debug layer (aka Inspector) associated with the scene
  46663. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46664. */
  46665. debugLayer: DebugLayer;
  46666. }
  46667. /**
  46668. * Enum of inspector action tab
  46669. */
  46670. export enum DebugLayerTab {
  46671. /**
  46672. * Properties tag (default)
  46673. */
  46674. Properties = 0,
  46675. /**
  46676. * Debug tab
  46677. */
  46678. Debug = 1,
  46679. /**
  46680. * Statistics tab
  46681. */
  46682. Statistics = 2,
  46683. /**
  46684. * Tools tab
  46685. */
  46686. Tools = 3,
  46687. /**
  46688. * Settings tab
  46689. */
  46690. Settings = 4
  46691. }
  46692. /**
  46693. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46694. * what is happening in your scene
  46695. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46696. */
  46697. export class DebugLayer {
  46698. /**
  46699. * Define the url to get the inspector script from.
  46700. * By default it uses the babylonjs CDN.
  46701. * @ignoreNaming
  46702. */
  46703. static InspectorURL: string;
  46704. private _scene;
  46705. private BJSINSPECTOR;
  46706. private _onPropertyChangedObservable?;
  46707. /**
  46708. * Observable triggered when a property is changed through the inspector.
  46709. */
  46710. get onPropertyChangedObservable(): any;
  46711. /**
  46712. * Instantiates a new debug layer.
  46713. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46714. * what is happening in your scene
  46715. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46716. * @param scene Defines the scene to inspect
  46717. */
  46718. constructor(scene: Scene);
  46719. /** Creates the inspector window. */
  46720. private _createInspector;
  46721. /**
  46722. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46723. * @param entity defines the entity to select
  46724. * @param lineContainerTitle defines the specific block to highlight
  46725. */
  46726. select(entity: any, lineContainerTitle?: string): void;
  46727. /** Get the inspector from bundle or global */
  46728. private _getGlobalInspector;
  46729. /**
  46730. * Get if the inspector is visible or not.
  46731. * @returns true if visible otherwise, false
  46732. */
  46733. isVisible(): boolean;
  46734. /**
  46735. * Hide the inspector and close its window.
  46736. */
  46737. hide(): void;
  46738. /**
  46739. * Launch the debugLayer.
  46740. * @param config Define the configuration of the inspector
  46741. * @return a promise fulfilled when the debug layer is visible
  46742. */
  46743. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46744. }
  46745. }
  46746. declare module BABYLON {
  46747. /**
  46748. * Class containing static functions to help procedurally build meshes
  46749. */
  46750. export class BoxBuilder {
  46751. /**
  46752. * Creates a box mesh
  46753. * * The parameter `size` sets the size (float) of each box side (default 1)
  46754. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46755. * * 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)
  46756. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46758. * * 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
  46759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46760. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46761. * @param name defines the name of the mesh
  46762. * @param options defines the options used to create the mesh
  46763. * @param scene defines the hosting scene
  46764. * @returns the box mesh
  46765. */
  46766. static CreateBox(name: string, options: {
  46767. size?: number;
  46768. width?: number;
  46769. height?: number;
  46770. depth?: number;
  46771. faceUV?: Vector4[];
  46772. faceColors?: Color4[];
  46773. sideOrientation?: number;
  46774. frontUVs?: Vector4;
  46775. backUVs?: Vector4;
  46776. wrap?: boolean;
  46777. topBaseAt?: number;
  46778. bottomBaseAt?: number;
  46779. updatable?: boolean;
  46780. }, scene?: Nullable<Scene>): Mesh;
  46781. }
  46782. }
  46783. declare module BABYLON.Debug {
  46784. /**
  46785. * Used to show the physics impostor around the specific mesh
  46786. */
  46787. export class PhysicsViewer {
  46788. /** @hidden */
  46789. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46790. /** @hidden */
  46791. protected _meshes: Array<Nullable<AbstractMesh>>;
  46792. /** @hidden */
  46793. protected _scene: Nullable<Scene>;
  46794. /** @hidden */
  46795. protected _numMeshes: number;
  46796. /** @hidden */
  46797. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46798. private _renderFunction;
  46799. private _utilityLayer;
  46800. private _debugBoxMesh;
  46801. private _debugSphereMesh;
  46802. private _debugCylinderMesh;
  46803. private _debugMaterial;
  46804. private _debugMeshMeshes;
  46805. /**
  46806. * Creates a new PhysicsViewer
  46807. * @param scene defines the hosting scene
  46808. */
  46809. constructor(scene: Scene);
  46810. /** @hidden */
  46811. protected _updateDebugMeshes(): void;
  46812. /**
  46813. * Renders a specified physic impostor
  46814. * @param impostor defines the impostor to render
  46815. * @param targetMesh defines the mesh represented by the impostor
  46816. * @returns the new debug mesh used to render the impostor
  46817. */
  46818. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46819. /**
  46820. * Hides a specified physic impostor
  46821. * @param impostor defines the impostor to hide
  46822. */
  46823. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46824. private _getDebugMaterial;
  46825. private _getDebugBoxMesh;
  46826. private _getDebugSphereMesh;
  46827. private _getDebugCylinderMesh;
  46828. private _getDebugMeshMesh;
  46829. private _getDebugMesh;
  46830. /** Releases all resources */
  46831. dispose(): void;
  46832. }
  46833. }
  46834. declare module BABYLON {
  46835. /**
  46836. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46837. * in order to better appreciate the issue one might have.
  46838. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46839. */
  46840. export class RayHelper {
  46841. /**
  46842. * Defines the ray we are currently tryin to visualize.
  46843. */
  46844. ray: Nullable<Ray>;
  46845. private _renderPoints;
  46846. private _renderLine;
  46847. private _renderFunction;
  46848. private _scene;
  46849. private _updateToMeshFunction;
  46850. private _attachedToMesh;
  46851. private _meshSpaceDirection;
  46852. private _meshSpaceOrigin;
  46853. /**
  46854. * Helper function to create a colored helper in a scene in one line.
  46855. * @param ray Defines the ray we are currently tryin to visualize
  46856. * @param scene Defines the scene the ray is used in
  46857. * @param color Defines the color we want to see the ray in
  46858. * @returns The newly created ray helper.
  46859. */
  46860. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46861. /**
  46862. * Instantiate a new ray helper.
  46863. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46864. * in order to better appreciate the issue one might have.
  46865. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46866. * @param ray Defines the ray we are currently tryin to visualize
  46867. */
  46868. constructor(ray: Ray);
  46869. /**
  46870. * Shows the ray we are willing to debug.
  46871. * @param scene Defines the scene the ray needs to be rendered in
  46872. * @param color Defines the color the ray needs to be rendered in
  46873. */
  46874. show(scene: Scene, color?: Color3): void;
  46875. /**
  46876. * Hides the ray we are debugging.
  46877. */
  46878. hide(): void;
  46879. private _render;
  46880. /**
  46881. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46882. * @param mesh Defines the mesh we want the helper attached to
  46883. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46884. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46885. * @param length Defines the length of the ray
  46886. */
  46887. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46888. /**
  46889. * Detach the ray helper from the mesh it has previously been attached to.
  46890. */
  46891. detachFromMesh(): void;
  46892. private _updateToMesh;
  46893. /**
  46894. * Dispose the helper and release its associated resources.
  46895. */
  46896. dispose(): void;
  46897. }
  46898. }
  46899. declare module BABYLON.Debug {
  46900. /**
  46901. * Class used to render a debug view of a given skeleton
  46902. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46903. */
  46904. export class SkeletonViewer {
  46905. /** defines the skeleton to render */
  46906. skeleton: Skeleton;
  46907. /** defines the mesh attached to the skeleton */
  46908. mesh: AbstractMesh;
  46909. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46910. autoUpdateBonesMatrices: boolean;
  46911. /** defines the rendering group id to use with the viewer */
  46912. renderingGroupId: number;
  46913. /** Gets or sets the color used to render the skeleton */
  46914. color: Color3;
  46915. private _scene;
  46916. private _debugLines;
  46917. private _debugMesh;
  46918. private _isEnabled;
  46919. private _renderFunction;
  46920. private _utilityLayer;
  46921. /**
  46922. * Returns the mesh used to render the bones
  46923. */
  46924. get debugMesh(): Nullable<LinesMesh>;
  46925. /**
  46926. * Creates a new SkeletonViewer
  46927. * @param skeleton defines the skeleton to render
  46928. * @param mesh defines the mesh attached to the skeleton
  46929. * @param scene defines the hosting scene
  46930. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46931. * @param renderingGroupId defines the rendering group id to use with the viewer
  46932. */
  46933. constructor(
  46934. /** defines the skeleton to render */
  46935. skeleton: Skeleton,
  46936. /** defines the mesh attached to the skeleton */
  46937. mesh: AbstractMesh, scene: Scene,
  46938. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46939. autoUpdateBonesMatrices?: boolean,
  46940. /** defines the rendering group id to use with the viewer */
  46941. renderingGroupId?: number);
  46942. /** Gets or sets a boolean indicating if the viewer is enabled */
  46943. set isEnabled(value: boolean);
  46944. get isEnabled(): boolean;
  46945. private _getBonePosition;
  46946. private _getLinesForBonesWithLength;
  46947. private _getLinesForBonesNoLength;
  46948. /** Update the viewer to sync with current skeleton state */
  46949. update(): void;
  46950. /** Release associated resources */
  46951. dispose(): void;
  46952. }
  46953. }
  46954. declare module BABYLON {
  46955. /**
  46956. * Options to create the null engine
  46957. */
  46958. export class NullEngineOptions {
  46959. /**
  46960. * Render width (Default: 512)
  46961. */
  46962. renderWidth: number;
  46963. /**
  46964. * Render height (Default: 256)
  46965. */
  46966. renderHeight: number;
  46967. /**
  46968. * Texture size (Default: 512)
  46969. */
  46970. textureSize: number;
  46971. /**
  46972. * If delta time between frames should be constant
  46973. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46974. */
  46975. deterministicLockstep: boolean;
  46976. /**
  46977. * Maximum about of steps between frames (Default: 4)
  46978. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46979. */
  46980. lockstepMaxSteps: number;
  46981. }
  46982. /**
  46983. * The null engine class provides support for headless version of babylon.js.
  46984. * This can be used in server side scenario or for testing purposes
  46985. */
  46986. export class NullEngine extends Engine {
  46987. private _options;
  46988. /**
  46989. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46990. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46991. * @returns true if engine is in deterministic lock step mode
  46992. */
  46993. isDeterministicLockStep(): boolean;
  46994. /**
  46995. * Gets the max steps when engine is running in deterministic lock step
  46996. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46997. * @returns the max steps
  46998. */
  46999. getLockstepMaxSteps(): number;
  47000. /**
  47001. * Gets the current hardware scaling level.
  47002. * By default the hardware scaling level is computed from the window device ratio.
  47003. * 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.
  47004. * @returns a number indicating the current hardware scaling level
  47005. */
  47006. getHardwareScalingLevel(): number;
  47007. constructor(options?: NullEngineOptions);
  47008. /**
  47009. * Creates a vertex buffer
  47010. * @param vertices the data for the vertex buffer
  47011. * @returns the new WebGL static buffer
  47012. */
  47013. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47014. /**
  47015. * Creates a new index buffer
  47016. * @param indices defines the content of the index buffer
  47017. * @param updatable defines if the index buffer must be updatable
  47018. * @returns a new webGL buffer
  47019. */
  47020. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47021. /**
  47022. * Clear the current render buffer or the current render target (if any is set up)
  47023. * @param color defines the color to use
  47024. * @param backBuffer defines if the back buffer must be cleared
  47025. * @param depth defines if the depth buffer must be cleared
  47026. * @param stencil defines if the stencil buffer must be cleared
  47027. */
  47028. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47029. /**
  47030. * Gets the current render width
  47031. * @param useScreen defines if screen size must be used (or the current render target if any)
  47032. * @returns a number defining the current render width
  47033. */
  47034. getRenderWidth(useScreen?: boolean): number;
  47035. /**
  47036. * Gets the current render height
  47037. * @param useScreen defines if screen size must be used (or the current render target if any)
  47038. * @returns a number defining the current render height
  47039. */
  47040. getRenderHeight(useScreen?: boolean): number;
  47041. /**
  47042. * Set the WebGL's viewport
  47043. * @param viewport defines the viewport element to be used
  47044. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47045. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47046. */
  47047. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47048. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47049. /**
  47050. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47051. * @param pipelineContext defines the pipeline context to use
  47052. * @param uniformsNames defines the list of uniform names
  47053. * @returns an array of webGL uniform locations
  47054. */
  47055. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47056. /**
  47057. * Gets the lsit of active attributes for a given webGL program
  47058. * @param pipelineContext defines the pipeline context to use
  47059. * @param attributesNames defines the list of attribute names to get
  47060. * @returns an array of indices indicating the offset of each attribute
  47061. */
  47062. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47063. /**
  47064. * Binds an effect to the webGL context
  47065. * @param effect defines the effect to bind
  47066. */
  47067. bindSamplers(effect: Effect): void;
  47068. /**
  47069. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47070. * @param effect defines the effect to activate
  47071. */
  47072. enableEffect(effect: Effect): void;
  47073. /**
  47074. * Set various states to the webGL context
  47075. * @param culling defines backface culling state
  47076. * @param zOffset defines the value to apply to zOffset (0 by default)
  47077. * @param force defines if states must be applied even if cache is up to date
  47078. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47079. */
  47080. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47081. /**
  47082. * Set the value of an uniform to an array of int32
  47083. * @param uniform defines the webGL uniform location where to store the value
  47084. * @param array defines the array of int32 to store
  47085. */
  47086. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47087. /**
  47088. * Set the value of an uniform to an array of int32 (stored as vec2)
  47089. * @param uniform defines the webGL uniform location where to store the value
  47090. * @param array defines the array of int32 to store
  47091. */
  47092. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47093. /**
  47094. * Set the value of an uniform to an array of int32 (stored as vec3)
  47095. * @param uniform defines the webGL uniform location where to store the value
  47096. * @param array defines the array of int32 to store
  47097. */
  47098. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47099. /**
  47100. * Set the value of an uniform to an array of int32 (stored as vec4)
  47101. * @param uniform defines the webGL uniform location where to store the value
  47102. * @param array defines the array of int32 to store
  47103. */
  47104. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47105. /**
  47106. * Set the value of an uniform to an array of float32
  47107. * @param uniform defines the webGL uniform location where to store the value
  47108. * @param array defines the array of float32 to store
  47109. */
  47110. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47111. /**
  47112. * Set the value of an uniform to an array of float32 (stored as vec2)
  47113. * @param uniform defines the webGL uniform location where to store the value
  47114. * @param array defines the array of float32 to store
  47115. */
  47116. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47117. /**
  47118. * Set the value of an uniform to an array of float32 (stored as vec3)
  47119. * @param uniform defines the webGL uniform location where to store the value
  47120. * @param array defines the array of float32 to store
  47121. */
  47122. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47123. /**
  47124. * Set the value of an uniform to an array of float32 (stored as vec4)
  47125. * @param uniform defines the webGL uniform location where to store the value
  47126. * @param array defines the array of float32 to store
  47127. */
  47128. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47129. /**
  47130. * Set the value of an uniform to an array of number
  47131. * @param uniform defines the webGL uniform location where to store the value
  47132. * @param array defines the array of number to store
  47133. */
  47134. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47135. /**
  47136. * Set the value of an uniform to an array of number (stored as vec2)
  47137. * @param uniform defines the webGL uniform location where to store the value
  47138. * @param array defines the array of number to store
  47139. */
  47140. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47141. /**
  47142. * Set the value of an uniform to an array of number (stored as vec3)
  47143. * @param uniform defines the webGL uniform location where to store the value
  47144. * @param array defines the array of number to store
  47145. */
  47146. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47147. /**
  47148. * Set the value of an uniform to an array of number (stored as vec4)
  47149. * @param uniform defines the webGL uniform location where to store the value
  47150. * @param array defines the array of number to store
  47151. */
  47152. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47153. /**
  47154. * Set the value of an uniform to an array of float32 (stored as matrices)
  47155. * @param uniform defines the webGL uniform location where to store the value
  47156. * @param matrices defines the array of float32 to store
  47157. */
  47158. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47159. /**
  47160. * Set the value of an uniform to a matrix (3x3)
  47161. * @param uniform defines the webGL uniform location where to store the value
  47162. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47163. */
  47164. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47165. /**
  47166. * Set the value of an uniform to a matrix (2x2)
  47167. * @param uniform defines the webGL uniform location where to store the value
  47168. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47169. */
  47170. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47171. /**
  47172. * Set the value of an uniform to a number (float)
  47173. * @param uniform defines the webGL uniform location where to store the value
  47174. * @param value defines the float number to store
  47175. */
  47176. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47177. /**
  47178. * Set the value of an uniform to a vec2
  47179. * @param uniform defines the webGL uniform location where to store the value
  47180. * @param x defines the 1st component of the value
  47181. * @param y defines the 2nd component of the value
  47182. */
  47183. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47184. /**
  47185. * Set the value of an uniform to a vec3
  47186. * @param uniform defines the webGL uniform location where to store the value
  47187. * @param x defines the 1st component of the value
  47188. * @param y defines the 2nd component of the value
  47189. * @param z defines the 3rd component of the value
  47190. */
  47191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47192. /**
  47193. * Set the value of an uniform to a boolean
  47194. * @param uniform defines the webGL uniform location where to store the value
  47195. * @param bool defines the boolean to store
  47196. */
  47197. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47198. /**
  47199. * Set the value of an uniform to a vec4
  47200. * @param uniform defines the webGL uniform location where to store the value
  47201. * @param x defines the 1st component of the value
  47202. * @param y defines the 2nd component of the value
  47203. * @param z defines the 3rd component of the value
  47204. * @param w defines the 4th component of the value
  47205. */
  47206. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47207. /**
  47208. * Sets the current alpha mode
  47209. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47210. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47211. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47212. */
  47213. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47214. /**
  47215. * Bind webGl buffers directly to the webGL context
  47216. * @param vertexBuffers defines the vertex buffer to bind
  47217. * @param indexBuffer defines the index buffer to bind
  47218. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47219. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47220. * @param effect defines the effect associated with the vertex buffer
  47221. */
  47222. bindBuffers(vertexBuffers: {
  47223. [key: string]: VertexBuffer;
  47224. }, indexBuffer: DataBuffer, effect: Effect): void;
  47225. /**
  47226. * Force the entire cache to be cleared
  47227. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47228. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47229. */
  47230. wipeCaches(bruteForce?: boolean): void;
  47231. /**
  47232. * Send a draw order
  47233. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47234. * @param indexStart defines the starting index
  47235. * @param indexCount defines the number of index to draw
  47236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47237. */
  47238. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47239. /**
  47240. * Draw a list of indexed primitives
  47241. * @param fillMode defines the primitive to use
  47242. * @param indexStart defines the starting index
  47243. * @param indexCount defines the number of index to draw
  47244. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47245. */
  47246. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47247. /**
  47248. * Draw a list of unindexed primitives
  47249. * @param fillMode defines the primitive to use
  47250. * @param verticesStart defines the index of first vertex to draw
  47251. * @param verticesCount defines the count of vertices to draw
  47252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47253. */
  47254. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47255. /** @hidden */
  47256. _createTexture(): WebGLTexture;
  47257. /** @hidden */
  47258. _releaseTexture(texture: InternalTexture): void;
  47259. /**
  47260. * Usually called from Texture.ts.
  47261. * Passed information to create a WebGLTexture
  47262. * @param urlArg defines a value which contains one of the following:
  47263. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47264. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47265. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47267. * @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)
  47268. * @param scene needed for loading to the correct scene
  47269. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47270. * @param onLoad optional callback to be called upon successful completion
  47271. * @param onError optional callback to be called upon failure
  47272. * @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
  47273. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47274. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47275. * @param forcedExtension defines the extension to use to pick the right loader
  47276. * @param mimeType defines an optional mime type
  47277. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47278. */
  47279. 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;
  47280. /**
  47281. * Creates a new render target texture
  47282. * @param size defines the size of the texture
  47283. * @param options defines the options used to create the texture
  47284. * @returns a new render target texture stored in an InternalTexture
  47285. */
  47286. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47287. /**
  47288. * Update the sampling mode of a given texture
  47289. * @param samplingMode defines the required sampling mode
  47290. * @param texture defines the texture to update
  47291. */
  47292. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47293. /**
  47294. * Binds the frame buffer to the specified texture.
  47295. * @param texture The texture to render to or null for the default canvas
  47296. * @param faceIndex The face of the texture to render to in case of cube texture
  47297. * @param requiredWidth The width of the target to render to
  47298. * @param requiredHeight The height of the target to render to
  47299. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47300. * @param lodLevel defines le lod level to bind to the frame buffer
  47301. */
  47302. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47303. /**
  47304. * Unbind the current render target texture from the webGL context
  47305. * @param texture defines the render target texture to unbind
  47306. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47307. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47308. */
  47309. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47310. /**
  47311. * Creates a dynamic vertex buffer
  47312. * @param vertices the data for the dynamic vertex buffer
  47313. * @returns the new WebGL dynamic buffer
  47314. */
  47315. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47316. /**
  47317. * Update the content of a dynamic texture
  47318. * @param texture defines the texture to update
  47319. * @param canvas defines the canvas containing the source
  47320. * @param invertY defines if data must be stored with Y axis inverted
  47321. * @param premulAlpha defines if alpha is stored as premultiplied
  47322. * @param format defines the format of the data
  47323. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47324. */
  47325. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47326. /**
  47327. * Gets a boolean indicating if all created effects are ready
  47328. * @returns true if all effects are ready
  47329. */
  47330. areAllEffectsReady(): boolean;
  47331. /**
  47332. * @hidden
  47333. * Get the current error code of the webGL context
  47334. * @returns the error code
  47335. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47336. */
  47337. getError(): number;
  47338. /** @hidden */
  47339. _getUnpackAlignement(): number;
  47340. /** @hidden */
  47341. _unpackFlipY(value: boolean): void;
  47342. /**
  47343. * Update a dynamic index buffer
  47344. * @param indexBuffer defines the target index buffer
  47345. * @param indices defines the data to update
  47346. * @param offset defines the offset in the target index buffer where update should start
  47347. */
  47348. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47349. /**
  47350. * Updates a dynamic vertex buffer.
  47351. * @param vertexBuffer the vertex buffer to update
  47352. * @param vertices the data used to update the vertex buffer
  47353. * @param byteOffset the byte offset of the data (optional)
  47354. * @param byteLength the byte length of the data (optional)
  47355. */
  47356. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47357. /** @hidden */
  47358. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47359. /** @hidden */
  47360. _bindTexture(channel: number, texture: InternalTexture): void;
  47361. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47362. /**
  47363. * 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
  47364. */
  47365. releaseEffects(): void;
  47366. displayLoadingUI(): void;
  47367. hideLoadingUI(): void;
  47368. /** @hidden */
  47369. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47370. /** @hidden */
  47371. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47372. /** @hidden */
  47373. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47374. /** @hidden */
  47375. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47376. }
  47377. }
  47378. declare module BABYLON {
  47379. /**
  47380. * @hidden
  47381. **/
  47382. export class _TimeToken {
  47383. _startTimeQuery: Nullable<WebGLQuery>;
  47384. _endTimeQuery: Nullable<WebGLQuery>;
  47385. _timeElapsedQuery: Nullable<WebGLQuery>;
  47386. _timeElapsedQueryEnded: boolean;
  47387. }
  47388. }
  47389. declare module BABYLON {
  47390. /** @hidden */
  47391. export class _OcclusionDataStorage {
  47392. /** @hidden */
  47393. occlusionInternalRetryCounter: number;
  47394. /** @hidden */
  47395. isOcclusionQueryInProgress: boolean;
  47396. /** @hidden */
  47397. isOccluded: boolean;
  47398. /** @hidden */
  47399. occlusionRetryCount: number;
  47400. /** @hidden */
  47401. occlusionType: number;
  47402. /** @hidden */
  47403. occlusionQueryAlgorithmType: number;
  47404. }
  47405. interface Engine {
  47406. /**
  47407. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47408. * @return the new query
  47409. */
  47410. createQuery(): WebGLQuery;
  47411. /**
  47412. * Delete and release a webGL query
  47413. * @param query defines the query to delete
  47414. * @return the current engine
  47415. */
  47416. deleteQuery(query: WebGLQuery): Engine;
  47417. /**
  47418. * Check if a given query has resolved and got its value
  47419. * @param query defines the query to check
  47420. * @returns true if the query got its value
  47421. */
  47422. isQueryResultAvailable(query: WebGLQuery): boolean;
  47423. /**
  47424. * Gets the value of a given query
  47425. * @param query defines the query to check
  47426. * @returns the value of the query
  47427. */
  47428. getQueryResult(query: WebGLQuery): number;
  47429. /**
  47430. * Initiates an occlusion query
  47431. * @param algorithmType defines the algorithm to use
  47432. * @param query defines the query to use
  47433. * @returns the current engine
  47434. * @see http://doc.babylonjs.com/features/occlusionquery
  47435. */
  47436. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47437. /**
  47438. * Ends an occlusion query
  47439. * @see http://doc.babylonjs.com/features/occlusionquery
  47440. * @param algorithmType defines the algorithm to use
  47441. * @returns the current engine
  47442. */
  47443. endOcclusionQuery(algorithmType: number): Engine;
  47444. /**
  47445. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47446. * Please note that only one query can be issued at a time
  47447. * @returns a time token used to track the time span
  47448. */
  47449. startTimeQuery(): Nullable<_TimeToken>;
  47450. /**
  47451. * Ends a time query
  47452. * @param token defines the token used to measure the time span
  47453. * @returns the time spent (in ns)
  47454. */
  47455. endTimeQuery(token: _TimeToken): int;
  47456. /** @hidden */
  47457. _currentNonTimestampToken: Nullable<_TimeToken>;
  47458. /** @hidden */
  47459. _createTimeQuery(): WebGLQuery;
  47460. /** @hidden */
  47461. _deleteTimeQuery(query: WebGLQuery): void;
  47462. /** @hidden */
  47463. _getGlAlgorithmType(algorithmType: number): number;
  47464. /** @hidden */
  47465. _getTimeQueryResult(query: WebGLQuery): any;
  47466. /** @hidden */
  47467. _getTimeQueryAvailability(query: WebGLQuery): any;
  47468. }
  47469. interface AbstractMesh {
  47470. /**
  47471. * Backing filed
  47472. * @hidden
  47473. */
  47474. __occlusionDataStorage: _OcclusionDataStorage;
  47475. /**
  47476. * Access property
  47477. * @hidden
  47478. */
  47479. _occlusionDataStorage: _OcclusionDataStorage;
  47480. /**
  47481. * 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.
  47482. * The default value is -1 which means don't break the query and wait till the result
  47483. * @see http://doc.babylonjs.com/features/occlusionquery
  47484. */
  47485. occlusionRetryCount: number;
  47486. /**
  47487. * 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:
  47488. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47489. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47490. * * 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.
  47491. * @see http://doc.babylonjs.com/features/occlusionquery
  47492. */
  47493. occlusionType: number;
  47494. /**
  47495. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47496. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47497. * * 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.
  47498. * @see http://doc.babylonjs.com/features/occlusionquery
  47499. */
  47500. occlusionQueryAlgorithmType: number;
  47501. /**
  47502. * 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
  47503. * @see http://doc.babylonjs.com/features/occlusionquery
  47504. */
  47505. isOccluded: boolean;
  47506. /**
  47507. * Flag to check the progress status of the query
  47508. * @see http://doc.babylonjs.com/features/occlusionquery
  47509. */
  47510. isOcclusionQueryInProgress: boolean;
  47511. }
  47512. }
  47513. declare module BABYLON {
  47514. /** @hidden */
  47515. export var _forceTransformFeedbackToBundle: boolean;
  47516. interface Engine {
  47517. /**
  47518. * Creates a webGL transform feedback object
  47519. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47520. * @returns the webGL transform feedback object
  47521. */
  47522. createTransformFeedback(): WebGLTransformFeedback;
  47523. /**
  47524. * Delete a webGL transform feedback object
  47525. * @param value defines the webGL transform feedback object to delete
  47526. */
  47527. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47528. /**
  47529. * Bind a webGL transform feedback object to the webgl context
  47530. * @param value defines the webGL transform feedback object to bind
  47531. */
  47532. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47533. /**
  47534. * Begins a transform feedback operation
  47535. * @param usePoints defines if points or triangles must be used
  47536. */
  47537. beginTransformFeedback(usePoints: boolean): void;
  47538. /**
  47539. * Ends a transform feedback operation
  47540. */
  47541. endTransformFeedback(): void;
  47542. /**
  47543. * Specify the varyings to use with transform feedback
  47544. * @param program defines the associated webGL program
  47545. * @param value defines the list of strings representing the varying names
  47546. */
  47547. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47548. /**
  47549. * Bind a webGL buffer for a transform feedback operation
  47550. * @param value defines the webGL buffer to bind
  47551. */
  47552. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47553. }
  47554. }
  47555. declare module BABYLON {
  47556. /**
  47557. * Creation options of the multi render target texture.
  47558. */
  47559. export interface IMultiRenderTargetOptions {
  47560. /**
  47561. * Define if the texture needs to create mip maps after render.
  47562. */
  47563. generateMipMaps?: boolean;
  47564. /**
  47565. * Define the types of all the draw buffers we want to create
  47566. */
  47567. types?: number[];
  47568. /**
  47569. * Define the sampling modes of all the draw buffers we want to create
  47570. */
  47571. samplingModes?: number[];
  47572. /**
  47573. * Define if a depth buffer is required
  47574. */
  47575. generateDepthBuffer?: boolean;
  47576. /**
  47577. * Define if a stencil buffer is required
  47578. */
  47579. generateStencilBuffer?: boolean;
  47580. /**
  47581. * Define if a depth texture is required instead of a depth buffer
  47582. */
  47583. generateDepthTexture?: boolean;
  47584. /**
  47585. * Define the number of desired draw buffers
  47586. */
  47587. textureCount?: number;
  47588. /**
  47589. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47590. */
  47591. doNotChangeAspectRatio?: boolean;
  47592. /**
  47593. * Define the default type of the buffers we are creating
  47594. */
  47595. defaultType?: number;
  47596. }
  47597. /**
  47598. * A multi render target, like a render target provides the ability to render to a texture.
  47599. * Unlike the render target, it can render to several draw buffers in one draw.
  47600. * This is specially interesting in deferred rendering or for any effects requiring more than
  47601. * just one color from a single pass.
  47602. */
  47603. export class MultiRenderTarget extends RenderTargetTexture {
  47604. private _internalTextures;
  47605. private _textures;
  47606. private _multiRenderTargetOptions;
  47607. /**
  47608. * Get if draw buffers are currently supported by the used hardware and browser.
  47609. */
  47610. get isSupported(): boolean;
  47611. /**
  47612. * Get the list of textures generated by the multi render target.
  47613. */
  47614. get textures(): Texture[];
  47615. /**
  47616. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47617. */
  47618. get depthTexture(): Texture;
  47619. /**
  47620. * Set the wrapping mode on U of all the textures we are rendering to.
  47621. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47622. */
  47623. set wrapU(wrap: number);
  47624. /**
  47625. * Set the wrapping mode on V of all the textures we are rendering to.
  47626. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47627. */
  47628. set wrapV(wrap: number);
  47629. /**
  47630. * Instantiate a new multi render target texture.
  47631. * A multi render target, like a render target provides the ability to render to a texture.
  47632. * Unlike the render target, it can render to several draw buffers in one draw.
  47633. * This is specially interesting in deferred rendering or for any effects requiring more than
  47634. * just one color from a single pass.
  47635. * @param name Define the name of the texture
  47636. * @param size Define the size of the buffers to render to
  47637. * @param count Define the number of target we are rendering into
  47638. * @param scene Define the scene the texture belongs to
  47639. * @param options Define the options used to create the multi render target
  47640. */
  47641. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47642. /** @hidden */
  47643. _rebuild(): void;
  47644. private _createInternalTextures;
  47645. private _createTextures;
  47646. /**
  47647. * Define the number of samples used if MSAA is enabled.
  47648. */
  47649. get samples(): number;
  47650. set samples(value: number);
  47651. /**
  47652. * Resize all the textures in the multi render target.
  47653. * Be carrefull as it will recreate all the data in the new texture.
  47654. * @param size Define the new size
  47655. */
  47656. resize(size: any): void;
  47657. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47658. /**
  47659. * Dispose the render targets and their associated resources
  47660. */
  47661. dispose(): void;
  47662. /**
  47663. * Release all the underlying texture used as draw buffers.
  47664. */
  47665. releaseInternalTextures(): void;
  47666. }
  47667. }
  47668. declare module BABYLON {
  47669. interface ThinEngine {
  47670. /**
  47671. * Unbind a list of render target textures from the webGL context
  47672. * This is used only when drawBuffer extension or webGL2 are active
  47673. * @param textures defines the render target textures to unbind
  47674. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47675. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47676. */
  47677. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47678. /**
  47679. * Create a multi render target texture
  47680. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47681. * @param size defines the size of the texture
  47682. * @param options defines the creation options
  47683. * @returns the cube texture as an InternalTexture
  47684. */
  47685. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47686. /**
  47687. * Update the sample count for a given multiple render target texture
  47688. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47689. * @param textures defines the textures to update
  47690. * @param samples defines the sample count to set
  47691. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47692. */
  47693. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47694. }
  47695. }
  47696. declare module BABYLON {
  47697. /**
  47698. * Class used to define an additional view for the engine
  47699. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47700. */
  47701. export class EngineView {
  47702. /** Defines the canvas where to render the view */
  47703. target: HTMLCanvasElement;
  47704. /** Defines an optional camera used to render the view (will use active camera else) */
  47705. camera?: Camera;
  47706. }
  47707. interface Engine {
  47708. /**
  47709. * Gets or sets the HTML element to use for attaching events
  47710. */
  47711. inputElement: Nullable<HTMLElement>;
  47712. /**
  47713. * Gets the current engine view
  47714. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47715. */
  47716. activeView: Nullable<EngineView>;
  47717. /** Gets or sets the list of views */
  47718. views: EngineView[];
  47719. /**
  47720. * Register a new child canvas
  47721. * @param canvas defines the canvas to register
  47722. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47723. * @returns the associated view
  47724. */
  47725. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47726. /**
  47727. * Remove a registered child canvas
  47728. * @param canvas defines the canvas to remove
  47729. * @returns the current engine
  47730. */
  47731. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47732. }
  47733. }
  47734. declare module BABYLON {
  47735. interface Engine {
  47736. /** @hidden */
  47737. _excludedCompressedTextures: string[];
  47738. /** @hidden */
  47739. _textureFormatInUse: string;
  47740. /**
  47741. * Gets the list of texture formats supported
  47742. */
  47743. readonly texturesSupported: Array<string>;
  47744. /**
  47745. * Gets the texture format in use
  47746. */
  47747. readonly textureFormatInUse: Nullable<string>;
  47748. /**
  47749. * Set the compressed texture extensions or file names to skip.
  47750. *
  47751. * @param skippedFiles defines the list of those texture files you want to skip
  47752. * Example: [".dds", ".env", "myfile.png"]
  47753. */
  47754. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47755. /**
  47756. * Set the compressed texture format to use, based on the formats you have, and the formats
  47757. * supported by the hardware / browser.
  47758. *
  47759. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47760. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47761. * to API arguments needed to compressed textures. This puts the burden on the container
  47762. * generator to house the arcane code for determining these for current & future formats.
  47763. *
  47764. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47765. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47766. *
  47767. * Note: The result of this call is not taken into account when a texture is base64.
  47768. *
  47769. * @param formatsAvailable defines the list of those format families you have created
  47770. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47771. *
  47772. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47773. * @returns The extension selected.
  47774. */
  47775. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47781. */
  47782. export interface CubeMapInfo {
  47783. /**
  47784. * The pixel array for the front face.
  47785. * This is stored in format, left to right, up to down format.
  47786. */
  47787. front: Nullable<ArrayBufferView>;
  47788. /**
  47789. * The pixel array for the back face.
  47790. * This is stored in format, left to right, up to down format.
  47791. */
  47792. back: Nullable<ArrayBufferView>;
  47793. /**
  47794. * The pixel array for the left face.
  47795. * This is stored in format, left to right, up to down format.
  47796. */
  47797. left: Nullable<ArrayBufferView>;
  47798. /**
  47799. * The pixel array for the right face.
  47800. * This is stored in format, left to right, up to down format.
  47801. */
  47802. right: Nullable<ArrayBufferView>;
  47803. /**
  47804. * The pixel array for the up face.
  47805. * This is stored in format, left to right, up to down format.
  47806. */
  47807. up: Nullable<ArrayBufferView>;
  47808. /**
  47809. * The pixel array for the down face.
  47810. * This is stored in format, left to right, up to down format.
  47811. */
  47812. down: Nullable<ArrayBufferView>;
  47813. /**
  47814. * The size of the cubemap stored.
  47815. *
  47816. * Each faces will be size * size pixels.
  47817. */
  47818. size: number;
  47819. /**
  47820. * The format of the texture.
  47821. *
  47822. * RGBA, RGB.
  47823. */
  47824. format: number;
  47825. /**
  47826. * The type of the texture data.
  47827. *
  47828. * UNSIGNED_INT, FLOAT.
  47829. */
  47830. type: number;
  47831. /**
  47832. * Specifies whether the texture is in gamma space.
  47833. */
  47834. gammaSpace: boolean;
  47835. }
  47836. /**
  47837. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47838. */
  47839. export class PanoramaToCubeMapTools {
  47840. private static FACE_FRONT;
  47841. private static FACE_BACK;
  47842. private static FACE_RIGHT;
  47843. private static FACE_LEFT;
  47844. private static FACE_DOWN;
  47845. private static FACE_UP;
  47846. /**
  47847. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47848. *
  47849. * @param float32Array The source data.
  47850. * @param inputWidth The width of the input panorama.
  47851. * @param inputHeight The height of the input panorama.
  47852. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47853. * @return The cubemap data
  47854. */
  47855. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47856. private static CreateCubemapTexture;
  47857. private static CalcProjectionSpherical;
  47858. }
  47859. }
  47860. declare module BABYLON {
  47861. /**
  47862. * Helper class dealing with the extraction of spherical polynomial dataArray
  47863. * from a cube map.
  47864. */
  47865. export class CubeMapToSphericalPolynomialTools {
  47866. private static FileFaces;
  47867. /**
  47868. * Converts a texture to the according Spherical Polynomial data.
  47869. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47870. *
  47871. * @param texture The texture to extract the information from.
  47872. * @return The Spherical Polynomial data.
  47873. */
  47874. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47875. /**
  47876. * Converts a cubemap to the according Spherical Polynomial data.
  47877. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47878. *
  47879. * @param cubeInfo The Cube map to extract the information from.
  47880. * @return The Spherical Polynomial data.
  47881. */
  47882. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47883. }
  47884. }
  47885. declare module BABYLON {
  47886. interface BaseTexture {
  47887. /**
  47888. * Get the polynomial representation of the texture data.
  47889. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47890. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47891. */
  47892. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47893. }
  47894. }
  47895. declare module BABYLON {
  47896. /** @hidden */
  47897. export var rgbdEncodePixelShader: {
  47898. name: string;
  47899. shader: string;
  47900. };
  47901. }
  47902. declare module BABYLON {
  47903. /** @hidden */
  47904. export var rgbdDecodePixelShader: {
  47905. name: string;
  47906. shader: string;
  47907. };
  47908. }
  47909. declare module BABYLON {
  47910. /**
  47911. * Raw texture data and descriptor sufficient for WebGL texture upload
  47912. */
  47913. export interface EnvironmentTextureInfo {
  47914. /**
  47915. * Version of the environment map
  47916. */
  47917. version: number;
  47918. /**
  47919. * Width of image
  47920. */
  47921. width: number;
  47922. /**
  47923. * Irradiance information stored in the file.
  47924. */
  47925. irradiance: any;
  47926. /**
  47927. * Specular information stored in the file.
  47928. */
  47929. specular: any;
  47930. }
  47931. /**
  47932. * Defines One Image in the file. It requires only the position in the file
  47933. * as well as the length.
  47934. */
  47935. interface BufferImageData {
  47936. /**
  47937. * Length of the image data.
  47938. */
  47939. length: number;
  47940. /**
  47941. * Position of the data from the null terminator delimiting the end of the JSON.
  47942. */
  47943. position: number;
  47944. }
  47945. /**
  47946. * Defines the specular data enclosed in the file.
  47947. * This corresponds to the version 1 of the data.
  47948. */
  47949. export interface EnvironmentTextureSpecularInfoV1 {
  47950. /**
  47951. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47952. */
  47953. specularDataPosition?: number;
  47954. /**
  47955. * This contains all the images data needed to reconstruct the cubemap.
  47956. */
  47957. mipmaps: Array<BufferImageData>;
  47958. /**
  47959. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47960. */
  47961. lodGenerationScale: number;
  47962. }
  47963. /**
  47964. * Sets of helpers addressing the serialization and deserialization of environment texture
  47965. * stored in a BabylonJS env file.
  47966. * Those files are usually stored as .env files.
  47967. */
  47968. export class EnvironmentTextureTools {
  47969. /**
  47970. * Magic number identifying the env file.
  47971. */
  47972. private static _MagicBytes;
  47973. /**
  47974. * Gets the environment info from an env file.
  47975. * @param data The array buffer containing the .env bytes.
  47976. * @returns the environment file info (the json header) if successfully parsed.
  47977. */
  47978. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47979. /**
  47980. * Creates an environment texture from a loaded cube texture.
  47981. * @param texture defines the cube texture to convert in env file
  47982. * @return a promise containing the environment data if succesfull.
  47983. */
  47984. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47985. /**
  47986. * Creates a JSON representation of the spherical data.
  47987. * @param texture defines the texture containing the polynomials
  47988. * @return the JSON representation of the spherical info
  47989. */
  47990. private static _CreateEnvTextureIrradiance;
  47991. /**
  47992. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47993. * @param data the image data
  47994. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47995. * @return the views described by info providing access to the underlying buffer
  47996. */
  47997. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47998. /**
  47999. * Uploads the texture info contained in the env file to the GPU.
  48000. * @param texture defines the internal texture to upload to
  48001. * @param data defines the data to load
  48002. * @param info defines the texture info retrieved through the GetEnvInfo method
  48003. * @returns a promise
  48004. */
  48005. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48006. private static _OnImageReadyAsync;
  48007. /**
  48008. * Uploads the levels of image data to the GPU.
  48009. * @param texture defines the internal texture to upload to
  48010. * @param imageData defines the array buffer views of image data [mipmap][face]
  48011. * @returns a promise
  48012. */
  48013. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48014. /**
  48015. * Uploads spherical polynomials information to the texture.
  48016. * @param texture defines the texture we are trying to upload the information to
  48017. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48018. */
  48019. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48020. /** @hidden */
  48021. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48022. }
  48023. }
  48024. declare module BABYLON {
  48025. /**
  48026. * Contains position and normal vectors for a vertex
  48027. */
  48028. export class PositionNormalVertex {
  48029. /** the position of the vertex (defaut: 0,0,0) */
  48030. position: Vector3;
  48031. /** the normal of the vertex (defaut: 0,1,0) */
  48032. normal: Vector3;
  48033. /**
  48034. * Creates a PositionNormalVertex
  48035. * @param position the position of the vertex (defaut: 0,0,0)
  48036. * @param normal the normal of the vertex (defaut: 0,1,0)
  48037. */
  48038. constructor(
  48039. /** the position of the vertex (defaut: 0,0,0) */
  48040. position?: Vector3,
  48041. /** the normal of the vertex (defaut: 0,1,0) */
  48042. normal?: Vector3);
  48043. /**
  48044. * Clones the PositionNormalVertex
  48045. * @returns the cloned PositionNormalVertex
  48046. */
  48047. clone(): PositionNormalVertex;
  48048. }
  48049. /**
  48050. * Contains position, normal and uv vectors for a vertex
  48051. */
  48052. export class PositionNormalTextureVertex {
  48053. /** the position of the vertex (defaut: 0,0,0) */
  48054. position: Vector3;
  48055. /** the normal of the vertex (defaut: 0,1,0) */
  48056. normal: Vector3;
  48057. /** the uv of the vertex (default: 0,0) */
  48058. uv: Vector2;
  48059. /**
  48060. * Creates a PositionNormalTextureVertex
  48061. * @param position the position of the vertex (defaut: 0,0,0)
  48062. * @param normal the normal of the vertex (defaut: 0,1,0)
  48063. * @param uv the uv of the vertex (default: 0,0)
  48064. */
  48065. constructor(
  48066. /** the position of the vertex (defaut: 0,0,0) */
  48067. position?: Vector3,
  48068. /** the normal of the vertex (defaut: 0,1,0) */
  48069. normal?: Vector3,
  48070. /** the uv of the vertex (default: 0,0) */
  48071. uv?: Vector2);
  48072. /**
  48073. * Clones the PositionNormalTextureVertex
  48074. * @returns the cloned PositionNormalTextureVertex
  48075. */
  48076. clone(): PositionNormalTextureVertex;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /** @hidden */
  48081. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48082. private _genericAttributeLocation;
  48083. private _varyingLocationCount;
  48084. private _varyingLocationMap;
  48085. private _replacements;
  48086. private _textureCount;
  48087. private _uniforms;
  48088. lineProcessor(line: string): string;
  48089. attributeProcessor(attribute: string): string;
  48090. varyingProcessor(varying: string, isFragment: boolean): string;
  48091. uniformProcessor(uniform: string): string;
  48092. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48093. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48094. }
  48095. }
  48096. declare module BABYLON {
  48097. /**
  48098. * Container for accessors for natively-stored mesh data buffers.
  48099. */
  48100. class NativeDataBuffer extends DataBuffer {
  48101. /**
  48102. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48103. */
  48104. nativeIndexBuffer?: any;
  48105. /**
  48106. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48107. */
  48108. nativeVertexBuffer?: any;
  48109. }
  48110. /** @hidden */
  48111. class NativeTexture extends InternalTexture {
  48112. getInternalTexture(): InternalTexture;
  48113. getViewCount(): number;
  48114. }
  48115. /** @hidden */
  48116. export class NativeEngine extends Engine {
  48117. private readonly _native;
  48118. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48119. private readonly INVALID_HANDLE;
  48120. getHardwareScalingLevel(): number;
  48121. constructor();
  48122. dispose(): void;
  48123. /**
  48124. * Can be used to override the current requestAnimationFrame requester.
  48125. * @hidden
  48126. */
  48127. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48128. /**
  48129. * Override default engine behavior.
  48130. * @param color
  48131. * @param backBuffer
  48132. * @param depth
  48133. * @param stencil
  48134. */
  48135. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48136. /**
  48137. * Gets host document
  48138. * @returns the host document object
  48139. */
  48140. getHostDocument(): Nullable<Document>;
  48141. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48142. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48143. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48144. recordVertexArrayObject(vertexBuffers: {
  48145. [key: string]: VertexBuffer;
  48146. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48147. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48148. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48149. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48150. /**
  48151. * Draw a list of indexed primitives
  48152. * @param fillMode defines the primitive to use
  48153. * @param indexStart defines the starting index
  48154. * @param indexCount defines the number of index to draw
  48155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48156. */
  48157. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48158. /**
  48159. * Draw a list of unindexed primitives
  48160. * @param fillMode defines the primitive to use
  48161. * @param verticesStart defines the index of first vertex to draw
  48162. * @param verticesCount defines the count of vertices to draw
  48163. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48164. */
  48165. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48166. createPipelineContext(): IPipelineContext;
  48167. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48168. /** @hidden */
  48169. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48170. /** @hidden */
  48171. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48172. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48173. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48174. protected _setProgram(program: WebGLProgram): void;
  48175. _releaseEffect(effect: Effect): void;
  48176. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48177. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48178. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48179. bindSamplers(effect: Effect): void;
  48180. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48181. getRenderWidth(useScreen?: boolean): number;
  48182. getRenderHeight(useScreen?: boolean): number;
  48183. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48184. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48185. /**
  48186. * Set the z offset to apply to current rendering
  48187. * @param value defines the offset to apply
  48188. */
  48189. setZOffset(value: number): void;
  48190. /**
  48191. * Gets the current value of the zOffset
  48192. * @returns the current zOffset state
  48193. */
  48194. getZOffset(): number;
  48195. /**
  48196. * Enable or disable depth buffering
  48197. * @param enable defines the state to set
  48198. */
  48199. setDepthBuffer(enable: boolean): void;
  48200. /**
  48201. * Gets a boolean indicating if depth writing is enabled
  48202. * @returns the current depth writing state
  48203. */
  48204. getDepthWrite(): boolean;
  48205. /**
  48206. * Enable or disable depth writing
  48207. * @param enable defines the state to set
  48208. */
  48209. setDepthWrite(enable: boolean): void;
  48210. /**
  48211. * Enable or disable color writing
  48212. * @param enable defines the state to set
  48213. */
  48214. setColorWrite(enable: boolean): void;
  48215. /**
  48216. * Gets a boolean indicating if color writing is enabled
  48217. * @returns the current color writing state
  48218. */
  48219. getColorWrite(): boolean;
  48220. /**
  48221. * Sets alpha constants used by some alpha blending modes
  48222. * @param r defines the red component
  48223. * @param g defines the green component
  48224. * @param b defines the blue component
  48225. * @param a defines the alpha component
  48226. */
  48227. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48228. /**
  48229. * Sets the current alpha mode
  48230. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48231. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48232. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48233. */
  48234. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48235. /**
  48236. * Gets the current alpha mode
  48237. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48238. * @returns the current alpha mode
  48239. */
  48240. getAlphaMode(): number;
  48241. setInt(uniform: WebGLUniformLocation, int: number): void;
  48242. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48243. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48244. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48245. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48246. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48247. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48248. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48249. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48250. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48251. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48252. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48253. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48254. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48255. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48256. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48257. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48258. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48259. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48260. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48261. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48262. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48263. wipeCaches(bruteForce?: boolean): void;
  48264. _createTexture(): WebGLTexture;
  48265. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48266. /**
  48267. * Usually called from Texture.ts.
  48268. * Passed information to create a WebGLTexture
  48269. * @param url defines a value which contains one of the following:
  48270. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48271. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48272. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48273. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48274. * @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)
  48275. * @param scene needed for loading to the correct scene
  48276. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48277. * @param onLoad optional callback to be called upon successful completion
  48278. * @param onError optional callback to be called upon failure
  48279. * @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
  48280. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48281. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48282. * @param forcedExtension defines the extension to use to pick the right loader
  48283. * @param mimeType defines an optional mime type
  48284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48285. */
  48286. 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;
  48287. /**
  48288. * Creates a cube texture
  48289. * @param rootUrl defines the url where the files to load is located
  48290. * @param scene defines the current scene
  48291. * @param files defines the list of files to load (1 per face)
  48292. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48293. * @param onLoad defines an optional callback raised when the texture is loaded
  48294. * @param onError defines an optional callback raised if there is an issue to load the texture
  48295. * @param format defines the format of the data
  48296. * @param forcedExtension defines the extension to use to pick the right loader
  48297. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48298. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48299. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48300. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48301. * @returns the cube texture as an InternalTexture
  48302. */
  48303. 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;
  48304. private _getSamplingFilter;
  48305. private static _GetNativeTextureFormat;
  48306. createRenderTargetTexture(size: number | {
  48307. width: number;
  48308. height: number;
  48309. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48310. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48311. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48312. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48313. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48314. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48315. /**
  48316. * Updates a dynamic vertex buffer.
  48317. * @param vertexBuffer the vertex buffer to update
  48318. * @param data the data used to update the vertex buffer
  48319. * @param byteOffset the byte offset of the data (optional)
  48320. * @param byteLength the byte length of the data (optional)
  48321. */
  48322. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48323. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48324. private _updateAnisotropicLevel;
  48325. private _getAddressMode;
  48326. /** @hidden */
  48327. _bindTexture(channel: number, texture: InternalTexture): void;
  48328. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48329. releaseEffects(): void;
  48330. /** @hidden */
  48331. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48332. /** @hidden */
  48333. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48334. /** @hidden */
  48335. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48336. /** @hidden */
  48337. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48338. }
  48339. }
  48340. declare module BABYLON {
  48341. /**
  48342. * Gather the list of clipboard event types as constants.
  48343. */
  48344. export class ClipboardEventTypes {
  48345. /**
  48346. * The clipboard event is fired when a copy command is active (pressed).
  48347. */
  48348. static readonly COPY: number;
  48349. /**
  48350. * The clipboard event is fired when a cut command is active (pressed).
  48351. */
  48352. static readonly CUT: number;
  48353. /**
  48354. * The clipboard event is fired when a paste command is active (pressed).
  48355. */
  48356. static readonly PASTE: number;
  48357. }
  48358. /**
  48359. * This class is used to store clipboard related info for the onClipboardObservable event.
  48360. */
  48361. export class ClipboardInfo {
  48362. /**
  48363. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48364. */
  48365. type: number;
  48366. /**
  48367. * Defines the related dom event
  48368. */
  48369. event: ClipboardEvent;
  48370. /**
  48371. *Creates an instance of ClipboardInfo.
  48372. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48373. * @param event Defines the related dom event
  48374. */
  48375. constructor(
  48376. /**
  48377. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48378. */
  48379. type: number,
  48380. /**
  48381. * Defines the related dom event
  48382. */
  48383. event: ClipboardEvent);
  48384. /**
  48385. * Get the clipboard event's type from the keycode.
  48386. * @param keyCode Defines the keyCode for the current keyboard event.
  48387. * @return {number}
  48388. */
  48389. static GetTypeFromCharacter(keyCode: number): number;
  48390. }
  48391. }
  48392. declare module BABYLON {
  48393. /**
  48394. * Google Daydream controller
  48395. */
  48396. export class DaydreamController extends WebVRController {
  48397. /**
  48398. * Base Url for the controller model.
  48399. */
  48400. static MODEL_BASE_URL: string;
  48401. /**
  48402. * File name for the controller model.
  48403. */
  48404. static MODEL_FILENAME: string;
  48405. /**
  48406. * Gamepad Id prefix used to identify Daydream Controller.
  48407. */
  48408. static readonly GAMEPAD_ID_PREFIX: string;
  48409. /**
  48410. * Creates a new DaydreamController from a gamepad
  48411. * @param vrGamepad the gamepad that the controller should be created from
  48412. */
  48413. constructor(vrGamepad: any);
  48414. /**
  48415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48416. * @param scene scene in which to add meshes
  48417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48418. */
  48419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48420. /**
  48421. * Called once for each button that changed state since the last frame
  48422. * @param buttonIdx Which button index changed
  48423. * @param state New state of the button
  48424. * @param changes Which properties on the state changed since last frame
  48425. */
  48426. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48427. }
  48428. }
  48429. declare module BABYLON {
  48430. /**
  48431. * Gear VR Controller
  48432. */
  48433. export class GearVRController extends WebVRController {
  48434. /**
  48435. * Base Url for the controller model.
  48436. */
  48437. static MODEL_BASE_URL: string;
  48438. /**
  48439. * File name for the controller model.
  48440. */
  48441. static MODEL_FILENAME: string;
  48442. /**
  48443. * Gamepad Id prefix used to identify this controller.
  48444. */
  48445. static readonly GAMEPAD_ID_PREFIX: string;
  48446. private readonly _buttonIndexToObservableNameMap;
  48447. /**
  48448. * Creates a new GearVRController from a gamepad
  48449. * @param vrGamepad the gamepad that the controller should be created from
  48450. */
  48451. constructor(vrGamepad: any);
  48452. /**
  48453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48454. * @param scene scene in which to add meshes
  48455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48456. */
  48457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48458. /**
  48459. * Called once for each button that changed state since the last frame
  48460. * @param buttonIdx Which button index changed
  48461. * @param state New state of the button
  48462. * @param changes Which properties on the state changed since last frame
  48463. */
  48464. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /**
  48469. * Generic Controller
  48470. */
  48471. export class GenericController extends WebVRController {
  48472. /**
  48473. * Base Url for the controller model.
  48474. */
  48475. static readonly MODEL_BASE_URL: string;
  48476. /**
  48477. * File name for the controller model.
  48478. */
  48479. static readonly MODEL_FILENAME: string;
  48480. /**
  48481. * Creates a new GenericController from a gamepad
  48482. * @param vrGamepad the gamepad that the controller should be created from
  48483. */
  48484. constructor(vrGamepad: any);
  48485. /**
  48486. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48487. * @param scene scene in which to add meshes
  48488. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48489. */
  48490. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48491. /**
  48492. * Called once for each button that changed state since the last frame
  48493. * @param buttonIdx Which button index changed
  48494. * @param state New state of the button
  48495. * @param changes Which properties on the state changed since last frame
  48496. */
  48497. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48498. }
  48499. }
  48500. declare module BABYLON {
  48501. /**
  48502. * Oculus Touch Controller
  48503. */
  48504. export class OculusTouchController extends WebVRController {
  48505. /**
  48506. * Base Url for the controller model.
  48507. */
  48508. static MODEL_BASE_URL: string;
  48509. /**
  48510. * File name for the left controller model.
  48511. */
  48512. static MODEL_LEFT_FILENAME: string;
  48513. /**
  48514. * File name for the right controller model.
  48515. */
  48516. static MODEL_RIGHT_FILENAME: string;
  48517. /**
  48518. * Base Url for the Quest controller model.
  48519. */
  48520. static QUEST_MODEL_BASE_URL: string;
  48521. /**
  48522. * @hidden
  48523. * If the controllers are running on a device that needs the updated Quest controller models
  48524. */
  48525. static _IsQuest: boolean;
  48526. /**
  48527. * Fired when the secondary trigger on this controller is modified
  48528. */
  48529. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48530. /**
  48531. * Fired when the thumb rest on this controller is modified
  48532. */
  48533. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48534. /**
  48535. * Creates a new OculusTouchController from a gamepad
  48536. * @param vrGamepad the gamepad that the controller should be created from
  48537. */
  48538. constructor(vrGamepad: any);
  48539. /**
  48540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48541. * @param scene scene in which to add meshes
  48542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48543. */
  48544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48545. /**
  48546. * Fired when the A button on this controller is modified
  48547. */
  48548. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48549. /**
  48550. * Fired when the B button on this controller is modified
  48551. */
  48552. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48553. /**
  48554. * Fired when the X button on this controller is modified
  48555. */
  48556. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48557. /**
  48558. * Fired when the Y button on this controller is modified
  48559. */
  48560. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48561. /**
  48562. * Called once for each button that changed state since the last frame
  48563. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48564. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48565. * 2) secondary trigger (same)
  48566. * 3) A (right) X (left), touch, pressed = value
  48567. * 4) B / Y
  48568. * 5) thumb rest
  48569. * @param buttonIdx Which button index changed
  48570. * @param state New state of the button
  48571. * @param changes Which properties on the state changed since last frame
  48572. */
  48573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48574. }
  48575. }
  48576. declare module BABYLON {
  48577. /**
  48578. * Vive Controller
  48579. */
  48580. export class ViveController extends WebVRController {
  48581. /**
  48582. * Base Url for the controller model.
  48583. */
  48584. static MODEL_BASE_URL: string;
  48585. /**
  48586. * File name for the controller model.
  48587. */
  48588. static MODEL_FILENAME: string;
  48589. /**
  48590. * Creates a new ViveController from a gamepad
  48591. * @param vrGamepad the gamepad that the controller should be created from
  48592. */
  48593. constructor(vrGamepad: any);
  48594. /**
  48595. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48596. * @param scene scene in which to add meshes
  48597. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48598. */
  48599. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48600. /**
  48601. * Fired when the left button on this controller is modified
  48602. */
  48603. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48604. /**
  48605. * Fired when the right button on this controller is modified
  48606. */
  48607. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48608. /**
  48609. * Fired when the menu button on this controller is modified
  48610. */
  48611. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48612. /**
  48613. * Called once for each button that changed state since the last frame
  48614. * Vive mapping:
  48615. * 0: touchpad
  48616. * 1: trigger
  48617. * 2: left AND right buttons
  48618. * 3: menu button
  48619. * @param buttonIdx Which button index changed
  48620. * @param state New state of the button
  48621. * @param changes Which properties on the state changed since last frame
  48622. */
  48623. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48624. }
  48625. }
  48626. declare module BABYLON {
  48627. /**
  48628. * Defines the WindowsMotionController object that the state of the windows motion controller
  48629. */
  48630. export class WindowsMotionController extends WebVRController {
  48631. /**
  48632. * The base url used to load the left and right controller models
  48633. */
  48634. static MODEL_BASE_URL: string;
  48635. /**
  48636. * The name of the left controller model file
  48637. */
  48638. static MODEL_LEFT_FILENAME: string;
  48639. /**
  48640. * The name of the right controller model file
  48641. */
  48642. static MODEL_RIGHT_FILENAME: string;
  48643. /**
  48644. * The controller name prefix for this controller type
  48645. */
  48646. static readonly GAMEPAD_ID_PREFIX: string;
  48647. /**
  48648. * The controller id pattern for this controller type
  48649. */
  48650. private static readonly GAMEPAD_ID_PATTERN;
  48651. private _loadedMeshInfo;
  48652. protected readonly _mapping: {
  48653. buttons: string[];
  48654. buttonMeshNames: {
  48655. trigger: string;
  48656. menu: string;
  48657. grip: string;
  48658. thumbstick: string;
  48659. trackpad: string;
  48660. };
  48661. buttonObservableNames: {
  48662. trigger: string;
  48663. menu: string;
  48664. grip: string;
  48665. thumbstick: string;
  48666. trackpad: string;
  48667. };
  48668. axisMeshNames: string[];
  48669. pointingPoseMeshName: string;
  48670. };
  48671. /**
  48672. * Fired when the trackpad on this controller is clicked
  48673. */
  48674. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48675. /**
  48676. * Fired when the trackpad on this controller is modified
  48677. */
  48678. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48679. /**
  48680. * The current x and y values of this controller's trackpad
  48681. */
  48682. trackpad: StickValues;
  48683. /**
  48684. * Creates a new WindowsMotionController from a gamepad
  48685. * @param vrGamepad the gamepad that the controller should be created from
  48686. */
  48687. constructor(vrGamepad: any);
  48688. /**
  48689. * Fired when the trigger on this controller is modified
  48690. */
  48691. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48692. /**
  48693. * Fired when the menu button on this controller is modified
  48694. */
  48695. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48696. /**
  48697. * Fired when the grip button on this controller is modified
  48698. */
  48699. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48700. /**
  48701. * Fired when the thumbstick button on this controller is modified
  48702. */
  48703. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48704. /**
  48705. * Fired when the touchpad button on this controller is modified
  48706. */
  48707. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48708. /**
  48709. * Fired when the touchpad values on this controller are modified
  48710. */
  48711. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48712. protected _updateTrackpad(): void;
  48713. /**
  48714. * Called once per frame by the engine.
  48715. */
  48716. update(): void;
  48717. /**
  48718. * Called once for each button that changed state since the last frame
  48719. * @param buttonIdx Which button index changed
  48720. * @param state New state of the button
  48721. * @param changes Which properties on the state changed since last frame
  48722. */
  48723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48724. /**
  48725. * Moves the buttons on the controller mesh based on their current state
  48726. * @param buttonName the name of the button to move
  48727. * @param buttonValue the value of the button which determines the buttons new position
  48728. */
  48729. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48730. /**
  48731. * Moves the axis on the controller mesh based on its current state
  48732. * @param axis the index of the axis
  48733. * @param axisValue the value of the axis which determines the meshes new position
  48734. * @hidden
  48735. */
  48736. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48737. /**
  48738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48739. * @param scene scene in which to add meshes
  48740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48741. */
  48742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48743. /**
  48744. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48745. * can be transformed by button presses and axes values, based on this._mapping.
  48746. *
  48747. * @param scene scene in which the meshes exist
  48748. * @param meshes list of meshes that make up the controller model to process
  48749. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48750. */
  48751. private processModel;
  48752. private createMeshInfo;
  48753. /**
  48754. * Gets the ray of the controller in the direction the controller is pointing
  48755. * @param length the length the resulting ray should be
  48756. * @returns a ray in the direction the controller is pointing
  48757. */
  48758. getForwardRay(length?: number): Ray;
  48759. /**
  48760. * Disposes of the controller
  48761. */
  48762. dispose(): void;
  48763. }
  48764. /**
  48765. * This class represents a new windows motion controller in XR.
  48766. */
  48767. export class XRWindowsMotionController extends WindowsMotionController {
  48768. /**
  48769. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48770. */
  48771. protected readonly _mapping: {
  48772. buttons: string[];
  48773. buttonMeshNames: {
  48774. trigger: string;
  48775. menu: string;
  48776. grip: string;
  48777. thumbstick: string;
  48778. trackpad: string;
  48779. };
  48780. buttonObservableNames: {
  48781. trigger: string;
  48782. menu: string;
  48783. grip: string;
  48784. thumbstick: string;
  48785. trackpad: string;
  48786. };
  48787. axisMeshNames: string[];
  48788. pointingPoseMeshName: string;
  48789. };
  48790. /**
  48791. * Construct a new XR-Based windows motion controller
  48792. *
  48793. * @param gamepadInfo the gamepad object from the browser
  48794. */
  48795. constructor(gamepadInfo: any);
  48796. /**
  48797. * holds the thumbstick values (X,Y)
  48798. */
  48799. thumbstickValues: StickValues;
  48800. /**
  48801. * Fired when the thumbstick on this controller is clicked
  48802. */
  48803. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48804. /**
  48805. * Fired when the thumbstick on this controller is modified
  48806. */
  48807. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48808. /**
  48809. * Fired when the touchpad button on this controller is modified
  48810. */
  48811. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48812. /**
  48813. * Fired when the touchpad values on this controller are modified
  48814. */
  48815. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48816. /**
  48817. * Fired when the thumbstick button on this controller is modified
  48818. * here to prevent breaking changes
  48819. */
  48820. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48821. /**
  48822. * updating the thumbstick(!) and not the trackpad.
  48823. * This is named this way due to the difference between WebVR and XR and to avoid
  48824. * changing the parent class.
  48825. */
  48826. protected _updateTrackpad(): void;
  48827. /**
  48828. * Disposes the class with joy
  48829. */
  48830. dispose(): void;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * Class containing static functions to help procedurally build meshes
  48836. */
  48837. export class PolyhedronBuilder {
  48838. /**
  48839. * Creates a polyhedron mesh
  48840. * * 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
  48841. * * The parameter `size` (positive float, default 1) sets the polygon size
  48842. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48843. * * 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`
  48844. * * 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
  48845. * * 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)`)
  48846. * * 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
  48847. * * 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
  48848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48849. * * 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
  48850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48851. * @param name defines the name of the mesh
  48852. * @param options defines the options used to create the mesh
  48853. * @param scene defines the hosting scene
  48854. * @returns the polyhedron mesh
  48855. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48856. */
  48857. static CreatePolyhedron(name: string, options: {
  48858. type?: number;
  48859. size?: number;
  48860. sizeX?: number;
  48861. sizeY?: number;
  48862. sizeZ?: number;
  48863. custom?: any;
  48864. faceUV?: Vector4[];
  48865. faceColors?: Color4[];
  48866. flat?: boolean;
  48867. updatable?: boolean;
  48868. sideOrientation?: number;
  48869. frontUVs?: Vector4;
  48870. backUVs?: Vector4;
  48871. }, scene?: Nullable<Scene>): Mesh;
  48872. }
  48873. }
  48874. declare module BABYLON {
  48875. /**
  48876. * Gizmo that enables scaling a mesh along 3 axis
  48877. */
  48878. export class ScaleGizmo extends Gizmo {
  48879. /**
  48880. * Internal gizmo used for interactions on the x axis
  48881. */
  48882. xGizmo: AxisScaleGizmo;
  48883. /**
  48884. * Internal gizmo used for interactions on the y axis
  48885. */
  48886. yGizmo: AxisScaleGizmo;
  48887. /**
  48888. * Internal gizmo used for interactions on the z axis
  48889. */
  48890. zGizmo: AxisScaleGizmo;
  48891. /**
  48892. * Internal gizmo used to scale all axis equally
  48893. */
  48894. uniformScaleGizmo: AxisScaleGizmo;
  48895. private _meshAttached;
  48896. private _updateGizmoRotationToMatchAttachedMesh;
  48897. private _snapDistance;
  48898. private _scaleRatio;
  48899. private _uniformScalingMesh;
  48900. private _octahedron;
  48901. private _sensitivity;
  48902. /** Fires an event when any of it's sub gizmos are dragged */
  48903. onDragStartObservable: Observable<unknown>;
  48904. /** Fires an event when any of it's sub gizmos are released from dragging */
  48905. onDragEndObservable: Observable<unknown>;
  48906. get attachedMesh(): Nullable<AbstractMesh>;
  48907. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48908. /**
  48909. * Creates a ScaleGizmo
  48910. * @param gizmoLayer The utility layer the gizmo will be added to
  48911. */
  48912. constructor(gizmoLayer?: UtilityLayerRenderer);
  48913. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48914. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48915. /**
  48916. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48917. */
  48918. set snapDistance(value: number);
  48919. get snapDistance(): number;
  48920. /**
  48921. * Ratio for the scale of the gizmo (Default: 1)
  48922. */
  48923. set scaleRatio(value: number);
  48924. get scaleRatio(): number;
  48925. /**
  48926. * Sensitivity factor for dragging (Default: 1)
  48927. */
  48928. set sensitivity(value: number);
  48929. get sensitivity(): number;
  48930. /**
  48931. * Disposes of the gizmo
  48932. */
  48933. dispose(): void;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Single axis scale gizmo
  48939. */
  48940. export class AxisScaleGizmo extends Gizmo {
  48941. /**
  48942. * Drag behavior responsible for the gizmos dragging interactions
  48943. */
  48944. dragBehavior: PointerDragBehavior;
  48945. private _pointerObserver;
  48946. /**
  48947. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48948. */
  48949. snapDistance: number;
  48950. /**
  48951. * Event that fires each time the gizmo snaps to a new location.
  48952. * * snapDistance is the the change in distance
  48953. */
  48954. onSnapObservable: Observable<{
  48955. snapDistance: number;
  48956. }>;
  48957. /**
  48958. * If the scaling operation should be done on all axis (default: false)
  48959. */
  48960. uniformScaling: boolean;
  48961. /**
  48962. * Custom sensitivity value for the drag strength
  48963. */
  48964. sensitivity: number;
  48965. private _isEnabled;
  48966. private _parent;
  48967. private _arrow;
  48968. private _coloredMaterial;
  48969. private _hoverMaterial;
  48970. /**
  48971. * Creates an AxisScaleGizmo
  48972. * @param gizmoLayer The utility layer the gizmo will be added to
  48973. * @param dragAxis The axis which the gizmo will be able to scale on
  48974. * @param color The color of the gizmo
  48975. */
  48976. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48977. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48978. /**
  48979. * If the gizmo is enabled
  48980. */
  48981. set isEnabled(value: boolean);
  48982. get isEnabled(): boolean;
  48983. /**
  48984. * Disposes of the gizmo
  48985. */
  48986. dispose(): void;
  48987. /**
  48988. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48989. * @param mesh The mesh to replace the default mesh of the gizmo
  48990. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48991. */
  48992. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48993. }
  48994. }
  48995. declare module BABYLON {
  48996. /**
  48997. * Bounding box gizmo
  48998. */
  48999. export class BoundingBoxGizmo extends Gizmo {
  49000. private _lineBoundingBox;
  49001. private _rotateSpheresParent;
  49002. private _scaleBoxesParent;
  49003. private _boundingDimensions;
  49004. private _renderObserver;
  49005. private _pointerObserver;
  49006. private _scaleDragSpeed;
  49007. private _tmpQuaternion;
  49008. private _tmpVector;
  49009. private _tmpRotationMatrix;
  49010. /**
  49011. * 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)
  49012. */
  49013. ignoreChildren: boolean;
  49014. /**
  49015. * 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)
  49016. */
  49017. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49018. /**
  49019. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49020. */
  49021. rotationSphereSize: number;
  49022. /**
  49023. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49024. */
  49025. scaleBoxSize: number;
  49026. /**
  49027. * 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)
  49028. */
  49029. fixedDragMeshScreenSize: boolean;
  49030. /**
  49031. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49032. */
  49033. fixedDragMeshScreenSizeDistanceFactor: number;
  49034. /**
  49035. * Fired when a rotation sphere or scale box is dragged
  49036. */
  49037. onDragStartObservable: Observable<{}>;
  49038. /**
  49039. * Fired when a scale box is dragged
  49040. */
  49041. onScaleBoxDragObservable: Observable<{}>;
  49042. /**
  49043. * Fired when a scale box drag is ended
  49044. */
  49045. onScaleBoxDragEndObservable: Observable<{}>;
  49046. /**
  49047. * Fired when a rotation sphere is dragged
  49048. */
  49049. onRotationSphereDragObservable: Observable<{}>;
  49050. /**
  49051. * Fired when a rotation sphere drag is ended
  49052. */
  49053. onRotationSphereDragEndObservable: Observable<{}>;
  49054. /**
  49055. * 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)
  49056. */
  49057. scalePivot: Nullable<Vector3>;
  49058. /**
  49059. * Mesh used as a pivot to rotate the attached mesh
  49060. */
  49061. private _anchorMesh;
  49062. private _existingMeshScale;
  49063. private _dragMesh;
  49064. private pointerDragBehavior;
  49065. private coloredMaterial;
  49066. private hoverColoredMaterial;
  49067. /**
  49068. * Sets the color of the bounding box gizmo
  49069. * @param color the color to set
  49070. */
  49071. setColor(color: Color3): void;
  49072. /**
  49073. * Creates an BoundingBoxGizmo
  49074. * @param gizmoLayer The utility layer the gizmo will be added to
  49075. * @param color The color of the gizmo
  49076. */
  49077. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49078. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49079. private _selectNode;
  49080. /**
  49081. * Updates the bounding box information for the Gizmo
  49082. */
  49083. updateBoundingBox(): void;
  49084. private _updateRotationSpheres;
  49085. private _updateScaleBoxes;
  49086. /**
  49087. * Enables rotation on the specified axis and disables rotation on the others
  49088. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49089. */
  49090. setEnabledRotationAxis(axis: string): void;
  49091. /**
  49092. * Enables/disables scaling
  49093. * @param enable if scaling should be enabled
  49094. * @param homogeneousScaling defines if scaling should only be homogeneous
  49095. */
  49096. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49097. private _updateDummy;
  49098. /**
  49099. * Enables a pointer drag behavior on the bounding box of the gizmo
  49100. */
  49101. enableDragBehavior(): void;
  49102. /**
  49103. * Disposes of the gizmo
  49104. */
  49105. dispose(): void;
  49106. /**
  49107. * 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)
  49108. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49109. * @returns the bounding box mesh with the passed in mesh as a child
  49110. */
  49111. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49112. /**
  49113. * CustomMeshes are not supported by this gizmo
  49114. * @param mesh The mesh to replace the default mesh of the gizmo
  49115. */
  49116. setCustomMesh(mesh: Mesh): void;
  49117. }
  49118. }
  49119. declare module BABYLON {
  49120. /**
  49121. * Single plane rotation gizmo
  49122. */
  49123. export class PlaneRotationGizmo extends Gizmo {
  49124. /**
  49125. * Drag behavior responsible for the gizmos dragging interactions
  49126. */
  49127. dragBehavior: PointerDragBehavior;
  49128. private _pointerObserver;
  49129. /**
  49130. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49131. */
  49132. snapDistance: number;
  49133. /**
  49134. * Event that fires each time the gizmo snaps to a new location.
  49135. * * snapDistance is the the change in distance
  49136. */
  49137. onSnapObservable: Observable<{
  49138. snapDistance: number;
  49139. }>;
  49140. private _isEnabled;
  49141. private _parent;
  49142. /**
  49143. * Creates a PlaneRotationGizmo
  49144. * @param gizmoLayer The utility layer the gizmo will be added to
  49145. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49146. * @param color The color of the gizmo
  49147. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49148. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49149. */
  49150. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49152. /**
  49153. * If the gizmo is enabled
  49154. */
  49155. set isEnabled(value: boolean);
  49156. get isEnabled(): boolean;
  49157. /**
  49158. * Disposes of the gizmo
  49159. */
  49160. dispose(): void;
  49161. }
  49162. }
  49163. declare module BABYLON {
  49164. /**
  49165. * Gizmo that enables rotating a mesh along 3 axis
  49166. */
  49167. export class RotationGizmo extends Gizmo {
  49168. /**
  49169. * Internal gizmo used for interactions on the x axis
  49170. */
  49171. xGizmo: PlaneRotationGizmo;
  49172. /**
  49173. * Internal gizmo used for interactions on the y axis
  49174. */
  49175. yGizmo: PlaneRotationGizmo;
  49176. /**
  49177. * Internal gizmo used for interactions on the z axis
  49178. */
  49179. zGizmo: PlaneRotationGizmo;
  49180. /** Fires an event when any of it's sub gizmos are dragged */
  49181. onDragStartObservable: Observable<unknown>;
  49182. /** Fires an event when any of it's sub gizmos are released from dragging */
  49183. onDragEndObservable: Observable<unknown>;
  49184. private _meshAttached;
  49185. get attachedMesh(): Nullable<AbstractMesh>;
  49186. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49187. /**
  49188. * Creates a RotationGizmo
  49189. * @param gizmoLayer The utility layer the gizmo will be added to
  49190. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49191. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49192. */
  49193. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49194. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49195. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49196. /**
  49197. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49198. */
  49199. set snapDistance(value: number);
  49200. get snapDistance(): number;
  49201. /**
  49202. * Ratio for the scale of the gizmo (Default: 1)
  49203. */
  49204. set scaleRatio(value: number);
  49205. get scaleRatio(): number;
  49206. /**
  49207. * Disposes of the gizmo
  49208. */
  49209. dispose(): void;
  49210. /**
  49211. * CustomMeshes are not supported by this gizmo
  49212. * @param mesh The mesh to replace the default mesh of the gizmo
  49213. */
  49214. setCustomMesh(mesh: Mesh): void;
  49215. }
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49220. */
  49221. export class GizmoManager implements IDisposable {
  49222. private scene;
  49223. /**
  49224. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49225. */
  49226. gizmos: {
  49227. positionGizmo: Nullable<PositionGizmo>;
  49228. rotationGizmo: Nullable<RotationGizmo>;
  49229. scaleGizmo: Nullable<ScaleGizmo>;
  49230. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49231. };
  49232. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49233. clearGizmoOnEmptyPointerEvent: boolean;
  49234. /** Fires an event when the manager is attached to a mesh */
  49235. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49236. private _gizmosEnabled;
  49237. private _pointerObserver;
  49238. private _attachedMesh;
  49239. private _boundingBoxColor;
  49240. private _defaultUtilityLayer;
  49241. private _defaultKeepDepthUtilityLayer;
  49242. /**
  49243. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49244. */
  49245. boundingBoxDragBehavior: SixDofDragBehavior;
  49246. /**
  49247. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49248. */
  49249. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49250. /**
  49251. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49252. */
  49253. usePointerToAttachGizmos: boolean;
  49254. /**
  49255. * Utility layer that the bounding box gizmo belongs to
  49256. */
  49257. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49258. /**
  49259. * Utility layer that all gizmos besides bounding box belong to
  49260. */
  49261. get utilityLayer(): UtilityLayerRenderer;
  49262. /**
  49263. * Instatiates a gizmo manager
  49264. * @param scene the scene to overlay the gizmos on top of
  49265. */
  49266. constructor(scene: Scene);
  49267. /**
  49268. * Attaches a set of gizmos to the specified mesh
  49269. * @param mesh The mesh the gizmo's should be attached to
  49270. */
  49271. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49272. /**
  49273. * If the position gizmo is enabled
  49274. */
  49275. set positionGizmoEnabled(value: boolean);
  49276. get positionGizmoEnabled(): boolean;
  49277. /**
  49278. * If the rotation gizmo is enabled
  49279. */
  49280. set rotationGizmoEnabled(value: boolean);
  49281. get rotationGizmoEnabled(): boolean;
  49282. /**
  49283. * If the scale gizmo is enabled
  49284. */
  49285. set scaleGizmoEnabled(value: boolean);
  49286. get scaleGizmoEnabled(): boolean;
  49287. /**
  49288. * If the boundingBox gizmo is enabled
  49289. */
  49290. set boundingBoxGizmoEnabled(value: boolean);
  49291. get boundingBoxGizmoEnabled(): boolean;
  49292. /**
  49293. * Disposes of the gizmo manager
  49294. */
  49295. dispose(): void;
  49296. }
  49297. }
  49298. declare module BABYLON {
  49299. /**
  49300. * A directional light is defined by a direction (what a surprise!).
  49301. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49302. * 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.
  49303. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49304. */
  49305. export class DirectionalLight extends ShadowLight {
  49306. private _shadowFrustumSize;
  49307. /**
  49308. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49309. */
  49310. get shadowFrustumSize(): number;
  49311. /**
  49312. * Specifies a fix frustum size for the shadow generation.
  49313. */
  49314. set shadowFrustumSize(value: number);
  49315. private _shadowOrthoScale;
  49316. /**
  49317. * Gets the shadow projection scale against the optimal computed one.
  49318. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49319. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49320. */
  49321. get shadowOrthoScale(): number;
  49322. /**
  49323. * Sets the shadow projection scale against the optimal computed one.
  49324. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49325. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49326. */
  49327. set shadowOrthoScale(value: number);
  49328. /**
  49329. * Automatically compute the projection matrix to best fit (including all the casters)
  49330. * on each frame.
  49331. */
  49332. autoUpdateExtends: boolean;
  49333. /**
  49334. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49335. * on each frame. autoUpdateExtends must be set to true for this to work
  49336. */
  49337. autoCalcShadowZBounds: boolean;
  49338. private _orthoLeft;
  49339. private _orthoRight;
  49340. private _orthoTop;
  49341. private _orthoBottom;
  49342. /**
  49343. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49344. * The directional light is emitted from everywhere in the given direction.
  49345. * It can cast shadows.
  49346. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49347. * @param name The friendly name of the light
  49348. * @param direction The direction of the light
  49349. * @param scene The scene the light belongs to
  49350. */
  49351. constructor(name: string, direction: Vector3, scene: Scene);
  49352. /**
  49353. * Returns the string "DirectionalLight".
  49354. * @return The class name
  49355. */
  49356. getClassName(): string;
  49357. /**
  49358. * Returns the integer 1.
  49359. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49360. */
  49361. getTypeID(): number;
  49362. /**
  49363. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49364. * Returns the DirectionalLight Shadow projection matrix.
  49365. */
  49366. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49367. /**
  49368. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49369. * Returns the DirectionalLight Shadow projection matrix.
  49370. */
  49371. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49372. /**
  49373. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49374. * Returns the DirectionalLight Shadow projection matrix.
  49375. */
  49376. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49377. protected _buildUniformLayout(): void;
  49378. /**
  49379. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49380. * @param effect The effect to update
  49381. * @param lightIndex The index of the light in the effect to update
  49382. * @returns The directional light
  49383. */
  49384. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49385. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49386. /**
  49387. * Gets the minZ used for shadow according to both the scene and the light.
  49388. *
  49389. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49390. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49391. * @param activeCamera The camera we are returning the min for
  49392. * @returns the depth min z
  49393. */
  49394. getDepthMinZ(activeCamera: Camera): number;
  49395. /**
  49396. * Gets the maxZ used for shadow according to both the scene and the light.
  49397. *
  49398. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49399. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49400. * @param activeCamera The camera we are returning the max for
  49401. * @returns the depth max z
  49402. */
  49403. getDepthMaxZ(activeCamera: Camera): number;
  49404. /**
  49405. * Prepares the list of defines specific to the light type.
  49406. * @param defines the list of defines
  49407. * @param lightIndex defines the index of the light for the effect
  49408. */
  49409. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49410. }
  49411. }
  49412. declare module BABYLON {
  49413. /**
  49414. * Class containing static functions to help procedurally build meshes
  49415. */
  49416. export class HemisphereBuilder {
  49417. /**
  49418. * Creates a hemisphere mesh
  49419. * @param name defines the name of the mesh
  49420. * @param options defines the options used to create the mesh
  49421. * @param scene defines the hosting scene
  49422. * @returns the hemisphere mesh
  49423. */
  49424. static CreateHemisphere(name: string, options: {
  49425. segments?: number;
  49426. diameter?: number;
  49427. sideOrientation?: number;
  49428. }, scene: any): Mesh;
  49429. }
  49430. }
  49431. declare module BABYLON {
  49432. /**
  49433. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49434. * These values define a cone of light starting from the position, emitting toward the direction.
  49435. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49436. * and the exponent defines the speed of the decay of the light with distance (reach).
  49437. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49438. */
  49439. export class SpotLight extends ShadowLight {
  49440. private _angle;
  49441. private _innerAngle;
  49442. private _cosHalfAngle;
  49443. private _lightAngleScale;
  49444. private _lightAngleOffset;
  49445. /**
  49446. * Gets the cone angle of the spot light in Radians.
  49447. */
  49448. get angle(): number;
  49449. /**
  49450. * Sets the cone angle of the spot light in Radians.
  49451. */
  49452. set angle(value: number);
  49453. /**
  49454. * Only used in gltf falloff mode, this defines the angle where
  49455. * the directional falloff will start before cutting at angle which could be seen
  49456. * as outer angle.
  49457. */
  49458. get innerAngle(): number;
  49459. /**
  49460. * Only used in gltf falloff mode, this defines the angle where
  49461. * the directional falloff will start before cutting at angle which could be seen
  49462. * as outer angle.
  49463. */
  49464. set innerAngle(value: number);
  49465. private _shadowAngleScale;
  49466. /**
  49467. * Allows scaling the angle of the light for shadow generation only.
  49468. */
  49469. get shadowAngleScale(): number;
  49470. /**
  49471. * Allows scaling the angle of the light for shadow generation only.
  49472. */
  49473. set shadowAngleScale(value: number);
  49474. /**
  49475. * The light decay speed with the distance from the emission spot.
  49476. */
  49477. exponent: number;
  49478. private _projectionTextureMatrix;
  49479. /**
  49480. * Allows reading the projecton texture
  49481. */
  49482. get projectionTextureMatrix(): Matrix;
  49483. protected _projectionTextureLightNear: number;
  49484. /**
  49485. * Gets the near clip of the Spotlight for texture projection.
  49486. */
  49487. get projectionTextureLightNear(): number;
  49488. /**
  49489. * Sets the near clip of the Spotlight for texture projection.
  49490. */
  49491. set projectionTextureLightNear(value: number);
  49492. protected _projectionTextureLightFar: number;
  49493. /**
  49494. * Gets the far clip of the Spotlight for texture projection.
  49495. */
  49496. get projectionTextureLightFar(): number;
  49497. /**
  49498. * Sets the far clip of the Spotlight for texture projection.
  49499. */
  49500. set projectionTextureLightFar(value: number);
  49501. protected _projectionTextureUpDirection: Vector3;
  49502. /**
  49503. * Gets the Up vector of the Spotlight for texture projection.
  49504. */
  49505. get projectionTextureUpDirection(): Vector3;
  49506. /**
  49507. * Sets the Up vector of the Spotlight for texture projection.
  49508. */
  49509. set projectionTextureUpDirection(value: Vector3);
  49510. private _projectionTexture;
  49511. /**
  49512. * Gets the projection texture of the light.
  49513. */
  49514. get projectionTexture(): Nullable<BaseTexture>;
  49515. /**
  49516. * Sets the projection texture of the light.
  49517. */
  49518. set projectionTexture(value: Nullable<BaseTexture>);
  49519. private _projectionTextureViewLightDirty;
  49520. private _projectionTextureProjectionLightDirty;
  49521. private _projectionTextureDirty;
  49522. private _projectionTextureViewTargetVector;
  49523. private _projectionTextureViewLightMatrix;
  49524. private _projectionTextureProjectionLightMatrix;
  49525. private _projectionTextureScalingMatrix;
  49526. /**
  49527. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49528. * It can cast shadows.
  49529. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49530. * @param name The light friendly name
  49531. * @param position The position of the spot light in the scene
  49532. * @param direction The direction of the light in the scene
  49533. * @param angle The cone angle of the light in Radians
  49534. * @param exponent The light decay speed with the distance from the emission spot
  49535. * @param scene The scene the lights belongs to
  49536. */
  49537. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49538. /**
  49539. * Returns the string "SpotLight".
  49540. * @returns the class name
  49541. */
  49542. getClassName(): string;
  49543. /**
  49544. * Returns the integer 2.
  49545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49546. */
  49547. getTypeID(): number;
  49548. /**
  49549. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49550. */
  49551. protected _setDirection(value: Vector3): void;
  49552. /**
  49553. * Overrides the position setter to recompute the projection texture view light Matrix.
  49554. */
  49555. protected _setPosition(value: Vector3): void;
  49556. /**
  49557. * 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.
  49558. * Returns the SpotLight.
  49559. */
  49560. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49561. protected _computeProjectionTextureViewLightMatrix(): void;
  49562. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49563. /**
  49564. * Main function for light texture projection matrix computing.
  49565. */
  49566. protected _computeProjectionTextureMatrix(): void;
  49567. protected _buildUniformLayout(): void;
  49568. private _computeAngleValues;
  49569. /**
  49570. * Sets the passed Effect "effect" with the Light textures.
  49571. * @param effect The effect to update
  49572. * @param lightIndex The index of the light in the effect to update
  49573. * @returns The light
  49574. */
  49575. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49576. /**
  49577. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49578. * @param effect The effect to update
  49579. * @param lightIndex The index of the light in the effect to update
  49580. * @returns The spot light
  49581. */
  49582. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49583. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49584. /**
  49585. * Disposes the light and the associated resources.
  49586. */
  49587. dispose(): void;
  49588. /**
  49589. * Prepares the list of defines specific to the light type.
  49590. * @param defines the list of defines
  49591. * @param lightIndex defines the index of the light for the effect
  49592. */
  49593. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49594. }
  49595. }
  49596. declare module BABYLON {
  49597. /**
  49598. * Gizmo that enables viewing a light
  49599. */
  49600. export class LightGizmo extends Gizmo {
  49601. private _lightMesh;
  49602. private _material;
  49603. private _cachedPosition;
  49604. private _cachedForward;
  49605. private _attachedMeshParent;
  49606. /**
  49607. * Creates a LightGizmo
  49608. * @param gizmoLayer The utility layer the gizmo will be added to
  49609. */
  49610. constructor(gizmoLayer?: UtilityLayerRenderer);
  49611. private _light;
  49612. /**
  49613. * The light that the gizmo is attached to
  49614. */
  49615. set light(light: Nullable<Light>);
  49616. get light(): Nullable<Light>;
  49617. /**
  49618. * Gets the material used to render the light gizmo
  49619. */
  49620. get material(): StandardMaterial;
  49621. /**
  49622. * @hidden
  49623. * Updates the gizmo to match the attached mesh's position/rotation
  49624. */
  49625. protected _update(): void;
  49626. private static _Scale;
  49627. /**
  49628. * Creates the lines for a light mesh
  49629. */
  49630. private static _CreateLightLines;
  49631. /**
  49632. * Disposes of the light gizmo
  49633. */
  49634. dispose(): void;
  49635. private static _CreateHemisphericLightMesh;
  49636. private static _CreatePointLightMesh;
  49637. private static _CreateSpotLightMesh;
  49638. private static _CreateDirectionalLightMesh;
  49639. }
  49640. }
  49641. declare module BABYLON {
  49642. /** @hidden */
  49643. export var backgroundFragmentDeclaration: {
  49644. name: string;
  49645. shader: string;
  49646. };
  49647. }
  49648. declare module BABYLON {
  49649. /** @hidden */
  49650. export var backgroundUboDeclaration: {
  49651. name: string;
  49652. shader: string;
  49653. };
  49654. }
  49655. declare module BABYLON {
  49656. /** @hidden */
  49657. export var backgroundPixelShader: {
  49658. name: string;
  49659. shader: string;
  49660. };
  49661. }
  49662. declare module BABYLON {
  49663. /** @hidden */
  49664. export var backgroundVertexDeclaration: {
  49665. name: string;
  49666. shader: string;
  49667. };
  49668. }
  49669. declare module BABYLON {
  49670. /** @hidden */
  49671. export var backgroundVertexShader: {
  49672. name: string;
  49673. shader: string;
  49674. };
  49675. }
  49676. declare module BABYLON {
  49677. /**
  49678. * Background material used to create an efficient environement around your scene.
  49679. */
  49680. export class BackgroundMaterial extends PushMaterial {
  49681. /**
  49682. * Standard reflectance value at parallel view angle.
  49683. */
  49684. static StandardReflectance0: number;
  49685. /**
  49686. * Standard reflectance value at grazing angle.
  49687. */
  49688. static StandardReflectance90: number;
  49689. protected _primaryColor: Color3;
  49690. /**
  49691. * Key light Color (multiply against the environement texture)
  49692. */
  49693. primaryColor: Color3;
  49694. protected __perceptualColor: Nullable<Color3>;
  49695. /**
  49696. * Experimental Internal Use Only.
  49697. *
  49698. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49699. * This acts as a helper to set the primary color to a more "human friendly" value.
  49700. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49701. * output color as close as possible from the chosen value.
  49702. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49703. * part of lighting setup.)
  49704. */
  49705. get _perceptualColor(): Nullable<Color3>;
  49706. set _perceptualColor(value: Nullable<Color3>);
  49707. protected _primaryColorShadowLevel: float;
  49708. /**
  49709. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49710. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49711. */
  49712. get primaryColorShadowLevel(): float;
  49713. set primaryColorShadowLevel(value: float);
  49714. protected _primaryColorHighlightLevel: float;
  49715. /**
  49716. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49717. * The primary color is used at the level chosen to define what the white area would look.
  49718. */
  49719. get primaryColorHighlightLevel(): float;
  49720. set primaryColorHighlightLevel(value: float);
  49721. protected _reflectionTexture: Nullable<BaseTexture>;
  49722. /**
  49723. * Reflection Texture used in the material.
  49724. * Should be author in a specific way for the best result (refer to the documentation).
  49725. */
  49726. reflectionTexture: Nullable<BaseTexture>;
  49727. protected _reflectionBlur: float;
  49728. /**
  49729. * Reflection Texture level of blur.
  49730. *
  49731. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49732. * texture twice.
  49733. */
  49734. reflectionBlur: float;
  49735. protected _diffuseTexture: Nullable<BaseTexture>;
  49736. /**
  49737. * Diffuse Texture used in the material.
  49738. * Should be author in a specific way for the best result (refer to the documentation).
  49739. */
  49740. diffuseTexture: Nullable<BaseTexture>;
  49741. protected _shadowLights: Nullable<IShadowLight[]>;
  49742. /**
  49743. * Specify the list of lights casting shadow on the material.
  49744. * All scene shadow lights will be included if null.
  49745. */
  49746. shadowLights: Nullable<IShadowLight[]>;
  49747. protected _shadowLevel: float;
  49748. /**
  49749. * Helps adjusting the shadow to a softer level if required.
  49750. * 0 means black shadows and 1 means no shadows.
  49751. */
  49752. shadowLevel: float;
  49753. protected _sceneCenter: Vector3;
  49754. /**
  49755. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49756. * It is usually zero but might be interesting to modify according to your setup.
  49757. */
  49758. sceneCenter: Vector3;
  49759. protected _opacityFresnel: boolean;
  49760. /**
  49761. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49762. * This helps ensuring a nice transition when the camera goes under the ground.
  49763. */
  49764. opacityFresnel: boolean;
  49765. protected _reflectionFresnel: boolean;
  49766. /**
  49767. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49768. * This helps adding a mirror texture on the ground.
  49769. */
  49770. reflectionFresnel: boolean;
  49771. protected _reflectionFalloffDistance: number;
  49772. /**
  49773. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49774. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49775. */
  49776. reflectionFalloffDistance: number;
  49777. protected _reflectionAmount: number;
  49778. /**
  49779. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49780. */
  49781. reflectionAmount: number;
  49782. protected _reflectionReflectance0: number;
  49783. /**
  49784. * This specifies the weight of the reflection at grazing angle.
  49785. */
  49786. reflectionReflectance0: number;
  49787. protected _reflectionReflectance90: number;
  49788. /**
  49789. * This specifies the weight of the reflection at a perpendicular point of view.
  49790. */
  49791. reflectionReflectance90: number;
  49792. /**
  49793. * Sets the reflection reflectance fresnel values according to the default standard
  49794. * empirically know to work well :-)
  49795. */
  49796. set reflectionStandardFresnelWeight(value: number);
  49797. protected _useRGBColor: boolean;
  49798. /**
  49799. * Helps to directly use the maps channels instead of their level.
  49800. */
  49801. useRGBColor: boolean;
  49802. protected _enableNoise: boolean;
  49803. /**
  49804. * This helps reducing the banding effect that could occur on the background.
  49805. */
  49806. enableNoise: boolean;
  49807. /**
  49808. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49809. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49810. * Recommended to be keep at 1.0 except for special cases.
  49811. */
  49812. get fovMultiplier(): number;
  49813. set fovMultiplier(value: number);
  49814. private _fovMultiplier;
  49815. /**
  49816. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49817. */
  49818. useEquirectangularFOV: boolean;
  49819. private _maxSimultaneousLights;
  49820. /**
  49821. * Number of Simultaneous lights allowed on the material.
  49822. */
  49823. maxSimultaneousLights: int;
  49824. /**
  49825. * Default configuration related to image processing available in the Background Material.
  49826. */
  49827. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49828. /**
  49829. * Keep track of the image processing observer to allow dispose and replace.
  49830. */
  49831. private _imageProcessingObserver;
  49832. /**
  49833. * Attaches a new image processing configuration to the PBR Material.
  49834. * @param configuration (if null the scene configuration will be use)
  49835. */
  49836. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49837. /**
  49838. * Gets the image processing configuration used either in this material.
  49839. */
  49840. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49841. /**
  49842. * Sets the Default image processing configuration used either in the this material.
  49843. *
  49844. * If sets to null, the scene one is in use.
  49845. */
  49846. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49847. /**
  49848. * Gets wether the color curves effect is enabled.
  49849. */
  49850. get cameraColorCurvesEnabled(): boolean;
  49851. /**
  49852. * Sets wether the color curves effect is enabled.
  49853. */
  49854. set cameraColorCurvesEnabled(value: boolean);
  49855. /**
  49856. * Gets wether the color grading effect is enabled.
  49857. */
  49858. get cameraColorGradingEnabled(): boolean;
  49859. /**
  49860. * Gets wether the color grading effect is enabled.
  49861. */
  49862. set cameraColorGradingEnabled(value: boolean);
  49863. /**
  49864. * Gets wether tonemapping is enabled or not.
  49865. */
  49866. get cameraToneMappingEnabled(): boolean;
  49867. /**
  49868. * Sets wether tonemapping is enabled or not
  49869. */
  49870. set cameraToneMappingEnabled(value: boolean);
  49871. /**
  49872. * The camera exposure used on this material.
  49873. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49874. * This corresponds to a photographic exposure.
  49875. */
  49876. get cameraExposure(): float;
  49877. /**
  49878. * The camera exposure used on this material.
  49879. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49880. * This corresponds to a photographic exposure.
  49881. */
  49882. set cameraExposure(value: float);
  49883. /**
  49884. * Gets The camera contrast used on this material.
  49885. */
  49886. get cameraContrast(): float;
  49887. /**
  49888. * Sets The camera contrast used on this material.
  49889. */
  49890. set cameraContrast(value: float);
  49891. /**
  49892. * Gets the Color Grading 2D Lookup Texture.
  49893. */
  49894. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49895. /**
  49896. * Sets the Color Grading 2D Lookup Texture.
  49897. */
  49898. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49899. /**
  49900. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49901. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49902. * 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;
  49903. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49904. */
  49905. get cameraColorCurves(): Nullable<ColorCurves>;
  49906. /**
  49907. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49908. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49909. * 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;
  49910. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49911. */
  49912. set cameraColorCurves(value: Nullable<ColorCurves>);
  49913. /**
  49914. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49915. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49916. */
  49917. switchToBGR: boolean;
  49918. private _renderTargets;
  49919. private _reflectionControls;
  49920. private _white;
  49921. private _primaryShadowColor;
  49922. private _primaryHighlightColor;
  49923. /**
  49924. * Instantiates a Background Material in the given scene
  49925. * @param name The friendly name of the material
  49926. * @param scene The scene to add the material to
  49927. */
  49928. constructor(name: string, scene: Scene);
  49929. /**
  49930. * Gets a boolean indicating that current material needs to register RTT
  49931. */
  49932. get hasRenderTargetTextures(): boolean;
  49933. /**
  49934. * The entire material has been created in order to prevent overdraw.
  49935. * @returns false
  49936. */
  49937. needAlphaTesting(): boolean;
  49938. /**
  49939. * The entire material has been created in order to prevent overdraw.
  49940. * @returns true if blending is enable
  49941. */
  49942. needAlphaBlending(): boolean;
  49943. /**
  49944. * Checks wether the material is ready to be rendered for a given mesh.
  49945. * @param mesh The mesh to render
  49946. * @param subMesh The submesh to check against
  49947. * @param useInstances Specify wether or not the material is used with instances
  49948. * @returns true if all the dependencies are ready (Textures, Effects...)
  49949. */
  49950. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49951. /**
  49952. * Compute the primary color according to the chosen perceptual color.
  49953. */
  49954. private _computePrimaryColorFromPerceptualColor;
  49955. /**
  49956. * Compute the highlights and shadow colors according to their chosen levels.
  49957. */
  49958. private _computePrimaryColors;
  49959. /**
  49960. * Build the uniform buffer used in the material.
  49961. */
  49962. buildUniformLayout(): void;
  49963. /**
  49964. * Unbind the material.
  49965. */
  49966. unbind(): void;
  49967. /**
  49968. * Bind only the world matrix to the material.
  49969. * @param world The world matrix to bind.
  49970. */
  49971. bindOnlyWorldMatrix(world: Matrix): void;
  49972. /**
  49973. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49974. * @param world The world matrix to bind.
  49975. * @param subMesh The submesh to bind for.
  49976. */
  49977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49978. /**
  49979. * Checks to see if a texture is used in the material.
  49980. * @param texture - Base texture to use.
  49981. * @returns - Boolean specifying if a texture is used in the material.
  49982. */
  49983. hasTexture(texture: BaseTexture): boolean;
  49984. /**
  49985. * Dispose the material.
  49986. * @param forceDisposeEffect Force disposal of the associated effect.
  49987. * @param forceDisposeTextures Force disposal of the associated textures.
  49988. */
  49989. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49990. /**
  49991. * Clones the material.
  49992. * @param name The cloned name.
  49993. * @returns The cloned material.
  49994. */
  49995. clone(name: string): BackgroundMaterial;
  49996. /**
  49997. * Serializes the current material to its JSON representation.
  49998. * @returns The JSON representation.
  49999. */
  50000. serialize(): any;
  50001. /**
  50002. * Gets the class name of the material
  50003. * @returns "BackgroundMaterial"
  50004. */
  50005. getClassName(): string;
  50006. /**
  50007. * Parse a JSON input to create back a background material.
  50008. * @param source The JSON data to parse
  50009. * @param scene The scene to create the parsed material in
  50010. * @param rootUrl The root url of the assets the material depends upon
  50011. * @returns the instantiated BackgroundMaterial.
  50012. */
  50013. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50014. }
  50015. }
  50016. declare module BABYLON {
  50017. /**
  50018. * Represents the different options available during the creation of
  50019. * a Environment helper.
  50020. *
  50021. * This can control the default ground, skybox and image processing setup of your scene.
  50022. */
  50023. export interface IEnvironmentHelperOptions {
  50024. /**
  50025. * Specifies whether or not to create a ground.
  50026. * True by default.
  50027. */
  50028. createGround: boolean;
  50029. /**
  50030. * Specifies the ground size.
  50031. * 15 by default.
  50032. */
  50033. groundSize: number;
  50034. /**
  50035. * The texture used on the ground for the main color.
  50036. * Comes from the BabylonJS CDN by default.
  50037. *
  50038. * Remarks: Can be either a texture or a url.
  50039. */
  50040. groundTexture: string | BaseTexture;
  50041. /**
  50042. * The color mixed in the ground texture by default.
  50043. * BabylonJS clearColor by default.
  50044. */
  50045. groundColor: Color3;
  50046. /**
  50047. * Specifies the ground opacity.
  50048. * 1 by default.
  50049. */
  50050. groundOpacity: number;
  50051. /**
  50052. * Enables the ground to receive shadows.
  50053. * True by default.
  50054. */
  50055. enableGroundShadow: boolean;
  50056. /**
  50057. * Helps preventing the shadow to be fully black on the ground.
  50058. * 0.5 by default.
  50059. */
  50060. groundShadowLevel: number;
  50061. /**
  50062. * Creates a mirror texture attach to the ground.
  50063. * false by default.
  50064. */
  50065. enableGroundMirror: boolean;
  50066. /**
  50067. * Specifies the ground mirror size ratio.
  50068. * 0.3 by default as the default kernel is 64.
  50069. */
  50070. groundMirrorSizeRatio: number;
  50071. /**
  50072. * Specifies the ground mirror blur kernel size.
  50073. * 64 by default.
  50074. */
  50075. groundMirrorBlurKernel: number;
  50076. /**
  50077. * Specifies the ground mirror visibility amount.
  50078. * 1 by default
  50079. */
  50080. groundMirrorAmount: number;
  50081. /**
  50082. * Specifies the ground mirror reflectance weight.
  50083. * This uses the standard weight of the background material to setup the fresnel effect
  50084. * of the mirror.
  50085. * 1 by default.
  50086. */
  50087. groundMirrorFresnelWeight: number;
  50088. /**
  50089. * Specifies the ground mirror Falloff distance.
  50090. * This can helps reducing the size of the reflection.
  50091. * 0 by Default.
  50092. */
  50093. groundMirrorFallOffDistance: number;
  50094. /**
  50095. * Specifies the ground mirror texture type.
  50096. * Unsigned Int by Default.
  50097. */
  50098. groundMirrorTextureType: number;
  50099. /**
  50100. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50101. * the shown objects.
  50102. */
  50103. groundYBias: number;
  50104. /**
  50105. * Specifies whether or not to create a skybox.
  50106. * True by default.
  50107. */
  50108. createSkybox: boolean;
  50109. /**
  50110. * Specifies the skybox size.
  50111. * 20 by default.
  50112. */
  50113. skyboxSize: number;
  50114. /**
  50115. * The texture used on the skybox for the main color.
  50116. * Comes from the BabylonJS CDN by default.
  50117. *
  50118. * Remarks: Can be either a texture or a url.
  50119. */
  50120. skyboxTexture: string | BaseTexture;
  50121. /**
  50122. * The color mixed in the skybox texture by default.
  50123. * BabylonJS clearColor by default.
  50124. */
  50125. skyboxColor: Color3;
  50126. /**
  50127. * The background rotation around the Y axis of the scene.
  50128. * This helps aligning the key lights of your scene with the background.
  50129. * 0 by default.
  50130. */
  50131. backgroundYRotation: number;
  50132. /**
  50133. * Compute automatically the size of the elements to best fit with the scene.
  50134. */
  50135. sizeAuto: boolean;
  50136. /**
  50137. * Default position of the rootMesh if autoSize is not true.
  50138. */
  50139. rootPosition: Vector3;
  50140. /**
  50141. * Sets up the image processing in the scene.
  50142. * true by default.
  50143. */
  50144. setupImageProcessing: boolean;
  50145. /**
  50146. * The texture used as your environment texture in the scene.
  50147. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50148. *
  50149. * Remarks: Can be either a texture or a url.
  50150. */
  50151. environmentTexture: string | BaseTexture;
  50152. /**
  50153. * The value of the exposure to apply to the scene.
  50154. * 0.6 by default if setupImageProcessing is true.
  50155. */
  50156. cameraExposure: number;
  50157. /**
  50158. * The value of the contrast to apply to the scene.
  50159. * 1.6 by default if setupImageProcessing is true.
  50160. */
  50161. cameraContrast: number;
  50162. /**
  50163. * Specifies whether or not tonemapping should be enabled in the scene.
  50164. * true by default if setupImageProcessing is true.
  50165. */
  50166. toneMappingEnabled: boolean;
  50167. }
  50168. /**
  50169. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50170. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50171. * It also helps with the default setup of your imageProcessing configuration.
  50172. */
  50173. export class EnvironmentHelper {
  50174. /**
  50175. * Default ground texture URL.
  50176. */
  50177. private static _groundTextureCDNUrl;
  50178. /**
  50179. * Default skybox texture URL.
  50180. */
  50181. private static _skyboxTextureCDNUrl;
  50182. /**
  50183. * Default environment texture URL.
  50184. */
  50185. private static _environmentTextureCDNUrl;
  50186. /**
  50187. * Creates the default options for the helper.
  50188. */
  50189. private static _getDefaultOptions;
  50190. private _rootMesh;
  50191. /**
  50192. * Gets the root mesh created by the helper.
  50193. */
  50194. get rootMesh(): Mesh;
  50195. private _skybox;
  50196. /**
  50197. * Gets the skybox created by the helper.
  50198. */
  50199. get skybox(): Nullable<Mesh>;
  50200. private _skyboxTexture;
  50201. /**
  50202. * Gets the skybox texture created by the helper.
  50203. */
  50204. get skyboxTexture(): Nullable<BaseTexture>;
  50205. private _skyboxMaterial;
  50206. /**
  50207. * Gets the skybox material created by the helper.
  50208. */
  50209. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50210. private _ground;
  50211. /**
  50212. * Gets the ground mesh created by the helper.
  50213. */
  50214. get ground(): Nullable<Mesh>;
  50215. private _groundTexture;
  50216. /**
  50217. * Gets the ground texture created by the helper.
  50218. */
  50219. get groundTexture(): Nullable<BaseTexture>;
  50220. private _groundMirror;
  50221. /**
  50222. * Gets the ground mirror created by the helper.
  50223. */
  50224. get groundMirror(): Nullable<MirrorTexture>;
  50225. /**
  50226. * Gets the ground mirror render list to helps pushing the meshes
  50227. * you wish in the ground reflection.
  50228. */
  50229. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50230. private _groundMaterial;
  50231. /**
  50232. * Gets the ground material created by the helper.
  50233. */
  50234. get groundMaterial(): Nullable<BackgroundMaterial>;
  50235. /**
  50236. * Stores the creation options.
  50237. */
  50238. private readonly _scene;
  50239. private _options;
  50240. /**
  50241. * This observable will be notified with any error during the creation of the environment,
  50242. * mainly texture creation errors.
  50243. */
  50244. onErrorObservable: Observable<{
  50245. message?: string;
  50246. exception?: any;
  50247. }>;
  50248. /**
  50249. * constructor
  50250. * @param options Defines the options we want to customize the helper
  50251. * @param scene The scene to add the material to
  50252. */
  50253. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50254. /**
  50255. * Updates the background according to the new options
  50256. * @param options
  50257. */
  50258. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50259. /**
  50260. * Sets the primary color of all the available elements.
  50261. * @param color the main color to affect to the ground and the background
  50262. */
  50263. setMainColor(color: Color3): void;
  50264. /**
  50265. * Setup the image processing according to the specified options.
  50266. */
  50267. private _setupImageProcessing;
  50268. /**
  50269. * Setup the environment texture according to the specified options.
  50270. */
  50271. private _setupEnvironmentTexture;
  50272. /**
  50273. * Setup the background according to the specified options.
  50274. */
  50275. private _setupBackground;
  50276. /**
  50277. * Get the scene sizes according to the setup.
  50278. */
  50279. private _getSceneSize;
  50280. /**
  50281. * Setup the ground according to the specified options.
  50282. */
  50283. private _setupGround;
  50284. /**
  50285. * Setup the ground material according to the specified options.
  50286. */
  50287. private _setupGroundMaterial;
  50288. /**
  50289. * Setup the ground diffuse texture according to the specified options.
  50290. */
  50291. private _setupGroundDiffuseTexture;
  50292. /**
  50293. * Setup the ground mirror texture according to the specified options.
  50294. */
  50295. private _setupGroundMirrorTexture;
  50296. /**
  50297. * Setup the ground to receive the mirror texture.
  50298. */
  50299. private _setupMirrorInGroundMaterial;
  50300. /**
  50301. * Setup the skybox according to the specified options.
  50302. */
  50303. private _setupSkybox;
  50304. /**
  50305. * Setup the skybox material according to the specified options.
  50306. */
  50307. private _setupSkyboxMaterial;
  50308. /**
  50309. * Setup the skybox reflection texture according to the specified options.
  50310. */
  50311. private _setupSkyboxReflectionTexture;
  50312. private _errorHandler;
  50313. /**
  50314. * Dispose all the elements created by the Helper.
  50315. */
  50316. dispose(): void;
  50317. }
  50318. }
  50319. declare module BABYLON {
  50320. /**
  50321. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50322. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50323. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50324. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50325. */
  50326. export class PhotoDome extends TransformNode {
  50327. /**
  50328. * Define the image as a Monoscopic panoramic 360 image.
  50329. */
  50330. static readonly MODE_MONOSCOPIC: number;
  50331. /**
  50332. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50333. */
  50334. static readonly MODE_TOPBOTTOM: number;
  50335. /**
  50336. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50337. */
  50338. static readonly MODE_SIDEBYSIDE: number;
  50339. private _useDirectMapping;
  50340. /**
  50341. * The texture being displayed on the sphere
  50342. */
  50343. protected _photoTexture: Texture;
  50344. /**
  50345. * Gets or sets the texture being displayed on the sphere
  50346. */
  50347. get photoTexture(): Texture;
  50348. set photoTexture(value: Texture);
  50349. /**
  50350. * Observable raised when an error occured while loading the 360 image
  50351. */
  50352. onLoadErrorObservable: Observable<string>;
  50353. /**
  50354. * The skybox material
  50355. */
  50356. protected _material: BackgroundMaterial;
  50357. /**
  50358. * The surface used for the skybox
  50359. */
  50360. protected _mesh: Mesh;
  50361. /**
  50362. * Gets the mesh used for the skybox.
  50363. */
  50364. get mesh(): Mesh;
  50365. /**
  50366. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50367. * Also see the options.resolution property.
  50368. */
  50369. get fovMultiplier(): number;
  50370. set fovMultiplier(value: number);
  50371. private _imageMode;
  50372. /**
  50373. * Gets or set the current video mode for the video. It can be:
  50374. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50375. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50376. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50377. */
  50378. get imageMode(): number;
  50379. set imageMode(value: number);
  50380. /**
  50381. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50382. * @param name Element's name, child elements will append suffixes for their own names.
  50383. * @param urlsOfPhoto defines the url of the photo to display
  50384. * @param options defines an object containing optional or exposed sub element properties
  50385. * @param onError defines a callback called when an error occured while loading the texture
  50386. */
  50387. constructor(name: string, urlOfPhoto: string, options: {
  50388. resolution?: number;
  50389. size?: number;
  50390. useDirectMapping?: boolean;
  50391. faceForward?: boolean;
  50392. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50393. private _onBeforeCameraRenderObserver;
  50394. private _changeImageMode;
  50395. /**
  50396. * Releases resources associated with this node.
  50397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50399. */
  50400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50401. }
  50402. }
  50403. declare module BABYLON {
  50404. /**
  50405. * Class used to host RGBD texture specific utilities
  50406. */
  50407. export class RGBDTextureTools {
  50408. /**
  50409. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50410. * @param texture the texture to expand.
  50411. */
  50412. static ExpandRGBDTexture(texture: Texture): void;
  50413. }
  50414. }
  50415. declare module BABYLON {
  50416. /**
  50417. * Class used to host texture specific utilities
  50418. */
  50419. export class BRDFTextureTools {
  50420. /**
  50421. * Prevents texture cache collision
  50422. */
  50423. private static _instanceNumber;
  50424. /**
  50425. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50426. * @param scene defines the hosting scene
  50427. * @returns the environment BRDF texture
  50428. */
  50429. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50430. private static _environmentBRDFBase64Texture;
  50431. }
  50432. }
  50433. declare module BABYLON {
  50434. /**
  50435. * @hidden
  50436. */
  50437. export interface IMaterialClearCoatDefines {
  50438. CLEARCOAT: boolean;
  50439. CLEARCOAT_DEFAULTIOR: boolean;
  50440. CLEARCOAT_TEXTURE: boolean;
  50441. CLEARCOAT_TEXTUREDIRECTUV: number;
  50442. CLEARCOAT_BUMP: boolean;
  50443. CLEARCOAT_BUMPDIRECTUV: number;
  50444. CLEARCOAT_TINT: boolean;
  50445. CLEARCOAT_TINT_TEXTURE: boolean;
  50446. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50447. /** @hidden */
  50448. _areTexturesDirty: boolean;
  50449. }
  50450. /**
  50451. * Define the code related to the clear coat parameters of the pbr material.
  50452. */
  50453. export class PBRClearCoatConfiguration {
  50454. /**
  50455. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50456. * The default fits with a polyurethane material.
  50457. */
  50458. private static readonly _DefaultIndexOfRefraction;
  50459. private _isEnabled;
  50460. /**
  50461. * Defines if the clear coat is enabled in the material.
  50462. */
  50463. isEnabled: boolean;
  50464. /**
  50465. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50466. */
  50467. intensity: number;
  50468. /**
  50469. * Defines the clear coat layer roughness.
  50470. */
  50471. roughness: number;
  50472. private _indexOfRefraction;
  50473. /**
  50474. * Defines the index of refraction of the clear coat.
  50475. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50476. * The default fits with a polyurethane material.
  50477. * Changing the default value is more performance intensive.
  50478. */
  50479. indexOfRefraction: number;
  50480. private _texture;
  50481. /**
  50482. * Stores the clear coat values in a texture.
  50483. */
  50484. texture: Nullable<BaseTexture>;
  50485. private _bumpTexture;
  50486. /**
  50487. * Define the clear coat specific bump texture.
  50488. */
  50489. bumpTexture: Nullable<BaseTexture>;
  50490. private _isTintEnabled;
  50491. /**
  50492. * Defines if the clear coat tint is enabled in the material.
  50493. */
  50494. isTintEnabled: boolean;
  50495. /**
  50496. * Defines the clear coat tint of the material.
  50497. * This is only use if tint is enabled
  50498. */
  50499. tintColor: Color3;
  50500. /**
  50501. * Defines the distance at which the tint color should be found in the
  50502. * clear coat media.
  50503. * This is only use if tint is enabled
  50504. */
  50505. tintColorAtDistance: number;
  50506. /**
  50507. * Defines the clear coat layer thickness.
  50508. * This is only use if tint is enabled
  50509. */
  50510. tintThickness: number;
  50511. private _tintTexture;
  50512. /**
  50513. * Stores the clear tint values in a texture.
  50514. * rgb is tint
  50515. * a is a thickness factor
  50516. */
  50517. tintTexture: Nullable<BaseTexture>;
  50518. /** @hidden */
  50519. private _internalMarkAllSubMeshesAsTexturesDirty;
  50520. /** @hidden */
  50521. _markAllSubMeshesAsTexturesDirty(): void;
  50522. /**
  50523. * Instantiate a new istance of clear coat configuration.
  50524. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50525. */
  50526. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50527. /**
  50528. * Gets wehter the submesh is ready to be used or not.
  50529. * @param defines the list of "defines" to update.
  50530. * @param scene defines the scene the material belongs to.
  50531. * @param engine defines the engine the material belongs to.
  50532. * @param disableBumpMap defines wether the material disables bump or not.
  50533. * @returns - boolean indicating that the submesh is ready or not.
  50534. */
  50535. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50536. /**
  50537. * Checks to see if a texture is used in the material.
  50538. * @param defines the list of "defines" to update.
  50539. * @param scene defines the scene to the material belongs to.
  50540. */
  50541. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50542. /**
  50543. * Binds the material data.
  50544. * @param uniformBuffer defines the Uniform buffer to fill in.
  50545. * @param scene defines the scene the material belongs to.
  50546. * @param engine defines the engine the material belongs to.
  50547. * @param disableBumpMap defines wether the material disables bump or not.
  50548. * @param isFrozen defines wether the material is frozen or not.
  50549. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50550. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50551. */
  50552. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50553. /**
  50554. * Checks to see if a texture is used in the material.
  50555. * @param texture - Base texture to use.
  50556. * @returns - Boolean specifying if a texture is used in the material.
  50557. */
  50558. hasTexture(texture: BaseTexture): boolean;
  50559. /**
  50560. * Returns an array of the actively used textures.
  50561. * @param activeTextures Array of BaseTextures
  50562. */
  50563. getActiveTextures(activeTextures: BaseTexture[]): void;
  50564. /**
  50565. * Returns the animatable textures.
  50566. * @param animatables Array of animatable textures.
  50567. */
  50568. getAnimatables(animatables: IAnimatable[]): void;
  50569. /**
  50570. * Disposes the resources of the material.
  50571. * @param forceDisposeTextures - Forces the disposal of all textures.
  50572. */
  50573. dispose(forceDisposeTextures?: boolean): void;
  50574. /**
  50575. * Get the current class name of the texture useful for serialization or dynamic coding.
  50576. * @returns "PBRClearCoatConfiguration"
  50577. */
  50578. getClassName(): string;
  50579. /**
  50580. * Add fallbacks to the effect fallbacks list.
  50581. * @param defines defines the Base texture to use.
  50582. * @param fallbacks defines the current fallback list.
  50583. * @param currentRank defines the current fallback rank.
  50584. * @returns the new fallback rank.
  50585. */
  50586. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50587. /**
  50588. * Add the required uniforms to the current list.
  50589. * @param uniforms defines the current uniform list.
  50590. */
  50591. static AddUniforms(uniforms: string[]): void;
  50592. /**
  50593. * Add the required samplers to the current list.
  50594. * @param samplers defines the current sampler list.
  50595. */
  50596. static AddSamplers(samplers: string[]): void;
  50597. /**
  50598. * Add the required uniforms to the current buffer.
  50599. * @param uniformBuffer defines the current uniform buffer.
  50600. */
  50601. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50602. /**
  50603. * Makes a duplicate of the current configuration into another one.
  50604. * @param clearCoatConfiguration define the config where to copy the info
  50605. */
  50606. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50607. /**
  50608. * Serializes this clear coat configuration.
  50609. * @returns - An object with the serialized config.
  50610. */
  50611. serialize(): any;
  50612. /**
  50613. * Parses a anisotropy Configuration from a serialized object.
  50614. * @param source - Serialized object.
  50615. * @param scene Defines the scene we are parsing for
  50616. * @param rootUrl Defines the rootUrl to load from
  50617. */
  50618. parse(source: any, scene: Scene, rootUrl: string): void;
  50619. }
  50620. }
  50621. declare module BABYLON {
  50622. /**
  50623. * @hidden
  50624. */
  50625. export interface IMaterialAnisotropicDefines {
  50626. ANISOTROPIC: boolean;
  50627. ANISOTROPIC_TEXTURE: boolean;
  50628. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50629. MAINUV1: boolean;
  50630. _areTexturesDirty: boolean;
  50631. _needUVs: boolean;
  50632. }
  50633. /**
  50634. * Define the code related to the anisotropic parameters of the pbr material.
  50635. */
  50636. export class PBRAnisotropicConfiguration {
  50637. private _isEnabled;
  50638. /**
  50639. * Defines if the anisotropy is enabled in the material.
  50640. */
  50641. isEnabled: boolean;
  50642. /**
  50643. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50644. */
  50645. intensity: number;
  50646. /**
  50647. * Defines if the effect is along the tangents, bitangents or in between.
  50648. * By default, the effect is "strectching" the highlights along the tangents.
  50649. */
  50650. direction: Vector2;
  50651. private _texture;
  50652. /**
  50653. * Stores the anisotropy values in a texture.
  50654. * rg is direction (like normal from -1 to 1)
  50655. * b is a intensity
  50656. */
  50657. texture: Nullable<BaseTexture>;
  50658. /** @hidden */
  50659. private _internalMarkAllSubMeshesAsTexturesDirty;
  50660. /** @hidden */
  50661. _markAllSubMeshesAsTexturesDirty(): void;
  50662. /**
  50663. * Instantiate a new istance of anisotropy configuration.
  50664. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50665. */
  50666. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50667. /**
  50668. * Specifies that the submesh is ready to be used.
  50669. * @param defines the list of "defines" to update.
  50670. * @param scene defines the scene the material belongs to.
  50671. * @returns - boolean indicating that the submesh is ready or not.
  50672. */
  50673. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50674. /**
  50675. * Checks to see if a texture is used in the material.
  50676. * @param defines the list of "defines" to update.
  50677. * @param mesh the mesh we are preparing the defines for.
  50678. * @param scene defines the scene the material belongs to.
  50679. */
  50680. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50681. /**
  50682. * Binds the material data.
  50683. * @param uniformBuffer defines the Uniform buffer to fill in.
  50684. * @param scene defines the scene the material belongs to.
  50685. * @param isFrozen defines wether the material is frozen or not.
  50686. */
  50687. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50688. /**
  50689. * Checks to see if a texture is used in the material.
  50690. * @param texture - Base texture to use.
  50691. * @returns - Boolean specifying if a texture is used in the material.
  50692. */
  50693. hasTexture(texture: BaseTexture): boolean;
  50694. /**
  50695. * Returns an array of the actively used textures.
  50696. * @param activeTextures Array of BaseTextures
  50697. */
  50698. getActiveTextures(activeTextures: BaseTexture[]): void;
  50699. /**
  50700. * Returns the animatable textures.
  50701. * @param animatables Array of animatable textures.
  50702. */
  50703. getAnimatables(animatables: IAnimatable[]): void;
  50704. /**
  50705. * Disposes the resources of the material.
  50706. * @param forceDisposeTextures - Forces the disposal of all textures.
  50707. */
  50708. dispose(forceDisposeTextures?: boolean): void;
  50709. /**
  50710. * Get the current class name of the texture useful for serialization or dynamic coding.
  50711. * @returns "PBRAnisotropicConfiguration"
  50712. */
  50713. getClassName(): string;
  50714. /**
  50715. * Add fallbacks to the effect fallbacks list.
  50716. * @param defines defines the Base texture to use.
  50717. * @param fallbacks defines the current fallback list.
  50718. * @param currentRank defines the current fallback rank.
  50719. * @returns the new fallback rank.
  50720. */
  50721. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50722. /**
  50723. * Add the required uniforms to the current list.
  50724. * @param uniforms defines the current uniform list.
  50725. */
  50726. static AddUniforms(uniforms: string[]): void;
  50727. /**
  50728. * Add the required uniforms to the current buffer.
  50729. * @param uniformBuffer defines the current uniform buffer.
  50730. */
  50731. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50732. /**
  50733. * Add the required samplers to the current list.
  50734. * @param samplers defines the current sampler list.
  50735. */
  50736. static AddSamplers(samplers: string[]): void;
  50737. /**
  50738. * Makes a duplicate of the current configuration into another one.
  50739. * @param anisotropicConfiguration define the config where to copy the info
  50740. */
  50741. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50742. /**
  50743. * Serializes this anisotropy configuration.
  50744. * @returns - An object with the serialized config.
  50745. */
  50746. serialize(): any;
  50747. /**
  50748. * Parses a anisotropy Configuration from a serialized object.
  50749. * @param source - Serialized object.
  50750. * @param scene Defines the scene we are parsing for
  50751. * @param rootUrl Defines the rootUrl to load from
  50752. */
  50753. parse(source: any, scene: Scene, rootUrl: string): void;
  50754. }
  50755. }
  50756. declare module BABYLON {
  50757. /**
  50758. * @hidden
  50759. */
  50760. export interface IMaterialBRDFDefines {
  50761. BRDF_V_HEIGHT_CORRELATED: boolean;
  50762. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50763. SPHERICAL_HARMONICS: boolean;
  50764. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50765. /** @hidden */
  50766. _areMiscDirty: boolean;
  50767. }
  50768. /**
  50769. * Define the code related to the BRDF parameters of the pbr material.
  50770. */
  50771. export class PBRBRDFConfiguration {
  50772. /**
  50773. * Default value used for the energy conservation.
  50774. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50775. */
  50776. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50777. /**
  50778. * Default value used for the Smith Visibility Height Correlated mode.
  50779. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50780. */
  50781. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50782. /**
  50783. * Default value used for the IBL diffuse part.
  50784. * This can help switching back to the polynomials mode globally which is a tiny bit
  50785. * less GPU intensive at the drawback of a lower quality.
  50786. */
  50787. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50788. /**
  50789. * Default value used for activating energy conservation for the specular workflow.
  50790. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50791. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50792. */
  50793. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50794. private _useEnergyConservation;
  50795. /**
  50796. * Defines if the material uses energy conservation.
  50797. */
  50798. useEnergyConservation: boolean;
  50799. private _useSmithVisibilityHeightCorrelated;
  50800. /**
  50801. * LEGACY Mode set to false
  50802. * Defines if the material uses height smith correlated visibility term.
  50803. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50804. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50805. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50806. * Not relying on height correlated will also disable energy conservation.
  50807. */
  50808. useSmithVisibilityHeightCorrelated: boolean;
  50809. private _useSphericalHarmonics;
  50810. /**
  50811. * LEGACY Mode set to false
  50812. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50813. * diffuse part of the IBL.
  50814. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50815. * to the ground truth.
  50816. */
  50817. useSphericalHarmonics: boolean;
  50818. private _useSpecularGlossinessInputEnergyConservation;
  50819. /**
  50820. * Defines if the material uses energy conservation, when the specular workflow is active.
  50821. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50822. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50823. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50824. */
  50825. useSpecularGlossinessInputEnergyConservation: boolean;
  50826. /** @hidden */
  50827. private _internalMarkAllSubMeshesAsMiscDirty;
  50828. /** @hidden */
  50829. _markAllSubMeshesAsMiscDirty(): void;
  50830. /**
  50831. * Instantiate a new istance of clear coat configuration.
  50832. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50833. */
  50834. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50835. /**
  50836. * Checks to see if a texture is used in the material.
  50837. * @param defines the list of "defines" to update.
  50838. */
  50839. prepareDefines(defines: IMaterialBRDFDefines): void;
  50840. /**
  50841. * Get the current class name of the texture useful for serialization or dynamic coding.
  50842. * @returns "PBRClearCoatConfiguration"
  50843. */
  50844. getClassName(): string;
  50845. /**
  50846. * Makes a duplicate of the current configuration into another one.
  50847. * @param brdfConfiguration define the config where to copy the info
  50848. */
  50849. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50850. /**
  50851. * Serializes this BRDF configuration.
  50852. * @returns - An object with the serialized config.
  50853. */
  50854. serialize(): any;
  50855. /**
  50856. * Parses a anisotropy Configuration from a serialized object.
  50857. * @param source - Serialized object.
  50858. * @param scene Defines the scene we are parsing for
  50859. * @param rootUrl Defines the rootUrl to load from
  50860. */
  50861. parse(source: any, scene: Scene, rootUrl: string): void;
  50862. }
  50863. }
  50864. declare module BABYLON {
  50865. /**
  50866. * @hidden
  50867. */
  50868. export interface IMaterialSheenDefines {
  50869. SHEEN: boolean;
  50870. SHEEN_TEXTURE: boolean;
  50871. SHEEN_TEXTUREDIRECTUV: number;
  50872. SHEEN_LINKWITHALBEDO: boolean;
  50873. SHEEN_ROUGHNESS: boolean;
  50874. SHEEN_ALBEDOSCALING: boolean;
  50875. /** @hidden */
  50876. _areTexturesDirty: boolean;
  50877. }
  50878. /**
  50879. * Define the code related to the Sheen parameters of the pbr material.
  50880. */
  50881. export class PBRSheenConfiguration {
  50882. private _isEnabled;
  50883. /**
  50884. * Defines if the material uses sheen.
  50885. */
  50886. isEnabled: boolean;
  50887. private _linkSheenWithAlbedo;
  50888. /**
  50889. * Defines if the sheen is linked to the sheen color.
  50890. */
  50891. linkSheenWithAlbedo: boolean;
  50892. /**
  50893. * Defines the sheen intensity.
  50894. */
  50895. intensity: number;
  50896. /**
  50897. * Defines the sheen color.
  50898. */
  50899. color: Color3;
  50900. private _texture;
  50901. /**
  50902. * Stores the sheen tint values in a texture.
  50903. * rgb is tint
  50904. * a is a intensity
  50905. */
  50906. texture: Nullable<BaseTexture>;
  50907. private _roughness;
  50908. /**
  50909. * Defines the sheen roughness.
  50910. * It is not taken into account if linkSheenWithAlbedo is true.
  50911. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50912. */
  50913. roughness: Nullable<number>;
  50914. private _albedoScaling;
  50915. /**
  50916. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50917. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50918. * making it easier to setup and tweak the effect
  50919. */
  50920. albedoScaling: boolean;
  50921. /** @hidden */
  50922. private _internalMarkAllSubMeshesAsTexturesDirty;
  50923. /** @hidden */
  50924. _markAllSubMeshesAsTexturesDirty(): void;
  50925. /**
  50926. * Instantiate a new istance of clear coat configuration.
  50927. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50928. */
  50929. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50930. /**
  50931. * Specifies that the submesh is ready to be used.
  50932. * @param defines the list of "defines" to update.
  50933. * @param scene defines the scene the material belongs to.
  50934. * @returns - boolean indicating that the submesh is ready or not.
  50935. */
  50936. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50937. /**
  50938. * Checks to see if a texture is used in the material.
  50939. * @param defines the list of "defines" to update.
  50940. * @param scene defines the scene the material belongs to.
  50941. */
  50942. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50943. /**
  50944. * Binds the material data.
  50945. * @param uniformBuffer defines the Uniform buffer to fill in.
  50946. * @param scene defines the scene the material belongs to.
  50947. * @param isFrozen defines wether the material is frozen or not.
  50948. */
  50949. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50950. /**
  50951. * Checks to see if a texture is used in the material.
  50952. * @param texture - Base texture to use.
  50953. * @returns - Boolean specifying if a texture is used in the material.
  50954. */
  50955. hasTexture(texture: BaseTexture): boolean;
  50956. /**
  50957. * Returns an array of the actively used textures.
  50958. * @param activeTextures Array of BaseTextures
  50959. */
  50960. getActiveTextures(activeTextures: BaseTexture[]): void;
  50961. /**
  50962. * Returns the animatable textures.
  50963. * @param animatables Array of animatable textures.
  50964. */
  50965. getAnimatables(animatables: IAnimatable[]): void;
  50966. /**
  50967. * Disposes the resources of the material.
  50968. * @param forceDisposeTextures - Forces the disposal of all textures.
  50969. */
  50970. dispose(forceDisposeTextures?: boolean): void;
  50971. /**
  50972. * Get the current class name of the texture useful for serialization or dynamic coding.
  50973. * @returns "PBRSheenConfiguration"
  50974. */
  50975. getClassName(): string;
  50976. /**
  50977. * Add fallbacks to the effect fallbacks list.
  50978. * @param defines defines the Base texture to use.
  50979. * @param fallbacks defines the current fallback list.
  50980. * @param currentRank defines the current fallback rank.
  50981. * @returns the new fallback rank.
  50982. */
  50983. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50984. /**
  50985. * Add the required uniforms to the current list.
  50986. * @param uniforms defines the current uniform list.
  50987. */
  50988. static AddUniforms(uniforms: string[]): void;
  50989. /**
  50990. * Add the required uniforms to the current buffer.
  50991. * @param uniformBuffer defines the current uniform buffer.
  50992. */
  50993. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50994. /**
  50995. * Add the required samplers to the current list.
  50996. * @param samplers defines the current sampler list.
  50997. */
  50998. static AddSamplers(samplers: string[]): void;
  50999. /**
  51000. * Makes a duplicate of the current configuration into another one.
  51001. * @param sheenConfiguration define the config where to copy the info
  51002. */
  51003. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51004. /**
  51005. * Serializes this BRDF configuration.
  51006. * @returns - An object with the serialized config.
  51007. */
  51008. serialize(): any;
  51009. /**
  51010. * Parses a anisotropy Configuration from a serialized object.
  51011. * @param source - Serialized object.
  51012. * @param scene Defines the scene we are parsing for
  51013. * @param rootUrl Defines the rootUrl to load from
  51014. */
  51015. parse(source: any, scene: Scene, rootUrl: string): void;
  51016. }
  51017. }
  51018. declare module BABYLON {
  51019. /**
  51020. * @hidden
  51021. */
  51022. export interface IMaterialSubSurfaceDefines {
  51023. SUBSURFACE: boolean;
  51024. SS_REFRACTION: boolean;
  51025. SS_TRANSLUCENCY: boolean;
  51026. SS_SCATERRING: boolean;
  51027. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51028. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51029. SS_REFRACTIONMAP_3D: boolean;
  51030. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51031. SS_LODINREFRACTIONALPHA: boolean;
  51032. SS_GAMMAREFRACTION: boolean;
  51033. SS_RGBDREFRACTION: boolean;
  51034. SS_LINEARSPECULARREFRACTION: boolean;
  51035. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51036. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51037. /** @hidden */
  51038. _areTexturesDirty: boolean;
  51039. }
  51040. /**
  51041. * Define the code related to the sub surface parameters of the pbr material.
  51042. */
  51043. export class PBRSubSurfaceConfiguration {
  51044. private _isRefractionEnabled;
  51045. /**
  51046. * Defines if the refraction is enabled in the material.
  51047. */
  51048. isRefractionEnabled: boolean;
  51049. private _isTranslucencyEnabled;
  51050. /**
  51051. * Defines if the translucency is enabled in the material.
  51052. */
  51053. isTranslucencyEnabled: boolean;
  51054. private _isScatteringEnabled;
  51055. /**
  51056. * Defines the refraction intensity of the material.
  51057. * The refraction when enabled replaces the Diffuse part of the material.
  51058. * The intensity helps transitionning between diffuse and refraction.
  51059. */
  51060. refractionIntensity: number;
  51061. /**
  51062. * Defines the translucency intensity of the material.
  51063. * When translucency has been enabled, this defines how much of the "translucency"
  51064. * is addded to the diffuse part of the material.
  51065. */
  51066. translucencyIntensity: number;
  51067. /**
  51068. * Defines the scattering intensity of the material.
  51069. * When scattering has been enabled, this defines how much of the "scattered light"
  51070. * is addded to the diffuse part of the material.
  51071. */
  51072. scatteringIntensity: number;
  51073. private _thicknessTexture;
  51074. /**
  51075. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51076. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51077. * 0 would mean minimumThickness
  51078. * 1 would mean maximumThickness
  51079. * The other channels might be use as a mask to vary the different effects intensity.
  51080. */
  51081. thicknessTexture: Nullable<BaseTexture>;
  51082. private _refractionTexture;
  51083. /**
  51084. * Defines the texture to use for refraction.
  51085. */
  51086. refractionTexture: Nullable<BaseTexture>;
  51087. private _indexOfRefraction;
  51088. /**
  51089. * Defines the index of refraction used in the material.
  51090. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51091. */
  51092. indexOfRefraction: number;
  51093. private _invertRefractionY;
  51094. /**
  51095. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51096. */
  51097. invertRefractionY: boolean;
  51098. private _linkRefractionWithTransparency;
  51099. /**
  51100. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51101. * Materials half opaque for instance using refraction could benefit from this control.
  51102. */
  51103. linkRefractionWithTransparency: boolean;
  51104. /**
  51105. * Defines the minimum thickness stored in the thickness map.
  51106. * If no thickness map is defined, this value will be used to simulate thickness.
  51107. */
  51108. minimumThickness: number;
  51109. /**
  51110. * Defines the maximum thickness stored in the thickness map.
  51111. */
  51112. maximumThickness: number;
  51113. /**
  51114. * Defines the volume tint of the material.
  51115. * This is used for both translucency and scattering.
  51116. */
  51117. tintColor: Color3;
  51118. /**
  51119. * Defines the distance at which the tint color should be found in the media.
  51120. * This is used for refraction only.
  51121. */
  51122. tintColorAtDistance: number;
  51123. /**
  51124. * Defines how far each channel transmit through the media.
  51125. * It is defined as a color to simplify it selection.
  51126. */
  51127. diffusionDistance: Color3;
  51128. private _useMaskFromThicknessTexture;
  51129. /**
  51130. * Stores the intensity of the different subsurface effects in the thickness texture.
  51131. * * the green channel is the translucency intensity.
  51132. * * the blue channel is the scattering intensity.
  51133. * * the alpha channel is the refraction intensity.
  51134. */
  51135. useMaskFromThicknessTexture: boolean;
  51136. /** @hidden */
  51137. private _internalMarkAllSubMeshesAsTexturesDirty;
  51138. /** @hidden */
  51139. _markAllSubMeshesAsTexturesDirty(): void;
  51140. /**
  51141. * Instantiate a new istance of sub surface configuration.
  51142. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51143. */
  51144. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51145. /**
  51146. * Gets wehter the submesh is ready to be used or not.
  51147. * @param defines the list of "defines" to update.
  51148. * @param scene defines the scene the material belongs to.
  51149. * @returns - boolean indicating that the submesh is ready or not.
  51150. */
  51151. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51152. /**
  51153. * Checks to see if a texture is used in the material.
  51154. * @param defines the list of "defines" to update.
  51155. * @param scene defines the scene to the material belongs to.
  51156. */
  51157. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51158. /**
  51159. * Binds the material data.
  51160. * @param uniformBuffer defines the Uniform buffer to fill in.
  51161. * @param scene defines the scene the material belongs to.
  51162. * @param engine defines the engine the material belongs to.
  51163. * @param isFrozen defines wether the material is frozen or not.
  51164. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51165. */
  51166. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51167. /**
  51168. * Unbinds the material from the mesh.
  51169. * @param activeEffect defines the effect that should be unbound from.
  51170. * @returns true if unbound, otherwise false
  51171. */
  51172. unbind(activeEffect: Effect): boolean;
  51173. /**
  51174. * Returns the texture used for refraction or null if none is used.
  51175. * @param scene defines the scene the material belongs to.
  51176. * @returns - Refraction texture if present. If no refraction texture and refraction
  51177. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51178. */
  51179. private _getRefractionTexture;
  51180. /**
  51181. * Returns true if alpha blending should be disabled.
  51182. */
  51183. get disableAlphaBlending(): boolean;
  51184. /**
  51185. * Fills the list of render target textures.
  51186. * @param renderTargets the list of render targets to update
  51187. */
  51188. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51189. /**
  51190. * Checks to see if a texture is used in the material.
  51191. * @param texture - Base texture to use.
  51192. * @returns - Boolean specifying if a texture is used in the material.
  51193. */
  51194. hasTexture(texture: BaseTexture): boolean;
  51195. /**
  51196. * Gets a boolean indicating that current material needs to register RTT
  51197. * @returns true if this uses a render target otherwise false.
  51198. */
  51199. hasRenderTargetTextures(): boolean;
  51200. /**
  51201. * Returns an array of the actively used textures.
  51202. * @param activeTextures Array of BaseTextures
  51203. */
  51204. getActiveTextures(activeTextures: BaseTexture[]): void;
  51205. /**
  51206. * Returns the animatable textures.
  51207. * @param animatables Array of animatable textures.
  51208. */
  51209. getAnimatables(animatables: IAnimatable[]): void;
  51210. /**
  51211. * Disposes the resources of the material.
  51212. * @param forceDisposeTextures - Forces the disposal of all textures.
  51213. */
  51214. dispose(forceDisposeTextures?: boolean): void;
  51215. /**
  51216. * Get the current class name of the texture useful for serialization or dynamic coding.
  51217. * @returns "PBRSubSurfaceConfiguration"
  51218. */
  51219. getClassName(): string;
  51220. /**
  51221. * Add fallbacks to the effect fallbacks list.
  51222. * @param defines defines the Base texture to use.
  51223. * @param fallbacks defines the current fallback list.
  51224. * @param currentRank defines the current fallback rank.
  51225. * @returns the new fallback rank.
  51226. */
  51227. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51228. /**
  51229. * Add the required uniforms to the current list.
  51230. * @param uniforms defines the current uniform list.
  51231. */
  51232. static AddUniforms(uniforms: string[]): void;
  51233. /**
  51234. * Add the required samplers to the current list.
  51235. * @param samplers defines the current sampler list.
  51236. */
  51237. static AddSamplers(samplers: string[]): void;
  51238. /**
  51239. * Add the required uniforms to the current buffer.
  51240. * @param uniformBuffer defines the current uniform buffer.
  51241. */
  51242. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51243. /**
  51244. * Makes a duplicate of the current configuration into another one.
  51245. * @param configuration define the config where to copy the info
  51246. */
  51247. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51248. /**
  51249. * Serializes this Sub Surface configuration.
  51250. * @returns - An object with the serialized config.
  51251. */
  51252. serialize(): any;
  51253. /**
  51254. * Parses a anisotropy Configuration from a serialized object.
  51255. * @param source - Serialized object.
  51256. * @param scene Defines the scene we are parsing for
  51257. * @param rootUrl Defines the rootUrl to load from
  51258. */
  51259. parse(source: any, scene: Scene, rootUrl: string): void;
  51260. }
  51261. }
  51262. declare module BABYLON {
  51263. /** @hidden */
  51264. export var pbrFragmentDeclaration: {
  51265. name: string;
  51266. shader: string;
  51267. };
  51268. }
  51269. declare module BABYLON {
  51270. /** @hidden */
  51271. export var pbrUboDeclaration: {
  51272. name: string;
  51273. shader: string;
  51274. };
  51275. }
  51276. declare module BABYLON {
  51277. /** @hidden */
  51278. export var pbrFragmentExtraDeclaration: {
  51279. name: string;
  51280. shader: string;
  51281. };
  51282. }
  51283. declare module BABYLON {
  51284. /** @hidden */
  51285. export var pbrFragmentSamplersDeclaration: {
  51286. name: string;
  51287. shader: string;
  51288. };
  51289. }
  51290. declare module BABYLON {
  51291. /** @hidden */
  51292. export var pbrHelperFunctions: {
  51293. name: string;
  51294. shader: string;
  51295. };
  51296. }
  51297. declare module BABYLON {
  51298. /** @hidden */
  51299. export var harmonicsFunctions: {
  51300. name: string;
  51301. shader: string;
  51302. };
  51303. }
  51304. declare module BABYLON {
  51305. /** @hidden */
  51306. export var pbrDirectLightingSetupFunctions: {
  51307. name: string;
  51308. shader: string;
  51309. };
  51310. }
  51311. declare module BABYLON {
  51312. /** @hidden */
  51313. export var pbrDirectLightingFalloffFunctions: {
  51314. name: string;
  51315. shader: string;
  51316. };
  51317. }
  51318. declare module BABYLON {
  51319. /** @hidden */
  51320. export var pbrBRDFFunctions: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module BABYLON {
  51326. /** @hidden */
  51327. export var pbrDirectLightingFunctions: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module BABYLON {
  51333. /** @hidden */
  51334. export var pbrIBLFunctions: {
  51335. name: string;
  51336. shader: string;
  51337. };
  51338. }
  51339. declare module BABYLON {
  51340. /** @hidden */
  51341. export var pbrBlockAlbedoOpacity: {
  51342. name: string;
  51343. shader: string;
  51344. };
  51345. }
  51346. declare module BABYLON {
  51347. /** @hidden */
  51348. export var pbrBlockReflectivity: {
  51349. name: string;
  51350. shader: string;
  51351. };
  51352. }
  51353. declare module BABYLON {
  51354. /** @hidden */
  51355. export var pbrBlockAmbientOcclusion: {
  51356. name: string;
  51357. shader: string;
  51358. };
  51359. }
  51360. declare module BABYLON {
  51361. /** @hidden */
  51362. export var pbrBlockAlphaFresnel: {
  51363. name: string;
  51364. shader: string;
  51365. };
  51366. }
  51367. declare module BABYLON {
  51368. /** @hidden */
  51369. export var pbrBlockAnisotropic: {
  51370. name: string;
  51371. shader: string;
  51372. };
  51373. }
  51374. declare module BABYLON {
  51375. /** @hidden */
  51376. export var pbrBlockReflection: {
  51377. name: string;
  51378. shader: string;
  51379. };
  51380. }
  51381. declare module BABYLON {
  51382. /** @hidden */
  51383. export var pbrBlockSheen: {
  51384. name: string;
  51385. shader: string;
  51386. };
  51387. }
  51388. declare module BABYLON {
  51389. /** @hidden */
  51390. export var pbrBlockClearcoat: {
  51391. name: string;
  51392. shader: string;
  51393. };
  51394. }
  51395. declare module BABYLON {
  51396. /** @hidden */
  51397. export var pbrBlockSubSurface: {
  51398. name: string;
  51399. shader: string;
  51400. };
  51401. }
  51402. declare module BABYLON {
  51403. /** @hidden */
  51404. export var pbrBlockNormalGeometric: {
  51405. name: string;
  51406. shader: string;
  51407. };
  51408. }
  51409. declare module BABYLON {
  51410. /** @hidden */
  51411. export var pbrBlockNormalFinal: {
  51412. name: string;
  51413. shader: string;
  51414. };
  51415. }
  51416. declare module BABYLON {
  51417. /** @hidden */
  51418. export var pbrBlockGeometryInfo: {
  51419. name: string;
  51420. shader: string;
  51421. };
  51422. }
  51423. declare module BABYLON {
  51424. /** @hidden */
  51425. export var pbrBlockReflectance0: {
  51426. name: string;
  51427. shader: string;
  51428. };
  51429. }
  51430. declare module BABYLON {
  51431. /** @hidden */
  51432. export var pbrBlockReflectance: {
  51433. name: string;
  51434. shader: string;
  51435. };
  51436. }
  51437. declare module BABYLON {
  51438. /** @hidden */
  51439. export var pbrBlockDirectLighting: {
  51440. name: string;
  51441. shader: string;
  51442. };
  51443. }
  51444. declare module BABYLON {
  51445. /** @hidden */
  51446. export var pbrBlockFinalLitComponents: {
  51447. name: string;
  51448. shader: string;
  51449. };
  51450. }
  51451. declare module BABYLON {
  51452. /** @hidden */
  51453. export var pbrBlockFinalUnlitComponents: {
  51454. name: string;
  51455. shader: string;
  51456. };
  51457. }
  51458. declare module BABYLON {
  51459. /** @hidden */
  51460. export var pbrBlockFinalColorComposition: {
  51461. name: string;
  51462. shader: string;
  51463. };
  51464. }
  51465. declare module BABYLON {
  51466. /** @hidden */
  51467. export var pbrBlockImageProcessing: {
  51468. name: string;
  51469. shader: string;
  51470. };
  51471. }
  51472. declare module BABYLON {
  51473. /** @hidden */
  51474. export var pbrDebug: {
  51475. name: string;
  51476. shader: string;
  51477. };
  51478. }
  51479. declare module BABYLON {
  51480. /** @hidden */
  51481. export var pbrPixelShader: {
  51482. name: string;
  51483. shader: string;
  51484. };
  51485. }
  51486. declare module BABYLON {
  51487. /** @hidden */
  51488. export var pbrVertexDeclaration: {
  51489. name: string;
  51490. shader: string;
  51491. };
  51492. }
  51493. declare module BABYLON {
  51494. /** @hidden */
  51495. export var pbrVertexShader: {
  51496. name: string;
  51497. shader: string;
  51498. };
  51499. }
  51500. declare module BABYLON {
  51501. /**
  51502. * Manages the defines for the PBR Material.
  51503. * @hidden
  51504. */
  51505. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51506. PBR: boolean;
  51507. MAINUV1: boolean;
  51508. MAINUV2: boolean;
  51509. UV1: boolean;
  51510. UV2: boolean;
  51511. ALBEDO: boolean;
  51512. GAMMAALBEDO: boolean;
  51513. ALBEDODIRECTUV: number;
  51514. VERTEXCOLOR: boolean;
  51515. AMBIENT: boolean;
  51516. AMBIENTDIRECTUV: number;
  51517. AMBIENTINGRAYSCALE: boolean;
  51518. OPACITY: boolean;
  51519. VERTEXALPHA: boolean;
  51520. OPACITYDIRECTUV: number;
  51521. OPACITYRGB: boolean;
  51522. ALPHATEST: boolean;
  51523. DEPTHPREPASS: boolean;
  51524. ALPHABLEND: boolean;
  51525. ALPHAFROMALBEDO: boolean;
  51526. ALPHATESTVALUE: string;
  51527. SPECULAROVERALPHA: boolean;
  51528. RADIANCEOVERALPHA: boolean;
  51529. ALPHAFRESNEL: boolean;
  51530. LINEARALPHAFRESNEL: boolean;
  51531. PREMULTIPLYALPHA: boolean;
  51532. EMISSIVE: boolean;
  51533. EMISSIVEDIRECTUV: number;
  51534. REFLECTIVITY: boolean;
  51535. REFLECTIVITYDIRECTUV: number;
  51536. SPECULARTERM: boolean;
  51537. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51538. MICROSURFACEAUTOMATIC: boolean;
  51539. LODBASEDMICROSFURACE: boolean;
  51540. MICROSURFACEMAP: boolean;
  51541. MICROSURFACEMAPDIRECTUV: number;
  51542. METALLICWORKFLOW: boolean;
  51543. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51544. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51545. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51546. AOSTOREINMETALMAPRED: boolean;
  51547. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51548. ENVIRONMENTBRDF: boolean;
  51549. ENVIRONMENTBRDF_RGBD: boolean;
  51550. NORMAL: boolean;
  51551. TANGENT: boolean;
  51552. BUMP: boolean;
  51553. BUMPDIRECTUV: number;
  51554. OBJECTSPACE_NORMALMAP: boolean;
  51555. PARALLAX: boolean;
  51556. PARALLAXOCCLUSION: boolean;
  51557. NORMALXYSCALE: boolean;
  51558. LIGHTMAP: boolean;
  51559. LIGHTMAPDIRECTUV: number;
  51560. USELIGHTMAPASSHADOWMAP: boolean;
  51561. GAMMALIGHTMAP: boolean;
  51562. RGBDLIGHTMAP: boolean;
  51563. REFLECTION: boolean;
  51564. REFLECTIONMAP_3D: boolean;
  51565. REFLECTIONMAP_SPHERICAL: boolean;
  51566. REFLECTIONMAP_PLANAR: boolean;
  51567. REFLECTIONMAP_CUBIC: boolean;
  51568. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51569. REFLECTIONMAP_PROJECTION: boolean;
  51570. REFLECTIONMAP_SKYBOX: boolean;
  51571. REFLECTIONMAP_EXPLICIT: boolean;
  51572. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51573. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51574. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51575. INVERTCUBICMAP: boolean;
  51576. USESPHERICALFROMREFLECTIONMAP: boolean;
  51577. USEIRRADIANCEMAP: boolean;
  51578. SPHERICAL_HARMONICS: boolean;
  51579. USESPHERICALINVERTEX: boolean;
  51580. REFLECTIONMAP_OPPOSITEZ: boolean;
  51581. LODINREFLECTIONALPHA: boolean;
  51582. GAMMAREFLECTION: boolean;
  51583. RGBDREFLECTION: boolean;
  51584. LINEARSPECULARREFLECTION: boolean;
  51585. RADIANCEOCCLUSION: boolean;
  51586. HORIZONOCCLUSION: boolean;
  51587. INSTANCES: boolean;
  51588. NUM_BONE_INFLUENCERS: number;
  51589. BonesPerMesh: number;
  51590. BONETEXTURE: boolean;
  51591. NONUNIFORMSCALING: boolean;
  51592. MORPHTARGETS: boolean;
  51593. MORPHTARGETS_NORMAL: boolean;
  51594. MORPHTARGETS_TANGENT: boolean;
  51595. MORPHTARGETS_UV: boolean;
  51596. NUM_MORPH_INFLUENCERS: number;
  51597. IMAGEPROCESSING: boolean;
  51598. VIGNETTE: boolean;
  51599. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51600. VIGNETTEBLENDMODEOPAQUE: boolean;
  51601. TONEMAPPING: boolean;
  51602. TONEMAPPING_ACES: boolean;
  51603. CONTRAST: boolean;
  51604. COLORCURVES: boolean;
  51605. COLORGRADING: boolean;
  51606. COLORGRADING3D: boolean;
  51607. SAMPLER3DGREENDEPTH: boolean;
  51608. SAMPLER3DBGRMAP: boolean;
  51609. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51610. EXPOSURE: boolean;
  51611. MULTIVIEW: boolean;
  51612. USEPHYSICALLIGHTFALLOFF: boolean;
  51613. USEGLTFLIGHTFALLOFF: boolean;
  51614. TWOSIDEDLIGHTING: boolean;
  51615. SHADOWFLOAT: boolean;
  51616. CLIPPLANE: boolean;
  51617. CLIPPLANE2: boolean;
  51618. CLIPPLANE3: boolean;
  51619. CLIPPLANE4: boolean;
  51620. CLIPPLANE5: boolean;
  51621. CLIPPLANE6: boolean;
  51622. POINTSIZE: boolean;
  51623. FOG: boolean;
  51624. LOGARITHMICDEPTH: boolean;
  51625. FORCENORMALFORWARD: boolean;
  51626. SPECULARAA: boolean;
  51627. CLEARCOAT: boolean;
  51628. CLEARCOAT_DEFAULTIOR: boolean;
  51629. CLEARCOAT_TEXTURE: boolean;
  51630. CLEARCOAT_TEXTUREDIRECTUV: number;
  51631. CLEARCOAT_BUMP: boolean;
  51632. CLEARCOAT_BUMPDIRECTUV: number;
  51633. CLEARCOAT_TINT: boolean;
  51634. CLEARCOAT_TINT_TEXTURE: boolean;
  51635. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51636. ANISOTROPIC: boolean;
  51637. ANISOTROPIC_TEXTURE: boolean;
  51638. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51639. BRDF_V_HEIGHT_CORRELATED: boolean;
  51640. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51641. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51642. SHEEN: boolean;
  51643. SHEEN_TEXTURE: boolean;
  51644. SHEEN_TEXTUREDIRECTUV: number;
  51645. SHEEN_LINKWITHALBEDO: boolean;
  51646. SHEEN_ROUGHNESS: boolean;
  51647. SHEEN_ALBEDOSCALING: boolean;
  51648. SUBSURFACE: boolean;
  51649. SS_REFRACTION: boolean;
  51650. SS_TRANSLUCENCY: boolean;
  51651. SS_SCATERRING: boolean;
  51652. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51653. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51654. SS_REFRACTIONMAP_3D: boolean;
  51655. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51656. SS_LODINREFRACTIONALPHA: boolean;
  51657. SS_GAMMAREFRACTION: boolean;
  51658. SS_RGBDREFRACTION: boolean;
  51659. SS_LINEARSPECULARREFRACTION: boolean;
  51660. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51661. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51662. UNLIT: boolean;
  51663. DEBUGMODE: number;
  51664. /**
  51665. * Initializes the PBR Material defines.
  51666. */
  51667. constructor();
  51668. /**
  51669. * Resets the PBR Material defines.
  51670. */
  51671. reset(): void;
  51672. }
  51673. /**
  51674. * The Physically based material base class of BJS.
  51675. *
  51676. * This offers the main features of a standard PBR material.
  51677. * For more information, please refer to the documentation :
  51678. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51679. */
  51680. export abstract class PBRBaseMaterial extends PushMaterial {
  51681. /**
  51682. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51683. */
  51684. static readonly PBRMATERIAL_OPAQUE: number;
  51685. /**
  51686. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51687. */
  51688. static readonly PBRMATERIAL_ALPHATEST: number;
  51689. /**
  51690. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51691. */
  51692. static readonly PBRMATERIAL_ALPHABLEND: number;
  51693. /**
  51694. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51695. * They are also discarded below the alpha cutoff threshold to improve performances.
  51696. */
  51697. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51698. /**
  51699. * Defines the default value of how much AO map is occluding the analytical lights
  51700. * (point spot...).
  51701. */
  51702. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51703. /**
  51704. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51705. */
  51706. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51707. /**
  51708. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51709. * to enhance interoperability with other engines.
  51710. */
  51711. static readonly LIGHTFALLOFF_GLTF: number;
  51712. /**
  51713. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51714. * to enhance interoperability with other materials.
  51715. */
  51716. static readonly LIGHTFALLOFF_STANDARD: number;
  51717. /**
  51718. * Intensity of the direct lights e.g. the four lights available in your scene.
  51719. * This impacts both the direct diffuse and specular highlights.
  51720. */
  51721. protected _directIntensity: number;
  51722. /**
  51723. * Intensity of the emissive part of the material.
  51724. * This helps controlling the emissive effect without modifying the emissive color.
  51725. */
  51726. protected _emissiveIntensity: number;
  51727. /**
  51728. * Intensity of the environment e.g. how much the environment will light the object
  51729. * either through harmonics for rough material or through the refelction for shiny ones.
  51730. */
  51731. protected _environmentIntensity: number;
  51732. /**
  51733. * This is a special control allowing the reduction of the specular highlights coming from the
  51734. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51735. */
  51736. protected _specularIntensity: number;
  51737. /**
  51738. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51739. */
  51740. private _lightingInfos;
  51741. /**
  51742. * Debug Control allowing disabling the bump map on this material.
  51743. */
  51744. protected _disableBumpMap: boolean;
  51745. /**
  51746. * AKA Diffuse Texture in standard nomenclature.
  51747. */
  51748. protected _albedoTexture: Nullable<BaseTexture>;
  51749. /**
  51750. * AKA Occlusion Texture in other nomenclature.
  51751. */
  51752. protected _ambientTexture: Nullable<BaseTexture>;
  51753. /**
  51754. * AKA Occlusion Texture Intensity in other nomenclature.
  51755. */
  51756. protected _ambientTextureStrength: number;
  51757. /**
  51758. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51759. * 1 means it completely occludes it
  51760. * 0 mean it has no impact
  51761. */
  51762. protected _ambientTextureImpactOnAnalyticalLights: number;
  51763. /**
  51764. * Stores the alpha values in a texture.
  51765. */
  51766. protected _opacityTexture: Nullable<BaseTexture>;
  51767. /**
  51768. * Stores the reflection values in a texture.
  51769. */
  51770. protected _reflectionTexture: Nullable<BaseTexture>;
  51771. /**
  51772. * Stores the emissive values in a texture.
  51773. */
  51774. protected _emissiveTexture: Nullable<BaseTexture>;
  51775. /**
  51776. * AKA Specular texture in other nomenclature.
  51777. */
  51778. protected _reflectivityTexture: Nullable<BaseTexture>;
  51779. /**
  51780. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51781. */
  51782. protected _metallicTexture: Nullable<BaseTexture>;
  51783. /**
  51784. * Specifies the metallic scalar of the metallic/roughness workflow.
  51785. * Can also be used to scale the metalness values of the metallic texture.
  51786. */
  51787. protected _metallic: Nullable<number>;
  51788. /**
  51789. * Specifies the roughness scalar of the metallic/roughness workflow.
  51790. * Can also be used to scale the roughness values of the metallic texture.
  51791. */
  51792. protected _roughness: Nullable<number>;
  51793. /**
  51794. * Specifies the an F0 factor to help configuring the material F0.
  51795. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51796. * to 0.5 the previously hard coded value stays the same.
  51797. * Can also be used to scale the F0 values of the metallic texture.
  51798. */
  51799. protected _metallicF0Factor: number;
  51800. /**
  51801. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51802. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51803. * your expectation as it multiplies with the texture data.
  51804. */
  51805. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51806. /**
  51807. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51808. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51809. */
  51810. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51811. /**
  51812. * Stores surface normal data used to displace a mesh in a texture.
  51813. */
  51814. protected _bumpTexture: Nullable<BaseTexture>;
  51815. /**
  51816. * Stores the pre-calculated light information of a mesh in a texture.
  51817. */
  51818. protected _lightmapTexture: Nullable<BaseTexture>;
  51819. /**
  51820. * The color of a material in ambient lighting.
  51821. */
  51822. protected _ambientColor: Color3;
  51823. /**
  51824. * AKA Diffuse Color in other nomenclature.
  51825. */
  51826. protected _albedoColor: Color3;
  51827. /**
  51828. * AKA Specular Color in other nomenclature.
  51829. */
  51830. protected _reflectivityColor: Color3;
  51831. /**
  51832. * The color applied when light is reflected from a material.
  51833. */
  51834. protected _reflectionColor: Color3;
  51835. /**
  51836. * The color applied when light is emitted from a material.
  51837. */
  51838. protected _emissiveColor: Color3;
  51839. /**
  51840. * AKA Glossiness in other nomenclature.
  51841. */
  51842. protected _microSurface: number;
  51843. /**
  51844. * Specifies that the material will use the light map as a show map.
  51845. */
  51846. protected _useLightmapAsShadowmap: boolean;
  51847. /**
  51848. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51849. * makes the reflect vector face the model (under horizon).
  51850. */
  51851. protected _useHorizonOcclusion: boolean;
  51852. /**
  51853. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51854. * too much the area relying on ambient texture to define their ambient occlusion.
  51855. */
  51856. protected _useRadianceOcclusion: boolean;
  51857. /**
  51858. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51859. */
  51860. protected _useAlphaFromAlbedoTexture: boolean;
  51861. /**
  51862. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51863. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51864. */
  51865. protected _useSpecularOverAlpha: boolean;
  51866. /**
  51867. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51868. */
  51869. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51870. /**
  51871. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51872. */
  51873. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51874. /**
  51875. * Specifies if the metallic texture contains the roughness information in its green channel.
  51876. */
  51877. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51878. /**
  51879. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51880. */
  51881. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51882. /**
  51883. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51884. */
  51885. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51886. /**
  51887. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51888. */
  51889. protected _useAmbientInGrayScale: boolean;
  51890. /**
  51891. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51892. * The material will try to infer what glossiness each pixel should be.
  51893. */
  51894. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51895. /**
  51896. * Defines the falloff type used in this material.
  51897. * It by default is Physical.
  51898. */
  51899. protected _lightFalloff: number;
  51900. /**
  51901. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51902. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51903. */
  51904. protected _useRadianceOverAlpha: boolean;
  51905. /**
  51906. * Allows using an object space normal map (instead of tangent space).
  51907. */
  51908. protected _useObjectSpaceNormalMap: boolean;
  51909. /**
  51910. * Allows using the bump map in parallax mode.
  51911. */
  51912. protected _useParallax: boolean;
  51913. /**
  51914. * Allows using the bump map in parallax occlusion mode.
  51915. */
  51916. protected _useParallaxOcclusion: boolean;
  51917. /**
  51918. * Controls the scale bias of the parallax mode.
  51919. */
  51920. protected _parallaxScaleBias: number;
  51921. /**
  51922. * If sets to true, disables all the lights affecting the material.
  51923. */
  51924. protected _disableLighting: boolean;
  51925. /**
  51926. * Number of Simultaneous lights allowed on the material.
  51927. */
  51928. protected _maxSimultaneousLights: number;
  51929. /**
  51930. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51931. */
  51932. protected _invertNormalMapX: boolean;
  51933. /**
  51934. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51935. */
  51936. protected _invertNormalMapY: boolean;
  51937. /**
  51938. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51939. */
  51940. protected _twoSidedLighting: boolean;
  51941. /**
  51942. * Defines the alpha limits in alpha test mode.
  51943. */
  51944. protected _alphaCutOff: number;
  51945. /**
  51946. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51947. */
  51948. protected _forceAlphaTest: boolean;
  51949. /**
  51950. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51951. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51952. */
  51953. protected _useAlphaFresnel: boolean;
  51954. /**
  51955. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51956. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51957. */
  51958. protected _useLinearAlphaFresnel: boolean;
  51959. /**
  51960. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51961. * from cos thetav and roughness:
  51962. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51963. */
  51964. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51965. /**
  51966. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51967. */
  51968. protected _forceIrradianceInFragment: boolean;
  51969. /**
  51970. * Force normal to face away from face.
  51971. */
  51972. protected _forceNormalForward: boolean;
  51973. /**
  51974. * Enables specular anti aliasing in the PBR shader.
  51975. * It will both interacts on the Geometry for analytical and IBL lighting.
  51976. * It also prefilter the roughness map based on the bump values.
  51977. */
  51978. protected _enableSpecularAntiAliasing: boolean;
  51979. /**
  51980. * Default configuration related to image processing available in the PBR Material.
  51981. */
  51982. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51983. /**
  51984. * Keep track of the image processing observer to allow dispose and replace.
  51985. */
  51986. private _imageProcessingObserver;
  51987. /**
  51988. * Attaches a new image processing configuration to the PBR Material.
  51989. * @param configuration
  51990. */
  51991. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51992. /**
  51993. * Stores the available render targets.
  51994. */
  51995. private _renderTargets;
  51996. /**
  51997. * Sets the global ambient color for the material used in lighting calculations.
  51998. */
  51999. private _globalAmbientColor;
  52000. /**
  52001. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52002. */
  52003. private _useLogarithmicDepth;
  52004. /**
  52005. * If set to true, no lighting calculations will be applied.
  52006. */
  52007. private _unlit;
  52008. private _debugMode;
  52009. /**
  52010. * @hidden
  52011. * This is reserved for the inspector.
  52012. * Defines the material debug mode.
  52013. * It helps seeing only some components of the material while troubleshooting.
  52014. */
  52015. debugMode: number;
  52016. /**
  52017. * @hidden
  52018. * This is reserved for the inspector.
  52019. * Specify from where on screen the debug mode should start.
  52020. * The value goes from -1 (full screen) to 1 (not visible)
  52021. * It helps with side by side comparison against the final render
  52022. * This defaults to -1
  52023. */
  52024. private debugLimit;
  52025. /**
  52026. * @hidden
  52027. * This is reserved for the inspector.
  52028. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52029. * You can use the factor to better multiply the final value.
  52030. */
  52031. private debugFactor;
  52032. /**
  52033. * Defines the clear coat layer parameters for the material.
  52034. */
  52035. readonly clearCoat: PBRClearCoatConfiguration;
  52036. /**
  52037. * Defines the anisotropic parameters for the material.
  52038. */
  52039. readonly anisotropy: PBRAnisotropicConfiguration;
  52040. /**
  52041. * Defines the BRDF parameters for the material.
  52042. */
  52043. readonly brdf: PBRBRDFConfiguration;
  52044. /**
  52045. * Defines the Sheen parameters for the material.
  52046. */
  52047. readonly sheen: PBRSheenConfiguration;
  52048. /**
  52049. * Defines the SubSurface parameters for the material.
  52050. */
  52051. readonly subSurface: PBRSubSurfaceConfiguration;
  52052. protected _rebuildInParallel: boolean;
  52053. /**
  52054. * Instantiates a new PBRMaterial instance.
  52055. *
  52056. * @param name The material name
  52057. * @param scene The scene the material will be use in.
  52058. */
  52059. constructor(name: string, scene: Scene);
  52060. /**
  52061. * Gets a boolean indicating that current material needs to register RTT
  52062. */
  52063. get hasRenderTargetTextures(): boolean;
  52064. /**
  52065. * Gets the name of the material class.
  52066. */
  52067. getClassName(): string;
  52068. /**
  52069. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52070. */
  52071. get useLogarithmicDepth(): boolean;
  52072. /**
  52073. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52074. */
  52075. set useLogarithmicDepth(value: boolean);
  52076. /**
  52077. * Returns true if alpha blending should be disabled.
  52078. */
  52079. protected get _disableAlphaBlending(): boolean;
  52080. /**
  52081. * Specifies whether or not this material should be rendered in alpha blend mode.
  52082. */
  52083. needAlphaBlending(): boolean;
  52084. /**
  52085. * Specifies whether or not this material should be rendered in alpha test mode.
  52086. */
  52087. needAlphaTesting(): boolean;
  52088. /**
  52089. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52090. */
  52091. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52092. /**
  52093. * Gets the texture used for the alpha test.
  52094. */
  52095. getAlphaTestTexture(): Nullable<BaseTexture>;
  52096. /**
  52097. * Specifies that the submesh is ready to be used.
  52098. * @param mesh - BJS mesh.
  52099. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52100. * @param useInstances - Specifies that instances should be used.
  52101. * @returns - boolean indicating that the submesh is ready or not.
  52102. */
  52103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52104. /**
  52105. * Specifies if the material uses metallic roughness workflow.
  52106. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52107. */
  52108. isMetallicWorkflow(): boolean;
  52109. private _prepareEffect;
  52110. private _prepareDefines;
  52111. /**
  52112. * Force shader compilation
  52113. */
  52114. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52115. /**
  52116. * Initializes the uniform buffer layout for the shader.
  52117. */
  52118. buildUniformLayout(): void;
  52119. /**
  52120. * Unbinds the material from the mesh
  52121. */
  52122. unbind(): void;
  52123. /**
  52124. * Binds the submesh data.
  52125. * @param world - The world matrix.
  52126. * @param mesh - The BJS mesh.
  52127. * @param subMesh - A submesh of the BJS mesh.
  52128. */
  52129. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52130. /**
  52131. * Returns the animatable textures.
  52132. * @returns - Array of animatable textures.
  52133. */
  52134. getAnimatables(): IAnimatable[];
  52135. /**
  52136. * Returns the texture used for reflections.
  52137. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52138. */
  52139. private _getReflectionTexture;
  52140. /**
  52141. * Returns an array of the actively used textures.
  52142. * @returns - Array of BaseTextures
  52143. */
  52144. getActiveTextures(): BaseTexture[];
  52145. /**
  52146. * Checks to see if a texture is used in the material.
  52147. * @param texture - Base texture to use.
  52148. * @returns - Boolean specifying if a texture is used in the material.
  52149. */
  52150. hasTexture(texture: BaseTexture): boolean;
  52151. /**
  52152. * Disposes the resources of the material.
  52153. * @param forceDisposeEffect - Forces the disposal of effects.
  52154. * @param forceDisposeTextures - Forces the disposal of all textures.
  52155. */
  52156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52157. }
  52158. }
  52159. declare module BABYLON {
  52160. /**
  52161. * The Physically based material of BJS.
  52162. *
  52163. * This offers the main features of a standard PBR material.
  52164. * For more information, please refer to the documentation :
  52165. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52166. */
  52167. export class PBRMaterial extends PBRBaseMaterial {
  52168. /**
  52169. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52170. */
  52171. static readonly PBRMATERIAL_OPAQUE: number;
  52172. /**
  52173. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52174. */
  52175. static readonly PBRMATERIAL_ALPHATEST: number;
  52176. /**
  52177. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52178. */
  52179. static readonly PBRMATERIAL_ALPHABLEND: number;
  52180. /**
  52181. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52182. * They are also discarded below the alpha cutoff threshold to improve performances.
  52183. */
  52184. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52185. /**
  52186. * Defines the default value of how much AO map is occluding the analytical lights
  52187. * (point spot...).
  52188. */
  52189. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52190. /**
  52191. * Intensity of the direct lights e.g. the four lights available in your scene.
  52192. * This impacts both the direct diffuse and specular highlights.
  52193. */
  52194. directIntensity: number;
  52195. /**
  52196. * Intensity of the emissive part of the material.
  52197. * This helps controlling the emissive effect without modifying the emissive color.
  52198. */
  52199. emissiveIntensity: number;
  52200. /**
  52201. * Intensity of the environment e.g. how much the environment will light the object
  52202. * either through harmonics for rough material or through the refelction for shiny ones.
  52203. */
  52204. environmentIntensity: number;
  52205. /**
  52206. * This is a special control allowing the reduction of the specular highlights coming from the
  52207. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52208. */
  52209. specularIntensity: number;
  52210. /**
  52211. * Debug Control allowing disabling the bump map on this material.
  52212. */
  52213. disableBumpMap: boolean;
  52214. /**
  52215. * AKA Diffuse Texture in standard nomenclature.
  52216. */
  52217. albedoTexture: BaseTexture;
  52218. /**
  52219. * AKA Occlusion Texture in other nomenclature.
  52220. */
  52221. ambientTexture: BaseTexture;
  52222. /**
  52223. * AKA Occlusion Texture Intensity in other nomenclature.
  52224. */
  52225. ambientTextureStrength: number;
  52226. /**
  52227. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52228. * 1 means it completely occludes it
  52229. * 0 mean it has no impact
  52230. */
  52231. ambientTextureImpactOnAnalyticalLights: number;
  52232. /**
  52233. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52234. */
  52235. opacityTexture: BaseTexture;
  52236. /**
  52237. * Stores the reflection values in a texture.
  52238. */
  52239. reflectionTexture: Nullable<BaseTexture>;
  52240. /**
  52241. * Stores the emissive values in a texture.
  52242. */
  52243. emissiveTexture: BaseTexture;
  52244. /**
  52245. * AKA Specular texture in other nomenclature.
  52246. */
  52247. reflectivityTexture: BaseTexture;
  52248. /**
  52249. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52250. */
  52251. metallicTexture: BaseTexture;
  52252. /**
  52253. * Specifies the metallic scalar of the metallic/roughness workflow.
  52254. * Can also be used to scale the metalness values of the metallic texture.
  52255. */
  52256. metallic: Nullable<number>;
  52257. /**
  52258. * Specifies the roughness scalar of the metallic/roughness workflow.
  52259. * Can also be used to scale the roughness values of the metallic texture.
  52260. */
  52261. roughness: Nullable<number>;
  52262. /**
  52263. * Specifies the an F0 factor to help configuring the material F0.
  52264. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52265. * to 0.5 the previously hard coded value stays the same.
  52266. * Can also be used to scale the F0 values of the metallic texture.
  52267. */
  52268. metallicF0Factor: number;
  52269. /**
  52270. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52271. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52272. * your expectation as it multiplies with the texture data.
  52273. */
  52274. useMetallicF0FactorFromMetallicTexture: boolean;
  52275. /**
  52276. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52277. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52278. */
  52279. microSurfaceTexture: BaseTexture;
  52280. /**
  52281. * Stores surface normal data used to displace a mesh in a texture.
  52282. */
  52283. bumpTexture: BaseTexture;
  52284. /**
  52285. * Stores the pre-calculated light information of a mesh in a texture.
  52286. */
  52287. lightmapTexture: BaseTexture;
  52288. /**
  52289. * Stores the refracted light information in a texture.
  52290. */
  52291. get refractionTexture(): Nullable<BaseTexture>;
  52292. set refractionTexture(value: Nullable<BaseTexture>);
  52293. /**
  52294. * The color of a material in ambient lighting.
  52295. */
  52296. ambientColor: Color3;
  52297. /**
  52298. * AKA Diffuse Color in other nomenclature.
  52299. */
  52300. albedoColor: Color3;
  52301. /**
  52302. * AKA Specular Color in other nomenclature.
  52303. */
  52304. reflectivityColor: Color3;
  52305. /**
  52306. * The color reflected from the material.
  52307. */
  52308. reflectionColor: Color3;
  52309. /**
  52310. * The color emitted from the material.
  52311. */
  52312. emissiveColor: Color3;
  52313. /**
  52314. * AKA Glossiness in other nomenclature.
  52315. */
  52316. microSurface: number;
  52317. /**
  52318. * source material index of refraction (IOR)' / 'destination material IOR.
  52319. */
  52320. get indexOfRefraction(): number;
  52321. set indexOfRefraction(value: number);
  52322. /**
  52323. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52324. */
  52325. get invertRefractionY(): boolean;
  52326. set invertRefractionY(value: boolean);
  52327. /**
  52328. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52329. * Materials half opaque for instance using refraction could benefit from this control.
  52330. */
  52331. get linkRefractionWithTransparency(): boolean;
  52332. set linkRefractionWithTransparency(value: boolean);
  52333. /**
  52334. * If true, the light map contains occlusion information instead of lighting info.
  52335. */
  52336. useLightmapAsShadowmap: boolean;
  52337. /**
  52338. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52339. */
  52340. useAlphaFromAlbedoTexture: boolean;
  52341. /**
  52342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52343. */
  52344. forceAlphaTest: boolean;
  52345. /**
  52346. * Defines the alpha limits in alpha test mode.
  52347. */
  52348. alphaCutOff: number;
  52349. /**
  52350. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52351. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52352. */
  52353. useSpecularOverAlpha: boolean;
  52354. /**
  52355. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52356. */
  52357. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52358. /**
  52359. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52360. */
  52361. useRoughnessFromMetallicTextureAlpha: boolean;
  52362. /**
  52363. * Specifies if the metallic texture contains the roughness information in its green channel.
  52364. */
  52365. useRoughnessFromMetallicTextureGreen: boolean;
  52366. /**
  52367. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52368. */
  52369. useMetallnessFromMetallicTextureBlue: boolean;
  52370. /**
  52371. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52372. */
  52373. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52374. /**
  52375. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52376. */
  52377. useAmbientInGrayScale: boolean;
  52378. /**
  52379. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52380. * The material will try to infer what glossiness each pixel should be.
  52381. */
  52382. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52383. /**
  52384. * BJS is using an harcoded light falloff based on a manually sets up range.
  52385. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52386. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52387. */
  52388. get usePhysicalLightFalloff(): boolean;
  52389. /**
  52390. * BJS is using an harcoded light falloff based on a manually sets up range.
  52391. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52392. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52393. */
  52394. set usePhysicalLightFalloff(value: boolean);
  52395. /**
  52396. * In order to support the falloff compatibility with gltf, a special mode has been added
  52397. * to reproduce the gltf light falloff.
  52398. */
  52399. get useGLTFLightFalloff(): boolean;
  52400. /**
  52401. * In order to support the falloff compatibility with gltf, a special mode has been added
  52402. * to reproduce the gltf light falloff.
  52403. */
  52404. set useGLTFLightFalloff(value: boolean);
  52405. /**
  52406. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52407. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52408. */
  52409. useRadianceOverAlpha: boolean;
  52410. /**
  52411. * Allows using an object space normal map (instead of tangent space).
  52412. */
  52413. useObjectSpaceNormalMap: boolean;
  52414. /**
  52415. * Allows using the bump map in parallax mode.
  52416. */
  52417. useParallax: boolean;
  52418. /**
  52419. * Allows using the bump map in parallax occlusion mode.
  52420. */
  52421. useParallaxOcclusion: boolean;
  52422. /**
  52423. * Controls the scale bias of the parallax mode.
  52424. */
  52425. parallaxScaleBias: number;
  52426. /**
  52427. * If sets to true, disables all the lights affecting the material.
  52428. */
  52429. disableLighting: boolean;
  52430. /**
  52431. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52432. */
  52433. forceIrradianceInFragment: boolean;
  52434. /**
  52435. * Number of Simultaneous lights allowed on the material.
  52436. */
  52437. maxSimultaneousLights: number;
  52438. /**
  52439. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52440. */
  52441. invertNormalMapX: boolean;
  52442. /**
  52443. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52444. */
  52445. invertNormalMapY: boolean;
  52446. /**
  52447. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52448. */
  52449. twoSidedLighting: boolean;
  52450. /**
  52451. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52452. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52453. */
  52454. useAlphaFresnel: boolean;
  52455. /**
  52456. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52457. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52458. */
  52459. useLinearAlphaFresnel: boolean;
  52460. /**
  52461. * Let user defines the brdf lookup texture used for IBL.
  52462. * A default 8bit version is embedded but you could point at :
  52463. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52464. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52465. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52466. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52467. */
  52468. environmentBRDFTexture: Nullable<BaseTexture>;
  52469. /**
  52470. * Force normal to face away from face.
  52471. */
  52472. forceNormalForward: boolean;
  52473. /**
  52474. * Enables specular anti aliasing in the PBR shader.
  52475. * It will both interacts on the Geometry for analytical and IBL lighting.
  52476. * It also prefilter the roughness map based on the bump values.
  52477. */
  52478. enableSpecularAntiAliasing: boolean;
  52479. /**
  52480. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52481. * makes the reflect vector face the model (under horizon).
  52482. */
  52483. useHorizonOcclusion: boolean;
  52484. /**
  52485. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52486. * too much the area relying on ambient texture to define their ambient occlusion.
  52487. */
  52488. useRadianceOcclusion: boolean;
  52489. /**
  52490. * If set to true, no lighting calculations will be applied.
  52491. */
  52492. unlit: boolean;
  52493. /**
  52494. * Gets the image processing configuration used either in this material.
  52495. */
  52496. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52497. /**
  52498. * Sets the Default image processing configuration used either in the this material.
  52499. *
  52500. * If sets to null, the scene one is in use.
  52501. */
  52502. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52503. /**
  52504. * Gets wether the color curves effect is enabled.
  52505. */
  52506. get cameraColorCurvesEnabled(): boolean;
  52507. /**
  52508. * Sets wether the color curves effect is enabled.
  52509. */
  52510. set cameraColorCurvesEnabled(value: boolean);
  52511. /**
  52512. * Gets wether the color grading effect is enabled.
  52513. */
  52514. get cameraColorGradingEnabled(): boolean;
  52515. /**
  52516. * Gets wether the color grading effect is enabled.
  52517. */
  52518. set cameraColorGradingEnabled(value: boolean);
  52519. /**
  52520. * Gets wether tonemapping is enabled or not.
  52521. */
  52522. get cameraToneMappingEnabled(): boolean;
  52523. /**
  52524. * Sets wether tonemapping is enabled or not
  52525. */
  52526. set cameraToneMappingEnabled(value: boolean);
  52527. /**
  52528. * The camera exposure used on this material.
  52529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52530. * This corresponds to a photographic exposure.
  52531. */
  52532. get cameraExposure(): number;
  52533. /**
  52534. * The camera exposure used on this material.
  52535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52536. * This corresponds to a photographic exposure.
  52537. */
  52538. set cameraExposure(value: number);
  52539. /**
  52540. * Gets The camera contrast used on this material.
  52541. */
  52542. get cameraContrast(): number;
  52543. /**
  52544. * Sets The camera contrast used on this material.
  52545. */
  52546. set cameraContrast(value: number);
  52547. /**
  52548. * Gets the Color Grading 2D Lookup Texture.
  52549. */
  52550. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52551. /**
  52552. * Sets the Color Grading 2D Lookup Texture.
  52553. */
  52554. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52555. /**
  52556. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52557. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52558. * 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;
  52559. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52560. */
  52561. get cameraColorCurves(): Nullable<ColorCurves>;
  52562. /**
  52563. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52564. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52565. * 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;
  52566. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52567. */
  52568. set cameraColorCurves(value: Nullable<ColorCurves>);
  52569. /**
  52570. * Instantiates a new PBRMaterial instance.
  52571. *
  52572. * @param name The material name
  52573. * @param scene The scene the material will be use in.
  52574. */
  52575. constructor(name: string, scene: Scene);
  52576. /**
  52577. * Returns the name of this material class.
  52578. */
  52579. getClassName(): string;
  52580. /**
  52581. * Makes a duplicate of the current material.
  52582. * @param name - name to use for the new material.
  52583. */
  52584. clone(name: string): PBRMaterial;
  52585. /**
  52586. * Serializes this PBR Material.
  52587. * @returns - An object with the serialized material.
  52588. */
  52589. serialize(): any;
  52590. /**
  52591. * Parses a PBR Material from a serialized object.
  52592. * @param source - Serialized object.
  52593. * @param scene - BJS scene instance.
  52594. * @param rootUrl - url for the scene object
  52595. * @returns - PBRMaterial
  52596. */
  52597. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52598. }
  52599. }
  52600. declare module BABYLON {
  52601. /**
  52602. * Direct draw surface info
  52603. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52604. */
  52605. export interface DDSInfo {
  52606. /**
  52607. * Width of the texture
  52608. */
  52609. width: number;
  52610. /**
  52611. * Width of the texture
  52612. */
  52613. height: number;
  52614. /**
  52615. * Number of Mipmaps for the texture
  52616. * @see https://en.wikipedia.org/wiki/Mipmap
  52617. */
  52618. mipmapCount: number;
  52619. /**
  52620. * If the textures format is a known fourCC format
  52621. * @see https://www.fourcc.org/
  52622. */
  52623. isFourCC: boolean;
  52624. /**
  52625. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52626. */
  52627. isRGB: boolean;
  52628. /**
  52629. * If the texture is a lumincance format
  52630. */
  52631. isLuminance: boolean;
  52632. /**
  52633. * If this is a cube texture
  52634. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52635. */
  52636. isCube: boolean;
  52637. /**
  52638. * If the texture is a compressed format eg. FOURCC_DXT1
  52639. */
  52640. isCompressed: boolean;
  52641. /**
  52642. * The dxgiFormat of the texture
  52643. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52644. */
  52645. dxgiFormat: number;
  52646. /**
  52647. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52648. */
  52649. textureType: number;
  52650. /**
  52651. * Sphericle polynomial created for the dds texture
  52652. */
  52653. sphericalPolynomial?: SphericalPolynomial;
  52654. }
  52655. /**
  52656. * Class used to provide DDS decompression tools
  52657. */
  52658. export class DDSTools {
  52659. /**
  52660. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52661. */
  52662. static StoreLODInAlphaChannel: boolean;
  52663. /**
  52664. * Gets DDS information from an array buffer
  52665. * @param data defines the array buffer view to read data from
  52666. * @returns the DDS information
  52667. */
  52668. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52669. private static _FloatView;
  52670. private static _Int32View;
  52671. private static _ToHalfFloat;
  52672. private static _FromHalfFloat;
  52673. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52674. private static _GetHalfFloatRGBAArrayBuffer;
  52675. private static _GetFloatRGBAArrayBuffer;
  52676. private static _GetFloatAsUIntRGBAArrayBuffer;
  52677. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52678. private static _GetRGBAArrayBuffer;
  52679. private static _ExtractLongWordOrder;
  52680. private static _GetRGBArrayBuffer;
  52681. private static _GetLuminanceArrayBuffer;
  52682. /**
  52683. * Uploads DDS Levels to a Babylon Texture
  52684. * @hidden
  52685. */
  52686. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52687. }
  52688. interface ThinEngine {
  52689. /**
  52690. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52691. * @param rootUrl defines the url where the file to load is located
  52692. * @param scene defines the current scene
  52693. * @param lodScale defines scale to apply to the mip map selection
  52694. * @param lodOffset defines offset to apply to the mip map selection
  52695. * @param onLoad defines an optional callback raised when the texture is loaded
  52696. * @param onError defines an optional callback raised if there is an issue to load the texture
  52697. * @param format defines the format of the data
  52698. * @param forcedExtension defines the extension to use to pick the right loader
  52699. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52700. * @returns the cube texture as an InternalTexture
  52701. */
  52702. 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;
  52703. }
  52704. }
  52705. declare module BABYLON {
  52706. /**
  52707. * Implementation of the DDS Texture Loader.
  52708. * @hidden
  52709. */
  52710. export class _DDSTextureLoader implements IInternalTextureLoader {
  52711. /**
  52712. * Defines wether the loader supports cascade loading the different faces.
  52713. */
  52714. readonly supportCascades: boolean;
  52715. /**
  52716. * This returns if the loader support the current file information.
  52717. * @param extension defines the file extension of the file being loaded
  52718. * @returns true if the loader can load the specified file
  52719. */
  52720. canLoad(extension: string): boolean;
  52721. /**
  52722. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52723. * @param data contains the texture data
  52724. * @param texture defines the BabylonJS internal texture
  52725. * @param createPolynomials will be true if polynomials have been requested
  52726. * @param onLoad defines the callback to trigger once the texture is ready
  52727. * @param onError defines the callback to trigger in case of error
  52728. */
  52729. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52730. /**
  52731. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52732. * @param data contains the texture data
  52733. * @param texture defines the BabylonJS internal texture
  52734. * @param callback defines the method to call once ready to upload
  52735. */
  52736. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52737. }
  52738. }
  52739. declare module BABYLON {
  52740. /**
  52741. * Implementation of the ENV Texture Loader.
  52742. * @hidden
  52743. */
  52744. export class _ENVTextureLoader implements IInternalTextureLoader {
  52745. /**
  52746. * Defines wether the loader supports cascade loading the different faces.
  52747. */
  52748. readonly supportCascades: boolean;
  52749. /**
  52750. * This returns if the loader support the current file information.
  52751. * @param extension defines the file extension of the file being loaded
  52752. * @returns true if the loader can load the specified file
  52753. */
  52754. canLoad(extension: string): boolean;
  52755. /**
  52756. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52757. * @param data contains the texture data
  52758. * @param texture defines the BabylonJS internal texture
  52759. * @param createPolynomials will be true if polynomials have been requested
  52760. * @param onLoad defines the callback to trigger once the texture is ready
  52761. * @param onError defines the callback to trigger in case of error
  52762. */
  52763. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52764. /**
  52765. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52766. * @param data contains the texture data
  52767. * @param texture defines the BabylonJS internal texture
  52768. * @param callback defines the method to call once ready to upload
  52769. */
  52770. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52771. }
  52772. }
  52773. declare module BABYLON {
  52774. /**
  52775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52777. */
  52778. export class KhronosTextureContainer {
  52779. /** contents of the KTX container file */
  52780. data: ArrayBufferView;
  52781. private static HEADER_LEN;
  52782. private static COMPRESSED_2D;
  52783. private static COMPRESSED_3D;
  52784. private static TEX_2D;
  52785. private static TEX_3D;
  52786. /**
  52787. * Gets the openGL type
  52788. */
  52789. glType: number;
  52790. /**
  52791. * Gets the openGL type size
  52792. */
  52793. glTypeSize: number;
  52794. /**
  52795. * Gets the openGL format
  52796. */
  52797. glFormat: number;
  52798. /**
  52799. * Gets the openGL internal format
  52800. */
  52801. glInternalFormat: number;
  52802. /**
  52803. * Gets the base internal format
  52804. */
  52805. glBaseInternalFormat: number;
  52806. /**
  52807. * Gets image width in pixel
  52808. */
  52809. pixelWidth: number;
  52810. /**
  52811. * Gets image height in pixel
  52812. */
  52813. pixelHeight: number;
  52814. /**
  52815. * Gets image depth in pixels
  52816. */
  52817. pixelDepth: number;
  52818. /**
  52819. * Gets the number of array elements
  52820. */
  52821. numberOfArrayElements: number;
  52822. /**
  52823. * Gets the number of faces
  52824. */
  52825. numberOfFaces: number;
  52826. /**
  52827. * Gets the number of mipmap levels
  52828. */
  52829. numberOfMipmapLevels: number;
  52830. /**
  52831. * Gets the bytes of key value data
  52832. */
  52833. bytesOfKeyValueData: number;
  52834. /**
  52835. * Gets the load type
  52836. */
  52837. loadType: number;
  52838. /**
  52839. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52840. */
  52841. isInvalid: boolean;
  52842. /**
  52843. * Creates a new KhronosTextureContainer
  52844. * @param data contents of the KTX container file
  52845. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52846. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52847. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52848. */
  52849. constructor(
  52850. /** contents of the KTX container file */
  52851. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52852. /**
  52853. * Uploads KTX content to a Babylon Texture.
  52854. * It is assumed that the texture has already been created & is currently bound
  52855. * @hidden
  52856. */
  52857. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52858. private _upload2DCompressedLevels;
  52859. /**
  52860. * Checks if the given data starts with a KTX file identifier.
  52861. * @param data the data to check
  52862. * @returns true if the data is a KTX file or false otherwise
  52863. */
  52864. static IsValid(data: ArrayBufferView): boolean;
  52865. }
  52866. }
  52867. declare module BABYLON {
  52868. /**
  52869. * Class for loading KTX2 files
  52870. * !!! Experimental Extension Subject to Changes !!!
  52871. * @hidden
  52872. */
  52873. export class KhronosTextureContainer2 {
  52874. private static _ModulePromise;
  52875. private static _TranscodeFormat;
  52876. constructor(engine: ThinEngine);
  52877. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52878. private _determineTranscodeFormat;
  52879. /**
  52880. * Checks if the given data starts with a KTX2 file identifier.
  52881. * @param data the data to check
  52882. * @returns true if the data is a KTX2 file or false otherwise
  52883. */
  52884. static IsValid(data: ArrayBufferView): boolean;
  52885. }
  52886. }
  52887. declare module BABYLON {
  52888. /**
  52889. * Implementation of the KTX Texture Loader.
  52890. * @hidden
  52891. */
  52892. export class _KTXTextureLoader implements IInternalTextureLoader {
  52893. /**
  52894. * Defines wether the loader supports cascade loading the different faces.
  52895. */
  52896. readonly supportCascades: boolean;
  52897. /**
  52898. * This returns if the loader support the current file information.
  52899. * @param extension defines the file extension of the file being loaded
  52900. * @returns true if the loader can load the specified file
  52901. */
  52902. canLoad(extension: string): boolean;
  52903. /**
  52904. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52905. * @param data contains the texture data
  52906. * @param texture defines the BabylonJS internal texture
  52907. * @param createPolynomials will be true if polynomials have been requested
  52908. * @param onLoad defines the callback to trigger once the texture is ready
  52909. * @param onError defines the callback to trigger in case of error
  52910. */
  52911. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52912. /**
  52913. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52914. * @param data contains the texture data
  52915. * @param texture defines the BabylonJS internal texture
  52916. * @param callback defines the method to call once ready to upload
  52917. */
  52918. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52919. }
  52920. }
  52921. declare module BABYLON {
  52922. /** @hidden */
  52923. export var _forceSceneHelpersToBundle: boolean;
  52924. interface Scene {
  52925. /**
  52926. * Creates a default light for the scene.
  52927. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52928. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52929. */
  52930. createDefaultLight(replace?: boolean): void;
  52931. /**
  52932. * Creates a default camera for the scene.
  52933. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52934. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52935. * @param replace has default false, when true replaces the active camera in the scene
  52936. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52937. */
  52938. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52939. /**
  52940. * Creates a default camera and a default light.
  52941. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52942. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52943. * @param replace has the default false, when true replaces the active camera/light in the scene
  52944. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52945. */
  52946. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52947. /**
  52948. * Creates a new sky box
  52949. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52950. * @param environmentTexture defines the texture to use as environment texture
  52951. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52952. * @param scale defines the overall scale of the skybox
  52953. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52954. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52955. * @returns a new mesh holding the sky box
  52956. */
  52957. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52958. /**
  52959. * Creates a new environment
  52960. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52961. * @param options defines the options you can use to configure the environment
  52962. * @returns the new EnvironmentHelper
  52963. */
  52964. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52965. /**
  52966. * Creates a new VREXperienceHelper
  52967. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52968. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52969. * @returns a new VREXperienceHelper
  52970. */
  52971. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52972. /**
  52973. * Creates a new WebXRDefaultExperience
  52974. * @see http://doc.babylonjs.com/how_to/webxr
  52975. * @param options experience options
  52976. * @returns a promise for a new WebXRDefaultExperience
  52977. */
  52978. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52979. }
  52980. }
  52981. declare module BABYLON {
  52982. /**
  52983. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52984. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52985. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52986. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52987. */
  52988. export class VideoDome extends TransformNode {
  52989. /**
  52990. * Define the video source as a Monoscopic panoramic 360 video.
  52991. */
  52992. static readonly MODE_MONOSCOPIC: number;
  52993. /**
  52994. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52995. */
  52996. static readonly MODE_TOPBOTTOM: number;
  52997. /**
  52998. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52999. */
  53000. static readonly MODE_SIDEBYSIDE: number;
  53001. private _halfDome;
  53002. private _useDirectMapping;
  53003. /**
  53004. * The video texture being displayed on the sphere
  53005. */
  53006. protected _videoTexture: VideoTexture;
  53007. /**
  53008. * Gets the video texture being displayed on the sphere
  53009. */
  53010. get videoTexture(): VideoTexture;
  53011. /**
  53012. * The skybox material
  53013. */
  53014. protected _material: BackgroundMaterial;
  53015. /**
  53016. * The surface used for the skybox
  53017. */
  53018. protected _mesh: Mesh;
  53019. /**
  53020. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53021. */
  53022. private _halfDomeMask;
  53023. /**
  53024. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53025. * Also see the options.resolution property.
  53026. */
  53027. get fovMultiplier(): number;
  53028. set fovMultiplier(value: number);
  53029. private _videoMode;
  53030. /**
  53031. * Gets or set the current video mode for the video. It can be:
  53032. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53033. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53034. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53035. */
  53036. get videoMode(): number;
  53037. set videoMode(value: number);
  53038. /**
  53039. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53040. *
  53041. */
  53042. get halfDome(): boolean;
  53043. /**
  53044. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53045. */
  53046. set halfDome(enabled: boolean);
  53047. /**
  53048. * Oberserver used in Stereoscopic VR Mode.
  53049. */
  53050. private _onBeforeCameraRenderObserver;
  53051. /**
  53052. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53053. * @param name Element's name, child elements will append suffixes for their own names.
  53054. * @param urlsOrVideo defines the url(s) or the video element to use
  53055. * @param options An object containing optional or exposed sub element properties
  53056. */
  53057. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53058. resolution?: number;
  53059. clickToPlay?: boolean;
  53060. autoPlay?: boolean;
  53061. loop?: boolean;
  53062. size?: number;
  53063. poster?: string;
  53064. faceForward?: boolean;
  53065. useDirectMapping?: boolean;
  53066. halfDomeMode?: boolean;
  53067. }, scene: Scene);
  53068. private _changeVideoMode;
  53069. /**
  53070. * Releases resources associated with this node.
  53071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53073. */
  53074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53075. }
  53076. }
  53077. declare module BABYLON {
  53078. /**
  53079. * This class can be used to get instrumentation data from a Babylon engine
  53080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53081. */
  53082. export class EngineInstrumentation implements IDisposable {
  53083. /**
  53084. * Define the instrumented engine.
  53085. */
  53086. engine: Engine;
  53087. private _captureGPUFrameTime;
  53088. private _gpuFrameTimeToken;
  53089. private _gpuFrameTime;
  53090. private _captureShaderCompilationTime;
  53091. private _shaderCompilationTime;
  53092. private _onBeginFrameObserver;
  53093. private _onEndFrameObserver;
  53094. private _onBeforeShaderCompilationObserver;
  53095. private _onAfterShaderCompilationObserver;
  53096. /**
  53097. * Gets the perf counter used for GPU frame time
  53098. */
  53099. get gpuFrameTimeCounter(): PerfCounter;
  53100. /**
  53101. * Gets the GPU frame time capture status
  53102. */
  53103. get captureGPUFrameTime(): boolean;
  53104. /**
  53105. * Enable or disable the GPU frame time capture
  53106. */
  53107. set captureGPUFrameTime(value: boolean);
  53108. /**
  53109. * Gets the perf counter used for shader compilation time
  53110. */
  53111. get shaderCompilationTimeCounter(): PerfCounter;
  53112. /**
  53113. * Gets the shader compilation time capture status
  53114. */
  53115. get captureShaderCompilationTime(): boolean;
  53116. /**
  53117. * Enable or disable the shader compilation time capture
  53118. */
  53119. set captureShaderCompilationTime(value: boolean);
  53120. /**
  53121. * Instantiates a new engine instrumentation.
  53122. * This class can be used to get instrumentation data from a Babylon engine
  53123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53124. * @param engine Defines the engine to instrument
  53125. */
  53126. constructor(
  53127. /**
  53128. * Define the instrumented engine.
  53129. */
  53130. engine: Engine);
  53131. /**
  53132. * Dispose and release associated resources.
  53133. */
  53134. dispose(): void;
  53135. }
  53136. }
  53137. declare module BABYLON {
  53138. /**
  53139. * This class can be used to get instrumentation data from a Babylon engine
  53140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53141. */
  53142. export class SceneInstrumentation implements IDisposable {
  53143. /**
  53144. * Defines the scene to instrument
  53145. */
  53146. scene: Scene;
  53147. private _captureActiveMeshesEvaluationTime;
  53148. private _activeMeshesEvaluationTime;
  53149. private _captureRenderTargetsRenderTime;
  53150. private _renderTargetsRenderTime;
  53151. private _captureFrameTime;
  53152. private _frameTime;
  53153. private _captureRenderTime;
  53154. private _renderTime;
  53155. private _captureInterFrameTime;
  53156. private _interFrameTime;
  53157. private _captureParticlesRenderTime;
  53158. private _particlesRenderTime;
  53159. private _captureSpritesRenderTime;
  53160. private _spritesRenderTime;
  53161. private _capturePhysicsTime;
  53162. private _physicsTime;
  53163. private _captureAnimationsTime;
  53164. private _animationsTime;
  53165. private _captureCameraRenderTime;
  53166. private _cameraRenderTime;
  53167. private _onBeforeActiveMeshesEvaluationObserver;
  53168. private _onAfterActiveMeshesEvaluationObserver;
  53169. private _onBeforeRenderTargetsRenderObserver;
  53170. private _onAfterRenderTargetsRenderObserver;
  53171. private _onAfterRenderObserver;
  53172. private _onBeforeDrawPhaseObserver;
  53173. private _onAfterDrawPhaseObserver;
  53174. private _onBeforeAnimationsObserver;
  53175. private _onBeforeParticlesRenderingObserver;
  53176. private _onAfterParticlesRenderingObserver;
  53177. private _onBeforeSpritesRenderingObserver;
  53178. private _onAfterSpritesRenderingObserver;
  53179. private _onBeforePhysicsObserver;
  53180. private _onAfterPhysicsObserver;
  53181. private _onAfterAnimationsObserver;
  53182. private _onBeforeCameraRenderObserver;
  53183. private _onAfterCameraRenderObserver;
  53184. /**
  53185. * Gets the perf counter used for active meshes evaluation time
  53186. */
  53187. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53188. /**
  53189. * Gets the active meshes evaluation time capture status
  53190. */
  53191. get captureActiveMeshesEvaluationTime(): boolean;
  53192. /**
  53193. * Enable or disable the active meshes evaluation time capture
  53194. */
  53195. set captureActiveMeshesEvaluationTime(value: boolean);
  53196. /**
  53197. * Gets the perf counter used for render targets render time
  53198. */
  53199. get renderTargetsRenderTimeCounter(): PerfCounter;
  53200. /**
  53201. * Gets the render targets render time capture status
  53202. */
  53203. get captureRenderTargetsRenderTime(): boolean;
  53204. /**
  53205. * Enable or disable the render targets render time capture
  53206. */
  53207. set captureRenderTargetsRenderTime(value: boolean);
  53208. /**
  53209. * Gets the perf counter used for particles render time
  53210. */
  53211. get particlesRenderTimeCounter(): PerfCounter;
  53212. /**
  53213. * Gets the particles render time capture status
  53214. */
  53215. get captureParticlesRenderTime(): boolean;
  53216. /**
  53217. * Enable or disable the particles render time capture
  53218. */
  53219. set captureParticlesRenderTime(value: boolean);
  53220. /**
  53221. * Gets the perf counter used for sprites render time
  53222. */
  53223. get spritesRenderTimeCounter(): PerfCounter;
  53224. /**
  53225. * Gets the sprites render time capture status
  53226. */
  53227. get captureSpritesRenderTime(): boolean;
  53228. /**
  53229. * Enable or disable the sprites render time capture
  53230. */
  53231. set captureSpritesRenderTime(value: boolean);
  53232. /**
  53233. * Gets the perf counter used for physics time
  53234. */
  53235. get physicsTimeCounter(): PerfCounter;
  53236. /**
  53237. * Gets the physics time capture status
  53238. */
  53239. get capturePhysicsTime(): boolean;
  53240. /**
  53241. * Enable or disable the physics time capture
  53242. */
  53243. set capturePhysicsTime(value: boolean);
  53244. /**
  53245. * Gets the perf counter used for animations time
  53246. */
  53247. get animationsTimeCounter(): PerfCounter;
  53248. /**
  53249. * Gets the animations time capture status
  53250. */
  53251. get captureAnimationsTime(): boolean;
  53252. /**
  53253. * Enable or disable the animations time capture
  53254. */
  53255. set captureAnimationsTime(value: boolean);
  53256. /**
  53257. * Gets the perf counter used for frame time capture
  53258. */
  53259. get frameTimeCounter(): PerfCounter;
  53260. /**
  53261. * Gets the frame time capture status
  53262. */
  53263. get captureFrameTime(): boolean;
  53264. /**
  53265. * Enable or disable the frame time capture
  53266. */
  53267. set captureFrameTime(value: boolean);
  53268. /**
  53269. * Gets the perf counter used for inter-frames time capture
  53270. */
  53271. get interFrameTimeCounter(): PerfCounter;
  53272. /**
  53273. * Gets the inter-frames time capture status
  53274. */
  53275. get captureInterFrameTime(): boolean;
  53276. /**
  53277. * Enable or disable the inter-frames time capture
  53278. */
  53279. set captureInterFrameTime(value: boolean);
  53280. /**
  53281. * Gets the perf counter used for render time capture
  53282. */
  53283. get renderTimeCounter(): PerfCounter;
  53284. /**
  53285. * Gets the render time capture status
  53286. */
  53287. get captureRenderTime(): boolean;
  53288. /**
  53289. * Enable or disable the render time capture
  53290. */
  53291. set captureRenderTime(value: boolean);
  53292. /**
  53293. * Gets the perf counter used for camera render time capture
  53294. */
  53295. get cameraRenderTimeCounter(): PerfCounter;
  53296. /**
  53297. * Gets the camera render time capture status
  53298. */
  53299. get captureCameraRenderTime(): boolean;
  53300. /**
  53301. * Enable or disable the camera render time capture
  53302. */
  53303. set captureCameraRenderTime(value: boolean);
  53304. /**
  53305. * Gets the perf counter used for draw calls
  53306. */
  53307. get drawCallsCounter(): PerfCounter;
  53308. /**
  53309. * Instantiates a new scene instrumentation.
  53310. * This class can be used to get instrumentation data from a Babylon engine
  53311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53312. * @param scene Defines the scene to instrument
  53313. */
  53314. constructor(
  53315. /**
  53316. * Defines the scene to instrument
  53317. */
  53318. scene: Scene);
  53319. /**
  53320. * Dispose and release associated resources.
  53321. */
  53322. dispose(): void;
  53323. }
  53324. }
  53325. declare module BABYLON {
  53326. /** @hidden */
  53327. export var glowMapGenerationPixelShader: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module BABYLON {
  53333. /** @hidden */
  53334. export var glowMapGenerationVertexShader: {
  53335. name: string;
  53336. shader: string;
  53337. };
  53338. }
  53339. declare module BABYLON {
  53340. /**
  53341. * Effect layer options. This helps customizing the behaviour
  53342. * of the effect layer.
  53343. */
  53344. export interface IEffectLayerOptions {
  53345. /**
  53346. * Multiplication factor apply to the canvas size to compute the render target size
  53347. * used to generated the objects (the smaller the faster).
  53348. */
  53349. mainTextureRatio: number;
  53350. /**
  53351. * Enforces a fixed size texture to ensure effect stability across devices.
  53352. */
  53353. mainTextureFixedSize?: number;
  53354. /**
  53355. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53356. */
  53357. alphaBlendingMode: number;
  53358. /**
  53359. * The camera attached to the layer.
  53360. */
  53361. camera: Nullable<Camera>;
  53362. /**
  53363. * The rendering group to draw the layer in.
  53364. */
  53365. renderingGroupId: number;
  53366. }
  53367. /**
  53368. * The effect layer Helps adding post process effect blended with the main pass.
  53369. *
  53370. * This can be for instance use to generate glow or higlight effects on the scene.
  53371. *
  53372. * The effect layer class can not be used directly and is intented to inherited from to be
  53373. * customized per effects.
  53374. */
  53375. export abstract class EffectLayer {
  53376. private _vertexBuffers;
  53377. private _indexBuffer;
  53378. private _cachedDefines;
  53379. private _effectLayerMapGenerationEffect;
  53380. private _effectLayerOptions;
  53381. private _mergeEffect;
  53382. protected _scene: Scene;
  53383. protected _engine: Engine;
  53384. protected _maxSize: number;
  53385. protected _mainTextureDesiredSize: ISize;
  53386. protected _mainTexture: RenderTargetTexture;
  53387. protected _shouldRender: boolean;
  53388. protected _postProcesses: PostProcess[];
  53389. protected _textures: BaseTexture[];
  53390. protected _emissiveTextureAndColor: {
  53391. texture: Nullable<BaseTexture>;
  53392. color: Color4;
  53393. };
  53394. /**
  53395. * The name of the layer
  53396. */
  53397. name: string;
  53398. /**
  53399. * The clear color of the texture used to generate the glow map.
  53400. */
  53401. neutralColor: Color4;
  53402. /**
  53403. * Specifies whether the highlight layer is enabled or not.
  53404. */
  53405. isEnabled: boolean;
  53406. /**
  53407. * Gets the camera attached to the layer.
  53408. */
  53409. get camera(): Nullable<Camera>;
  53410. /**
  53411. * Gets the rendering group id the layer should render in.
  53412. */
  53413. get renderingGroupId(): number;
  53414. set renderingGroupId(renderingGroupId: number);
  53415. /**
  53416. * An event triggered when the effect layer has been disposed.
  53417. */
  53418. onDisposeObservable: Observable<EffectLayer>;
  53419. /**
  53420. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53421. */
  53422. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53423. /**
  53424. * An event triggered when the generated texture is being merged in the scene.
  53425. */
  53426. onBeforeComposeObservable: Observable<EffectLayer>;
  53427. /**
  53428. * An event triggered when the mesh is rendered into the effect render target.
  53429. */
  53430. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53431. /**
  53432. * An event triggered after the mesh has been rendered into the effect render target.
  53433. */
  53434. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53435. /**
  53436. * An event triggered when the generated texture has been merged in the scene.
  53437. */
  53438. onAfterComposeObservable: Observable<EffectLayer>;
  53439. /**
  53440. * An event triggered when the efffect layer changes its size.
  53441. */
  53442. onSizeChangedObservable: Observable<EffectLayer>;
  53443. /** @hidden */
  53444. static _SceneComponentInitialization: (scene: Scene) => void;
  53445. /**
  53446. * Instantiates a new effect Layer and references it in the scene.
  53447. * @param name The name of the layer
  53448. * @param scene The scene to use the layer in
  53449. */
  53450. constructor(
  53451. /** The Friendly of the effect in the scene */
  53452. name: string, scene: Scene);
  53453. /**
  53454. * Get the effect name of the layer.
  53455. * @return The effect name
  53456. */
  53457. abstract getEffectName(): string;
  53458. /**
  53459. * Checks for the readiness of the element composing the layer.
  53460. * @param subMesh the mesh to check for
  53461. * @param useInstances specify whether or not to use instances to render the mesh
  53462. * @return true if ready otherwise, false
  53463. */
  53464. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53465. /**
  53466. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53467. * @returns true if the effect requires stencil during the main canvas render pass.
  53468. */
  53469. abstract needStencil(): boolean;
  53470. /**
  53471. * Create the merge effect. This is the shader use to blit the information back
  53472. * to the main canvas at the end of the scene rendering.
  53473. * @returns The effect containing the shader used to merge the effect on the main canvas
  53474. */
  53475. protected abstract _createMergeEffect(): Effect;
  53476. /**
  53477. * Creates the render target textures and post processes used in the effect layer.
  53478. */
  53479. protected abstract _createTextureAndPostProcesses(): void;
  53480. /**
  53481. * Implementation specific of rendering the generating effect on the main canvas.
  53482. * @param effect The effect used to render through
  53483. */
  53484. protected abstract _internalRender(effect: Effect): void;
  53485. /**
  53486. * Sets the required values for both the emissive texture and and the main color.
  53487. */
  53488. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53489. /**
  53490. * Free any resources and references associated to a mesh.
  53491. * Internal use
  53492. * @param mesh The mesh to free.
  53493. */
  53494. abstract _disposeMesh(mesh: Mesh): void;
  53495. /**
  53496. * Serializes this layer (Glow or Highlight for example)
  53497. * @returns a serialized layer object
  53498. */
  53499. abstract serialize?(): any;
  53500. /**
  53501. * Initializes the effect layer with the required options.
  53502. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53503. */
  53504. protected _init(options: Partial<IEffectLayerOptions>): void;
  53505. /**
  53506. * Generates the index buffer of the full screen quad blending to the main canvas.
  53507. */
  53508. private _generateIndexBuffer;
  53509. /**
  53510. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53511. */
  53512. private _generateVertexBuffer;
  53513. /**
  53514. * Sets the main texture desired size which is the closest power of two
  53515. * of the engine canvas size.
  53516. */
  53517. private _setMainTextureSize;
  53518. /**
  53519. * Creates the main texture for the effect layer.
  53520. */
  53521. protected _createMainTexture(): void;
  53522. /**
  53523. * Adds specific effects defines.
  53524. * @param defines The defines to add specifics to.
  53525. */
  53526. protected _addCustomEffectDefines(defines: string[]): void;
  53527. /**
  53528. * Checks for the readiness of the element composing the layer.
  53529. * @param subMesh the mesh to check for
  53530. * @param useInstances specify whether or not to use instances to render the mesh
  53531. * @param emissiveTexture the associated emissive texture used to generate the glow
  53532. * @return true if ready otherwise, false
  53533. */
  53534. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53535. /**
  53536. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53537. */
  53538. render(): void;
  53539. /**
  53540. * Determine if a given mesh will be used in the current effect.
  53541. * @param mesh mesh to test
  53542. * @returns true if the mesh will be used
  53543. */
  53544. hasMesh(mesh: AbstractMesh): boolean;
  53545. /**
  53546. * Returns true if the layer contains information to display, otherwise false.
  53547. * @returns true if the glow layer should be rendered
  53548. */
  53549. shouldRender(): boolean;
  53550. /**
  53551. * Returns true if the mesh should render, otherwise false.
  53552. * @param mesh The mesh to render
  53553. * @returns true if it should render otherwise false
  53554. */
  53555. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53556. /**
  53557. * Returns true if the mesh can be rendered, otherwise false.
  53558. * @param mesh The mesh to render
  53559. * @param material The material used on the mesh
  53560. * @returns true if it can be rendered otherwise false
  53561. */
  53562. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53563. /**
  53564. * Returns true if the mesh should render, otherwise false.
  53565. * @param mesh The mesh to render
  53566. * @returns true if it should render otherwise false
  53567. */
  53568. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53569. /**
  53570. * Renders the submesh passed in parameter to the generation map.
  53571. */
  53572. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53573. /**
  53574. * Defines whether the current material of the mesh should be use to render the effect.
  53575. * @param mesh defines the current mesh to render
  53576. */
  53577. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53578. /**
  53579. * Rebuild the required buffers.
  53580. * @hidden Internal use only.
  53581. */
  53582. _rebuild(): void;
  53583. /**
  53584. * Dispose only the render target textures and post process.
  53585. */
  53586. private _disposeTextureAndPostProcesses;
  53587. /**
  53588. * Dispose the highlight layer and free resources.
  53589. */
  53590. dispose(): void;
  53591. /**
  53592. * Gets the class name of the effect layer
  53593. * @returns the string with the class name of the effect layer
  53594. */
  53595. getClassName(): string;
  53596. /**
  53597. * Creates an effect layer from parsed effect layer data
  53598. * @param parsedEffectLayer defines effect layer data
  53599. * @param scene defines the current scene
  53600. * @param rootUrl defines the root URL containing the effect layer information
  53601. * @returns a parsed effect Layer
  53602. */
  53603. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53604. }
  53605. }
  53606. declare module BABYLON {
  53607. interface AbstractScene {
  53608. /**
  53609. * The list of effect layers (highlights/glow) added to the scene
  53610. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53611. * @see http://doc.babylonjs.com/how_to/glow_layer
  53612. */
  53613. effectLayers: Array<EffectLayer>;
  53614. /**
  53615. * Removes the given effect layer from this scene.
  53616. * @param toRemove defines the effect layer to remove
  53617. * @returns the index of the removed effect layer
  53618. */
  53619. removeEffectLayer(toRemove: EffectLayer): number;
  53620. /**
  53621. * Adds the given effect layer to this scene
  53622. * @param newEffectLayer defines the effect layer to add
  53623. */
  53624. addEffectLayer(newEffectLayer: EffectLayer): void;
  53625. }
  53626. /**
  53627. * Defines the layer scene component responsible to manage any effect layers
  53628. * in a given scene.
  53629. */
  53630. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53631. /**
  53632. * The component name helpfull to identify the component in the list of scene components.
  53633. */
  53634. readonly name: string;
  53635. /**
  53636. * The scene the component belongs to.
  53637. */
  53638. scene: Scene;
  53639. private _engine;
  53640. private _renderEffects;
  53641. private _needStencil;
  53642. private _previousStencilState;
  53643. /**
  53644. * Creates a new instance of the component for the given scene
  53645. * @param scene Defines the scene to register the component in
  53646. */
  53647. constructor(scene: Scene);
  53648. /**
  53649. * Registers the component in a given scene
  53650. */
  53651. register(): void;
  53652. /**
  53653. * Rebuilds the elements related to this component in case of
  53654. * context lost for instance.
  53655. */
  53656. rebuild(): void;
  53657. /**
  53658. * Serializes the component data to the specified json object
  53659. * @param serializationObject The object to serialize to
  53660. */
  53661. serialize(serializationObject: any): void;
  53662. /**
  53663. * Adds all the elements from the container to the scene
  53664. * @param container the container holding the elements
  53665. */
  53666. addFromContainer(container: AbstractScene): void;
  53667. /**
  53668. * Removes all the elements in the container from the scene
  53669. * @param container contains the elements to remove
  53670. * @param dispose if the removed element should be disposed (default: false)
  53671. */
  53672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53673. /**
  53674. * Disposes the component and the associated ressources.
  53675. */
  53676. dispose(): void;
  53677. private _isReadyForMesh;
  53678. private _renderMainTexture;
  53679. private _setStencil;
  53680. private _setStencilBack;
  53681. private _draw;
  53682. private _drawCamera;
  53683. private _drawRenderingGroup;
  53684. }
  53685. }
  53686. declare module BABYLON {
  53687. /** @hidden */
  53688. export var glowMapMergePixelShader: {
  53689. name: string;
  53690. shader: string;
  53691. };
  53692. }
  53693. declare module BABYLON {
  53694. /** @hidden */
  53695. export var glowMapMergeVertexShader: {
  53696. name: string;
  53697. shader: string;
  53698. };
  53699. }
  53700. declare module BABYLON {
  53701. interface AbstractScene {
  53702. /**
  53703. * Return a the first highlight layer of the scene with a given name.
  53704. * @param name The name of the highlight layer to look for.
  53705. * @return The highlight layer if found otherwise null.
  53706. */
  53707. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53708. }
  53709. /**
  53710. * Glow layer options. This helps customizing the behaviour
  53711. * of the glow layer.
  53712. */
  53713. export interface IGlowLayerOptions {
  53714. /**
  53715. * Multiplication factor apply to the canvas size to compute the render target size
  53716. * used to generated the glowing objects (the smaller the faster).
  53717. */
  53718. mainTextureRatio: number;
  53719. /**
  53720. * Enforces a fixed size texture to ensure resize independant blur.
  53721. */
  53722. mainTextureFixedSize?: number;
  53723. /**
  53724. * How big is the kernel of the blur texture.
  53725. */
  53726. blurKernelSize: number;
  53727. /**
  53728. * The camera attached to the layer.
  53729. */
  53730. camera: Nullable<Camera>;
  53731. /**
  53732. * Enable MSAA by chosing the number of samples.
  53733. */
  53734. mainTextureSamples?: number;
  53735. /**
  53736. * The rendering group to draw the layer in.
  53737. */
  53738. renderingGroupId: number;
  53739. }
  53740. /**
  53741. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53742. *
  53743. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53744. *
  53745. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53746. */
  53747. export class GlowLayer extends EffectLayer {
  53748. /**
  53749. * Effect Name of the layer.
  53750. */
  53751. static readonly EffectName: string;
  53752. /**
  53753. * The default blur kernel size used for the glow.
  53754. */
  53755. static DefaultBlurKernelSize: number;
  53756. /**
  53757. * The default texture size ratio used for the glow.
  53758. */
  53759. static DefaultTextureRatio: number;
  53760. /**
  53761. * Sets the kernel size of the blur.
  53762. */
  53763. set blurKernelSize(value: number);
  53764. /**
  53765. * Gets the kernel size of the blur.
  53766. */
  53767. get blurKernelSize(): number;
  53768. /**
  53769. * Sets the glow intensity.
  53770. */
  53771. set intensity(value: number);
  53772. /**
  53773. * Gets the glow intensity.
  53774. */
  53775. get intensity(): number;
  53776. private _options;
  53777. private _intensity;
  53778. private _horizontalBlurPostprocess1;
  53779. private _verticalBlurPostprocess1;
  53780. private _horizontalBlurPostprocess2;
  53781. private _verticalBlurPostprocess2;
  53782. private _blurTexture1;
  53783. private _blurTexture2;
  53784. private _postProcesses1;
  53785. private _postProcesses2;
  53786. private _includedOnlyMeshes;
  53787. private _excludedMeshes;
  53788. private _meshesUsingTheirOwnMaterials;
  53789. /**
  53790. * Callback used to let the user override the color selection on a per mesh basis
  53791. */
  53792. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53793. /**
  53794. * Callback used to let the user override the texture selection on a per mesh basis
  53795. */
  53796. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53797. /**
  53798. * Instantiates a new glow Layer and references it to the scene.
  53799. * @param name The name of the layer
  53800. * @param scene The scene to use the layer in
  53801. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53802. */
  53803. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53804. /**
  53805. * Get the effect name of the layer.
  53806. * @return The effect name
  53807. */
  53808. getEffectName(): string;
  53809. /**
  53810. * Create the merge effect. This is the shader use to blit the information back
  53811. * to the main canvas at the end of the scene rendering.
  53812. */
  53813. protected _createMergeEffect(): Effect;
  53814. /**
  53815. * Creates the render target textures and post processes used in the glow layer.
  53816. */
  53817. protected _createTextureAndPostProcesses(): void;
  53818. /**
  53819. * Checks for the readiness of the element composing the layer.
  53820. * @param subMesh the mesh to check for
  53821. * @param useInstances specify wether or not to use instances to render the mesh
  53822. * @param emissiveTexture the associated emissive texture used to generate the glow
  53823. * @return true if ready otherwise, false
  53824. */
  53825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53826. /**
  53827. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53828. */
  53829. needStencil(): boolean;
  53830. /**
  53831. * Returns true if the mesh can be rendered, otherwise false.
  53832. * @param mesh The mesh to render
  53833. * @param material The material used on the mesh
  53834. * @returns true if it can be rendered otherwise false
  53835. */
  53836. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53837. /**
  53838. * Implementation specific of rendering the generating effect on the main canvas.
  53839. * @param effect The effect used to render through
  53840. */
  53841. protected _internalRender(effect: Effect): void;
  53842. /**
  53843. * Sets the required values for both the emissive texture and and the main color.
  53844. */
  53845. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53846. /**
  53847. * Returns true if the mesh should render, otherwise false.
  53848. * @param mesh The mesh to render
  53849. * @returns true if it should render otherwise false
  53850. */
  53851. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53852. /**
  53853. * Adds specific effects defines.
  53854. * @param defines The defines to add specifics to.
  53855. */
  53856. protected _addCustomEffectDefines(defines: string[]): void;
  53857. /**
  53858. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53859. * @param mesh The mesh to exclude from the glow layer
  53860. */
  53861. addExcludedMesh(mesh: Mesh): void;
  53862. /**
  53863. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53864. * @param mesh The mesh to remove
  53865. */
  53866. removeExcludedMesh(mesh: Mesh): void;
  53867. /**
  53868. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53869. * @param mesh The mesh to include in the glow layer
  53870. */
  53871. addIncludedOnlyMesh(mesh: Mesh): void;
  53872. /**
  53873. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53874. * @param mesh The mesh to remove
  53875. */
  53876. removeIncludedOnlyMesh(mesh: Mesh): void;
  53877. /**
  53878. * Determine if a given mesh will be used in the glow layer
  53879. * @param mesh The mesh to test
  53880. * @returns true if the mesh will be highlighted by the current glow layer
  53881. */
  53882. hasMesh(mesh: AbstractMesh): boolean;
  53883. /**
  53884. * Defines whether the current material of the mesh should be use to render the effect.
  53885. * @param mesh defines the current mesh to render
  53886. */
  53887. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53888. /**
  53889. * Add a mesh to be rendered through its own material and not with emissive only.
  53890. * @param mesh The mesh for which we need to use its material
  53891. */
  53892. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53893. /**
  53894. * Remove a mesh from being rendered through its own material and not with emissive only.
  53895. * @param mesh The mesh for which we need to not use its material
  53896. */
  53897. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53898. /**
  53899. * Free any resources and references associated to a mesh.
  53900. * Internal use
  53901. * @param mesh The mesh to free.
  53902. * @hidden
  53903. */
  53904. _disposeMesh(mesh: Mesh): void;
  53905. /**
  53906. * Gets the class name of the effect layer
  53907. * @returns the string with the class name of the effect layer
  53908. */
  53909. getClassName(): string;
  53910. /**
  53911. * Serializes this glow layer
  53912. * @returns a serialized glow layer object
  53913. */
  53914. serialize(): any;
  53915. /**
  53916. * Creates a Glow Layer from parsed glow layer data
  53917. * @param parsedGlowLayer defines glow layer data
  53918. * @param scene defines the current scene
  53919. * @param rootUrl defines the root URL containing the glow layer information
  53920. * @returns a parsed Glow Layer
  53921. */
  53922. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53923. }
  53924. }
  53925. declare module BABYLON {
  53926. /** @hidden */
  53927. export var glowBlurPostProcessPixelShader: {
  53928. name: string;
  53929. shader: string;
  53930. };
  53931. }
  53932. declare module BABYLON {
  53933. interface AbstractScene {
  53934. /**
  53935. * Return a the first highlight layer of the scene with a given name.
  53936. * @param name The name of the highlight layer to look for.
  53937. * @return The highlight layer if found otherwise null.
  53938. */
  53939. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53940. }
  53941. /**
  53942. * Highlight layer options. This helps customizing the behaviour
  53943. * of the highlight layer.
  53944. */
  53945. export interface IHighlightLayerOptions {
  53946. /**
  53947. * Multiplication factor apply to the canvas size to compute the render target size
  53948. * used to generated the glowing objects (the smaller the faster).
  53949. */
  53950. mainTextureRatio: number;
  53951. /**
  53952. * Enforces a fixed size texture to ensure resize independant blur.
  53953. */
  53954. mainTextureFixedSize?: number;
  53955. /**
  53956. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53957. * of the picture to blur (the smaller the faster).
  53958. */
  53959. blurTextureSizeRatio: number;
  53960. /**
  53961. * How big in texel of the blur texture is the vertical blur.
  53962. */
  53963. blurVerticalSize: number;
  53964. /**
  53965. * How big in texel of the blur texture is the horizontal blur.
  53966. */
  53967. blurHorizontalSize: number;
  53968. /**
  53969. * Alpha blending mode used to apply the blur. Default is combine.
  53970. */
  53971. alphaBlendingMode: number;
  53972. /**
  53973. * The camera attached to the layer.
  53974. */
  53975. camera: Nullable<Camera>;
  53976. /**
  53977. * Should we display highlight as a solid stroke?
  53978. */
  53979. isStroke?: boolean;
  53980. /**
  53981. * The rendering group to draw the layer in.
  53982. */
  53983. renderingGroupId: number;
  53984. }
  53985. /**
  53986. * The highlight layer Helps adding a glow effect around a mesh.
  53987. *
  53988. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53989. * glowy meshes to your scene.
  53990. *
  53991. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53992. */
  53993. export class HighlightLayer extends EffectLayer {
  53994. name: string;
  53995. /**
  53996. * Effect Name of the highlight layer.
  53997. */
  53998. static readonly EffectName: string;
  53999. /**
  54000. * The neutral color used during the preparation of the glow effect.
  54001. * This is black by default as the blend operation is a blend operation.
  54002. */
  54003. static NeutralColor: Color4;
  54004. /**
  54005. * Stencil value used for glowing meshes.
  54006. */
  54007. static GlowingMeshStencilReference: number;
  54008. /**
  54009. * Stencil value used for the other meshes in the scene.
  54010. */
  54011. static NormalMeshStencilReference: number;
  54012. /**
  54013. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54014. */
  54015. innerGlow: boolean;
  54016. /**
  54017. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54018. */
  54019. outerGlow: boolean;
  54020. /**
  54021. * Specifies the horizontal size of the blur.
  54022. */
  54023. set blurHorizontalSize(value: number);
  54024. /**
  54025. * Specifies the vertical size of the blur.
  54026. */
  54027. set blurVerticalSize(value: number);
  54028. /**
  54029. * Gets the horizontal size of the blur.
  54030. */
  54031. get blurHorizontalSize(): number;
  54032. /**
  54033. * Gets the vertical size of the blur.
  54034. */
  54035. get blurVerticalSize(): number;
  54036. /**
  54037. * An event triggered when the highlight layer is being blurred.
  54038. */
  54039. onBeforeBlurObservable: Observable<HighlightLayer>;
  54040. /**
  54041. * An event triggered when the highlight layer has been blurred.
  54042. */
  54043. onAfterBlurObservable: Observable<HighlightLayer>;
  54044. private _instanceGlowingMeshStencilReference;
  54045. private _options;
  54046. private _downSamplePostprocess;
  54047. private _horizontalBlurPostprocess;
  54048. private _verticalBlurPostprocess;
  54049. private _blurTexture;
  54050. private _meshes;
  54051. private _excludedMeshes;
  54052. /**
  54053. * Instantiates a new highlight Layer and references it to the scene..
  54054. * @param name The name of the layer
  54055. * @param scene The scene to use the layer in
  54056. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54057. */
  54058. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54059. /**
  54060. * Get the effect name of the layer.
  54061. * @return The effect name
  54062. */
  54063. getEffectName(): string;
  54064. /**
  54065. * Create the merge effect. This is the shader use to blit the information back
  54066. * to the main canvas at the end of the scene rendering.
  54067. */
  54068. protected _createMergeEffect(): Effect;
  54069. /**
  54070. * Creates the render target textures and post processes used in the highlight layer.
  54071. */
  54072. protected _createTextureAndPostProcesses(): void;
  54073. /**
  54074. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54075. */
  54076. needStencil(): boolean;
  54077. /**
  54078. * Checks for the readiness of the element composing the layer.
  54079. * @param subMesh the mesh to check for
  54080. * @param useInstances specify wether or not to use instances to render the mesh
  54081. * @param emissiveTexture the associated emissive texture used to generate the glow
  54082. * @return true if ready otherwise, false
  54083. */
  54084. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54085. /**
  54086. * Implementation specific of rendering the generating effect on the main canvas.
  54087. * @param effect The effect used to render through
  54088. */
  54089. protected _internalRender(effect: Effect): void;
  54090. /**
  54091. * Returns true if the layer contains information to display, otherwise false.
  54092. */
  54093. shouldRender(): boolean;
  54094. /**
  54095. * Returns true if the mesh should render, otherwise false.
  54096. * @param mesh The mesh to render
  54097. * @returns true if it should render otherwise false
  54098. */
  54099. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54100. /**
  54101. * Adds specific effects defines.
  54102. * @param defines The defines to add specifics to.
  54103. */
  54104. protected _addCustomEffectDefines(defines: string[]): void;
  54105. /**
  54106. * Sets the required values for both the emissive texture and and the main color.
  54107. */
  54108. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54109. /**
  54110. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54111. * @param mesh The mesh to exclude from the highlight layer
  54112. */
  54113. addExcludedMesh(mesh: Mesh): void;
  54114. /**
  54115. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54116. * @param mesh The mesh to highlight
  54117. */
  54118. removeExcludedMesh(mesh: Mesh): void;
  54119. /**
  54120. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54121. * @param mesh mesh to test
  54122. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54123. */
  54124. hasMesh(mesh: AbstractMesh): boolean;
  54125. /**
  54126. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54127. * @param mesh The mesh to highlight
  54128. * @param color The color of the highlight
  54129. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54130. */
  54131. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54132. /**
  54133. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54134. * @param mesh The mesh to highlight
  54135. */
  54136. removeMesh(mesh: Mesh): void;
  54137. /**
  54138. * Remove all the meshes currently referenced in the highlight layer
  54139. */
  54140. removeAllMeshes(): void;
  54141. /**
  54142. * Force the stencil to the normal expected value for none glowing parts
  54143. */
  54144. private _defaultStencilReference;
  54145. /**
  54146. * Free any resources and references associated to a mesh.
  54147. * Internal use
  54148. * @param mesh The mesh to free.
  54149. * @hidden
  54150. */
  54151. _disposeMesh(mesh: Mesh): void;
  54152. /**
  54153. * Dispose the highlight layer and free resources.
  54154. */
  54155. dispose(): void;
  54156. /**
  54157. * Gets the class name of the effect layer
  54158. * @returns the string with the class name of the effect layer
  54159. */
  54160. getClassName(): string;
  54161. /**
  54162. * Serializes this Highlight layer
  54163. * @returns a serialized Highlight layer object
  54164. */
  54165. serialize(): any;
  54166. /**
  54167. * Creates a Highlight layer from parsed Highlight layer data
  54168. * @param parsedHightlightLayer defines the Highlight layer data
  54169. * @param scene defines the current scene
  54170. * @param rootUrl defines the root URL containing the Highlight layer information
  54171. * @returns a parsed Highlight layer
  54172. */
  54173. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54174. }
  54175. }
  54176. declare module BABYLON {
  54177. interface AbstractScene {
  54178. /**
  54179. * The list of layers (background and foreground) of the scene
  54180. */
  54181. layers: Array<Layer>;
  54182. }
  54183. /**
  54184. * Defines the layer scene component responsible to manage any layers
  54185. * in a given scene.
  54186. */
  54187. export class LayerSceneComponent implements ISceneComponent {
  54188. /**
  54189. * The component name helpfull to identify the component in the list of scene components.
  54190. */
  54191. readonly name: string;
  54192. /**
  54193. * The scene the component belongs to.
  54194. */
  54195. scene: Scene;
  54196. private _engine;
  54197. /**
  54198. * Creates a new instance of the component for the given scene
  54199. * @param scene Defines the scene to register the component in
  54200. */
  54201. constructor(scene: Scene);
  54202. /**
  54203. * Registers the component in a given scene
  54204. */
  54205. register(): void;
  54206. /**
  54207. * Rebuilds the elements related to this component in case of
  54208. * context lost for instance.
  54209. */
  54210. rebuild(): void;
  54211. /**
  54212. * Disposes the component and the associated ressources.
  54213. */
  54214. dispose(): void;
  54215. private _draw;
  54216. private _drawCameraPredicate;
  54217. private _drawCameraBackground;
  54218. private _drawCameraForeground;
  54219. private _drawRenderTargetPredicate;
  54220. private _drawRenderTargetBackground;
  54221. private _drawRenderTargetForeground;
  54222. /**
  54223. * Adds all the elements from the container to the scene
  54224. * @param container the container holding the elements
  54225. */
  54226. addFromContainer(container: AbstractScene): void;
  54227. /**
  54228. * Removes all the elements in the container from the scene
  54229. * @param container contains the elements to remove
  54230. * @param dispose if the removed element should be disposed (default: false)
  54231. */
  54232. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54233. }
  54234. }
  54235. declare module BABYLON {
  54236. /** @hidden */
  54237. export var layerPixelShader: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var layerVertexShader: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * This represents a full screen 2d layer.
  54252. * This can be useful to display a picture in the background of your scene for instance.
  54253. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54254. */
  54255. export class Layer {
  54256. /**
  54257. * Define the name of the layer.
  54258. */
  54259. name: string;
  54260. /**
  54261. * Define the texture the layer should display.
  54262. */
  54263. texture: Nullable<Texture>;
  54264. /**
  54265. * Is the layer in background or foreground.
  54266. */
  54267. isBackground: boolean;
  54268. /**
  54269. * Define the color of the layer (instead of texture).
  54270. */
  54271. color: Color4;
  54272. /**
  54273. * Define the scale of the layer in order to zoom in out of the texture.
  54274. */
  54275. scale: Vector2;
  54276. /**
  54277. * Define an offset for the layer in order to shift the texture.
  54278. */
  54279. offset: Vector2;
  54280. /**
  54281. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54282. */
  54283. alphaBlendingMode: number;
  54284. /**
  54285. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54286. * Alpha test will not mix with the background color in case of transparency.
  54287. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54288. */
  54289. alphaTest: boolean;
  54290. /**
  54291. * Define a mask to restrict the layer to only some of the scene cameras.
  54292. */
  54293. layerMask: number;
  54294. /**
  54295. * Define the list of render target the layer is visible into.
  54296. */
  54297. renderTargetTextures: RenderTargetTexture[];
  54298. /**
  54299. * Define if the layer is only used in renderTarget or if it also
  54300. * renders in the main frame buffer of the canvas.
  54301. */
  54302. renderOnlyInRenderTargetTextures: boolean;
  54303. private _scene;
  54304. private _vertexBuffers;
  54305. private _indexBuffer;
  54306. private _effect;
  54307. private _previousDefines;
  54308. /**
  54309. * An event triggered when the layer is disposed.
  54310. */
  54311. onDisposeObservable: Observable<Layer>;
  54312. private _onDisposeObserver;
  54313. /**
  54314. * Back compatibility with callback before the onDisposeObservable existed.
  54315. * The set callback will be triggered when the layer has been disposed.
  54316. */
  54317. set onDispose(callback: () => void);
  54318. /**
  54319. * An event triggered before rendering the scene
  54320. */
  54321. onBeforeRenderObservable: Observable<Layer>;
  54322. private _onBeforeRenderObserver;
  54323. /**
  54324. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54325. * The set callback will be triggered just before rendering the layer.
  54326. */
  54327. set onBeforeRender(callback: () => void);
  54328. /**
  54329. * An event triggered after rendering the scene
  54330. */
  54331. onAfterRenderObservable: Observable<Layer>;
  54332. private _onAfterRenderObserver;
  54333. /**
  54334. * Back compatibility with callback before the onAfterRenderObservable existed.
  54335. * The set callback will be triggered just after rendering the layer.
  54336. */
  54337. set onAfterRender(callback: () => void);
  54338. /**
  54339. * Instantiates a new layer.
  54340. * This represents a full screen 2d layer.
  54341. * This can be useful to display a picture in the background of your scene for instance.
  54342. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54343. * @param name Define the name of the layer in the scene
  54344. * @param imgUrl Define the url of the texture to display in the layer
  54345. * @param scene Define the scene the layer belongs to
  54346. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54347. * @param color Defines a color for the layer
  54348. */
  54349. constructor(
  54350. /**
  54351. * Define the name of the layer.
  54352. */
  54353. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54354. private _createIndexBuffer;
  54355. /** @hidden */
  54356. _rebuild(): void;
  54357. /**
  54358. * Renders the layer in the scene.
  54359. */
  54360. render(): void;
  54361. /**
  54362. * Disposes and releases the associated ressources.
  54363. */
  54364. dispose(): void;
  54365. }
  54366. }
  54367. declare module BABYLON {
  54368. /** @hidden */
  54369. export var lensFlarePixelShader: {
  54370. name: string;
  54371. shader: string;
  54372. };
  54373. }
  54374. declare module BABYLON {
  54375. /** @hidden */
  54376. export var lensFlareVertexShader: {
  54377. name: string;
  54378. shader: string;
  54379. };
  54380. }
  54381. declare module BABYLON {
  54382. /**
  54383. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54384. * It is usually composed of several `lensFlare`.
  54385. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54386. */
  54387. export class LensFlareSystem {
  54388. /**
  54389. * Define the name of the lens flare system
  54390. */
  54391. name: string;
  54392. /**
  54393. * List of lens flares used in this system.
  54394. */
  54395. lensFlares: LensFlare[];
  54396. /**
  54397. * Define a limit from the border the lens flare can be visible.
  54398. */
  54399. borderLimit: number;
  54400. /**
  54401. * Define a viewport border we do not want to see the lens flare in.
  54402. */
  54403. viewportBorder: number;
  54404. /**
  54405. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54406. */
  54407. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54408. /**
  54409. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54410. */
  54411. layerMask: number;
  54412. /**
  54413. * Define the id of the lens flare system in the scene.
  54414. * (equal to name by default)
  54415. */
  54416. id: string;
  54417. private _scene;
  54418. private _emitter;
  54419. private _vertexBuffers;
  54420. private _indexBuffer;
  54421. private _effect;
  54422. private _positionX;
  54423. private _positionY;
  54424. private _isEnabled;
  54425. /** @hidden */
  54426. static _SceneComponentInitialization: (scene: Scene) => void;
  54427. /**
  54428. * Instantiates a lens flare system.
  54429. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54430. * It is usually composed of several `lensFlare`.
  54431. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54432. * @param name Define the name of the lens flare system in the scene
  54433. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54434. * @param scene Define the scene the lens flare system belongs to
  54435. */
  54436. constructor(
  54437. /**
  54438. * Define the name of the lens flare system
  54439. */
  54440. name: string, emitter: any, scene: Scene);
  54441. /**
  54442. * Define if the lens flare system is enabled.
  54443. */
  54444. get isEnabled(): boolean;
  54445. set isEnabled(value: boolean);
  54446. /**
  54447. * Get the scene the effects belongs to.
  54448. * @returns the scene holding the lens flare system
  54449. */
  54450. getScene(): Scene;
  54451. /**
  54452. * Get the emitter of the lens flare system.
  54453. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54454. * @returns the emitter of the lens flare system
  54455. */
  54456. getEmitter(): any;
  54457. /**
  54458. * Set the emitter of the lens flare system.
  54459. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54460. * @param newEmitter Define the new emitter of the system
  54461. */
  54462. setEmitter(newEmitter: any): void;
  54463. /**
  54464. * Get the lens flare system emitter position.
  54465. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54466. * @returns the position
  54467. */
  54468. getEmitterPosition(): Vector3;
  54469. /**
  54470. * @hidden
  54471. */
  54472. computeEffectivePosition(globalViewport: Viewport): boolean;
  54473. /** @hidden */
  54474. _isVisible(): boolean;
  54475. /**
  54476. * @hidden
  54477. */
  54478. render(): boolean;
  54479. /**
  54480. * Dispose and release the lens flare with its associated resources.
  54481. */
  54482. dispose(): void;
  54483. /**
  54484. * Parse a lens flare system from a JSON repressentation
  54485. * @param parsedLensFlareSystem Define the JSON to parse
  54486. * @param scene Define the scene the parsed system should be instantiated in
  54487. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54488. * @returns the parsed system
  54489. */
  54490. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54491. /**
  54492. * Serialize the current Lens Flare System into a JSON representation.
  54493. * @returns the serialized JSON
  54494. */
  54495. serialize(): any;
  54496. }
  54497. }
  54498. declare module BABYLON {
  54499. /**
  54500. * This represents one of the lens effect in a `lensFlareSystem`.
  54501. * It controls one of the indiviual texture used in the effect.
  54502. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54503. */
  54504. export class LensFlare {
  54505. /**
  54506. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54507. */
  54508. size: number;
  54509. /**
  54510. * 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.
  54511. */
  54512. position: number;
  54513. /**
  54514. * Define the lens color.
  54515. */
  54516. color: Color3;
  54517. /**
  54518. * Define the lens texture.
  54519. */
  54520. texture: Nullable<Texture>;
  54521. /**
  54522. * Define the alpha mode to render this particular lens.
  54523. */
  54524. alphaMode: number;
  54525. private _system;
  54526. /**
  54527. * Creates a new Lens Flare.
  54528. * This represents one of the lens effect in a `lensFlareSystem`.
  54529. * It controls one of the indiviual texture used in the effect.
  54530. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54531. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54532. * @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.
  54533. * @param color Define the lens color
  54534. * @param imgUrl Define the lens texture url
  54535. * @param system Define the `lensFlareSystem` this flare is part of
  54536. * @returns The newly created Lens Flare
  54537. */
  54538. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54539. /**
  54540. * Instantiates a new Lens Flare.
  54541. * This represents one of the lens effect in a `lensFlareSystem`.
  54542. * It controls one of the indiviual texture used in the effect.
  54543. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54544. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54545. * @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.
  54546. * @param color Define the lens color
  54547. * @param imgUrl Define the lens texture url
  54548. * @param system Define the `lensFlareSystem` this flare is part of
  54549. */
  54550. constructor(
  54551. /**
  54552. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54553. */
  54554. size: number,
  54555. /**
  54556. * 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.
  54557. */
  54558. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54559. /**
  54560. * Dispose and release the lens flare with its associated resources.
  54561. */
  54562. dispose(): void;
  54563. }
  54564. }
  54565. declare module BABYLON {
  54566. interface AbstractScene {
  54567. /**
  54568. * The list of lens flare system added to the scene
  54569. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54570. */
  54571. lensFlareSystems: Array<LensFlareSystem>;
  54572. /**
  54573. * Removes the given lens flare system from this scene.
  54574. * @param toRemove The lens flare system to remove
  54575. * @returns The index of the removed lens flare system
  54576. */
  54577. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54578. /**
  54579. * Adds the given lens flare system to this scene
  54580. * @param newLensFlareSystem The lens flare system to add
  54581. */
  54582. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54583. /**
  54584. * Gets a lens flare system using its name
  54585. * @param name defines the name to look for
  54586. * @returns the lens flare system or null if not found
  54587. */
  54588. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54589. /**
  54590. * Gets a lens flare system using its id
  54591. * @param id defines the id to look for
  54592. * @returns the lens flare system or null if not found
  54593. */
  54594. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54595. }
  54596. /**
  54597. * Defines the lens flare scene component responsible to manage any lens flares
  54598. * in a given scene.
  54599. */
  54600. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54601. /**
  54602. * The component name helpfull to identify the component in the list of scene components.
  54603. */
  54604. readonly name: string;
  54605. /**
  54606. * The scene the component belongs to.
  54607. */
  54608. scene: Scene;
  54609. /**
  54610. * Creates a new instance of the component for the given scene
  54611. * @param scene Defines the scene to register the component in
  54612. */
  54613. constructor(scene: Scene);
  54614. /**
  54615. * Registers the component in a given scene
  54616. */
  54617. register(): void;
  54618. /**
  54619. * Rebuilds the elements related to this component in case of
  54620. * context lost for instance.
  54621. */
  54622. rebuild(): void;
  54623. /**
  54624. * Adds all the elements from the container to the scene
  54625. * @param container the container holding the elements
  54626. */
  54627. addFromContainer(container: AbstractScene): void;
  54628. /**
  54629. * Removes all the elements in the container from the scene
  54630. * @param container contains the elements to remove
  54631. * @param dispose if the removed element should be disposed (default: false)
  54632. */
  54633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54634. /**
  54635. * Serializes the component data to the specified json object
  54636. * @param serializationObject The object to serialize to
  54637. */
  54638. serialize(serializationObject: any): void;
  54639. /**
  54640. * Disposes the component and the associated ressources.
  54641. */
  54642. dispose(): void;
  54643. private _draw;
  54644. }
  54645. }
  54646. declare module BABYLON {
  54647. /** @hidden */
  54648. export var depthPixelShader: {
  54649. name: string;
  54650. shader: string;
  54651. };
  54652. }
  54653. declare module BABYLON {
  54654. /** @hidden */
  54655. export var depthVertexShader: {
  54656. name: string;
  54657. shader: string;
  54658. };
  54659. }
  54660. declare module BABYLON {
  54661. /**
  54662. * This represents a depth renderer in Babylon.
  54663. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54664. */
  54665. export class DepthRenderer {
  54666. private _scene;
  54667. private _depthMap;
  54668. private _effect;
  54669. private readonly _storeNonLinearDepth;
  54670. private readonly _clearColor;
  54671. /** Get if the depth renderer is using packed depth or not */
  54672. readonly isPacked: boolean;
  54673. private _cachedDefines;
  54674. private _camera;
  54675. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54676. enabled: boolean;
  54677. /**
  54678. * Specifiess that the depth renderer will only be used within
  54679. * the camera it is created for.
  54680. * This can help forcing its rendering during the camera processing.
  54681. */
  54682. useOnlyInActiveCamera: boolean;
  54683. /** @hidden */
  54684. static _SceneComponentInitialization: (scene: Scene) => void;
  54685. /**
  54686. * Instantiates a depth renderer
  54687. * @param scene The scene the renderer belongs to
  54688. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54689. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54690. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54691. */
  54692. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54693. /**
  54694. * Creates the depth rendering effect and checks if the effect is ready.
  54695. * @param subMesh The submesh to be used to render the depth map of
  54696. * @param useInstances If multiple world instances should be used
  54697. * @returns if the depth renderer is ready to render the depth map
  54698. */
  54699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54700. /**
  54701. * Gets the texture which the depth map will be written to.
  54702. * @returns The depth map texture
  54703. */
  54704. getDepthMap(): RenderTargetTexture;
  54705. /**
  54706. * Disposes of the depth renderer.
  54707. */
  54708. dispose(): void;
  54709. }
  54710. }
  54711. declare module BABYLON {
  54712. /** @hidden */
  54713. export var minmaxReduxPixelShader: {
  54714. name: string;
  54715. shader: string;
  54716. };
  54717. }
  54718. declare module BABYLON {
  54719. /**
  54720. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54721. * and maximum values from all values of the texture.
  54722. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54723. * The source values are read from the red channel of the texture.
  54724. */
  54725. export class MinMaxReducer {
  54726. /**
  54727. * Observable triggered when the computation has been performed
  54728. */
  54729. onAfterReductionPerformed: Observable<{
  54730. min: number;
  54731. max: number;
  54732. }>;
  54733. protected _camera: Camera;
  54734. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54735. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54736. protected _postProcessManager: PostProcessManager;
  54737. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54738. protected _forceFullscreenViewport: boolean;
  54739. /**
  54740. * Creates a min/max reducer
  54741. * @param camera The camera to use for the post processes
  54742. */
  54743. constructor(camera: Camera);
  54744. /**
  54745. * Gets the texture used to read the values from.
  54746. */
  54747. get sourceTexture(): Nullable<RenderTargetTexture>;
  54748. /**
  54749. * Sets the source texture to read the values from.
  54750. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54751. * because in such textures '1' value must not be taken into account to compute the maximum
  54752. * as this value is used to clear the texture.
  54753. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54754. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54755. * @param depthRedux Indicates if the texture is a depth texture or not
  54756. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54757. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54758. */
  54759. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54760. /**
  54761. * Defines the refresh rate of the computation.
  54762. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54763. */
  54764. get refreshRate(): number;
  54765. set refreshRate(value: number);
  54766. protected _activated: boolean;
  54767. /**
  54768. * Gets the activation status of the reducer
  54769. */
  54770. get activated(): boolean;
  54771. /**
  54772. * Activates the reduction computation.
  54773. * When activated, the observers registered in onAfterReductionPerformed are
  54774. * called after the compuation is performed
  54775. */
  54776. activate(): void;
  54777. /**
  54778. * Deactivates the reduction computation.
  54779. */
  54780. deactivate(): void;
  54781. /**
  54782. * Disposes the min/max reducer
  54783. * @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.
  54784. */
  54785. dispose(disposeAll?: boolean): void;
  54786. }
  54787. }
  54788. declare module BABYLON {
  54789. /**
  54790. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54791. */
  54792. export class DepthReducer extends MinMaxReducer {
  54793. private _depthRenderer;
  54794. private _depthRendererId;
  54795. /**
  54796. * Gets the depth renderer used for the computation.
  54797. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54798. */
  54799. get depthRenderer(): Nullable<DepthRenderer>;
  54800. /**
  54801. * Creates a depth reducer
  54802. * @param camera The camera used to render the depth texture
  54803. */
  54804. constructor(camera: Camera);
  54805. /**
  54806. * Sets the depth renderer to use to generate the depth map
  54807. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54808. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54809. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54810. */
  54811. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54812. /** @hidden */
  54813. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54814. /**
  54815. * Activates the reduction computation.
  54816. * When activated, the observers registered in onAfterReductionPerformed are
  54817. * called after the compuation is performed
  54818. */
  54819. activate(): void;
  54820. /**
  54821. * Deactivates the reduction computation.
  54822. */
  54823. deactivate(): void;
  54824. /**
  54825. * Disposes the depth reducer
  54826. * @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.
  54827. */
  54828. dispose(disposeAll?: boolean): void;
  54829. }
  54830. }
  54831. declare module BABYLON {
  54832. /**
  54833. * A CSM implementation allowing casting shadows on large scenes.
  54834. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54835. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54836. */
  54837. export class CascadedShadowGenerator extends ShadowGenerator {
  54838. private static readonly frustumCornersNDCSpace;
  54839. /**
  54840. * Name of the CSM class
  54841. */
  54842. static CLASSNAME: string;
  54843. /**
  54844. * Defines the default number of cascades used by the CSM.
  54845. */
  54846. static readonly DEFAULT_CASCADES_COUNT: number;
  54847. /**
  54848. * Defines the minimum number of cascades used by the CSM.
  54849. */
  54850. static readonly MIN_CASCADES_COUNT: number;
  54851. /**
  54852. * Defines the maximum number of cascades used by the CSM.
  54853. */
  54854. static readonly MAX_CASCADES_COUNT: number;
  54855. protected _validateFilter(filter: number): number;
  54856. /**
  54857. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54858. */
  54859. penumbraDarkness: number;
  54860. private _numCascades;
  54861. /**
  54862. * Gets or set the number of cascades used by the CSM.
  54863. */
  54864. get numCascades(): number;
  54865. set numCascades(value: number);
  54866. /**
  54867. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54868. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54869. */
  54870. stabilizeCascades: boolean;
  54871. private _freezeShadowCastersBoundingInfo;
  54872. private _freezeShadowCastersBoundingInfoObservable;
  54873. /**
  54874. * Enables or disables the shadow casters bounding info computation.
  54875. * If your shadow casters don't move, you can disable this feature.
  54876. * If it is enabled, the bounding box computation is done every frame.
  54877. */
  54878. get freezeShadowCastersBoundingInfo(): boolean;
  54879. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54880. private _scbiMin;
  54881. private _scbiMax;
  54882. protected _computeShadowCastersBoundingInfo(): void;
  54883. protected _shadowCastersBoundingInfo: BoundingInfo;
  54884. /**
  54885. * Gets or sets the shadow casters bounding info.
  54886. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54887. * so that the system won't overwrite the bounds you provide
  54888. */
  54889. get shadowCastersBoundingInfo(): BoundingInfo;
  54890. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54891. protected _breaksAreDirty: boolean;
  54892. protected _minDistance: number;
  54893. protected _maxDistance: number;
  54894. /**
  54895. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54896. *
  54897. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54898. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54899. * @param min minimal distance for the breaks (default to 0.)
  54900. * @param max maximal distance for the breaks (default to 1.)
  54901. */
  54902. setMinMaxDistance(min: number, max: number): void;
  54903. /** Gets the minimal distance used in the cascade break computation */
  54904. get minDistance(): number;
  54905. /** Gets the maximal distance used in the cascade break computation */
  54906. get maxDistance(): number;
  54907. /**
  54908. * Gets the class name of that object
  54909. * @returns "CascadedShadowGenerator"
  54910. */
  54911. getClassName(): string;
  54912. private _cascadeMinExtents;
  54913. private _cascadeMaxExtents;
  54914. /**
  54915. * Gets a cascade minimum extents
  54916. * @param cascadeIndex index of the cascade
  54917. * @returns the minimum cascade extents
  54918. */
  54919. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54920. /**
  54921. * Gets a cascade maximum extents
  54922. * @param cascadeIndex index of the cascade
  54923. * @returns the maximum cascade extents
  54924. */
  54925. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54926. private _cascades;
  54927. private _currentLayer;
  54928. private _viewSpaceFrustumsZ;
  54929. private _viewMatrices;
  54930. private _projectionMatrices;
  54931. private _transformMatrices;
  54932. private _transformMatricesAsArray;
  54933. private _frustumLengths;
  54934. private _lightSizeUVCorrection;
  54935. private _depthCorrection;
  54936. private _frustumCornersWorldSpace;
  54937. private _frustumCenter;
  54938. private _shadowCameraPos;
  54939. private _shadowMaxZ;
  54940. /**
  54941. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54942. * It defaults to camera.maxZ
  54943. */
  54944. get shadowMaxZ(): number;
  54945. /**
  54946. * Sets the shadow max z distance.
  54947. */
  54948. set shadowMaxZ(value: number);
  54949. protected _debug: boolean;
  54950. /**
  54951. * Gets or sets the debug flag.
  54952. * When enabled, the cascades are materialized by different colors on the screen.
  54953. */
  54954. get debug(): boolean;
  54955. set debug(dbg: boolean);
  54956. private _depthClamp;
  54957. /**
  54958. * Gets or sets the depth clamping value.
  54959. *
  54960. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54961. * to account for the shadow casters far away.
  54962. *
  54963. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54964. */
  54965. get depthClamp(): boolean;
  54966. set depthClamp(value: boolean);
  54967. private _cascadeBlendPercentage;
  54968. /**
  54969. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54970. * It defaults to 0.1 (10% blending).
  54971. */
  54972. get cascadeBlendPercentage(): number;
  54973. set cascadeBlendPercentage(value: number);
  54974. private _lambda;
  54975. /**
  54976. * Gets or set the lambda parameter.
  54977. * This parameter is used to split the camera frustum and create the cascades.
  54978. * 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.
  54979. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54980. */
  54981. get lambda(): number;
  54982. set lambda(value: number);
  54983. /**
  54984. * Gets the view matrix corresponding to a given cascade
  54985. * @param cascadeNum cascade to retrieve the view matrix from
  54986. * @returns the cascade view matrix
  54987. */
  54988. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54989. /**
  54990. * Gets the projection matrix corresponding to a given cascade
  54991. * @param cascadeNum cascade to retrieve the projection matrix from
  54992. * @returns the cascade projection matrix
  54993. */
  54994. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54995. /**
  54996. * Gets the transformation matrix corresponding to a given cascade
  54997. * @param cascadeNum cascade to retrieve the transformation matrix from
  54998. * @returns the cascade transformation matrix
  54999. */
  55000. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55001. private _depthRenderer;
  55002. /**
  55003. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55004. *
  55005. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55006. *
  55007. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55008. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55009. * @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
  55010. */
  55011. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55012. private _depthReducer;
  55013. private _autoCalcDepthBounds;
  55014. /**
  55015. * Gets or sets the autoCalcDepthBounds property.
  55016. *
  55017. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55018. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55019. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55020. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55021. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55022. */
  55023. get autoCalcDepthBounds(): boolean;
  55024. set autoCalcDepthBounds(value: boolean);
  55025. /**
  55026. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55027. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55028. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55029. * for setting the refresh rate on the renderer yourself!
  55030. */
  55031. get autoCalcDepthBoundsRefreshRate(): number;
  55032. set autoCalcDepthBoundsRefreshRate(value: number);
  55033. /**
  55034. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55035. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55036. * you change the camera near/far planes!
  55037. */
  55038. splitFrustum(): void;
  55039. private _splitFrustum;
  55040. private _computeMatrices;
  55041. private _computeFrustumInWorldSpace;
  55042. private _computeCascadeFrustum;
  55043. /**
  55044. * Support test.
  55045. */
  55046. static get IsSupported(): boolean;
  55047. /** @hidden */
  55048. static _SceneComponentInitialization: (scene: Scene) => void;
  55049. /**
  55050. * Creates a Cascaded Shadow Generator object.
  55051. * A ShadowGenerator is the required tool to use the shadows.
  55052. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55053. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55054. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55055. * @param light The directional light object generating the shadows.
  55056. * @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.
  55057. */
  55058. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55059. protected _initializeGenerator(): void;
  55060. protected _createTargetRenderTexture(): void;
  55061. protected _initializeShadowMap(): void;
  55062. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any): void;
  55063. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55064. /**
  55065. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55066. * @param defines Defines of the material we want to update
  55067. * @param lightIndex Index of the light in the enabled light list of the material
  55068. */
  55069. prepareDefines(defines: any, lightIndex: number): void;
  55070. /**
  55071. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55072. * defined in the generator but impacting the effect).
  55073. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55074. * @param effect The effect we are binfing the information for
  55075. */
  55076. bindShadowLight(lightIndex: string, effect: Effect): void;
  55077. /**
  55078. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55079. * (eq to view projection * shadow projection matrices)
  55080. * @returns The transform matrix used to create the shadow map
  55081. */
  55082. getTransformMatrix(): Matrix;
  55083. /**
  55084. * Disposes the ShadowGenerator.
  55085. * Returns nothing.
  55086. */
  55087. dispose(): void;
  55088. /**
  55089. * Serializes the shadow generator setup to a json object.
  55090. * @returns The serialized JSON object
  55091. */
  55092. serialize(): any;
  55093. /**
  55094. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55095. * @param parsedShadowGenerator The JSON object to parse
  55096. * @param scene The scene to create the shadow map for
  55097. * @returns The parsed shadow generator
  55098. */
  55099. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55100. }
  55101. }
  55102. declare module BABYLON {
  55103. /**
  55104. * Defines the shadow generator component responsible to manage any shadow generators
  55105. * in a given scene.
  55106. */
  55107. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55108. /**
  55109. * The component name helpfull to identify the component in the list of scene components.
  55110. */
  55111. readonly name: string;
  55112. /**
  55113. * The scene the component belongs to.
  55114. */
  55115. scene: Scene;
  55116. /**
  55117. * Creates a new instance of the component for the given scene
  55118. * @param scene Defines the scene to register the component in
  55119. */
  55120. constructor(scene: Scene);
  55121. /**
  55122. * Registers the component in a given scene
  55123. */
  55124. register(): void;
  55125. /**
  55126. * Rebuilds the elements related to this component in case of
  55127. * context lost for instance.
  55128. */
  55129. rebuild(): void;
  55130. /**
  55131. * Serializes the component data to the specified json object
  55132. * @param serializationObject The object to serialize to
  55133. */
  55134. serialize(serializationObject: any): void;
  55135. /**
  55136. * Adds all the elements from the container to the scene
  55137. * @param container the container holding the elements
  55138. */
  55139. addFromContainer(container: AbstractScene): void;
  55140. /**
  55141. * Removes all the elements in the container from the scene
  55142. * @param container contains the elements to remove
  55143. * @param dispose if the removed element should be disposed (default: false)
  55144. */
  55145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55146. /**
  55147. * Rebuilds the elements related to this component in case of
  55148. * context lost for instance.
  55149. */
  55150. dispose(): void;
  55151. private _gatherRenderTargets;
  55152. }
  55153. }
  55154. declare module BABYLON {
  55155. /**
  55156. * A point light is a light defined by an unique point in world space.
  55157. * The light is emitted in every direction from this point.
  55158. * A good example of a point light is a standard light bulb.
  55159. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55160. */
  55161. export class PointLight extends ShadowLight {
  55162. private _shadowAngle;
  55163. /**
  55164. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55165. * This specifies what angle the shadow will use to be created.
  55166. *
  55167. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55168. */
  55169. get shadowAngle(): number;
  55170. /**
  55171. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55172. * This specifies what angle the shadow will use to be created.
  55173. *
  55174. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55175. */
  55176. set shadowAngle(value: number);
  55177. /**
  55178. * Gets the direction if it has been set.
  55179. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55180. */
  55181. get direction(): Vector3;
  55182. /**
  55183. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55184. */
  55185. set direction(value: Vector3);
  55186. /**
  55187. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55188. * A PointLight emits the light in every direction.
  55189. * It can cast shadows.
  55190. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55191. * ```javascript
  55192. * var pointLight = new PointLight("pl", camera.position, scene);
  55193. * ```
  55194. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55195. * @param name The light friendly name
  55196. * @param position The position of the point light in the scene
  55197. * @param scene The scene the lights belongs to
  55198. */
  55199. constructor(name: string, position: Vector3, scene: Scene);
  55200. /**
  55201. * Returns the string "PointLight"
  55202. * @returns the class name
  55203. */
  55204. getClassName(): string;
  55205. /**
  55206. * Returns the integer 0.
  55207. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55208. */
  55209. getTypeID(): number;
  55210. /**
  55211. * Specifies wether or not the shadowmap should be a cube texture.
  55212. * @returns true if the shadowmap needs to be a cube texture.
  55213. */
  55214. needCube(): boolean;
  55215. /**
  55216. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55217. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55218. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55219. */
  55220. getShadowDirection(faceIndex?: number): Vector3;
  55221. /**
  55222. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55223. * - fov = PI / 2
  55224. * - aspect ratio : 1.0
  55225. * - z-near and far equal to the active camera minZ and maxZ.
  55226. * Returns the PointLight.
  55227. */
  55228. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55229. protected _buildUniformLayout(): void;
  55230. /**
  55231. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55232. * @param effect The effect to update
  55233. * @param lightIndex The index of the light in the effect to update
  55234. * @returns The point light
  55235. */
  55236. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55237. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55238. /**
  55239. * Prepares the list of defines specific to the light type.
  55240. * @param defines the list of defines
  55241. * @param lightIndex defines the index of the light for the effect
  55242. */
  55243. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55244. }
  55245. }
  55246. declare module BABYLON {
  55247. /**
  55248. * Header information of HDR texture files.
  55249. */
  55250. export interface HDRInfo {
  55251. /**
  55252. * The height of the texture in pixels.
  55253. */
  55254. height: number;
  55255. /**
  55256. * The width of the texture in pixels.
  55257. */
  55258. width: number;
  55259. /**
  55260. * The index of the beginning of the data in the binary file.
  55261. */
  55262. dataPosition: number;
  55263. }
  55264. /**
  55265. * This groups tools to convert HDR texture to native colors array.
  55266. */
  55267. export class HDRTools {
  55268. private static Ldexp;
  55269. private static Rgbe2float;
  55270. private static readStringLine;
  55271. /**
  55272. * Reads header information from an RGBE texture stored in a native array.
  55273. * More information on this format are available here:
  55274. * https://en.wikipedia.org/wiki/RGBE_image_format
  55275. *
  55276. * @param uint8array The binary file stored in native array.
  55277. * @return The header information.
  55278. */
  55279. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55280. /**
  55281. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55282. * This RGBE texture needs to store the information as a panorama.
  55283. *
  55284. * More information on this format are available here:
  55285. * https://en.wikipedia.org/wiki/RGBE_image_format
  55286. *
  55287. * @param buffer The binary file stored in an array buffer.
  55288. * @param size The expected size of the extracted cubemap.
  55289. * @return The Cube Map information.
  55290. */
  55291. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55292. /**
  55293. * Returns the pixels data extracted from an RGBE texture.
  55294. * This pixels will be stored left to right up to down in the R G B order in one array.
  55295. *
  55296. * More information on this format are available here:
  55297. * https://en.wikipedia.org/wiki/RGBE_image_format
  55298. *
  55299. * @param uint8array The binary file stored in an array buffer.
  55300. * @param hdrInfo The header information of the file.
  55301. * @return The pixels data in RGB right to left up to down order.
  55302. */
  55303. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55304. private static RGBE_ReadPixels_RLE;
  55305. }
  55306. }
  55307. declare module BABYLON {
  55308. /**
  55309. * This represents a texture coming from an HDR input.
  55310. *
  55311. * The only supported format is currently panorama picture stored in RGBE format.
  55312. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55313. */
  55314. export class HDRCubeTexture extends BaseTexture {
  55315. private static _facesMapping;
  55316. private _generateHarmonics;
  55317. private _noMipmap;
  55318. private _textureMatrix;
  55319. private _size;
  55320. private _onLoad;
  55321. private _onError;
  55322. /**
  55323. * The texture URL.
  55324. */
  55325. url: string;
  55326. /**
  55327. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55328. */
  55329. coordinatesMode: number;
  55330. protected _isBlocking: boolean;
  55331. /**
  55332. * Sets wether or not the texture is blocking during loading.
  55333. */
  55334. set isBlocking(value: boolean);
  55335. /**
  55336. * Gets wether or not the texture is blocking during loading.
  55337. */
  55338. get isBlocking(): boolean;
  55339. protected _rotationY: number;
  55340. /**
  55341. * Sets texture matrix rotation angle around Y axis in radians.
  55342. */
  55343. set rotationY(value: number);
  55344. /**
  55345. * Gets texture matrix rotation angle around Y axis radians.
  55346. */
  55347. get rotationY(): number;
  55348. /**
  55349. * Gets or sets the center of the bounding box associated with the cube texture
  55350. * It must define where the camera used to render the texture was set
  55351. */
  55352. boundingBoxPosition: Vector3;
  55353. private _boundingBoxSize;
  55354. /**
  55355. * Gets or sets the size of the bounding box associated with the cube texture
  55356. * When defined, the cubemap will switch to local mode
  55357. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55358. * @example https://www.babylonjs-playground.com/#RNASML
  55359. */
  55360. set boundingBoxSize(value: Vector3);
  55361. get boundingBoxSize(): Vector3;
  55362. /**
  55363. * Instantiates an HDRTexture from the following parameters.
  55364. *
  55365. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55366. * @param scene The scene the texture will be used in
  55367. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55368. * @param noMipmap Forces to not generate the mipmap if true
  55369. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55370. * @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)
  55371. * @param reserved Reserved flag for internal use.
  55372. */
  55373. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55374. /**
  55375. * Get the current class name of the texture useful for serialization or dynamic coding.
  55376. * @returns "HDRCubeTexture"
  55377. */
  55378. getClassName(): string;
  55379. /**
  55380. * Occurs when the file is raw .hdr file.
  55381. */
  55382. private loadTexture;
  55383. clone(): HDRCubeTexture;
  55384. delayLoad(): void;
  55385. /**
  55386. * Get the texture reflection matrix used to rotate/transform the reflection.
  55387. * @returns the reflection matrix
  55388. */
  55389. getReflectionTextureMatrix(): Matrix;
  55390. /**
  55391. * Set the texture reflection matrix used to rotate/transform the reflection.
  55392. * @param value Define the reflection matrix to set
  55393. */
  55394. setReflectionTextureMatrix(value: Matrix): void;
  55395. /**
  55396. * Parses a JSON representation of an HDR Texture in order to create the texture
  55397. * @param parsedTexture Define the JSON representation
  55398. * @param scene Define the scene the texture should be created in
  55399. * @param rootUrl Define the root url in case we need to load relative dependencies
  55400. * @returns the newly created texture after parsing
  55401. */
  55402. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55403. serialize(): any;
  55404. }
  55405. }
  55406. declare module BABYLON {
  55407. /**
  55408. * Class used to control physics engine
  55409. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55410. */
  55411. export class PhysicsEngine implements IPhysicsEngine {
  55412. private _physicsPlugin;
  55413. /**
  55414. * Global value used to control the smallest number supported by the simulation
  55415. */
  55416. static Epsilon: number;
  55417. private _impostors;
  55418. private _joints;
  55419. private _subTimeStep;
  55420. /**
  55421. * Gets the gravity vector used by the simulation
  55422. */
  55423. gravity: Vector3;
  55424. /**
  55425. * Factory used to create the default physics plugin.
  55426. * @returns The default physics plugin
  55427. */
  55428. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55429. /**
  55430. * Creates a new Physics Engine
  55431. * @param gravity defines the gravity vector used by the simulation
  55432. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55433. */
  55434. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55435. /**
  55436. * Sets the gravity vector used by the simulation
  55437. * @param gravity defines the gravity vector to use
  55438. */
  55439. setGravity(gravity: Vector3): void;
  55440. /**
  55441. * Set the time step of the physics engine.
  55442. * Default is 1/60.
  55443. * To slow it down, enter 1/600 for example.
  55444. * To speed it up, 1/30
  55445. * @param newTimeStep defines the new timestep to apply to this world.
  55446. */
  55447. setTimeStep(newTimeStep?: number): void;
  55448. /**
  55449. * Get the time step of the physics engine.
  55450. * @returns the current time step
  55451. */
  55452. getTimeStep(): number;
  55453. /**
  55454. * Set the sub time step of the physics engine.
  55455. * Default is 0 meaning there is no sub steps
  55456. * To increase physics resolution precision, set a small value (like 1 ms)
  55457. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55458. */
  55459. setSubTimeStep(subTimeStep?: number): void;
  55460. /**
  55461. * Get the sub time step of the physics engine.
  55462. * @returns the current sub time step
  55463. */
  55464. getSubTimeStep(): number;
  55465. /**
  55466. * Release all resources
  55467. */
  55468. dispose(): void;
  55469. /**
  55470. * Gets the name of the current physics plugin
  55471. * @returns the name of the plugin
  55472. */
  55473. getPhysicsPluginName(): string;
  55474. /**
  55475. * Adding a new impostor for the impostor tracking.
  55476. * This will be done by the impostor itself.
  55477. * @param impostor the impostor to add
  55478. */
  55479. addImpostor(impostor: PhysicsImpostor): void;
  55480. /**
  55481. * Remove an impostor from the engine.
  55482. * This impostor and its mesh will not longer be updated by the physics engine.
  55483. * @param impostor the impostor to remove
  55484. */
  55485. removeImpostor(impostor: PhysicsImpostor): void;
  55486. /**
  55487. * Add a joint to the physics engine
  55488. * @param mainImpostor defines the main impostor to which the joint is added.
  55489. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55490. * @param joint defines the joint that will connect both impostors.
  55491. */
  55492. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55493. /**
  55494. * Removes a joint from the simulation
  55495. * @param mainImpostor defines the impostor used with the joint
  55496. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55497. * @param joint defines the joint to remove
  55498. */
  55499. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55500. /**
  55501. * Called by the scene. No need to call it.
  55502. * @param delta defines the timespam between frames
  55503. */
  55504. _step(delta: number): void;
  55505. /**
  55506. * Gets the current plugin used to run the simulation
  55507. * @returns current plugin
  55508. */
  55509. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55510. /**
  55511. * Gets the list of physic impostors
  55512. * @returns an array of PhysicsImpostor
  55513. */
  55514. getImpostors(): Array<PhysicsImpostor>;
  55515. /**
  55516. * Gets the impostor for a physics enabled object
  55517. * @param object defines the object impersonated by the impostor
  55518. * @returns the PhysicsImpostor or null if not found
  55519. */
  55520. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55521. /**
  55522. * Gets the impostor for a physics body object
  55523. * @param body defines physics body used by the impostor
  55524. * @returns the PhysicsImpostor or null if not found
  55525. */
  55526. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55527. /**
  55528. * Does a raycast in the physics world
  55529. * @param from when should the ray start?
  55530. * @param to when should the ray end?
  55531. * @returns PhysicsRaycastResult
  55532. */
  55533. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55534. }
  55535. }
  55536. declare module BABYLON {
  55537. /** @hidden */
  55538. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55539. private _useDeltaForWorldStep;
  55540. world: any;
  55541. name: string;
  55542. private _physicsMaterials;
  55543. private _fixedTimeStep;
  55544. private _cannonRaycastResult;
  55545. private _raycastResult;
  55546. private _physicsBodysToRemoveAfterStep;
  55547. BJSCANNON: any;
  55548. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55549. setGravity(gravity: Vector3): void;
  55550. setTimeStep(timeStep: number): void;
  55551. getTimeStep(): number;
  55552. executeStep(delta: number): void;
  55553. private _removeMarkedPhysicsBodiesFromWorld;
  55554. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55555. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55556. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55557. private _processChildMeshes;
  55558. removePhysicsBody(impostor: PhysicsImpostor): void;
  55559. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55560. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55561. private _addMaterial;
  55562. private _checkWithEpsilon;
  55563. private _createShape;
  55564. private _createHeightmap;
  55565. private _minus90X;
  55566. private _plus90X;
  55567. private _tmpPosition;
  55568. private _tmpDeltaPosition;
  55569. private _tmpUnityRotation;
  55570. private _updatePhysicsBodyTransformation;
  55571. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55572. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55573. isSupported(): boolean;
  55574. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55576. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55577. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55578. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55579. getBodyMass(impostor: PhysicsImpostor): number;
  55580. getBodyFriction(impostor: PhysicsImpostor): number;
  55581. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55582. getBodyRestitution(impostor: PhysicsImpostor): number;
  55583. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55584. sleepBody(impostor: PhysicsImpostor): void;
  55585. wakeUpBody(impostor: PhysicsImpostor): void;
  55586. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55587. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55588. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55589. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55590. getRadius(impostor: PhysicsImpostor): number;
  55591. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55592. dispose(): void;
  55593. private _extendNamespace;
  55594. /**
  55595. * Does a raycast in the physics world
  55596. * @param from when should the ray start?
  55597. * @param to when should the ray end?
  55598. * @returns PhysicsRaycastResult
  55599. */
  55600. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55601. }
  55602. }
  55603. declare module BABYLON {
  55604. /** @hidden */
  55605. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55606. private _useDeltaForWorldStep;
  55607. world: any;
  55608. name: string;
  55609. BJSOIMO: any;
  55610. private _raycastResult;
  55611. private _fixedTimeStep;
  55612. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55613. setGravity(gravity: Vector3): void;
  55614. setTimeStep(timeStep: number): void;
  55615. getTimeStep(): number;
  55616. private _tmpImpostorsArray;
  55617. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55618. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55619. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55620. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55621. private _tmpPositionVector;
  55622. removePhysicsBody(impostor: PhysicsImpostor): void;
  55623. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55624. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55625. isSupported(): boolean;
  55626. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55629. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55631. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55632. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55633. getBodyMass(impostor: PhysicsImpostor): number;
  55634. getBodyFriction(impostor: PhysicsImpostor): number;
  55635. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55636. getBodyRestitution(impostor: PhysicsImpostor): number;
  55637. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55638. sleepBody(impostor: PhysicsImpostor): void;
  55639. wakeUpBody(impostor: PhysicsImpostor): void;
  55640. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55641. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55642. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55643. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55644. getRadius(impostor: PhysicsImpostor): number;
  55645. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55646. dispose(): void;
  55647. /**
  55648. * Does a raycast in the physics world
  55649. * @param from when should the ray start?
  55650. * @param to when should the ray end?
  55651. * @returns PhysicsRaycastResult
  55652. */
  55653. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55654. }
  55655. }
  55656. declare module BABYLON {
  55657. /**
  55658. * Class containing static functions to help procedurally build meshes
  55659. */
  55660. export class RibbonBuilder {
  55661. /**
  55662. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55663. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55664. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55665. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55666. * * 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
  55667. * * 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
  55668. * * 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
  55669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55670. * * 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
  55671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55672. * * 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
  55673. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55674. * * 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
  55675. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55677. * @param name defines the name of the mesh
  55678. * @param options defines the options used to create the mesh
  55679. * @param scene defines the hosting scene
  55680. * @returns the ribbon mesh
  55681. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55683. */
  55684. static CreateRibbon(name: string, options: {
  55685. pathArray: Vector3[][];
  55686. closeArray?: boolean;
  55687. closePath?: boolean;
  55688. offset?: number;
  55689. updatable?: boolean;
  55690. sideOrientation?: number;
  55691. frontUVs?: Vector4;
  55692. backUVs?: Vector4;
  55693. instance?: Mesh;
  55694. invertUV?: boolean;
  55695. uvs?: Vector2[];
  55696. colors?: Color4[];
  55697. }, scene?: Nullable<Scene>): Mesh;
  55698. }
  55699. }
  55700. declare module BABYLON {
  55701. /**
  55702. * Class containing static functions to help procedurally build meshes
  55703. */
  55704. export class ShapeBuilder {
  55705. /**
  55706. * 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.
  55707. * * 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.
  55708. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55709. * * 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.
  55710. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55711. * * 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
  55712. * * 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
  55713. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55715. * * 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
  55716. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55718. * @param name defines the name of the mesh
  55719. * @param options defines the options used to create the mesh
  55720. * @param scene defines the hosting scene
  55721. * @returns the extruded shape mesh
  55722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55724. */
  55725. static ExtrudeShape(name: string, options: {
  55726. shape: Vector3[];
  55727. path: Vector3[];
  55728. scale?: number;
  55729. rotation?: number;
  55730. cap?: number;
  55731. updatable?: boolean;
  55732. sideOrientation?: number;
  55733. frontUVs?: Vector4;
  55734. backUVs?: Vector4;
  55735. instance?: Mesh;
  55736. invertUV?: boolean;
  55737. }, scene?: Nullable<Scene>): Mesh;
  55738. /**
  55739. * Creates an custom extruded shape mesh.
  55740. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55741. * * 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.
  55742. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55743. * * 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
  55744. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55745. * * 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
  55746. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55747. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55748. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55749. * * 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
  55750. * * 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
  55751. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55753. * * 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
  55754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55756. * @param name defines the name of the mesh
  55757. * @param options defines the options used to create the mesh
  55758. * @param scene defines the hosting scene
  55759. * @returns the custom extruded shape mesh
  55760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55761. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55763. */
  55764. static ExtrudeShapeCustom(name: string, options: {
  55765. shape: Vector3[];
  55766. path: Vector3[];
  55767. scaleFunction?: any;
  55768. rotationFunction?: any;
  55769. ribbonCloseArray?: boolean;
  55770. ribbonClosePath?: boolean;
  55771. cap?: number;
  55772. updatable?: boolean;
  55773. sideOrientation?: number;
  55774. frontUVs?: Vector4;
  55775. backUVs?: Vector4;
  55776. instance?: Mesh;
  55777. invertUV?: boolean;
  55778. }, scene?: Nullable<Scene>): Mesh;
  55779. private static _ExtrudeShapeGeneric;
  55780. }
  55781. }
  55782. declare module BABYLON {
  55783. /**
  55784. * AmmoJS Physics plugin
  55785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55786. * @see https://github.com/kripken/ammo.js/
  55787. */
  55788. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55789. private _useDeltaForWorldStep;
  55790. /**
  55791. * Reference to the Ammo library
  55792. */
  55793. bjsAMMO: any;
  55794. /**
  55795. * Created ammoJS world which physics bodies are added to
  55796. */
  55797. world: any;
  55798. /**
  55799. * Name of the plugin
  55800. */
  55801. name: string;
  55802. private _timeStep;
  55803. private _fixedTimeStep;
  55804. private _maxSteps;
  55805. private _tmpQuaternion;
  55806. private _tmpAmmoTransform;
  55807. private _tmpAmmoQuaternion;
  55808. private _tmpAmmoConcreteContactResultCallback;
  55809. private _collisionConfiguration;
  55810. private _dispatcher;
  55811. private _overlappingPairCache;
  55812. private _solver;
  55813. private _softBodySolver;
  55814. private _tmpAmmoVectorA;
  55815. private _tmpAmmoVectorB;
  55816. private _tmpAmmoVectorC;
  55817. private _tmpAmmoVectorD;
  55818. private _tmpContactCallbackResult;
  55819. private _tmpAmmoVectorRCA;
  55820. private _tmpAmmoVectorRCB;
  55821. private _raycastResult;
  55822. private static readonly DISABLE_COLLISION_FLAG;
  55823. private static readonly KINEMATIC_FLAG;
  55824. private static readonly DISABLE_DEACTIVATION_FLAG;
  55825. /**
  55826. * Initializes the ammoJS plugin
  55827. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55828. * @param ammoInjection can be used to inject your own ammo reference
  55829. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55830. */
  55831. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55832. /**
  55833. * Sets the gravity of the physics world (m/(s^2))
  55834. * @param gravity Gravity to set
  55835. */
  55836. setGravity(gravity: Vector3): void;
  55837. /**
  55838. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55839. * @param timeStep timestep to use in seconds
  55840. */
  55841. setTimeStep(timeStep: number): void;
  55842. /**
  55843. * 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)
  55844. * @param fixedTimeStep fixedTimeStep to use in seconds
  55845. */
  55846. setFixedTimeStep(fixedTimeStep: number): void;
  55847. /**
  55848. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55849. * @param maxSteps the maximum number of steps by the physics engine per frame
  55850. */
  55851. setMaxSteps(maxSteps: number): void;
  55852. /**
  55853. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55854. * @returns the current timestep in seconds
  55855. */
  55856. getTimeStep(): number;
  55857. /**
  55858. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55859. */
  55860. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55861. private _isImpostorInContact;
  55862. private _isImpostorPairInContact;
  55863. private _stepSimulation;
  55864. /**
  55865. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55866. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55867. * After the step the babylon meshes are set to the position of the physics imposters
  55868. * @param delta amount of time to step forward
  55869. * @param impostors array of imposters to update before/after the step
  55870. */
  55871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55872. /**
  55873. * Update babylon mesh to match physics world object
  55874. * @param impostor imposter to match
  55875. */
  55876. private _afterSoftStep;
  55877. /**
  55878. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55879. * @param impostor imposter to match
  55880. */
  55881. private _ropeStep;
  55882. /**
  55883. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55884. * @param impostor imposter to match
  55885. */
  55886. private _softbodyOrClothStep;
  55887. private _tmpMatrix;
  55888. /**
  55889. * Applies an impulse on the imposter
  55890. * @param impostor imposter to apply impulse to
  55891. * @param force amount of force to be applied to the imposter
  55892. * @param contactPoint the location to apply the impulse on the imposter
  55893. */
  55894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55895. /**
  55896. * Applies a force on the imposter
  55897. * @param impostor imposter to apply force
  55898. * @param force amount of force to be applied to the imposter
  55899. * @param contactPoint the location to apply the force on the imposter
  55900. */
  55901. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55902. /**
  55903. * Creates a physics body using the plugin
  55904. * @param impostor the imposter to create the physics body on
  55905. */
  55906. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55907. /**
  55908. * Removes the physics body from the imposter and disposes of the body's memory
  55909. * @param impostor imposter to remove the physics body from
  55910. */
  55911. removePhysicsBody(impostor: PhysicsImpostor): void;
  55912. /**
  55913. * Generates a joint
  55914. * @param impostorJoint the imposter joint to create the joint with
  55915. */
  55916. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55917. /**
  55918. * Removes a joint
  55919. * @param impostorJoint the imposter joint to remove the joint from
  55920. */
  55921. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55922. private _addMeshVerts;
  55923. /**
  55924. * Initialise the soft body vertices to match its object's (mesh) vertices
  55925. * Softbody vertices (nodes) are in world space and to match this
  55926. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55927. * @param impostor to create the softbody for
  55928. */
  55929. private _softVertexData;
  55930. /**
  55931. * Create an impostor's soft body
  55932. * @param impostor to create the softbody for
  55933. */
  55934. private _createSoftbody;
  55935. /**
  55936. * Create cloth for an impostor
  55937. * @param impostor to create the softbody for
  55938. */
  55939. private _createCloth;
  55940. /**
  55941. * Create rope for an impostor
  55942. * @param impostor to create the softbody for
  55943. */
  55944. private _createRope;
  55945. /**
  55946. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55947. * @param impostor to create the custom physics shape for
  55948. */
  55949. private _createCustom;
  55950. private _addHullVerts;
  55951. private _createShape;
  55952. /**
  55953. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55954. * @param impostor imposter containing the physics body and babylon object
  55955. */
  55956. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55957. /**
  55958. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55959. * @param impostor imposter containing the physics body and babylon object
  55960. * @param newPosition new position
  55961. * @param newRotation new rotation
  55962. */
  55963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55964. /**
  55965. * If this plugin is supported
  55966. * @returns true if its supported
  55967. */
  55968. isSupported(): boolean;
  55969. /**
  55970. * Sets the linear velocity of the physics body
  55971. * @param impostor imposter to set the velocity on
  55972. * @param velocity velocity to set
  55973. */
  55974. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55975. /**
  55976. * Sets the angular velocity of the physics body
  55977. * @param impostor imposter to set the velocity on
  55978. * @param velocity velocity to set
  55979. */
  55980. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55981. /**
  55982. * gets the linear velocity
  55983. * @param impostor imposter to get linear velocity from
  55984. * @returns linear velocity
  55985. */
  55986. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55987. /**
  55988. * gets the angular velocity
  55989. * @param impostor imposter to get angular velocity from
  55990. * @returns angular velocity
  55991. */
  55992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55993. /**
  55994. * Sets the mass of physics body
  55995. * @param impostor imposter to set the mass on
  55996. * @param mass mass to set
  55997. */
  55998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55999. /**
  56000. * Gets the mass of the physics body
  56001. * @param impostor imposter to get the mass from
  56002. * @returns mass
  56003. */
  56004. getBodyMass(impostor: PhysicsImpostor): number;
  56005. /**
  56006. * Gets friction of the impostor
  56007. * @param impostor impostor to get friction from
  56008. * @returns friction value
  56009. */
  56010. getBodyFriction(impostor: PhysicsImpostor): number;
  56011. /**
  56012. * Sets friction of the impostor
  56013. * @param impostor impostor to set friction on
  56014. * @param friction friction value
  56015. */
  56016. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56017. /**
  56018. * Gets restitution of the impostor
  56019. * @param impostor impostor to get restitution from
  56020. * @returns restitution value
  56021. */
  56022. getBodyRestitution(impostor: PhysicsImpostor): number;
  56023. /**
  56024. * Sets resitution of the impostor
  56025. * @param impostor impostor to set resitution on
  56026. * @param restitution resitution value
  56027. */
  56028. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56029. /**
  56030. * Gets pressure inside the impostor
  56031. * @param impostor impostor to get pressure from
  56032. * @returns pressure value
  56033. */
  56034. getBodyPressure(impostor: PhysicsImpostor): number;
  56035. /**
  56036. * Sets pressure inside a soft body impostor
  56037. * Cloth and rope must remain 0 pressure
  56038. * @param impostor impostor to set pressure on
  56039. * @param pressure pressure value
  56040. */
  56041. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56042. /**
  56043. * Gets stiffness of the impostor
  56044. * @param impostor impostor to get stiffness from
  56045. * @returns pressure value
  56046. */
  56047. getBodyStiffness(impostor: PhysicsImpostor): number;
  56048. /**
  56049. * Sets stiffness of the impostor
  56050. * @param impostor impostor to set stiffness on
  56051. * @param stiffness stiffness value from 0 to 1
  56052. */
  56053. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56054. /**
  56055. * Gets velocityIterations of the impostor
  56056. * @param impostor impostor to get velocity iterations from
  56057. * @returns velocityIterations value
  56058. */
  56059. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56060. /**
  56061. * Sets velocityIterations of the impostor
  56062. * @param impostor impostor to set velocity iterations on
  56063. * @param velocityIterations velocityIterations value
  56064. */
  56065. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56066. /**
  56067. * Gets positionIterations of the impostor
  56068. * @param impostor impostor to get position iterations from
  56069. * @returns positionIterations value
  56070. */
  56071. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56072. /**
  56073. * Sets positionIterations of the impostor
  56074. * @param impostor impostor to set position on
  56075. * @param positionIterations positionIterations value
  56076. */
  56077. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56078. /**
  56079. * Append an anchor to a cloth object
  56080. * @param impostor is the cloth impostor to add anchor to
  56081. * @param otherImpostor is the rigid impostor to anchor to
  56082. * @param width ratio across width from 0 to 1
  56083. * @param height ratio up height from 0 to 1
  56084. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56085. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56086. */
  56087. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56088. /**
  56089. * Append an hook to a rope object
  56090. * @param impostor is the rope impostor to add hook to
  56091. * @param otherImpostor is the rigid impostor to hook to
  56092. * @param length ratio along the rope from 0 to 1
  56093. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56094. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56095. */
  56096. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56097. /**
  56098. * Sleeps the physics body and stops it from being active
  56099. * @param impostor impostor to sleep
  56100. */
  56101. sleepBody(impostor: PhysicsImpostor): void;
  56102. /**
  56103. * Activates the physics body
  56104. * @param impostor impostor to activate
  56105. */
  56106. wakeUpBody(impostor: PhysicsImpostor): void;
  56107. /**
  56108. * Updates the distance parameters of the joint
  56109. * @param joint joint to update
  56110. * @param maxDistance maximum distance of the joint
  56111. * @param minDistance minimum distance of the joint
  56112. */
  56113. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56114. /**
  56115. * Sets a motor on the joint
  56116. * @param joint joint to set motor on
  56117. * @param speed speed of the motor
  56118. * @param maxForce maximum force of the motor
  56119. * @param motorIndex index of the motor
  56120. */
  56121. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56122. /**
  56123. * Sets the motors limit
  56124. * @param joint joint to set limit on
  56125. * @param upperLimit upper limit
  56126. * @param lowerLimit lower limit
  56127. */
  56128. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56129. /**
  56130. * Syncs the position and rotation of a mesh with the impostor
  56131. * @param mesh mesh to sync
  56132. * @param impostor impostor to update the mesh with
  56133. */
  56134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56135. /**
  56136. * Gets the radius of the impostor
  56137. * @param impostor impostor to get radius from
  56138. * @returns the radius
  56139. */
  56140. getRadius(impostor: PhysicsImpostor): number;
  56141. /**
  56142. * Gets the box size of the impostor
  56143. * @param impostor impostor to get box size from
  56144. * @param result the resulting box size
  56145. */
  56146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56147. /**
  56148. * Disposes of the impostor
  56149. */
  56150. dispose(): void;
  56151. /**
  56152. * Does a raycast in the physics world
  56153. * @param from when should the ray start?
  56154. * @param to when should the ray end?
  56155. * @returns PhysicsRaycastResult
  56156. */
  56157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56158. }
  56159. }
  56160. declare module BABYLON {
  56161. interface AbstractScene {
  56162. /**
  56163. * The list of reflection probes added to the scene
  56164. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56165. */
  56166. reflectionProbes: Array<ReflectionProbe>;
  56167. /**
  56168. * Removes the given reflection probe from this scene.
  56169. * @param toRemove The reflection probe to remove
  56170. * @returns The index of the removed reflection probe
  56171. */
  56172. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56173. /**
  56174. * Adds the given reflection probe to this scene.
  56175. * @param newReflectionProbe The reflection probe to add
  56176. */
  56177. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56178. }
  56179. /**
  56180. * Class used to generate realtime reflection / refraction cube textures
  56181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56182. */
  56183. export class ReflectionProbe {
  56184. /** defines the name of the probe */
  56185. name: string;
  56186. private _scene;
  56187. private _renderTargetTexture;
  56188. private _projectionMatrix;
  56189. private _viewMatrix;
  56190. private _target;
  56191. private _add;
  56192. private _attachedMesh;
  56193. private _invertYAxis;
  56194. /** Gets or sets probe position (center of the cube map) */
  56195. position: Vector3;
  56196. /**
  56197. * Creates a new reflection probe
  56198. * @param name defines the name of the probe
  56199. * @param size defines the texture resolution (for each face)
  56200. * @param scene defines the hosting scene
  56201. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56202. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56203. */
  56204. constructor(
  56205. /** defines the name of the probe */
  56206. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56207. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56208. get samples(): number;
  56209. set samples(value: number);
  56210. /** Gets or sets the refresh rate to use (on every frame by default) */
  56211. get refreshRate(): number;
  56212. set refreshRate(value: number);
  56213. /**
  56214. * Gets the hosting scene
  56215. * @returns a Scene
  56216. */
  56217. getScene(): Scene;
  56218. /** Gets the internal CubeTexture used to render to */
  56219. get cubeTexture(): RenderTargetTexture;
  56220. /** Gets the list of meshes to render */
  56221. get renderList(): Nullable<AbstractMesh[]>;
  56222. /**
  56223. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56224. * @param mesh defines the mesh to attach to
  56225. */
  56226. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56227. /**
  56228. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56229. * @param renderingGroupId The rendering group id corresponding to its index
  56230. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56231. */
  56232. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56233. /**
  56234. * Clean all associated resources
  56235. */
  56236. dispose(): void;
  56237. /**
  56238. * Converts the reflection probe information to a readable string for debug purpose.
  56239. * @param fullDetails Supports for multiple levels of logging within scene loading
  56240. * @returns the human readable reflection probe info
  56241. */
  56242. toString(fullDetails?: boolean): string;
  56243. /**
  56244. * Get the class name of the relfection probe.
  56245. * @returns "ReflectionProbe"
  56246. */
  56247. getClassName(): string;
  56248. /**
  56249. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56250. * @returns The JSON representation of the texture
  56251. */
  56252. serialize(): any;
  56253. /**
  56254. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56255. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56256. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56257. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56258. * @returns The parsed reflection probe if successful
  56259. */
  56260. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56261. }
  56262. }
  56263. declare module BABYLON {
  56264. /** @hidden */
  56265. export var _BabylonLoaderRegistered: boolean;
  56266. /**
  56267. * Helps setting up some configuration for the babylon file loader.
  56268. */
  56269. export class BabylonFileLoaderConfiguration {
  56270. /**
  56271. * The loader does not allow injecting custom physix engine into the plugins.
  56272. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56273. * So you could set this variable to your engine import to make it work.
  56274. */
  56275. static LoaderInjectedPhysicsEngine: any;
  56276. }
  56277. }
  56278. declare module BABYLON {
  56279. /**
  56280. * The Physically based simple base material of BJS.
  56281. *
  56282. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56283. * It is used as the base class for both the specGloss and metalRough conventions.
  56284. */
  56285. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56286. /**
  56287. * Number of Simultaneous lights allowed on the material.
  56288. */
  56289. maxSimultaneousLights: number;
  56290. /**
  56291. * If sets to true, disables all the lights affecting the material.
  56292. */
  56293. disableLighting: boolean;
  56294. /**
  56295. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56296. */
  56297. environmentTexture: BaseTexture;
  56298. /**
  56299. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56300. */
  56301. invertNormalMapX: boolean;
  56302. /**
  56303. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56304. */
  56305. invertNormalMapY: boolean;
  56306. /**
  56307. * Normal map used in the model.
  56308. */
  56309. normalTexture: BaseTexture;
  56310. /**
  56311. * Emissivie color used to self-illuminate the model.
  56312. */
  56313. emissiveColor: Color3;
  56314. /**
  56315. * Emissivie texture used to self-illuminate the model.
  56316. */
  56317. emissiveTexture: BaseTexture;
  56318. /**
  56319. * Occlusion Channel Strenght.
  56320. */
  56321. occlusionStrength: number;
  56322. /**
  56323. * Occlusion Texture of the material (adding extra occlusion effects).
  56324. */
  56325. occlusionTexture: BaseTexture;
  56326. /**
  56327. * Defines the alpha limits in alpha test mode.
  56328. */
  56329. alphaCutOff: number;
  56330. /**
  56331. * Gets the current double sided mode.
  56332. */
  56333. get doubleSided(): boolean;
  56334. /**
  56335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56336. */
  56337. set doubleSided(value: boolean);
  56338. /**
  56339. * Stores the pre-calculated light information of a mesh in a texture.
  56340. */
  56341. lightmapTexture: BaseTexture;
  56342. /**
  56343. * If true, the light map contains occlusion information instead of lighting info.
  56344. */
  56345. useLightmapAsShadowmap: boolean;
  56346. /**
  56347. * Instantiates a new PBRMaterial instance.
  56348. *
  56349. * @param name The material name
  56350. * @param scene The scene the material will be use in.
  56351. */
  56352. constructor(name: string, scene: Scene);
  56353. getClassName(): string;
  56354. }
  56355. }
  56356. declare module BABYLON {
  56357. /**
  56358. * The PBR material of BJS following the metal roughness convention.
  56359. *
  56360. * This fits to the PBR convention in the GLTF definition:
  56361. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56362. */
  56363. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56364. /**
  56365. * The base color has two different interpretations depending on the value of metalness.
  56366. * When the material is a metal, the base color is the specific measured reflectance value
  56367. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56368. * of the material.
  56369. */
  56370. baseColor: Color3;
  56371. /**
  56372. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56373. * well as opacity information in the alpha channel.
  56374. */
  56375. baseTexture: BaseTexture;
  56376. /**
  56377. * Specifies the metallic scalar value of the material.
  56378. * Can also be used to scale the metalness values of the metallic texture.
  56379. */
  56380. metallic: number;
  56381. /**
  56382. * Specifies the roughness scalar value of the material.
  56383. * Can also be used to scale the roughness values of the metallic texture.
  56384. */
  56385. roughness: number;
  56386. /**
  56387. * Texture containing both the metallic value in the B channel and the
  56388. * roughness value in the G channel to keep better precision.
  56389. */
  56390. metallicRoughnessTexture: BaseTexture;
  56391. /**
  56392. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56393. *
  56394. * @param name The material name
  56395. * @param scene The scene the material will be use in.
  56396. */
  56397. constructor(name: string, scene: Scene);
  56398. /**
  56399. * Return the currrent class name of the material.
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Makes a duplicate of the current material.
  56404. * @param name - name to use for the new material.
  56405. */
  56406. clone(name: string): PBRMetallicRoughnessMaterial;
  56407. /**
  56408. * Serialize the material to a parsable JSON object.
  56409. */
  56410. serialize(): any;
  56411. /**
  56412. * Parses a JSON object correponding to the serialize function.
  56413. */
  56414. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56415. }
  56416. }
  56417. declare module BABYLON {
  56418. /**
  56419. * The PBR material of BJS following the specular glossiness convention.
  56420. *
  56421. * This fits to the PBR convention in the GLTF definition:
  56422. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56423. */
  56424. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56425. /**
  56426. * Specifies the diffuse color of the material.
  56427. */
  56428. diffuseColor: Color3;
  56429. /**
  56430. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56431. * channel.
  56432. */
  56433. diffuseTexture: BaseTexture;
  56434. /**
  56435. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56436. */
  56437. specularColor: Color3;
  56438. /**
  56439. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56440. */
  56441. glossiness: number;
  56442. /**
  56443. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56444. */
  56445. specularGlossinessTexture: BaseTexture;
  56446. /**
  56447. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56448. *
  56449. * @param name The material name
  56450. * @param scene The scene the material will be use in.
  56451. */
  56452. constructor(name: string, scene: Scene);
  56453. /**
  56454. * Return the currrent class name of the material.
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Makes a duplicate of the current material.
  56459. * @param name - name to use for the new material.
  56460. */
  56461. clone(name: string): PBRSpecularGlossinessMaterial;
  56462. /**
  56463. * Serialize the material to a parsable JSON object.
  56464. */
  56465. serialize(): any;
  56466. /**
  56467. * Parses a JSON object correponding to the serialize function.
  56468. */
  56469. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56470. }
  56471. }
  56472. declare module BABYLON {
  56473. /**
  56474. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56475. * It can help converting any input color in a desired output one. This can then be used to create effects
  56476. * from sepia, black and white to sixties or futuristic rendering...
  56477. *
  56478. * The only supported format is currently 3dl.
  56479. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56480. */
  56481. export class ColorGradingTexture extends BaseTexture {
  56482. /**
  56483. * The texture URL.
  56484. */
  56485. url: string;
  56486. /**
  56487. * Empty line regex stored for GC.
  56488. */
  56489. private static _noneEmptyLineRegex;
  56490. private _textureMatrix;
  56491. private _engine;
  56492. private _onLoad;
  56493. /**
  56494. * Instantiates a ColorGradingTexture from the following parameters.
  56495. *
  56496. * @param url The location of the color gradind data (currently only supporting 3dl)
  56497. * @param sceneOrEngine The scene or engine the texture will be used in
  56498. * @param onLoad defines a callback triggered when the texture has been loaded
  56499. */
  56500. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56501. /**
  56502. * Fires the onload event from the constructor if requested.
  56503. */
  56504. private _triggerOnLoad;
  56505. /**
  56506. * Returns the texture matrix used in most of the material.
  56507. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56508. */
  56509. getTextureMatrix(): Matrix;
  56510. /**
  56511. * Occurs when the file being loaded is a .3dl LUT file.
  56512. */
  56513. private load3dlTexture;
  56514. /**
  56515. * Starts the loading process of the texture.
  56516. */
  56517. private loadTexture;
  56518. /**
  56519. * Clones the color gradind texture.
  56520. */
  56521. clone(): ColorGradingTexture;
  56522. /**
  56523. * Called during delayed load for textures.
  56524. */
  56525. delayLoad(): void;
  56526. /**
  56527. * Parses a color grading texture serialized by Babylon.
  56528. * @param parsedTexture The texture information being parsedTexture
  56529. * @param scene The scene to load the texture in
  56530. * @param rootUrl The root url of the data assets to load
  56531. * @return A color gradind texture
  56532. */
  56533. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56534. /**
  56535. * Serializes the LUT texture to json format.
  56536. */
  56537. serialize(): any;
  56538. /**
  56539. * Returns true if the passed parameter is a scene object (can be use for typings)
  56540. * @param sceneOrEngine The object to test.
  56541. */
  56542. private static _isScene;
  56543. }
  56544. }
  56545. declare module BABYLON {
  56546. /**
  56547. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56548. */
  56549. export class EquiRectangularCubeTexture extends BaseTexture {
  56550. /** The six faces of the cube. */
  56551. private static _FacesMapping;
  56552. private _noMipmap;
  56553. private _onLoad;
  56554. private _onError;
  56555. /** The size of the cubemap. */
  56556. private _size;
  56557. /** The buffer of the image. */
  56558. private _buffer;
  56559. /** The width of the input image. */
  56560. private _width;
  56561. /** The height of the input image. */
  56562. private _height;
  56563. /** The URL to the image. */
  56564. url: string;
  56565. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56566. coordinatesMode: number;
  56567. /**
  56568. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56569. * @param url The location of the image
  56570. * @param scene The scene the texture will be used in
  56571. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56572. * @param noMipmap Forces to not generate the mipmap if true
  56573. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56574. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56575. * @param onLoad — defines a callback called when texture is loaded
  56576. * @param onError — defines a callback called if there is an error
  56577. */
  56578. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56579. /**
  56580. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56581. */
  56582. private loadImage;
  56583. /**
  56584. * Convert the image buffer into a cubemap and create a CubeTexture.
  56585. */
  56586. private loadTexture;
  56587. /**
  56588. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56589. * @param buffer The ArrayBuffer that should be converted.
  56590. * @returns The buffer as Float32Array.
  56591. */
  56592. private getFloat32ArrayFromArrayBuffer;
  56593. /**
  56594. * Get the current class name of the texture useful for serialization or dynamic coding.
  56595. * @returns "EquiRectangularCubeTexture"
  56596. */
  56597. getClassName(): string;
  56598. /**
  56599. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56600. * @returns A clone of the current EquiRectangularCubeTexture.
  56601. */
  56602. clone(): EquiRectangularCubeTexture;
  56603. }
  56604. }
  56605. declare module BABYLON {
  56606. /**
  56607. * Based on jsTGALoader - Javascript loader for TGA file
  56608. * By Vincent Thibault
  56609. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56610. */
  56611. export class TGATools {
  56612. private static _TYPE_INDEXED;
  56613. private static _TYPE_RGB;
  56614. private static _TYPE_GREY;
  56615. private static _TYPE_RLE_INDEXED;
  56616. private static _TYPE_RLE_RGB;
  56617. private static _TYPE_RLE_GREY;
  56618. private static _ORIGIN_MASK;
  56619. private static _ORIGIN_SHIFT;
  56620. private static _ORIGIN_BL;
  56621. private static _ORIGIN_BR;
  56622. private static _ORIGIN_UL;
  56623. private static _ORIGIN_UR;
  56624. /**
  56625. * Gets the header of a TGA file
  56626. * @param data defines the TGA data
  56627. * @returns the header
  56628. */
  56629. static GetTGAHeader(data: Uint8Array): any;
  56630. /**
  56631. * Uploads TGA content to a Babylon Texture
  56632. * @hidden
  56633. */
  56634. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56635. /** @hidden */
  56636. 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;
  56637. /** @hidden */
  56638. 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;
  56639. /** @hidden */
  56640. 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;
  56641. /** @hidden */
  56642. 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;
  56643. /** @hidden */
  56644. 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;
  56645. /** @hidden */
  56646. 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;
  56647. }
  56648. }
  56649. declare module BABYLON {
  56650. /**
  56651. * Implementation of the TGA Texture Loader.
  56652. * @hidden
  56653. */
  56654. export class _TGATextureLoader implements IInternalTextureLoader {
  56655. /**
  56656. * Defines wether the loader supports cascade loading the different faces.
  56657. */
  56658. readonly supportCascades: boolean;
  56659. /**
  56660. * This returns if the loader support the current file information.
  56661. * @param extension defines the file extension of the file being loaded
  56662. * @returns true if the loader can load the specified file
  56663. */
  56664. canLoad(extension: string): boolean;
  56665. /**
  56666. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56667. * @param data contains the texture data
  56668. * @param texture defines the BabylonJS internal texture
  56669. * @param createPolynomials will be true if polynomials have been requested
  56670. * @param onLoad defines the callback to trigger once the texture is ready
  56671. * @param onError defines the callback to trigger in case of error
  56672. */
  56673. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56674. /**
  56675. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56676. * @param data contains the texture data
  56677. * @param texture defines the BabylonJS internal texture
  56678. * @param callback defines the method to call once ready to upload
  56679. */
  56680. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56681. }
  56682. }
  56683. declare module BABYLON {
  56684. /**
  56685. * Info about the .basis files
  56686. */
  56687. class BasisFileInfo {
  56688. /**
  56689. * If the file has alpha
  56690. */
  56691. hasAlpha: boolean;
  56692. /**
  56693. * Info about each image of the basis file
  56694. */
  56695. images: Array<{
  56696. levels: Array<{
  56697. width: number;
  56698. height: number;
  56699. transcodedPixels: ArrayBufferView;
  56700. }>;
  56701. }>;
  56702. }
  56703. /**
  56704. * Result of transcoding a basis file
  56705. */
  56706. class TranscodeResult {
  56707. /**
  56708. * Info about the .basis file
  56709. */
  56710. fileInfo: BasisFileInfo;
  56711. /**
  56712. * Format to use when loading the file
  56713. */
  56714. format: number;
  56715. }
  56716. /**
  56717. * Configuration options for the Basis transcoder
  56718. */
  56719. export class BasisTranscodeConfiguration {
  56720. /**
  56721. * Supported compression formats used to determine the supported output format of the transcoder
  56722. */
  56723. supportedCompressionFormats?: {
  56724. /**
  56725. * etc1 compression format
  56726. */
  56727. etc1?: boolean;
  56728. /**
  56729. * s3tc compression format
  56730. */
  56731. s3tc?: boolean;
  56732. /**
  56733. * pvrtc compression format
  56734. */
  56735. pvrtc?: boolean;
  56736. /**
  56737. * etc2 compression format
  56738. */
  56739. etc2?: boolean;
  56740. };
  56741. /**
  56742. * If mipmap levels should be loaded for transcoded images (Default: true)
  56743. */
  56744. loadMipmapLevels?: boolean;
  56745. /**
  56746. * Index of a single image to load (Default: all images)
  56747. */
  56748. loadSingleImage?: number;
  56749. }
  56750. /**
  56751. * Used to load .Basis files
  56752. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56753. */
  56754. export class BasisTools {
  56755. private static _IgnoreSupportedFormats;
  56756. /**
  56757. * URL to use when loading the basis transcoder
  56758. */
  56759. static JSModuleURL: string;
  56760. /**
  56761. * URL to use when loading the wasm module for the transcoder
  56762. */
  56763. static WasmModuleURL: string;
  56764. /**
  56765. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56766. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56767. * @returns internal format corresponding to the Basis format
  56768. */
  56769. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56770. private static _WorkerPromise;
  56771. private static _Worker;
  56772. private static _actionId;
  56773. private static _CreateWorkerAsync;
  56774. /**
  56775. * Transcodes a loaded image file to compressed pixel data
  56776. * @param data image data to transcode
  56777. * @param config configuration options for the transcoding
  56778. * @returns a promise resulting in the transcoded image
  56779. */
  56780. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56781. /**
  56782. * Loads a texture from the transcode result
  56783. * @param texture texture load to
  56784. * @param transcodeResult the result of transcoding the basis file to load from
  56785. */
  56786. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56787. }
  56788. }
  56789. declare module BABYLON {
  56790. /**
  56791. * Loader for .basis file format
  56792. */
  56793. export class _BasisTextureLoader implements IInternalTextureLoader {
  56794. /**
  56795. * Defines whether the loader supports cascade loading the different faces.
  56796. */
  56797. readonly supportCascades: boolean;
  56798. /**
  56799. * This returns if the loader support the current file information.
  56800. * @param extension defines the file extension of the file being loaded
  56801. * @returns true if the loader can load the specified file
  56802. */
  56803. canLoad(extension: string): boolean;
  56804. /**
  56805. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56806. * @param data contains the texture data
  56807. * @param texture defines the BabylonJS internal texture
  56808. * @param createPolynomials will be true if polynomials have been requested
  56809. * @param onLoad defines the callback to trigger once the texture is ready
  56810. * @param onError defines the callback to trigger in case of error
  56811. */
  56812. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56813. /**
  56814. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56815. * @param data contains the texture data
  56816. * @param texture defines the BabylonJS internal texture
  56817. * @param callback defines the method to call once ready to upload
  56818. */
  56819. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56820. }
  56821. }
  56822. declare module BABYLON {
  56823. /**
  56824. * 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.
  56825. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56827. */
  56828. export class CustomProceduralTexture extends ProceduralTexture {
  56829. private _animate;
  56830. private _time;
  56831. private _config;
  56832. private _texturePath;
  56833. /**
  56834. * Instantiates a new Custom Procedural Texture.
  56835. * 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.
  56836. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56837. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56838. * @param name Define the name of the texture
  56839. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56840. * @param size Define the size of the texture to create
  56841. * @param scene Define the scene the texture belongs to
  56842. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56843. * @param generateMipMaps Define if the texture should creates mip maps or not
  56844. */
  56845. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56846. private _loadJson;
  56847. /**
  56848. * Is the texture ready to be used ? (rendered at least once)
  56849. * @returns true if ready, otherwise, false.
  56850. */
  56851. isReady(): boolean;
  56852. /**
  56853. * Render the texture to its associated render target.
  56854. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56855. */
  56856. render(useCameraPostProcess?: boolean): void;
  56857. /**
  56858. * Update the list of dependant textures samplers in the shader.
  56859. */
  56860. updateTextures(): void;
  56861. /**
  56862. * Update the uniform values of the procedural texture in the shader.
  56863. */
  56864. updateShaderUniforms(): void;
  56865. /**
  56866. * Define if the texture animates or not.
  56867. */
  56868. get animate(): boolean;
  56869. set animate(value: boolean);
  56870. }
  56871. }
  56872. declare module BABYLON {
  56873. /** @hidden */
  56874. export var noisePixelShader: {
  56875. name: string;
  56876. shader: string;
  56877. };
  56878. }
  56879. declare module BABYLON {
  56880. /**
  56881. * Class used to generate noise procedural textures
  56882. */
  56883. export class NoiseProceduralTexture extends ProceduralTexture {
  56884. private _time;
  56885. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56886. brightness: number;
  56887. /** Defines the number of octaves to process */
  56888. octaves: number;
  56889. /** Defines the level of persistence (0.8 by default) */
  56890. persistence: number;
  56891. /** Gets or sets animation speed factor (default is 1) */
  56892. animationSpeedFactor: number;
  56893. /**
  56894. * Creates a new NoiseProceduralTexture
  56895. * @param name defines the name fo the texture
  56896. * @param size defines the size of the texture (default is 256)
  56897. * @param scene defines the hosting scene
  56898. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56899. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56900. */
  56901. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56902. private _updateShaderUniforms;
  56903. protected _getDefines(): string;
  56904. /** Generate the current state of the procedural texture */
  56905. render(useCameraPostProcess?: boolean): void;
  56906. /**
  56907. * Serializes this noise procedural texture
  56908. * @returns a serialized noise procedural texture object
  56909. */
  56910. serialize(): any;
  56911. /**
  56912. * Clone the texture.
  56913. * @returns the cloned texture
  56914. */
  56915. clone(): NoiseProceduralTexture;
  56916. /**
  56917. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56918. * @param parsedTexture defines parsed texture data
  56919. * @param scene defines the current scene
  56920. * @param rootUrl defines the root URL containing noise procedural texture information
  56921. * @returns a parsed NoiseProceduralTexture
  56922. */
  56923. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56924. }
  56925. }
  56926. declare module BABYLON {
  56927. /**
  56928. * Raw cube texture where the raw buffers are passed in
  56929. */
  56930. export class RawCubeTexture extends CubeTexture {
  56931. /**
  56932. * Creates a cube texture where the raw buffers are passed in.
  56933. * @param scene defines the scene the texture is attached to
  56934. * @param data defines the array of data to use to create each face
  56935. * @param size defines the size of the textures
  56936. * @param format defines the format of the data
  56937. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56938. * @param generateMipMaps defines if the engine should generate the mip levels
  56939. * @param invertY defines if data must be stored with Y axis inverted
  56940. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56941. * @param compression defines the compression used (null by default)
  56942. */
  56943. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56944. /**
  56945. * Updates the raw cube texture.
  56946. * @param data defines the data to store
  56947. * @param format defines the data format
  56948. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56949. * @param invertY defines if data must be stored with Y axis inverted
  56950. * @param compression defines the compression used (null by default)
  56951. * @param level defines which level of the texture to update
  56952. */
  56953. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56954. /**
  56955. * Updates a raw cube texture with RGBD encoded data.
  56956. * @param data defines the array of data [mipmap][face] to use to create each face
  56957. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56958. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56959. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56960. * @returns a promsie that resolves when the operation is complete
  56961. */
  56962. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56963. /**
  56964. * Clones the raw cube texture.
  56965. * @return a new cube texture
  56966. */
  56967. clone(): CubeTexture;
  56968. /** @hidden */
  56969. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56970. }
  56971. }
  56972. declare module BABYLON {
  56973. /**
  56974. * Class used to store 3D textures containing user data
  56975. */
  56976. export class RawTexture3D extends Texture {
  56977. /** Gets or sets the texture format to use */
  56978. format: number;
  56979. private _engine;
  56980. /**
  56981. * Create a new RawTexture3D
  56982. * @param data defines the data of the texture
  56983. * @param width defines the width of the texture
  56984. * @param height defines the height of the texture
  56985. * @param depth defines the depth of the texture
  56986. * @param format defines the texture format to use
  56987. * @param scene defines the hosting scene
  56988. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56989. * @param invertY defines if texture must be stored with Y axis inverted
  56990. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56991. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56992. */
  56993. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56994. /** Gets or sets the texture format to use */
  56995. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56996. /**
  56997. * Update the texture with new data
  56998. * @param data defines the data to store in the texture
  56999. */
  57000. update(data: ArrayBufferView): void;
  57001. }
  57002. }
  57003. declare module BABYLON {
  57004. /**
  57005. * Class used to store 2D array textures containing user data
  57006. */
  57007. export class RawTexture2DArray extends Texture {
  57008. /** Gets or sets the texture format to use */
  57009. format: number;
  57010. private _engine;
  57011. /**
  57012. * Create a new RawTexture2DArray
  57013. * @param data defines the data of the texture
  57014. * @param width defines the width of the texture
  57015. * @param height defines the height of the texture
  57016. * @param depth defines the number of layers of the texture
  57017. * @param format defines the texture format to use
  57018. * @param scene defines the hosting scene
  57019. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57020. * @param invertY defines if texture must be stored with Y axis inverted
  57021. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57022. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57023. */
  57024. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57025. /** Gets or sets the texture format to use */
  57026. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57027. /**
  57028. * Update the texture with new data
  57029. * @param data defines the data to store in the texture
  57030. */
  57031. update(data: ArrayBufferView): void;
  57032. }
  57033. }
  57034. declare module BABYLON {
  57035. /**
  57036. * Creates a refraction texture used by refraction channel of the standard material.
  57037. * It is like a mirror but to see through a material.
  57038. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57039. */
  57040. export class RefractionTexture extends RenderTargetTexture {
  57041. /**
  57042. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57043. * 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.
  57044. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57045. */
  57046. refractionPlane: Plane;
  57047. /**
  57048. * Define how deep under the surface we should see.
  57049. */
  57050. depth: number;
  57051. /**
  57052. * Creates a refraction texture used by refraction channel of the standard material.
  57053. * It is like a mirror but to see through a material.
  57054. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57055. * @param name Define the texture name
  57056. * @param size Define the size of the underlying texture
  57057. * @param scene Define the scene the refraction belongs to
  57058. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57059. */
  57060. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57061. /**
  57062. * Clone the refraction texture.
  57063. * @returns the cloned texture
  57064. */
  57065. clone(): RefractionTexture;
  57066. /**
  57067. * Serialize the texture to a JSON representation you could use in Parse later on
  57068. * @returns the serialized JSON representation
  57069. */
  57070. serialize(): any;
  57071. }
  57072. }
  57073. declare module BABYLON {
  57074. /**
  57075. * Defines the options related to the creation of an HtmlElementTexture
  57076. */
  57077. export interface IHtmlElementTextureOptions {
  57078. /**
  57079. * Defines wether mip maps should be created or not.
  57080. */
  57081. generateMipMaps?: boolean;
  57082. /**
  57083. * Defines the sampling mode of the texture.
  57084. */
  57085. samplingMode?: number;
  57086. /**
  57087. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57088. */
  57089. engine: Nullable<ThinEngine>;
  57090. /**
  57091. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57092. */
  57093. scene: Nullable<Scene>;
  57094. }
  57095. /**
  57096. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57097. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57098. * is automatically managed.
  57099. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57100. * in your application.
  57101. *
  57102. * As the update is not automatic, you need to call them manually.
  57103. */
  57104. export class HtmlElementTexture extends BaseTexture {
  57105. /**
  57106. * The texture URL.
  57107. */
  57108. element: HTMLVideoElement | HTMLCanvasElement;
  57109. private static readonly DefaultOptions;
  57110. private _textureMatrix;
  57111. private _engine;
  57112. private _isVideo;
  57113. private _generateMipMaps;
  57114. private _samplingMode;
  57115. /**
  57116. * Instantiates a HtmlElementTexture from the following parameters.
  57117. *
  57118. * @param name Defines the name of the texture
  57119. * @param element Defines the video or canvas the texture is filled with
  57120. * @param options Defines the other none mandatory texture creation options
  57121. */
  57122. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57123. private _createInternalTexture;
  57124. /**
  57125. * Returns the texture matrix used in most of the material.
  57126. */
  57127. getTextureMatrix(): Matrix;
  57128. /**
  57129. * Updates the content of the texture.
  57130. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57131. */
  57132. update(invertY?: Nullable<boolean>): void;
  57133. }
  57134. }
  57135. declare module BABYLON {
  57136. /**
  57137. * Defines the basic options interface of a TexturePacker Frame
  57138. */
  57139. export interface ITexturePackerFrame {
  57140. /**
  57141. * The frame ID
  57142. */
  57143. id: number;
  57144. /**
  57145. * The frames Scale
  57146. */
  57147. scale: Vector2;
  57148. /**
  57149. * The Frames offset
  57150. */
  57151. offset: Vector2;
  57152. }
  57153. /**
  57154. * This is a support class for frame Data on texture packer sets.
  57155. */
  57156. export class TexturePackerFrame implements ITexturePackerFrame {
  57157. /**
  57158. * The frame ID
  57159. */
  57160. id: number;
  57161. /**
  57162. * The frames Scale
  57163. */
  57164. scale: Vector2;
  57165. /**
  57166. * The Frames offset
  57167. */
  57168. offset: Vector2;
  57169. /**
  57170. * Initializes a texture package frame.
  57171. * @param id The numerical frame identifier
  57172. * @param scale Scalar Vector2 for UV frame
  57173. * @param offset Vector2 for the frame position in UV units.
  57174. * @returns TexturePackerFrame
  57175. */
  57176. constructor(id: number, scale: Vector2, offset: Vector2);
  57177. }
  57178. }
  57179. declare module BABYLON {
  57180. /**
  57181. * Defines the basic options interface of a TexturePacker
  57182. */
  57183. export interface ITexturePackerOptions {
  57184. /**
  57185. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57186. */
  57187. map?: string[];
  57188. /**
  57189. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57190. */
  57191. uvsIn?: string;
  57192. /**
  57193. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57194. */
  57195. uvsOut?: string;
  57196. /**
  57197. * number representing the layout style. Defaults to LAYOUT_STRIP
  57198. */
  57199. layout?: number;
  57200. /**
  57201. * number of columns if using custom column count layout(2). This defaults to 4.
  57202. */
  57203. colnum?: number;
  57204. /**
  57205. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57206. */
  57207. updateInputMeshes?: boolean;
  57208. /**
  57209. * boolean flag to dispose all the source textures. Defaults to true.
  57210. */
  57211. disposeSources?: boolean;
  57212. /**
  57213. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57214. */
  57215. fillBlanks?: boolean;
  57216. /**
  57217. * string value representing the context fill style color. Defaults to 'black'.
  57218. */
  57219. customFillColor?: string;
  57220. /**
  57221. * Width and Height Value of each Frame in the TexturePacker Sets
  57222. */
  57223. frameSize?: number;
  57224. /**
  57225. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57226. */
  57227. paddingRatio?: number;
  57228. /**
  57229. * Number that declares the fill method for the padding gutter.
  57230. */
  57231. paddingMode?: number;
  57232. /**
  57233. * If in SUBUV_COLOR padding mode what color to use.
  57234. */
  57235. paddingColor?: Color3 | Color4;
  57236. }
  57237. /**
  57238. * Defines the basic interface of a TexturePacker JSON File
  57239. */
  57240. export interface ITexturePackerJSON {
  57241. /**
  57242. * The frame ID
  57243. */
  57244. name: string;
  57245. /**
  57246. * The base64 channel data
  57247. */
  57248. sets: any;
  57249. /**
  57250. * The options of the Packer
  57251. */
  57252. options: ITexturePackerOptions;
  57253. /**
  57254. * The frame data of the Packer
  57255. */
  57256. frames: Array<number>;
  57257. }
  57258. /**
  57259. * This is a support class that generates a series of packed texture sets.
  57260. * @see https://doc.babylonjs.com/babylon101/materials
  57261. */
  57262. export class TexturePacker {
  57263. /** Packer Layout Constant 0 */
  57264. static readonly LAYOUT_STRIP: number;
  57265. /** Packer Layout Constant 1 */
  57266. static readonly LAYOUT_POWER2: number;
  57267. /** Packer Layout Constant 2 */
  57268. static readonly LAYOUT_COLNUM: number;
  57269. /** Packer Layout Constant 0 */
  57270. static readonly SUBUV_WRAP: number;
  57271. /** Packer Layout Constant 1 */
  57272. static readonly SUBUV_EXTEND: number;
  57273. /** Packer Layout Constant 2 */
  57274. static readonly SUBUV_COLOR: number;
  57275. /** The Name of the Texture Package */
  57276. name: string;
  57277. /** The scene scope of the TexturePacker */
  57278. scene: Scene;
  57279. /** The Meshes to target */
  57280. meshes: AbstractMesh[];
  57281. /** Arguments passed with the Constructor */
  57282. options: ITexturePackerOptions;
  57283. /** The promise that is started upon initialization */
  57284. promise: Nullable<Promise<TexturePacker | string>>;
  57285. /** The Container object for the channel sets that are generated */
  57286. sets: object;
  57287. /** The Container array for the frames that are generated */
  57288. frames: TexturePackerFrame[];
  57289. /** The expected number of textures the system is parsing. */
  57290. private _expecting;
  57291. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57292. private _paddingValue;
  57293. /**
  57294. * Initializes a texture package series from an array of meshes or a single mesh.
  57295. * @param name The name of the package
  57296. * @param meshes The target meshes to compose the package from
  57297. * @param options The arguments that texture packer should follow while building.
  57298. * @param scene The scene which the textures are scoped to.
  57299. * @returns TexturePacker
  57300. */
  57301. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57302. /**
  57303. * Starts the package process
  57304. * @param resolve The promises resolution function
  57305. * @returns TexturePacker
  57306. */
  57307. private _createFrames;
  57308. /**
  57309. * Calculates the Size of the Channel Sets
  57310. * @returns Vector2
  57311. */
  57312. private _calculateSize;
  57313. /**
  57314. * Calculates the UV data for the frames.
  57315. * @param baseSize the base frameSize
  57316. * @param padding the base frame padding
  57317. * @param dtSize size of the Dynamic Texture for that channel
  57318. * @param dtUnits is 1/dtSize
  57319. * @param update flag to update the input meshes
  57320. */
  57321. private _calculateMeshUVFrames;
  57322. /**
  57323. * Calculates the frames Offset.
  57324. * @param index of the frame
  57325. * @returns Vector2
  57326. */
  57327. private _getFrameOffset;
  57328. /**
  57329. * Updates a Mesh to the frame data
  57330. * @param mesh that is the target
  57331. * @param frameID or the frame index
  57332. */
  57333. private _updateMeshUV;
  57334. /**
  57335. * Updates a Meshes materials to use the texture packer channels
  57336. * @param m is the mesh to target
  57337. * @param force all channels on the packer to be set.
  57338. */
  57339. private _updateTextureReferences;
  57340. /**
  57341. * Public method to set a Mesh to a frame
  57342. * @param m that is the target
  57343. * @param frameID or the frame index
  57344. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57345. */
  57346. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57347. /**
  57348. * Starts the async promise to compile the texture packer.
  57349. * @returns Promise<void>
  57350. */
  57351. processAsync(): Promise<void>;
  57352. /**
  57353. * Disposes all textures associated with this packer
  57354. */
  57355. dispose(): void;
  57356. /**
  57357. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57358. * @param imageType is the image type to use.
  57359. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57360. */
  57361. download(imageType?: string, quality?: number): void;
  57362. /**
  57363. * Public method to load a texturePacker JSON file.
  57364. * @param data of the JSON file in string format.
  57365. */
  57366. updateFromJSON(data: string): void;
  57367. }
  57368. }
  57369. declare module BABYLON {
  57370. /**
  57371. * Enum used to define the target of a block
  57372. */
  57373. export enum NodeMaterialBlockTargets {
  57374. /** Vertex shader */
  57375. Vertex = 1,
  57376. /** Fragment shader */
  57377. Fragment = 2,
  57378. /** Neutral */
  57379. Neutral = 4,
  57380. /** Vertex and Fragment */
  57381. VertexAndFragment = 3
  57382. }
  57383. }
  57384. declare module BABYLON {
  57385. /**
  57386. * Defines the kind of connection point for node based material
  57387. */
  57388. export enum NodeMaterialBlockConnectionPointTypes {
  57389. /** Float */
  57390. Float = 1,
  57391. /** Int */
  57392. Int = 2,
  57393. /** Vector2 */
  57394. Vector2 = 4,
  57395. /** Vector3 */
  57396. Vector3 = 8,
  57397. /** Vector4 */
  57398. Vector4 = 16,
  57399. /** Color3 */
  57400. Color3 = 32,
  57401. /** Color4 */
  57402. Color4 = 64,
  57403. /** Matrix */
  57404. Matrix = 128,
  57405. /** Detect type based on connection */
  57406. AutoDetect = 1024,
  57407. /** Output type that will be defined by input type */
  57408. BasedOnInput = 2048
  57409. }
  57410. }
  57411. declare module BABYLON {
  57412. /**
  57413. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57414. */
  57415. export enum NodeMaterialBlockConnectionPointMode {
  57416. /** Value is an uniform */
  57417. Uniform = 0,
  57418. /** Value is a mesh attribute */
  57419. Attribute = 1,
  57420. /** Value is a varying between vertex and fragment shaders */
  57421. Varying = 2,
  57422. /** Mode is undefined */
  57423. Undefined = 3
  57424. }
  57425. }
  57426. declare module BABYLON {
  57427. /**
  57428. * Enum used to define system values e.g. values automatically provided by the system
  57429. */
  57430. export enum NodeMaterialSystemValues {
  57431. /** World */
  57432. World = 1,
  57433. /** View */
  57434. View = 2,
  57435. /** Projection */
  57436. Projection = 3,
  57437. /** ViewProjection */
  57438. ViewProjection = 4,
  57439. /** WorldView */
  57440. WorldView = 5,
  57441. /** WorldViewProjection */
  57442. WorldViewProjection = 6,
  57443. /** CameraPosition */
  57444. CameraPosition = 7,
  57445. /** Fog Color */
  57446. FogColor = 8,
  57447. /** Delta time */
  57448. DeltaTime = 9
  57449. }
  57450. }
  57451. declare module BABYLON {
  57452. /**
  57453. * Root class for all node material optimizers
  57454. */
  57455. export class NodeMaterialOptimizer {
  57456. /**
  57457. * Function used to optimize a NodeMaterial graph
  57458. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57459. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57460. */
  57461. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57462. }
  57463. }
  57464. declare module BABYLON {
  57465. /**
  57466. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57467. */
  57468. export class TransformBlock extends NodeMaterialBlock {
  57469. /**
  57470. * Defines the value to use to complement W value to transform it to a Vector4
  57471. */
  57472. complementW: number;
  57473. /**
  57474. * Defines the value to use to complement z value to transform it to a Vector4
  57475. */
  57476. complementZ: number;
  57477. /**
  57478. * Creates a new TransformBlock
  57479. * @param name defines the block name
  57480. */
  57481. constructor(name: string);
  57482. /**
  57483. * Gets the current class name
  57484. * @returns the class name
  57485. */
  57486. getClassName(): string;
  57487. /**
  57488. * Gets the vector input
  57489. */
  57490. get vector(): NodeMaterialConnectionPoint;
  57491. /**
  57492. * Gets the output component
  57493. */
  57494. get output(): NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the xyz output component
  57497. */
  57498. get xyz(): NodeMaterialConnectionPoint;
  57499. /**
  57500. * Gets the matrix transform input
  57501. */
  57502. get transform(): NodeMaterialConnectionPoint;
  57503. protected _buildBlock(state: NodeMaterialBuildState): this;
  57504. serialize(): any;
  57505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57506. protected _dumpPropertiesCode(): string;
  57507. }
  57508. }
  57509. declare module BABYLON {
  57510. /**
  57511. * Block used to output the vertex position
  57512. */
  57513. export class VertexOutputBlock extends NodeMaterialBlock {
  57514. /**
  57515. * Creates a new VertexOutputBlock
  57516. * @param name defines the block name
  57517. */
  57518. constructor(name: string);
  57519. /**
  57520. * Gets the current class name
  57521. * @returns the class name
  57522. */
  57523. getClassName(): string;
  57524. /**
  57525. * Gets the vector input component
  57526. */
  57527. get vector(): NodeMaterialConnectionPoint;
  57528. protected _buildBlock(state: NodeMaterialBuildState): this;
  57529. }
  57530. }
  57531. declare module BABYLON {
  57532. /**
  57533. * Block used to output the final color
  57534. */
  57535. export class FragmentOutputBlock extends NodeMaterialBlock {
  57536. /**
  57537. * Create a new FragmentOutputBlock
  57538. * @param name defines the block name
  57539. */
  57540. constructor(name: string);
  57541. /**
  57542. * Gets the current class name
  57543. * @returns the class name
  57544. */
  57545. getClassName(): string;
  57546. /**
  57547. * Gets the rgba input component
  57548. */
  57549. get rgba(): NodeMaterialConnectionPoint;
  57550. /**
  57551. * Gets the rgb input component
  57552. */
  57553. get rgb(): NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the a input component
  57556. */
  57557. get a(): NodeMaterialConnectionPoint;
  57558. protected _buildBlock(state: NodeMaterialBuildState): this;
  57559. }
  57560. }
  57561. declare module BABYLON {
  57562. /**
  57563. * Block used to read a reflection texture from a sampler
  57564. */
  57565. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57566. private _define3DName;
  57567. private _defineCubicName;
  57568. private _defineExplicitName;
  57569. private _defineProjectionName;
  57570. private _defineLocalCubicName;
  57571. private _defineSphericalName;
  57572. private _definePlanarName;
  57573. private _defineEquirectangularName;
  57574. private _defineMirroredEquirectangularFixedName;
  57575. private _defineEquirectangularFixedName;
  57576. private _defineSkyboxName;
  57577. private _cubeSamplerName;
  57578. private _2DSamplerName;
  57579. private _positionUVWName;
  57580. private _directionWName;
  57581. private _reflectionCoordsName;
  57582. private _reflection2DCoordsName;
  57583. private _reflectionColorName;
  57584. private _reflectionMatrixName;
  57585. /**
  57586. * Gets or sets the texture associated with the node
  57587. */
  57588. texture: Nullable<BaseTexture>;
  57589. /**
  57590. * Create a new TextureBlock
  57591. * @param name defines the block name
  57592. */
  57593. constructor(name: string);
  57594. /**
  57595. * Gets the current class name
  57596. * @returns the class name
  57597. */
  57598. getClassName(): string;
  57599. /**
  57600. * Gets the world position input component
  57601. */
  57602. get position(): NodeMaterialConnectionPoint;
  57603. /**
  57604. * Gets the world position input component
  57605. */
  57606. get worldPosition(): NodeMaterialConnectionPoint;
  57607. /**
  57608. * Gets the world normal input component
  57609. */
  57610. get worldNormal(): NodeMaterialConnectionPoint;
  57611. /**
  57612. * Gets the world input component
  57613. */
  57614. get world(): NodeMaterialConnectionPoint;
  57615. /**
  57616. * Gets the camera (or eye) position component
  57617. */
  57618. get cameraPosition(): NodeMaterialConnectionPoint;
  57619. /**
  57620. * Gets the view input component
  57621. */
  57622. get view(): NodeMaterialConnectionPoint;
  57623. /**
  57624. * Gets the rgb output component
  57625. */
  57626. get rgb(): NodeMaterialConnectionPoint;
  57627. /**
  57628. * Gets the r output component
  57629. */
  57630. get r(): NodeMaterialConnectionPoint;
  57631. /**
  57632. * Gets the g output component
  57633. */
  57634. get g(): NodeMaterialConnectionPoint;
  57635. /**
  57636. * Gets the b output component
  57637. */
  57638. get b(): NodeMaterialConnectionPoint;
  57639. autoConfigure(material: NodeMaterial): void;
  57640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57641. isReady(): boolean;
  57642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57643. private _injectVertexCode;
  57644. private _writeOutput;
  57645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57646. protected _dumpPropertiesCode(): string;
  57647. serialize(): any;
  57648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57649. }
  57650. }
  57651. declare module BABYLON {
  57652. /**
  57653. * Interface used to configure the node material editor
  57654. */
  57655. export interface INodeMaterialEditorOptions {
  57656. /** Define the URl to load node editor script */
  57657. editorURL?: string;
  57658. }
  57659. /** @hidden */
  57660. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57661. NORMAL: boolean;
  57662. TANGENT: boolean;
  57663. UV1: boolean;
  57664. /** BONES */
  57665. NUM_BONE_INFLUENCERS: number;
  57666. BonesPerMesh: number;
  57667. BONETEXTURE: boolean;
  57668. /** MORPH TARGETS */
  57669. MORPHTARGETS: boolean;
  57670. MORPHTARGETS_NORMAL: boolean;
  57671. MORPHTARGETS_TANGENT: boolean;
  57672. MORPHTARGETS_UV: boolean;
  57673. NUM_MORPH_INFLUENCERS: number;
  57674. /** IMAGE PROCESSING */
  57675. IMAGEPROCESSING: boolean;
  57676. VIGNETTE: boolean;
  57677. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57678. VIGNETTEBLENDMODEOPAQUE: boolean;
  57679. TONEMAPPING: boolean;
  57680. TONEMAPPING_ACES: boolean;
  57681. CONTRAST: boolean;
  57682. EXPOSURE: boolean;
  57683. COLORCURVES: boolean;
  57684. COLORGRADING: boolean;
  57685. COLORGRADING3D: boolean;
  57686. SAMPLER3DGREENDEPTH: boolean;
  57687. SAMPLER3DBGRMAP: boolean;
  57688. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57689. /** MISC. */
  57690. BUMPDIRECTUV: number;
  57691. constructor();
  57692. setValue(name: string, value: boolean): void;
  57693. }
  57694. /**
  57695. * Class used to configure NodeMaterial
  57696. */
  57697. export interface INodeMaterialOptions {
  57698. /**
  57699. * Defines if blocks should emit comments
  57700. */
  57701. emitComments: boolean;
  57702. }
  57703. /**
  57704. * Class used to create a node based material built by assembling shader blocks
  57705. */
  57706. export class NodeMaterial extends PushMaterial {
  57707. private static _BuildIdGenerator;
  57708. private _options;
  57709. private _vertexCompilationState;
  57710. private _fragmentCompilationState;
  57711. private _sharedData;
  57712. private _buildId;
  57713. private _buildWasSuccessful;
  57714. private _cachedWorldViewMatrix;
  57715. private _cachedWorldViewProjectionMatrix;
  57716. private _optimizers;
  57717. private _animationFrame;
  57718. /** Define the Url to load node editor script */
  57719. static EditorURL: string;
  57720. /** Define the Url to load snippets */
  57721. static SnippetUrl: string;
  57722. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57723. static IgnoreTexturesAtLoadTime: boolean;
  57724. private BJSNODEMATERIALEDITOR;
  57725. /** Get the inspector from bundle or global */
  57726. private _getGlobalNodeMaterialEditor;
  57727. /**
  57728. * Snippet ID if the material was created from the snippet server
  57729. */
  57730. snippetId: string;
  57731. /**
  57732. * Gets or sets data used by visual editor
  57733. * @see https://nme.babylonjs.com
  57734. */
  57735. editorData: any;
  57736. /**
  57737. * 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)
  57738. */
  57739. ignoreAlpha: boolean;
  57740. /**
  57741. * Defines the maximum number of lights that can be used in the material
  57742. */
  57743. maxSimultaneousLights: number;
  57744. /**
  57745. * Observable raised when the material is built
  57746. */
  57747. onBuildObservable: Observable<NodeMaterial>;
  57748. /**
  57749. * Gets or sets the root nodes of the material vertex shader
  57750. */
  57751. _vertexOutputNodes: NodeMaterialBlock[];
  57752. /**
  57753. * Gets or sets the root nodes of the material fragment (pixel) shader
  57754. */
  57755. _fragmentOutputNodes: NodeMaterialBlock[];
  57756. /** Gets or sets options to control the node material overall behavior */
  57757. get options(): INodeMaterialOptions;
  57758. set options(options: INodeMaterialOptions);
  57759. /**
  57760. * Default configuration related to image processing available in the standard Material.
  57761. */
  57762. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57763. /**
  57764. * Gets the image processing configuration used either in this material.
  57765. */
  57766. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57767. /**
  57768. * Sets the Default image processing configuration used either in the this material.
  57769. *
  57770. * If sets to null, the scene one is in use.
  57771. */
  57772. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57773. /**
  57774. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57775. */
  57776. attachedBlocks: NodeMaterialBlock[];
  57777. /**
  57778. * Create a new node based material
  57779. * @param name defines the material name
  57780. * @param scene defines the hosting scene
  57781. * @param options defines creation option
  57782. */
  57783. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57784. /**
  57785. * Gets the current class name of the material e.g. "NodeMaterial"
  57786. * @returns the class name
  57787. */
  57788. getClassName(): string;
  57789. /**
  57790. * Keep track of the image processing observer to allow dispose and replace.
  57791. */
  57792. private _imageProcessingObserver;
  57793. /**
  57794. * Attaches a new image processing configuration to the Standard Material.
  57795. * @param configuration
  57796. */
  57797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57798. /**
  57799. * Get a block by its name
  57800. * @param name defines the name of the block to retrieve
  57801. * @returns the required block or null if not found
  57802. */
  57803. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57804. /**
  57805. * Get a block by its name
  57806. * @param predicate defines the predicate used to find the good candidate
  57807. * @returns the required block or null if not found
  57808. */
  57809. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57810. /**
  57811. * Get an input block by its name
  57812. * @param predicate defines the predicate used to find the good candidate
  57813. * @returns the required input block or null if not found
  57814. */
  57815. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57816. /**
  57817. * Gets the list of input blocks attached to this material
  57818. * @returns an array of InputBlocks
  57819. */
  57820. getInputBlocks(): InputBlock[];
  57821. /**
  57822. * Adds a new optimizer to the list of optimizers
  57823. * @param optimizer defines the optimizers to add
  57824. * @returns the current material
  57825. */
  57826. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57827. /**
  57828. * Remove an optimizer from the list of optimizers
  57829. * @param optimizer defines the optimizers to remove
  57830. * @returns the current material
  57831. */
  57832. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57833. /**
  57834. * Add a new block to the list of output nodes
  57835. * @param node defines the node to add
  57836. * @returns the current material
  57837. */
  57838. addOutputNode(node: NodeMaterialBlock): this;
  57839. /**
  57840. * Remove a block from the list of root nodes
  57841. * @param node defines the node to remove
  57842. * @returns the current material
  57843. */
  57844. removeOutputNode(node: NodeMaterialBlock): this;
  57845. private _addVertexOutputNode;
  57846. private _removeVertexOutputNode;
  57847. private _addFragmentOutputNode;
  57848. private _removeFragmentOutputNode;
  57849. /**
  57850. * Specifies if the material will require alpha blending
  57851. * @returns a boolean specifying if alpha blending is needed
  57852. */
  57853. needAlphaBlending(): boolean;
  57854. /**
  57855. * Specifies if this material should be rendered in alpha test mode
  57856. * @returns a boolean specifying if an alpha test is needed.
  57857. */
  57858. needAlphaTesting(): boolean;
  57859. private _initializeBlock;
  57860. private _resetDualBlocks;
  57861. /**
  57862. * Remove a block from the current node material
  57863. * @param block defines the block to remove
  57864. */
  57865. removeBlock(block: NodeMaterialBlock): void;
  57866. /**
  57867. * Build the material and generates the inner effect
  57868. * @param verbose defines if the build should log activity
  57869. */
  57870. build(verbose?: boolean): void;
  57871. /**
  57872. * Runs an otpimization phase to try to improve the shader code
  57873. */
  57874. optimize(): void;
  57875. private _prepareDefinesForAttributes;
  57876. /**
  57877. * Get if the submesh is ready to be used and all its information available.
  57878. * Child classes can use it to update shaders
  57879. * @param mesh defines the mesh to check
  57880. * @param subMesh defines which submesh to check
  57881. * @param useInstances specifies that instances should be used
  57882. * @returns a boolean indicating that the submesh is ready or not
  57883. */
  57884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57885. /**
  57886. * Get a string representing the shaders built by the current node graph
  57887. */
  57888. get compiledShaders(): string;
  57889. /**
  57890. * Binds the world matrix to the material
  57891. * @param world defines the world transformation matrix
  57892. */
  57893. bindOnlyWorldMatrix(world: Matrix): void;
  57894. /**
  57895. * Binds the submesh to this material by preparing the effect and shader to draw
  57896. * @param world defines the world transformation matrix
  57897. * @param mesh defines the mesh containing the submesh
  57898. * @param subMesh defines the submesh to bind the material to
  57899. */
  57900. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57901. /**
  57902. * Gets the active textures from the material
  57903. * @returns an array of textures
  57904. */
  57905. getActiveTextures(): BaseTexture[];
  57906. /**
  57907. * Gets the list of texture blocks
  57908. * @returns an array of texture blocks
  57909. */
  57910. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57911. /**
  57912. * Specifies if the material uses a texture
  57913. * @param texture defines the texture to check against the material
  57914. * @returns a boolean specifying if the material uses the texture
  57915. */
  57916. hasTexture(texture: BaseTexture): boolean;
  57917. /**
  57918. * Disposes the material
  57919. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57920. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57921. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57922. */
  57923. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57924. /** Creates the node editor window. */
  57925. private _createNodeEditor;
  57926. /**
  57927. * Launch the node material editor
  57928. * @param config Define the configuration of the editor
  57929. * @return a promise fulfilled when the node editor is visible
  57930. */
  57931. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57932. /**
  57933. * Clear the current material
  57934. */
  57935. clear(): void;
  57936. /**
  57937. * Clear the current material and set it to a default state
  57938. */
  57939. setToDefault(): void;
  57940. /**
  57941. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57942. * @param url defines the url to load from
  57943. * @returns a promise that will fullfil when the material is fully loaded
  57944. */
  57945. loadAsync(url: string): Promise<void>;
  57946. private _gatherBlocks;
  57947. /**
  57948. * Generate a string containing the code declaration required to create an equivalent of this material
  57949. * @returns a string
  57950. */
  57951. generateCode(): string;
  57952. /**
  57953. * Serializes this material in a JSON representation
  57954. * @returns the serialized material object
  57955. */
  57956. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57957. private _restoreConnections;
  57958. /**
  57959. * Clear the current graph and load a new one from a serialization object
  57960. * @param source defines the JSON representation of the material
  57961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57962. */
  57963. loadFromSerialization(source: any, rootUrl?: string): void;
  57964. /**
  57965. * Makes a duplicate of the current material.
  57966. * @param name - name to use for the new material.
  57967. */
  57968. clone(name: string): NodeMaterial;
  57969. /**
  57970. * Creates a node material from parsed material data
  57971. * @param source defines the JSON representation of the material
  57972. * @param scene defines the hosting scene
  57973. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57974. * @returns a new node material
  57975. */
  57976. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57977. /**
  57978. * Creates a node material from a snippet saved in a remote file
  57979. * @param name defines the name of the material to create
  57980. * @param url defines the url to load from
  57981. * @param scene defines the hosting scene
  57982. * @returns a promise that will resolve to the new node material
  57983. */
  57984. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57985. /**
  57986. * Creates a node material from a snippet saved by the node material editor
  57987. * @param snippetId defines the snippet to load
  57988. * @param scene defines the hosting scene
  57989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57990. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57991. * @returns a promise that will resolve to the new node material
  57992. */
  57993. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57994. /**
  57995. * Creates a new node material set to default basic configuration
  57996. * @param name defines the name of the material
  57997. * @param scene defines the hosting scene
  57998. * @returns a new NodeMaterial
  57999. */
  58000. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58001. }
  58002. }
  58003. declare module BABYLON {
  58004. /**
  58005. * Block used to read a texture from a sampler
  58006. */
  58007. export class TextureBlock extends NodeMaterialBlock {
  58008. private _defineName;
  58009. private _linearDefineName;
  58010. private _tempTextureRead;
  58011. private _samplerName;
  58012. private _transformedUVName;
  58013. private _textureTransformName;
  58014. private _textureInfoName;
  58015. private _mainUVName;
  58016. private _mainUVDefineName;
  58017. /**
  58018. * Gets or sets the texture associated with the node
  58019. */
  58020. texture: Nullable<Texture>;
  58021. /**
  58022. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58023. */
  58024. convertToGammaSpace: boolean;
  58025. /**
  58026. * Create a new TextureBlock
  58027. * @param name defines the block name
  58028. */
  58029. constructor(name: string);
  58030. /**
  58031. * Gets the current class name
  58032. * @returns the class name
  58033. */
  58034. getClassName(): string;
  58035. /**
  58036. * Gets the uv input component
  58037. */
  58038. get uv(): NodeMaterialConnectionPoint;
  58039. /**
  58040. * Gets the rgba output component
  58041. */
  58042. get rgba(): NodeMaterialConnectionPoint;
  58043. /**
  58044. * Gets the rgb output component
  58045. */
  58046. get rgb(): NodeMaterialConnectionPoint;
  58047. /**
  58048. * Gets the r output component
  58049. */
  58050. get r(): NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the g output component
  58053. */
  58054. get g(): NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the b output component
  58057. */
  58058. get b(): NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the a output component
  58061. */
  58062. get a(): NodeMaterialConnectionPoint;
  58063. get target(): NodeMaterialBlockTargets;
  58064. autoConfigure(material: NodeMaterial): void;
  58065. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58066. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58067. isReady(): boolean;
  58068. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58069. private get _isMixed();
  58070. private _injectVertexCode;
  58071. private _writeTextureRead;
  58072. private _writeOutput;
  58073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58074. protected _dumpPropertiesCode(): string;
  58075. serialize(): any;
  58076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58077. }
  58078. }
  58079. declare module BABYLON {
  58080. /**
  58081. * Class used to store shared data between 2 NodeMaterialBuildState
  58082. */
  58083. export class NodeMaterialBuildStateSharedData {
  58084. /**
  58085. * Gets the list of emitted varyings
  58086. */
  58087. temps: string[];
  58088. /**
  58089. * Gets the list of emitted varyings
  58090. */
  58091. varyings: string[];
  58092. /**
  58093. * Gets the varying declaration string
  58094. */
  58095. varyingDeclaration: string;
  58096. /**
  58097. * Input blocks
  58098. */
  58099. inputBlocks: InputBlock[];
  58100. /**
  58101. * Input blocks
  58102. */
  58103. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58104. /**
  58105. * Bindable blocks (Blocks that need to set data to the effect)
  58106. */
  58107. bindableBlocks: NodeMaterialBlock[];
  58108. /**
  58109. * List of blocks that can provide a compilation fallback
  58110. */
  58111. blocksWithFallbacks: NodeMaterialBlock[];
  58112. /**
  58113. * List of blocks that can provide a define update
  58114. */
  58115. blocksWithDefines: NodeMaterialBlock[];
  58116. /**
  58117. * List of blocks that can provide a repeatable content
  58118. */
  58119. repeatableContentBlocks: NodeMaterialBlock[];
  58120. /**
  58121. * List of blocks that can provide a dynamic list of uniforms
  58122. */
  58123. dynamicUniformBlocks: NodeMaterialBlock[];
  58124. /**
  58125. * List of blocks that can block the isReady function for the material
  58126. */
  58127. blockingBlocks: NodeMaterialBlock[];
  58128. /**
  58129. * Gets the list of animated inputs
  58130. */
  58131. animatedInputs: InputBlock[];
  58132. /**
  58133. * Build Id used to avoid multiple recompilations
  58134. */
  58135. buildId: number;
  58136. /** List of emitted variables */
  58137. variableNames: {
  58138. [key: string]: number;
  58139. };
  58140. /** List of emitted defines */
  58141. defineNames: {
  58142. [key: string]: number;
  58143. };
  58144. /** Should emit comments? */
  58145. emitComments: boolean;
  58146. /** Emit build activity */
  58147. verbose: boolean;
  58148. /** Gets or sets the hosting scene */
  58149. scene: Scene;
  58150. /**
  58151. * Gets the compilation hints emitted at compilation time
  58152. */
  58153. hints: {
  58154. needWorldViewMatrix: boolean;
  58155. needWorldViewProjectionMatrix: boolean;
  58156. needAlphaBlending: boolean;
  58157. needAlphaTesting: boolean;
  58158. };
  58159. /**
  58160. * List of compilation checks
  58161. */
  58162. checks: {
  58163. emitVertex: boolean;
  58164. emitFragment: boolean;
  58165. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58166. };
  58167. /** Creates a new shared data */
  58168. constructor();
  58169. /**
  58170. * Emits console errors and exceptions if there is a failing check
  58171. */
  58172. emitErrors(): void;
  58173. }
  58174. }
  58175. declare module BABYLON {
  58176. /**
  58177. * Class used to store node based material build state
  58178. */
  58179. export class NodeMaterialBuildState {
  58180. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58181. supportUniformBuffers: boolean;
  58182. /**
  58183. * Gets the list of emitted attributes
  58184. */
  58185. attributes: string[];
  58186. /**
  58187. * Gets the list of emitted uniforms
  58188. */
  58189. uniforms: string[];
  58190. /**
  58191. * Gets the list of emitted constants
  58192. */
  58193. constants: string[];
  58194. /**
  58195. * Gets the list of emitted samplers
  58196. */
  58197. samplers: string[];
  58198. /**
  58199. * Gets the list of emitted functions
  58200. */
  58201. functions: {
  58202. [key: string]: string;
  58203. };
  58204. /**
  58205. * Gets the list of emitted extensions
  58206. */
  58207. extensions: {
  58208. [key: string]: string;
  58209. };
  58210. /**
  58211. * Gets the target of the compilation state
  58212. */
  58213. target: NodeMaterialBlockTargets;
  58214. /**
  58215. * Gets the list of emitted counters
  58216. */
  58217. counters: {
  58218. [key: string]: number;
  58219. };
  58220. /**
  58221. * Shared data between multiple NodeMaterialBuildState instances
  58222. */
  58223. sharedData: NodeMaterialBuildStateSharedData;
  58224. /** @hidden */
  58225. _vertexState: NodeMaterialBuildState;
  58226. /** @hidden */
  58227. _attributeDeclaration: string;
  58228. /** @hidden */
  58229. _uniformDeclaration: string;
  58230. /** @hidden */
  58231. _constantDeclaration: string;
  58232. /** @hidden */
  58233. _samplerDeclaration: string;
  58234. /** @hidden */
  58235. _varyingTransfer: string;
  58236. private _repeatableContentAnchorIndex;
  58237. /** @hidden */
  58238. _builtCompilationString: string;
  58239. /**
  58240. * Gets the emitted compilation strings
  58241. */
  58242. compilationString: string;
  58243. /**
  58244. * Finalize the compilation strings
  58245. * @param state defines the current compilation state
  58246. */
  58247. finalize(state: NodeMaterialBuildState): void;
  58248. /** @hidden */
  58249. get _repeatableContentAnchor(): string;
  58250. /** @hidden */
  58251. _getFreeVariableName(prefix: string): string;
  58252. /** @hidden */
  58253. _getFreeDefineName(prefix: string): string;
  58254. /** @hidden */
  58255. _excludeVariableName(name: string): void;
  58256. /** @hidden */
  58257. _emit2DSampler(name: string): void;
  58258. /** @hidden */
  58259. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58260. /** @hidden */
  58261. _emitExtension(name: string, extension: string): void;
  58262. /** @hidden */
  58263. _emitFunction(name: string, code: string, comments: string): void;
  58264. /** @hidden */
  58265. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58266. replaceStrings?: {
  58267. search: RegExp;
  58268. replace: string;
  58269. }[];
  58270. repeatKey?: string;
  58271. }): string;
  58272. /** @hidden */
  58273. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58274. repeatKey?: string;
  58275. removeAttributes?: boolean;
  58276. removeUniforms?: boolean;
  58277. removeVaryings?: boolean;
  58278. removeIfDef?: boolean;
  58279. replaceStrings?: {
  58280. search: RegExp;
  58281. replace: string;
  58282. }[];
  58283. }, storeKey?: string): void;
  58284. /** @hidden */
  58285. _registerTempVariable(name: string): boolean;
  58286. /** @hidden */
  58287. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58288. /** @hidden */
  58289. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58290. /** @hidden */
  58291. _emitFloat(value: number): string;
  58292. }
  58293. }
  58294. declare module BABYLON {
  58295. /**
  58296. * Defines a block that can be used inside a node based material
  58297. */
  58298. export class NodeMaterialBlock {
  58299. private _buildId;
  58300. private _buildTarget;
  58301. private _target;
  58302. private _isFinalMerger;
  58303. private _isInput;
  58304. protected _isUnique: boolean;
  58305. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58306. inputsAreExclusive: boolean;
  58307. /** @hidden */
  58308. _codeVariableName: string;
  58309. /** @hidden */
  58310. _inputs: NodeMaterialConnectionPoint[];
  58311. /** @hidden */
  58312. _outputs: NodeMaterialConnectionPoint[];
  58313. /** @hidden */
  58314. _preparationId: number;
  58315. /**
  58316. * Gets or sets the name of the block
  58317. */
  58318. name: string;
  58319. /**
  58320. * Gets or sets the unique id of the node
  58321. */
  58322. uniqueId: number;
  58323. /**
  58324. * Gets or sets the comments associated with this block
  58325. */
  58326. comments: string;
  58327. /**
  58328. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58329. */
  58330. get isUnique(): boolean;
  58331. /**
  58332. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58333. */
  58334. get isFinalMerger(): boolean;
  58335. /**
  58336. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58337. */
  58338. get isInput(): boolean;
  58339. /**
  58340. * Gets or sets the build Id
  58341. */
  58342. get buildId(): number;
  58343. set buildId(value: number);
  58344. /**
  58345. * Gets or sets the target of the block
  58346. */
  58347. get target(): NodeMaterialBlockTargets;
  58348. set target(value: NodeMaterialBlockTargets);
  58349. /**
  58350. * Gets the list of input points
  58351. */
  58352. get inputs(): NodeMaterialConnectionPoint[];
  58353. /** Gets the list of output points */
  58354. get outputs(): NodeMaterialConnectionPoint[];
  58355. /**
  58356. * Find an input by its name
  58357. * @param name defines the name of the input to look for
  58358. * @returns the input or null if not found
  58359. */
  58360. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58361. /**
  58362. * Find an output by its name
  58363. * @param name defines the name of the outputto look for
  58364. * @returns the output or null if not found
  58365. */
  58366. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58367. /**
  58368. * Creates a new NodeMaterialBlock
  58369. * @param name defines the block name
  58370. * @param target defines the target of that block (Vertex by default)
  58371. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58372. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58373. */
  58374. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58375. /**
  58376. * Initialize the block and prepare the context for build
  58377. * @param state defines the state that will be used for the build
  58378. */
  58379. initialize(state: NodeMaterialBuildState): void;
  58380. /**
  58381. * Bind data to effect. Will only be called for blocks with isBindable === true
  58382. * @param effect defines the effect to bind data to
  58383. * @param nodeMaterial defines the hosting NodeMaterial
  58384. * @param mesh defines the mesh that will be rendered
  58385. */
  58386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58387. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58388. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58389. protected _writeFloat(value: number): string;
  58390. /**
  58391. * Gets the current class name e.g. "NodeMaterialBlock"
  58392. * @returns the class name
  58393. */
  58394. getClassName(): string;
  58395. /**
  58396. * Register a new input. Must be called inside a block constructor
  58397. * @param name defines the connection point name
  58398. * @param type defines the connection point type
  58399. * @param isOptional defines a boolean indicating that this input can be omitted
  58400. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58401. * @returns the current block
  58402. */
  58403. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58404. /**
  58405. * Register a new output. Must be called inside a block constructor
  58406. * @param name defines the connection point name
  58407. * @param type defines the connection point type
  58408. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58409. * @returns the current block
  58410. */
  58411. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58412. /**
  58413. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58414. * @param forOutput defines an optional connection point to check compatibility with
  58415. * @returns the first available input or null
  58416. */
  58417. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58418. /**
  58419. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58420. * @param forBlock defines an optional block to check compatibility with
  58421. * @returns the first available input or null
  58422. */
  58423. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58424. /**
  58425. * Gets the sibling of the given output
  58426. * @param current defines the current output
  58427. * @returns the next output in the list or null
  58428. */
  58429. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58430. /**
  58431. * Connect current block with another block
  58432. * @param other defines the block to connect with
  58433. * @param options define the various options to help pick the right connections
  58434. * @returns the current block
  58435. */
  58436. connectTo(other: NodeMaterialBlock, options?: {
  58437. input?: string;
  58438. output?: string;
  58439. outputSwizzle?: string;
  58440. }): this | undefined;
  58441. protected _buildBlock(state: NodeMaterialBuildState): void;
  58442. /**
  58443. * Add uniforms, samplers and uniform buffers at compilation time
  58444. * @param state defines the state to update
  58445. * @param nodeMaterial defines the node material requesting the update
  58446. * @param defines defines the material defines to update
  58447. * @param uniformBuffers defines the list of uniform buffer names
  58448. */
  58449. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58450. /**
  58451. * Add potential fallbacks if shader compilation fails
  58452. * @param mesh defines the mesh to be rendered
  58453. * @param fallbacks defines the current prioritized list of fallbacks
  58454. */
  58455. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58456. /**
  58457. * Initialize defines for shader compilation
  58458. * @param mesh defines the mesh to be rendered
  58459. * @param nodeMaterial defines the node material requesting the update
  58460. * @param defines defines the material defines to update
  58461. * @param useInstances specifies that instances should be used
  58462. */
  58463. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58464. /**
  58465. * Update defines for shader compilation
  58466. * @param mesh defines the mesh to be rendered
  58467. * @param nodeMaterial defines the node material requesting the update
  58468. * @param defines defines the material defines to update
  58469. * @param useInstances specifies that instances should be used
  58470. */
  58471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58472. /**
  58473. * Lets the block try to connect some inputs automatically
  58474. * @param material defines the hosting NodeMaterial
  58475. */
  58476. autoConfigure(material: NodeMaterial): void;
  58477. /**
  58478. * Function called when a block is declared as repeatable content generator
  58479. * @param vertexShaderState defines the current compilation state for the vertex shader
  58480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58481. * @param mesh defines the mesh to be rendered
  58482. * @param defines defines the material defines to update
  58483. */
  58484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58485. /**
  58486. * Checks if the block is ready
  58487. * @param mesh defines the mesh to be rendered
  58488. * @param nodeMaterial defines the node material requesting the update
  58489. * @param defines defines the material defines to update
  58490. * @param useInstances specifies that instances should be used
  58491. * @returns true if the block is ready
  58492. */
  58493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58495. private _processBuild;
  58496. /**
  58497. * Compile the current node and generate the shader code
  58498. * @param state defines the current compilation state (uniforms, samplers, current string)
  58499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58500. * @returns true if already built
  58501. */
  58502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58503. protected _inputRename(name: string): string;
  58504. protected _outputRename(name: string): string;
  58505. protected _dumpPropertiesCode(): string;
  58506. /** @hidden */
  58507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58508. /** @hidden */
  58509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58510. /**
  58511. * Clone the current block to a new identical block
  58512. * @param scene defines the hosting scene
  58513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58514. * @returns a copy of the current block
  58515. */
  58516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58517. /**
  58518. * Serializes this block in a JSON representation
  58519. * @returns the serialized block object
  58520. */
  58521. serialize(): any;
  58522. /** @hidden */
  58523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58524. /**
  58525. * Release resources
  58526. */
  58527. dispose(): void;
  58528. }
  58529. }
  58530. declare module BABYLON {
  58531. /**
  58532. * Enum defining the type of animations supported by InputBlock
  58533. */
  58534. export enum AnimatedInputBlockTypes {
  58535. /** No animation */
  58536. None = 0,
  58537. /** Time based animation. Will only work for floats */
  58538. Time = 1
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /**
  58543. * Block used to expose an input value
  58544. */
  58545. export class InputBlock extends NodeMaterialBlock {
  58546. private _mode;
  58547. private _associatedVariableName;
  58548. private _storedValue;
  58549. private _valueCallback;
  58550. private _type;
  58551. private _animationType;
  58552. /** Gets or set a value used to limit the range of float values */
  58553. min: number;
  58554. /** Gets or set a value used to limit the range of float values */
  58555. max: number;
  58556. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58557. isBoolean: boolean;
  58558. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58559. matrixMode: number;
  58560. /** @hidden */
  58561. _systemValue: Nullable<NodeMaterialSystemValues>;
  58562. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58563. visibleInInspector: boolean;
  58564. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58565. isConstant: boolean;
  58566. /** Gets or sets the group to use to display this block in the Inspector */
  58567. groupInInspector: string;
  58568. /** Gets an observable raised when the value is changed */
  58569. onValueChangedObservable: Observable<InputBlock>;
  58570. /**
  58571. * Gets or sets the connection point type (default is float)
  58572. */
  58573. get type(): NodeMaterialBlockConnectionPointTypes;
  58574. /**
  58575. * Creates a new InputBlock
  58576. * @param name defines the block name
  58577. * @param target defines the target of that block (Vertex by default)
  58578. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58579. */
  58580. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58581. /**
  58582. * Gets the output component
  58583. */
  58584. get output(): NodeMaterialConnectionPoint;
  58585. /**
  58586. * Set the source of this connection point to a vertex attribute
  58587. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58588. * @returns the current connection point
  58589. */
  58590. setAsAttribute(attributeName?: string): InputBlock;
  58591. /**
  58592. * Set the source of this connection point to a system value
  58593. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58594. * @returns the current connection point
  58595. */
  58596. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58597. /**
  58598. * Gets or sets the value of that point.
  58599. * Please note that this value will be ignored if valueCallback is defined
  58600. */
  58601. get value(): any;
  58602. set value(value: any);
  58603. /**
  58604. * Gets or sets a callback used to get the value of that point.
  58605. * Please note that setting this value will force the connection point to ignore the value property
  58606. */
  58607. get valueCallback(): () => any;
  58608. set valueCallback(value: () => any);
  58609. /**
  58610. * Gets or sets the associated variable name in the shader
  58611. */
  58612. get associatedVariableName(): string;
  58613. set associatedVariableName(value: string);
  58614. /** Gets or sets the type of animation applied to the input */
  58615. get animationType(): AnimatedInputBlockTypes;
  58616. set animationType(value: AnimatedInputBlockTypes);
  58617. /**
  58618. * Gets a boolean indicating that this connection point not defined yet
  58619. */
  58620. get isUndefined(): boolean;
  58621. /**
  58622. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58623. * In this case the connection point name must be the name of the uniform to use.
  58624. * Can only be set on inputs
  58625. */
  58626. get isUniform(): boolean;
  58627. set isUniform(value: boolean);
  58628. /**
  58629. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58630. * In this case the connection point name must be the name of the attribute to use
  58631. * Can only be set on inputs
  58632. */
  58633. get isAttribute(): boolean;
  58634. set isAttribute(value: boolean);
  58635. /**
  58636. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58637. * Can only be set on exit points
  58638. */
  58639. get isVarying(): boolean;
  58640. set isVarying(value: boolean);
  58641. /**
  58642. * Gets a boolean indicating that the current connection point is a system value
  58643. */
  58644. get isSystemValue(): boolean;
  58645. /**
  58646. * Gets or sets the current well known value or null if not defined as a system value
  58647. */
  58648. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58649. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58650. /**
  58651. * Gets the current class name
  58652. * @returns the class name
  58653. */
  58654. getClassName(): string;
  58655. /**
  58656. * Animate the input if animationType !== None
  58657. * @param scene defines the rendering scene
  58658. */
  58659. animate(scene: Scene): void;
  58660. private _emitDefine;
  58661. initialize(state: NodeMaterialBuildState): void;
  58662. /**
  58663. * Set the input block to its default value (based on its type)
  58664. */
  58665. setDefaultValue(): void;
  58666. private _emitConstant;
  58667. private _emit;
  58668. /** @hidden */
  58669. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58670. /** @hidden */
  58671. _transmit(effect: Effect, scene: Scene): void;
  58672. protected _buildBlock(state: NodeMaterialBuildState): void;
  58673. protected _dumpPropertiesCode(): string;
  58674. dispose(): void;
  58675. serialize(): any;
  58676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58677. }
  58678. }
  58679. declare module BABYLON {
  58680. /**
  58681. * Enum used to define the compatibility state between two connection points
  58682. */
  58683. export enum NodeMaterialConnectionPointCompatibilityStates {
  58684. /** Points are compatibles */
  58685. Compatible = 0,
  58686. /** Points are incompatible because of their types */
  58687. TypeIncompatible = 1,
  58688. /** Points are incompatible because of their targets (vertex vs fragment) */
  58689. TargetIncompatible = 2
  58690. }
  58691. /**
  58692. * Defines the direction of a connection point
  58693. */
  58694. export enum NodeMaterialConnectionPointDirection {
  58695. /** Input */
  58696. Input = 0,
  58697. /** Output */
  58698. Output = 1
  58699. }
  58700. /**
  58701. * Defines a connection point for a block
  58702. */
  58703. export class NodeMaterialConnectionPoint {
  58704. /** @hidden */
  58705. _ownerBlock: NodeMaterialBlock;
  58706. /** @hidden */
  58707. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58708. private _endpoints;
  58709. private _associatedVariableName;
  58710. private _direction;
  58711. /** @hidden */
  58712. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58713. /** @hidden */
  58714. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58715. private _type;
  58716. /** @hidden */
  58717. _enforceAssociatedVariableName: boolean;
  58718. /** Gets the direction of the point */
  58719. get direction(): NodeMaterialConnectionPointDirection;
  58720. /**
  58721. * Gets or sets the additional types supported by this connection point
  58722. */
  58723. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58724. /**
  58725. * Gets or sets the additional types excluded by this connection point
  58726. */
  58727. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58728. /**
  58729. * Observable triggered when this point is connected
  58730. */
  58731. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58732. /**
  58733. * Gets or sets the associated variable name in the shader
  58734. */
  58735. get associatedVariableName(): string;
  58736. set associatedVariableName(value: string);
  58737. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58738. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58739. /**
  58740. * Gets or sets the connection point type (default is float)
  58741. */
  58742. get type(): NodeMaterialBlockConnectionPointTypes;
  58743. set type(value: NodeMaterialBlockConnectionPointTypes);
  58744. /**
  58745. * Gets or sets the connection point name
  58746. */
  58747. name: string;
  58748. /**
  58749. * Gets or sets a boolean indicating that this connection point can be omitted
  58750. */
  58751. isOptional: boolean;
  58752. /**
  58753. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58754. */
  58755. define: string;
  58756. /** @hidden */
  58757. _prioritizeVertex: boolean;
  58758. private _target;
  58759. /** Gets or sets the target of that connection point */
  58760. get target(): NodeMaterialBlockTargets;
  58761. set target(value: NodeMaterialBlockTargets);
  58762. /**
  58763. * Gets a boolean indicating that the current point is connected
  58764. */
  58765. get isConnected(): boolean;
  58766. /**
  58767. * Gets a boolean indicating that the current point is connected to an input block
  58768. */
  58769. get isConnectedToInputBlock(): boolean;
  58770. /**
  58771. * Gets a the connected input block (if any)
  58772. */
  58773. get connectInputBlock(): Nullable<InputBlock>;
  58774. /** Get the other side of the connection (if any) */
  58775. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58776. /** Get the block that owns this connection point */
  58777. get ownerBlock(): NodeMaterialBlock;
  58778. /** Get the block connected on the other side of this connection (if any) */
  58779. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58780. /** Get the block connected on the endpoints of this connection (if any) */
  58781. get connectedBlocks(): Array<NodeMaterialBlock>;
  58782. /** Gets the list of connected endpoints */
  58783. get endpoints(): NodeMaterialConnectionPoint[];
  58784. /** Gets a boolean indicating if that output point is connected to at least one input */
  58785. get hasEndpoints(): boolean;
  58786. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58787. get isConnectedInVertexShader(): boolean;
  58788. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58789. get isConnectedInFragmentShader(): boolean;
  58790. /**
  58791. * Creates a new connection point
  58792. * @param name defines the connection point name
  58793. * @param ownerBlock defines the block hosting this connection point
  58794. * @param direction defines the direction of the connection point
  58795. */
  58796. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58797. /**
  58798. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58799. * @returns the class name
  58800. */
  58801. getClassName(): string;
  58802. /**
  58803. * Gets a boolean indicating if the current point can be connected to another point
  58804. * @param connectionPoint defines the other connection point
  58805. * @returns a boolean
  58806. */
  58807. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58808. /**
  58809. * Gets a number indicating if the current point can be connected to another point
  58810. * @param connectionPoint defines the other connection point
  58811. * @returns a number defining the compatibility state
  58812. */
  58813. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58814. /**
  58815. * Connect this point to another connection point
  58816. * @param connectionPoint defines the other connection point
  58817. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58818. * @returns the current connection point
  58819. */
  58820. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58821. /**
  58822. * Disconnect this point from one of his endpoint
  58823. * @param endpoint defines the other connection point
  58824. * @returns the current connection point
  58825. */
  58826. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58827. /**
  58828. * Serializes this point in a JSON representation
  58829. * @returns the serialized point object
  58830. */
  58831. serialize(): any;
  58832. /**
  58833. * Release resources
  58834. */
  58835. dispose(): void;
  58836. }
  58837. }
  58838. declare module BABYLON {
  58839. /**
  58840. * Block used to add support for vertex skinning (bones)
  58841. */
  58842. export class BonesBlock extends NodeMaterialBlock {
  58843. /**
  58844. * Creates a new BonesBlock
  58845. * @param name defines the block name
  58846. */
  58847. constructor(name: string);
  58848. /**
  58849. * Initialize the block and prepare the context for build
  58850. * @param state defines the state that will be used for the build
  58851. */
  58852. initialize(state: NodeMaterialBuildState): void;
  58853. /**
  58854. * Gets the current class name
  58855. * @returns the class name
  58856. */
  58857. getClassName(): string;
  58858. /**
  58859. * Gets the matrix indices input component
  58860. */
  58861. get matricesIndices(): NodeMaterialConnectionPoint;
  58862. /**
  58863. * Gets the matrix weights input component
  58864. */
  58865. get matricesWeights(): NodeMaterialConnectionPoint;
  58866. /**
  58867. * Gets the extra matrix indices input component
  58868. */
  58869. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58870. /**
  58871. * Gets the extra matrix weights input component
  58872. */
  58873. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58874. /**
  58875. * Gets the world input component
  58876. */
  58877. get world(): NodeMaterialConnectionPoint;
  58878. /**
  58879. * Gets the output component
  58880. */
  58881. get output(): NodeMaterialConnectionPoint;
  58882. autoConfigure(material: NodeMaterial): void;
  58883. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58886. protected _buildBlock(state: NodeMaterialBuildState): this;
  58887. }
  58888. }
  58889. declare module BABYLON {
  58890. /**
  58891. * Block used to add support for instances
  58892. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58893. */
  58894. export class InstancesBlock extends NodeMaterialBlock {
  58895. /**
  58896. * Creates a new InstancesBlock
  58897. * @param name defines the block name
  58898. */
  58899. constructor(name: string);
  58900. /**
  58901. * Gets the current class name
  58902. * @returns the class name
  58903. */
  58904. getClassName(): string;
  58905. /**
  58906. * Gets the first world row input component
  58907. */
  58908. get world0(): NodeMaterialConnectionPoint;
  58909. /**
  58910. * Gets the second world row input component
  58911. */
  58912. get world1(): NodeMaterialConnectionPoint;
  58913. /**
  58914. * Gets the third world row input component
  58915. */
  58916. get world2(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the forth world row input component
  58919. */
  58920. get world3(): NodeMaterialConnectionPoint;
  58921. /**
  58922. * Gets the world input component
  58923. */
  58924. get world(): NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the output component
  58927. */
  58928. get output(): NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the isntanceID component
  58931. */
  58932. get instanceID(): NodeMaterialConnectionPoint;
  58933. autoConfigure(material: NodeMaterial): void;
  58934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58935. protected _buildBlock(state: NodeMaterialBuildState): this;
  58936. }
  58937. }
  58938. declare module BABYLON {
  58939. /**
  58940. * Block used to add morph targets support to vertex shader
  58941. */
  58942. export class MorphTargetsBlock extends NodeMaterialBlock {
  58943. private _repeatableContentAnchor;
  58944. /**
  58945. * Create a new MorphTargetsBlock
  58946. * @param name defines the block name
  58947. */
  58948. constructor(name: string);
  58949. /**
  58950. * Gets the current class name
  58951. * @returns the class name
  58952. */
  58953. getClassName(): string;
  58954. /**
  58955. * Gets the position input component
  58956. */
  58957. get position(): NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the normal input component
  58960. */
  58961. get normal(): NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the tangent input component
  58964. */
  58965. get tangent(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the tangent input component
  58968. */
  58969. get uv(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the position output component
  58972. */
  58973. get positionOutput(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the normal output component
  58976. */
  58977. get normalOutput(): NodeMaterialConnectionPoint;
  58978. /**
  58979. * Gets the tangent output component
  58980. */
  58981. get tangentOutput(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the tangent output component
  58984. */
  58985. get uvOutput(): NodeMaterialConnectionPoint;
  58986. initialize(state: NodeMaterialBuildState): void;
  58987. autoConfigure(material: NodeMaterial): void;
  58988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58990. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58991. protected _buildBlock(state: NodeMaterialBuildState): this;
  58992. }
  58993. }
  58994. declare module BABYLON {
  58995. /**
  58996. * Block used to get data information from a light
  58997. */
  58998. export class LightInformationBlock extends NodeMaterialBlock {
  58999. private _lightDataUniformName;
  59000. private _lightColorUniformName;
  59001. private _lightTypeDefineName;
  59002. /**
  59003. * Gets or sets the light associated with this block
  59004. */
  59005. light: Nullable<Light>;
  59006. /**
  59007. * Creates a new LightInformationBlock
  59008. * @param name defines the block name
  59009. */
  59010. constructor(name: string);
  59011. /**
  59012. * Gets the current class name
  59013. * @returns the class name
  59014. */
  59015. getClassName(): string;
  59016. /**
  59017. * Gets the world position input component
  59018. */
  59019. get worldPosition(): NodeMaterialConnectionPoint;
  59020. /**
  59021. * Gets the direction output component
  59022. */
  59023. get direction(): NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the direction output component
  59026. */
  59027. get color(): NodeMaterialConnectionPoint;
  59028. /**
  59029. * Gets the direction output component
  59030. */
  59031. get intensity(): NodeMaterialConnectionPoint;
  59032. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59034. protected _buildBlock(state: NodeMaterialBuildState): this;
  59035. serialize(): any;
  59036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59037. }
  59038. }
  59039. declare module BABYLON {
  59040. /**
  59041. * Block used to add image processing support to fragment shader
  59042. */
  59043. export class ImageProcessingBlock extends NodeMaterialBlock {
  59044. /**
  59045. * Create a new ImageProcessingBlock
  59046. * @param name defines the block name
  59047. */
  59048. constructor(name: string);
  59049. /**
  59050. * Gets the current class name
  59051. * @returns the class name
  59052. */
  59053. getClassName(): string;
  59054. /**
  59055. * Gets the color input component
  59056. */
  59057. get color(): NodeMaterialConnectionPoint;
  59058. /**
  59059. * Gets the output component
  59060. */
  59061. get output(): NodeMaterialConnectionPoint;
  59062. /**
  59063. * Initialize the block and prepare the context for build
  59064. * @param state defines the state that will be used for the build
  59065. */
  59066. initialize(state: NodeMaterialBuildState): void;
  59067. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59069. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59070. protected _buildBlock(state: NodeMaterialBuildState): this;
  59071. }
  59072. }
  59073. declare module BABYLON {
  59074. /**
  59075. * Block used to pertub normals based on a normal map
  59076. */
  59077. export class PerturbNormalBlock extends NodeMaterialBlock {
  59078. private _tangentSpaceParameterName;
  59079. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59080. invertX: boolean;
  59081. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59082. invertY: boolean;
  59083. /**
  59084. * Create a new PerturbNormalBlock
  59085. * @param name defines the block name
  59086. */
  59087. constructor(name: string);
  59088. /**
  59089. * Gets the current class name
  59090. * @returns the class name
  59091. */
  59092. getClassName(): string;
  59093. /**
  59094. * Gets the world position input component
  59095. */
  59096. get worldPosition(): NodeMaterialConnectionPoint;
  59097. /**
  59098. * Gets the world normal input component
  59099. */
  59100. get worldNormal(): NodeMaterialConnectionPoint;
  59101. /**
  59102. * Gets the world tangent input component
  59103. */
  59104. get worldTangent(): NodeMaterialConnectionPoint;
  59105. /**
  59106. * Gets the uv input component
  59107. */
  59108. get uv(): NodeMaterialConnectionPoint;
  59109. /**
  59110. * Gets the normal map color input component
  59111. */
  59112. get normalMapColor(): NodeMaterialConnectionPoint;
  59113. /**
  59114. * Gets the strength input component
  59115. */
  59116. get strength(): NodeMaterialConnectionPoint;
  59117. /**
  59118. * Gets the output component
  59119. */
  59120. get output(): NodeMaterialConnectionPoint;
  59121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59122. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59123. autoConfigure(material: NodeMaterial): void;
  59124. protected _buildBlock(state: NodeMaterialBuildState): this;
  59125. protected _dumpPropertiesCode(): string;
  59126. serialize(): any;
  59127. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. /**
  59132. * Block used to discard a pixel if a value is smaller than a cutoff
  59133. */
  59134. export class DiscardBlock extends NodeMaterialBlock {
  59135. /**
  59136. * Create a new DiscardBlock
  59137. * @param name defines the block name
  59138. */
  59139. constructor(name: string);
  59140. /**
  59141. * Gets the current class name
  59142. * @returns the class name
  59143. */
  59144. getClassName(): string;
  59145. /**
  59146. * Gets the color input component
  59147. */
  59148. get value(): NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the cutoff input component
  59151. */
  59152. get cutoff(): NodeMaterialConnectionPoint;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. }
  59155. }
  59156. declare module BABYLON {
  59157. /**
  59158. * Block used to test if the fragment shader is front facing
  59159. */
  59160. export class FrontFacingBlock extends NodeMaterialBlock {
  59161. /**
  59162. * Creates a new FrontFacingBlock
  59163. * @param name defines the block name
  59164. */
  59165. constructor(name: string);
  59166. /**
  59167. * Gets the current class name
  59168. * @returns the class name
  59169. */
  59170. getClassName(): string;
  59171. /**
  59172. * Gets the output component
  59173. */
  59174. get output(): NodeMaterialConnectionPoint;
  59175. protected _buildBlock(state: NodeMaterialBuildState): this;
  59176. }
  59177. }
  59178. declare module BABYLON {
  59179. /**
  59180. * Block used to get the derivative value on x and y of a given input
  59181. */
  59182. export class DerivativeBlock extends NodeMaterialBlock {
  59183. /**
  59184. * Create a new DerivativeBlock
  59185. * @param name defines the block name
  59186. */
  59187. constructor(name: string);
  59188. /**
  59189. * Gets the current class name
  59190. * @returns the class name
  59191. */
  59192. getClassName(): string;
  59193. /**
  59194. * Gets the input component
  59195. */
  59196. get input(): NodeMaterialConnectionPoint;
  59197. /**
  59198. * Gets the derivative output on x
  59199. */
  59200. get dx(): NodeMaterialConnectionPoint;
  59201. /**
  59202. * Gets the derivative output on y
  59203. */
  59204. get dy(): NodeMaterialConnectionPoint;
  59205. protected _buildBlock(state: NodeMaterialBuildState): this;
  59206. }
  59207. }
  59208. declare module BABYLON {
  59209. /**
  59210. * Block used to add support for scene fog
  59211. */
  59212. export class FogBlock extends NodeMaterialBlock {
  59213. private _fogDistanceName;
  59214. private _fogParameters;
  59215. /**
  59216. * Create a new FogBlock
  59217. * @param name defines the block name
  59218. */
  59219. constructor(name: string);
  59220. /**
  59221. * Gets the current class name
  59222. * @returns the class name
  59223. */
  59224. getClassName(): string;
  59225. /**
  59226. * Gets the world position input component
  59227. */
  59228. get worldPosition(): NodeMaterialConnectionPoint;
  59229. /**
  59230. * Gets the view input component
  59231. */
  59232. get view(): NodeMaterialConnectionPoint;
  59233. /**
  59234. * Gets the color input component
  59235. */
  59236. get input(): NodeMaterialConnectionPoint;
  59237. /**
  59238. * Gets the fog color input component
  59239. */
  59240. get fogColor(): NodeMaterialConnectionPoint;
  59241. /**
  59242. * Gets the output component
  59243. */
  59244. get output(): NodeMaterialConnectionPoint;
  59245. autoConfigure(material: NodeMaterial): void;
  59246. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59247. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59248. protected _buildBlock(state: NodeMaterialBuildState): this;
  59249. }
  59250. }
  59251. declare module BABYLON {
  59252. /**
  59253. * Block used to add light in the fragment shader
  59254. */
  59255. export class LightBlock extends NodeMaterialBlock {
  59256. private _lightId;
  59257. /**
  59258. * Gets or sets the light associated with this block
  59259. */
  59260. light: Nullable<Light>;
  59261. /**
  59262. * Create a new LightBlock
  59263. * @param name defines the block name
  59264. */
  59265. constructor(name: string);
  59266. /**
  59267. * Gets the current class name
  59268. * @returns the class name
  59269. */
  59270. getClassName(): string;
  59271. /**
  59272. * Gets the world position input component
  59273. */
  59274. get worldPosition(): NodeMaterialConnectionPoint;
  59275. /**
  59276. * Gets the world normal input component
  59277. */
  59278. get worldNormal(): NodeMaterialConnectionPoint;
  59279. /**
  59280. * Gets the camera (or eye) position component
  59281. */
  59282. get cameraPosition(): NodeMaterialConnectionPoint;
  59283. /**
  59284. * Gets the glossiness component
  59285. */
  59286. get glossiness(): NodeMaterialConnectionPoint;
  59287. /**
  59288. * Gets the glossinness power component
  59289. */
  59290. get glossPower(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the diffuse color component
  59293. */
  59294. get diffuseColor(): NodeMaterialConnectionPoint;
  59295. /**
  59296. * Gets the specular color component
  59297. */
  59298. get specularColor(): NodeMaterialConnectionPoint;
  59299. /**
  59300. * Gets the diffuse output component
  59301. */
  59302. get diffuseOutput(): NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the specular output component
  59305. */
  59306. get specularOutput(): NodeMaterialConnectionPoint;
  59307. /**
  59308. * Gets the shadow output component
  59309. */
  59310. get shadow(): NodeMaterialConnectionPoint;
  59311. autoConfigure(material: NodeMaterial): void;
  59312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59313. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59315. private _injectVertexCode;
  59316. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59317. serialize(): any;
  59318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59319. }
  59320. }
  59321. declare module BABYLON {
  59322. /**
  59323. * Block used to multiply 2 values
  59324. */
  59325. export class MultiplyBlock extends NodeMaterialBlock {
  59326. /**
  59327. * Creates a new MultiplyBlock
  59328. * @param name defines the block name
  59329. */
  59330. constructor(name: string);
  59331. /**
  59332. * Gets the current class name
  59333. * @returns the class name
  59334. */
  59335. getClassName(): string;
  59336. /**
  59337. * Gets the left operand input component
  59338. */
  59339. get left(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the right operand input component
  59342. */
  59343. get right(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the output component
  59346. */
  59347. get output(): NodeMaterialConnectionPoint;
  59348. protected _buildBlock(state: NodeMaterialBuildState): this;
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. /**
  59353. * Block used to add 2 vectors
  59354. */
  59355. export class AddBlock extends NodeMaterialBlock {
  59356. /**
  59357. * Creates a new AddBlock
  59358. * @param name defines the block name
  59359. */
  59360. constructor(name: string);
  59361. /**
  59362. * Gets the current class name
  59363. * @returns the class name
  59364. */
  59365. getClassName(): string;
  59366. /**
  59367. * Gets the left operand input component
  59368. */
  59369. get left(): NodeMaterialConnectionPoint;
  59370. /**
  59371. * Gets the right operand input component
  59372. */
  59373. get right(): NodeMaterialConnectionPoint;
  59374. /**
  59375. * Gets the output component
  59376. */
  59377. get output(): NodeMaterialConnectionPoint;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /**
  59383. * Block used to scale a vector by a float
  59384. */
  59385. export class ScaleBlock extends NodeMaterialBlock {
  59386. /**
  59387. * Creates a new ScaleBlock
  59388. * @param name defines the block name
  59389. */
  59390. constructor(name: string);
  59391. /**
  59392. * Gets the current class name
  59393. * @returns the class name
  59394. */
  59395. getClassName(): string;
  59396. /**
  59397. * Gets the input component
  59398. */
  59399. get input(): NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the factor input component
  59402. */
  59403. get factor(): NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the output component
  59406. */
  59407. get output(): NodeMaterialConnectionPoint;
  59408. protected _buildBlock(state: NodeMaterialBuildState): this;
  59409. }
  59410. }
  59411. declare module BABYLON {
  59412. /**
  59413. * Block used to clamp a float
  59414. */
  59415. export class ClampBlock extends NodeMaterialBlock {
  59416. /** Gets or sets the minimum range */
  59417. minimum: number;
  59418. /** Gets or sets the maximum range */
  59419. maximum: number;
  59420. /**
  59421. * Creates a new ClampBlock
  59422. * @param name defines the block name
  59423. */
  59424. constructor(name: string);
  59425. /**
  59426. * Gets the current class name
  59427. * @returns the class name
  59428. */
  59429. getClassName(): string;
  59430. /**
  59431. * Gets the value input component
  59432. */
  59433. get value(): NodeMaterialConnectionPoint;
  59434. /**
  59435. * Gets the output component
  59436. */
  59437. get output(): NodeMaterialConnectionPoint;
  59438. protected _buildBlock(state: NodeMaterialBuildState): this;
  59439. protected _dumpPropertiesCode(): string;
  59440. serialize(): any;
  59441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59442. }
  59443. }
  59444. declare module BABYLON {
  59445. /**
  59446. * Block used to apply a cross product between 2 vectors
  59447. */
  59448. export class CrossBlock extends NodeMaterialBlock {
  59449. /**
  59450. * Creates a new CrossBlock
  59451. * @param name defines the block name
  59452. */
  59453. constructor(name: string);
  59454. /**
  59455. * Gets the current class name
  59456. * @returns the class name
  59457. */
  59458. getClassName(): string;
  59459. /**
  59460. * Gets the left operand input component
  59461. */
  59462. get left(): NodeMaterialConnectionPoint;
  59463. /**
  59464. * Gets the right operand input component
  59465. */
  59466. get right(): NodeMaterialConnectionPoint;
  59467. /**
  59468. * Gets the output component
  59469. */
  59470. get output(): NodeMaterialConnectionPoint;
  59471. protected _buildBlock(state: NodeMaterialBuildState): this;
  59472. }
  59473. }
  59474. declare module BABYLON {
  59475. /**
  59476. * Block used to apply a dot product between 2 vectors
  59477. */
  59478. export class DotBlock extends NodeMaterialBlock {
  59479. /**
  59480. * Creates a new DotBlock
  59481. * @param name defines the block name
  59482. */
  59483. constructor(name: string);
  59484. /**
  59485. * Gets the current class name
  59486. * @returns the class name
  59487. */
  59488. getClassName(): string;
  59489. /**
  59490. * Gets the left operand input component
  59491. */
  59492. get left(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the right operand input component
  59495. */
  59496. get right(): NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the output component
  59499. */
  59500. get output(): NodeMaterialConnectionPoint;
  59501. protected _buildBlock(state: NodeMaterialBuildState): this;
  59502. }
  59503. }
  59504. declare module BABYLON {
  59505. /**
  59506. * Block used to remap a float from a range to a new one
  59507. */
  59508. export class RemapBlock extends NodeMaterialBlock {
  59509. /**
  59510. * Gets or sets the source range
  59511. */
  59512. sourceRange: Vector2;
  59513. /**
  59514. * Gets or sets the target range
  59515. */
  59516. targetRange: Vector2;
  59517. /**
  59518. * Creates a new RemapBlock
  59519. * @param name defines the block name
  59520. */
  59521. constructor(name: string);
  59522. /**
  59523. * Gets the current class name
  59524. * @returns the class name
  59525. */
  59526. getClassName(): string;
  59527. /**
  59528. * Gets the input component
  59529. */
  59530. get input(): NodeMaterialConnectionPoint;
  59531. /**
  59532. * Gets the source min input component
  59533. */
  59534. get sourceMin(): NodeMaterialConnectionPoint;
  59535. /**
  59536. * Gets the source max input component
  59537. */
  59538. get sourceMax(): NodeMaterialConnectionPoint;
  59539. /**
  59540. * Gets the target min input component
  59541. */
  59542. get targetMin(): NodeMaterialConnectionPoint;
  59543. /**
  59544. * Gets the target max input component
  59545. */
  59546. get targetMax(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Gets the output component
  59549. */
  59550. get output(): NodeMaterialConnectionPoint;
  59551. protected _buildBlock(state: NodeMaterialBuildState): this;
  59552. protected _dumpPropertiesCode(): string;
  59553. serialize(): any;
  59554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59555. }
  59556. }
  59557. declare module BABYLON {
  59558. /**
  59559. * Block used to normalize a vector
  59560. */
  59561. export class NormalizeBlock extends NodeMaterialBlock {
  59562. /**
  59563. * Creates a new NormalizeBlock
  59564. * @param name defines the block name
  59565. */
  59566. constructor(name: string);
  59567. /**
  59568. * Gets the current class name
  59569. * @returns the class name
  59570. */
  59571. getClassName(): string;
  59572. /**
  59573. * Gets the input component
  59574. */
  59575. get input(): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Gets the output component
  59578. */
  59579. get output(): NodeMaterialConnectionPoint;
  59580. protected _buildBlock(state: NodeMaterialBuildState): this;
  59581. }
  59582. }
  59583. declare module BABYLON {
  59584. /**
  59585. * Operations supported by the Trigonometry block
  59586. */
  59587. export enum TrigonometryBlockOperations {
  59588. /** Cos */
  59589. Cos = 0,
  59590. /** Sin */
  59591. Sin = 1,
  59592. /** Abs */
  59593. Abs = 2,
  59594. /** Exp */
  59595. Exp = 3,
  59596. /** Exp2 */
  59597. Exp2 = 4,
  59598. /** Round */
  59599. Round = 5,
  59600. /** Floor */
  59601. Floor = 6,
  59602. /** Ceiling */
  59603. Ceiling = 7,
  59604. /** Square root */
  59605. Sqrt = 8,
  59606. /** Log */
  59607. Log = 9,
  59608. /** Tangent */
  59609. Tan = 10,
  59610. /** Arc tangent */
  59611. ArcTan = 11,
  59612. /** Arc cosinus */
  59613. ArcCos = 12,
  59614. /** Arc sinus */
  59615. ArcSin = 13,
  59616. /** Fraction */
  59617. Fract = 14,
  59618. /** Sign */
  59619. Sign = 15,
  59620. /** To radians (from degrees) */
  59621. Radians = 16,
  59622. /** To degrees (from radians) */
  59623. Degrees = 17
  59624. }
  59625. /**
  59626. * Block used to apply trigonometry operation to floats
  59627. */
  59628. export class TrigonometryBlock extends NodeMaterialBlock {
  59629. /**
  59630. * Gets or sets the operation applied by the block
  59631. */
  59632. operation: TrigonometryBlockOperations;
  59633. /**
  59634. * Creates a new TrigonometryBlock
  59635. * @param name defines the block name
  59636. */
  59637. constructor(name: string);
  59638. /**
  59639. * Gets the current class name
  59640. * @returns the class name
  59641. */
  59642. getClassName(): string;
  59643. /**
  59644. * Gets the input component
  59645. */
  59646. get input(): NodeMaterialConnectionPoint;
  59647. /**
  59648. * Gets the output component
  59649. */
  59650. get output(): NodeMaterialConnectionPoint;
  59651. protected _buildBlock(state: NodeMaterialBuildState): this;
  59652. serialize(): any;
  59653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59654. protected _dumpPropertiesCode(): string;
  59655. }
  59656. }
  59657. declare module BABYLON {
  59658. /**
  59659. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59660. */
  59661. export class ColorMergerBlock extends NodeMaterialBlock {
  59662. /**
  59663. * Create a new ColorMergerBlock
  59664. * @param name defines the block name
  59665. */
  59666. constructor(name: string);
  59667. /**
  59668. * Gets the current class name
  59669. * @returns the class name
  59670. */
  59671. getClassName(): string;
  59672. /**
  59673. * Gets the rgb component (input)
  59674. */
  59675. get rgbIn(): NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the r component (input)
  59678. */
  59679. get r(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the g component (input)
  59682. */
  59683. get g(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the b component (input)
  59686. */
  59687. get b(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the a component (input)
  59690. */
  59691. get a(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the rgba component (output)
  59694. */
  59695. get rgba(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the rgb component (output)
  59698. */
  59699. get rgbOut(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the rgb component (output)
  59702. * @deprecated Please use rgbOut instead.
  59703. */
  59704. get rgb(): NodeMaterialConnectionPoint;
  59705. protected _buildBlock(state: NodeMaterialBuildState): this;
  59706. }
  59707. }
  59708. declare module BABYLON {
  59709. /**
  59710. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59711. */
  59712. export class VectorMergerBlock extends NodeMaterialBlock {
  59713. /**
  59714. * Create a new VectorMergerBlock
  59715. * @param name defines the block name
  59716. */
  59717. constructor(name: string);
  59718. /**
  59719. * Gets the current class name
  59720. * @returns the class name
  59721. */
  59722. getClassName(): string;
  59723. /**
  59724. * Gets the xyz component (input)
  59725. */
  59726. get xyzIn(): NodeMaterialConnectionPoint;
  59727. /**
  59728. * Gets the xy component (input)
  59729. */
  59730. get xyIn(): NodeMaterialConnectionPoint;
  59731. /**
  59732. * Gets the x component (input)
  59733. */
  59734. get x(): NodeMaterialConnectionPoint;
  59735. /**
  59736. * Gets the y component (input)
  59737. */
  59738. get y(): NodeMaterialConnectionPoint;
  59739. /**
  59740. * Gets the z component (input)
  59741. */
  59742. get z(): NodeMaterialConnectionPoint;
  59743. /**
  59744. * Gets the w component (input)
  59745. */
  59746. get w(): NodeMaterialConnectionPoint;
  59747. /**
  59748. * Gets the xyzw component (output)
  59749. */
  59750. get xyzw(): NodeMaterialConnectionPoint;
  59751. /**
  59752. * Gets the xyz component (output)
  59753. */
  59754. get xyzOut(): NodeMaterialConnectionPoint;
  59755. /**
  59756. * Gets the xy component (output)
  59757. */
  59758. get xyOut(): NodeMaterialConnectionPoint;
  59759. /**
  59760. * Gets the xy component (output)
  59761. * @deprecated Please use xyOut instead.
  59762. */
  59763. get xy(): NodeMaterialConnectionPoint;
  59764. /**
  59765. * Gets the xyz component (output)
  59766. * @deprecated Please use xyzOut instead.
  59767. */
  59768. get xyz(): NodeMaterialConnectionPoint;
  59769. protected _buildBlock(state: NodeMaterialBuildState): this;
  59770. }
  59771. }
  59772. declare module BABYLON {
  59773. /**
  59774. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59775. */
  59776. export class ColorSplitterBlock extends NodeMaterialBlock {
  59777. /**
  59778. * Create a new ColorSplitterBlock
  59779. * @param name defines the block name
  59780. */
  59781. constructor(name: string);
  59782. /**
  59783. * Gets the current class name
  59784. * @returns the class name
  59785. */
  59786. getClassName(): string;
  59787. /**
  59788. * Gets the rgba component (input)
  59789. */
  59790. get rgba(): NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the rgb component (input)
  59793. */
  59794. get rgbIn(): NodeMaterialConnectionPoint;
  59795. /**
  59796. * Gets the rgb component (output)
  59797. */
  59798. get rgbOut(): NodeMaterialConnectionPoint;
  59799. /**
  59800. * Gets the r component (output)
  59801. */
  59802. get r(): NodeMaterialConnectionPoint;
  59803. /**
  59804. * Gets the g component (output)
  59805. */
  59806. get g(): NodeMaterialConnectionPoint;
  59807. /**
  59808. * Gets the b component (output)
  59809. */
  59810. get b(): NodeMaterialConnectionPoint;
  59811. /**
  59812. * Gets the a component (output)
  59813. */
  59814. get a(): NodeMaterialConnectionPoint;
  59815. protected _inputRename(name: string): string;
  59816. protected _outputRename(name: string): string;
  59817. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59818. }
  59819. }
  59820. declare module BABYLON {
  59821. /**
  59822. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59823. */
  59824. export class VectorSplitterBlock extends NodeMaterialBlock {
  59825. /**
  59826. * Create a new VectorSplitterBlock
  59827. * @param name defines the block name
  59828. */
  59829. constructor(name: string);
  59830. /**
  59831. * Gets the current class name
  59832. * @returns the class name
  59833. */
  59834. getClassName(): string;
  59835. /**
  59836. * Gets the xyzw component (input)
  59837. */
  59838. get xyzw(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the xyz component (input)
  59841. */
  59842. get xyzIn(): NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the xy component (input)
  59845. */
  59846. get xyIn(): NodeMaterialConnectionPoint;
  59847. /**
  59848. * Gets the xyz component (output)
  59849. */
  59850. get xyzOut(): NodeMaterialConnectionPoint;
  59851. /**
  59852. * Gets the xy component (output)
  59853. */
  59854. get xyOut(): NodeMaterialConnectionPoint;
  59855. /**
  59856. * Gets the x component (output)
  59857. */
  59858. get x(): NodeMaterialConnectionPoint;
  59859. /**
  59860. * Gets the y component (output)
  59861. */
  59862. get y(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the z component (output)
  59865. */
  59866. get z(): NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the w component (output)
  59869. */
  59870. get w(): NodeMaterialConnectionPoint;
  59871. protected _inputRename(name: string): string;
  59872. protected _outputRename(name: string): string;
  59873. protected _buildBlock(state: NodeMaterialBuildState): this;
  59874. }
  59875. }
  59876. declare module BABYLON {
  59877. /**
  59878. * Block used to lerp between 2 values
  59879. */
  59880. export class LerpBlock extends NodeMaterialBlock {
  59881. /**
  59882. * Creates a new LerpBlock
  59883. * @param name defines the block name
  59884. */
  59885. constructor(name: string);
  59886. /**
  59887. * Gets the current class name
  59888. * @returns the class name
  59889. */
  59890. getClassName(): string;
  59891. /**
  59892. * Gets the left operand input component
  59893. */
  59894. get left(): NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the right operand input component
  59897. */
  59898. get right(): NodeMaterialConnectionPoint;
  59899. /**
  59900. * Gets the gradient operand input component
  59901. */
  59902. get gradient(): NodeMaterialConnectionPoint;
  59903. /**
  59904. * Gets the output component
  59905. */
  59906. get output(): NodeMaterialConnectionPoint;
  59907. protected _buildBlock(state: NodeMaterialBuildState): this;
  59908. }
  59909. }
  59910. declare module BABYLON {
  59911. /**
  59912. * Block used to divide 2 vectors
  59913. */
  59914. export class DivideBlock extends NodeMaterialBlock {
  59915. /**
  59916. * Creates a new DivideBlock
  59917. * @param name defines the block name
  59918. */
  59919. constructor(name: string);
  59920. /**
  59921. * Gets the current class name
  59922. * @returns the class name
  59923. */
  59924. getClassName(): string;
  59925. /**
  59926. * Gets the left operand input component
  59927. */
  59928. get left(): NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the right operand input component
  59931. */
  59932. get right(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the output component
  59935. */
  59936. get output(): NodeMaterialConnectionPoint;
  59937. protected _buildBlock(state: NodeMaterialBuildState): this;
  59938. }
  59939. }
  59940. declare module BABYLON {
  59941. /**
  59942. * Block used to subtract 2 vectors
  59943. */
  59944. export class SubtractBlock extends NodeMaterialBlock {
  59945. /**
  59946. * Creates a new SubtractBlock
  59947. * @param name defines the block name
  59948. */
  59949. constructor(name: string);
  59950. /**
  59951. * Gets the current class name
  59952. * @returns the class name
  59953. */
  59954. getClassName(): string;
  59955. /**
  59956. * Gets the left operand input component
  59957. */
  59958. get left(): NodeMaterialConnectionPoint;
  59959. /**
  59960. * Gets the right operand input component
  59961. */
  59962. get right(): NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the output component
  59965. */
  59966. get output(): NodeMaterialConnectionPoint;
  59967. protected _buildBlock(state: NodeMaterialBuildState): this;
  59968. }
  59969. }
  59970. declare module BABYLON {
  59971. /**
  59972. * Block used to step a value
  59973. */
  59974. export class StepBlock extends NodeMaterialBlock {
  59975. /**
  59976. * Creates a new StepBlock
  59977. * @param name defines the block name
  59978. */
  59979. constructor(name: string);
  59980. /**
  59981. * Gets the current class name
  59982. * @returns the class name
  59983. */
  59984. getClassName(): string;
  59985. /**
  59986. * Gets the value operand input component
  59987. */
  59988. get value(): NodeMaterialConnectionPoint;
  59989. /**
  59990. * Gets the edge operand input component
  59991. */
  59992. get edge(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the output component
  59995. */
  59996. get output(): NodeMaterialConnectionPoint;
  59997. protected _buildBlock(state: NodeMaterialBuildState): this;
  59998. }
  59999. }
  60000. declare module BABYLON {
  60001. /**
  60002. * Block used to get the opposite (1 - x) of a value
  60003. */
  60004. export class OneMinusBlock extends NodeMaterialBlock {
  60005. /**
  60006. * Creates a new OneMinusBlock
  60007. * @param name defines the block name
  60008. */
  60009. constructor(name: string);
  60010. /**
  60011. * Gets the current class name
  60012. * @returns the class name
  60013. */
  60014. getClassName(): string;
  60015. /**
  60016. * Gets the input component
  60017. */
  60018. get input(): NodeMaterialConnectionPoint;
  60019. /**
  60020. * Gets the output component
  60021. */
  60022. get output(): NodeMaterialConnectionPoint;
  60023. protected _buildBlock(state: NodeMaterialBuildState): this;
  60024. }
  60025. }
  60026. declare module BABYLON {
  60027. /**
  60028. * Block used to get the view direction
  60029. */
  60030. export class ViewDirectionBlock extends NodeMaterialBlock {
  60031. /**
  60032. * Creates a new ViewDirectionBlock
  60033. * @param name defines the block name
  60034. */
  60035. constructor(name: string);
  60036. /**
  60037. * Gets the current class name
  60038. * @returns the class name
  60039. */
  60040. getClassName(): string;
  60041. /**
  60042. * Gets the world position component
  60043. */
  60044. get worldPosition(): NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the camera position component
  60047. */
  60048. get cameraPosition(): NodeMaterialConnectionPoint;
  60049. /**
  60050. * Gets the output component
  60051. */
  60052. get output(): NodeMaterialConnectionPoint;
  60053. autoConfigure(material: NodeMaterial): void;
  60054. protected _buildBlock(state: NodeMaterialBuildState): this;
  60055. }
  60056. }
  60057. declare module BABYLON {
  60058. /**
  60059. * Block used to compute fresnel value
  60060. */
  60061. export class FresnelBlock extends NodeMaterialBlock {
  60062. /**
  60063. * Create a new FresnelBlock
  60064. * @param name defines the block name
  60065. */
  60066. constructor(name: string);
  60067. /**
  60068. * Gets the current class name
  60069. * @returns the class name
  60070. */
  60071. getClassName(): string;
  60072. /**
  60073. * Gets the world normal input component
  60074. */
  60075. get worldNormal(): NodeMaterialConnectionPoint;
  60076. /**
  60077. * Gets the view direction input component
  60078. */
  60079. get viewDirection(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the bias input component
  60082. */
  60083. get bias(): NodeMaterialConnectionPoint;
  60084. /**
  60085. * Gets the camera (or eye) position component
  60086. */
  60087. get power(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the fresnel output component
  60090. */
  60091. get fresnel(): NodeMaterialConnectionPoint;
  60092. autoConfigure(material: NodeMaterial): void;
  60093. protected _buildBlock(state: NodeMaterialBuildState): this;
  60094. }
  60095. }
  60096. declare module BABYLON {
  60097. /**
  60098. * Block used to get the max of 2 values
  60099. */
  60100. export class MaxBlock extends NodeMaterialBlock {
  60101. /**
  60102. * Creates a new MaxBlock
  60103. * @param name defines the block name
  60104. */
  60105. constructor(name: string);
  60106. /**
  60107. * Gets the current class name
  60108. * @returns the class name
  60109. */
  60110. getClassName(): string;
  60111. /**
  60112. * Gets the left operand input component
  60113. */
  60114. get left(): NodeMaterialConnectionPoint;
  60115. /**
  60116. * Gets the right operand input component
  60117. */
  60118. get right(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the output component
  60121. */
  60122. get output(): NodeMaterialConnectionPoint;
  60123. protected _buildBlock(state: NodeMaterialBuildState): this;
  60124. }
  60125. }
  60126. declare module BABYLON {
  60127. /**
  60128. * Block used to get the min of 2 values
  60129. */
  60130. export class MinBlock extends NodeMaterialBlock {
  60131. /**
  60132. * Creates a new MinBlock
  60133. * @param name defines the block name
  60134. */
  60135. constructor(name: string);
  60136. /**
  60137. * Gets the current class name
  60138. * @returns the class name
  60139. */
  60140. getClassName(): string;
  60141. /**
  60142. * Gets the left operand input component
  60143. */
  60144. get left(): NodeMaterialConnectionPoint;
  60145. /**
  60146. * Gets the right operand input component
  60147. */
  60148. get right(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the output component
  60151. */
  60152. get output(): NodeMaterialConnectionPoint;
  60153. protected _buildBlock(state: NodeMaterialBuildState): this;
  60154. }
  60155. }
  60156. declare module BABYLON {
  60157. /**
  60158. * Block used to get the distance between 2 values
  60159. */
  60160. export class DistanceBlock extends NodeMaterialBlock {
  60161. /**
  60162. * Creates a new DistanceBlock
  60163. * @param name defines the block name
  60164. */
  60165. constructor(name: string);
  60166. /**
  60167. * Gets the current class name
  60168. * @returns the class name
  60169. */
  60170. getClassName(): string;
  60171. /**
  60172. * Gets the left operand input component
  60173. */
  60174. get left(): NodeMaterialConnectionPoint;
  60175. /**
  60176. * Gets the right operand input component
  60177. */
  60178. get right(): NodeMaterialConnectionPoint;
  60179. /**
  60180. * Gets the output component
  60181. */
  60182. get output(): NodeMaterialConnectionPoint;
  60183. protected _buildBlock(state: NodeMaterialBuildState): this;
  60184. }
  60185. }
  60186. declare module BABYLON {
  60187. /**
  60188. * Block used to get the length of a vector
  60189. */
  60190. export class LengthBlock extends NodeMaterialBlock {
  60191. /**
  60192. * Creates a new LengthBlock
  60193. * @param name defines the block name
  60194. */
  60195. constructor(name: string);
  60196. /**
  60197. * Gets the current class name
  60198. * @returns the class name
  60199. */
  60200. getClassName(): string;
  60201. /**
  60202. * Gets the value input component
  60203. */
  60204. get value(): NodeMaterialConnectionPoint;
  60205. /**
  60206. * Gets the output component
  60207. */
  60208. get output(): NodeMaterialConnectionPoint;
  60209. protected _buildBlock(state: NodeMaterialBuildState): this;
  60210. }
  60211. }
  60212. declare module BABYLON {
  60213. /**
  60214. * Block used to get negative version of a value (i.e. x * -1)
  60215. */
  60216. export class NegateBlock extends NodeMaterialBlock {
  60217. /**
  60218. * Creates a new NegateBlock
  60219. * @param name defines the block name
  60220. */
  60221. constructor(name: string);
  60222. /**
  60223. * Gets the current class name
  60224. * @returns the class name
  60225. */
  60226. getClassName(): string;
  60227. /**
  60228. * Gets the value input component
  60229. */
  60230. get value(): NodeMaterialConnectionPoint;
  60231. /**
  60232. * Gets the output component
  60233. */
  60234. get output(): NodeMaterialConnectionPoint;
  60235. protected _buildBlock(state: NodeMaterialBuildState): this;
  60236. }
  60237. }
  60238. declare module BABYLON {
  60239. /**
  60240. * Block used to get the value of the first parameter raised to the power of the second
  60241. */
  60242. export class PowBlock extends NodeMaterialBlock {
  60243. /**
  60244. * Creates a new PowBlock
  60245. * @param name defines the block name
  60246. */
  60247. constructor(name: string);
  60248. /**
  60249. * Gets the current class name
  60250. * @returns the class name
  60251. */
  60252. getClassName(): string;
  60253. /**
  60254. * Gets the value operand input component
  60255. */
  60256. get value(): NodeMaterialConnectionPoint;
  60257. /**
  60258. * Gets the power operand input component
  60259. */
  60260. get power(): NodeMaterialConnectionPoint;
  60261. /**
  60262. * Gets the output component
  60263. */
  60264. get output(): NodeMaterialConnectionPoint;
  60265. protected _buildBlock(state: NodeMaterialBuildState): this;
  60266. }
  60267. }
  60268. declare module BABYLON {
  60269. /**
  60270. * Block used to get a random number
  60271. */
  60272. export class RandomNumberBlock extends NodeMaterialBlock {
  60273. /**
  60274. * Creates a new RandomNumberBlock
  60275. * @param name defines the block name
  60276. */
  60277. constructor(name: string);
  60278. /**
  60279. * Gets the current class name
  60280. * @returns the class name
  60281. */
  60282. getClassName(): string;
  60283. /**
  60284. * Gets the seed input component
  60285. */
  60286. get seed(): NodeMaterialConnectionPoint;
  60287. /**
  60288. * Gets the output component
  60289. */
  60290. get output(): NodeMaterialConnectionPoint;
  60291. protected _buildBlock(state: NodeMaterialBuildState): this;
  60292. }
  60293. }
  60294. declare module BABYLON {
  60295. /**
  60296. * Block used to compute arc tangent of 2 values
  60297. */
  60298. export class ArcTan2Block extends NodeMaterialBlock {
  60299. /**
  60300. * Creates a new ArcTan2Block
  60301. * @param name defines the block name
  60302. */
  60303. constructor(name: string);
  60304. /**
  60305. * Gets the current class name
  60306. * @returns the class name
  60307. */
  60308. getClassName(): string;
  60309. /**
  60310. * Gets the x operand input component
  60311. */
  60312. get x(): NodeMaterialConnectionPoint;
  60313. /**
  60314. * Gets the y operand input component
  60315. */
  60316. get y(): NodeMaterialConnectionPoint;
  60317. /**
  60318. * Gets the output component
  60319. */
  60320. get output(): NodeMaterialConnectionPoint;
  60321. protected _buildBlock(state: NodeMaterialBuildState): this;
  60322. }
  60323. }
  60324. declare module BABYLON {
  60325. /**
  60326. * Block used to smooth step a value
  60327. */
  60328. export class SmoothStepBlock extends NodeMaterialBlock {
  60329. /**
  60330. * Creates a new SmoothStepBlock
  60331. * @param name defines the block name
  60332. */
  60333. constructor(name: string);
  60334. /**
  60335. * Gets the current class name
  60336. * @returns the class name
  60337. */
  60338. getClassName(): string;
  60339. /**
  60340. * Gets the value operand input component
  60341. */
  60342. get value(): NodeMaterialConnectionPoint;
  60343. /**
  60344. * Gets the first edge operand input component
  60345. */
  60346. get edge0(): NodeMaterialConnectionPoint;
  60347. /**
  60348. * Gets the second edge operand input component
  60349. */
  60350. get edge1(): NodeMaterialConnectionPoint;
  60351. /**
  60352. * Gets the output component
  60353. */
  60354. get output(): NodeMaterialConnectionPoint;
  60355. protected _buildBlock(state: NodeMaterialBuildState): this;
  60356. }
  60357. }
  60358. declare module BABYLON {
  60359. /**
  60360. * Block used to get the reciprocal (1 / x) of a value
  60361. */
  60362. export class ReciprocalBlock extends NodeMaterialBlock {
  60363. /**
  60364. * Creates a new ReciprocalBlock
  60365. * @param name defines the block name
  60366. */
  60367. constructor(name: string);
  60368. /**
  60369. * Gets the current class name
  60370. * @returns the class name
  60371. */
  60372. getClassName(): string;
  60373. /**
  60374. * Gets the input component
  60375. */
  60376. get input(): NodeMaterialConnectionPoint;
  60377. /**
  60378. * Gets the output component
  60379. */
  60380. get output(): NodeMaterialConnectionPoint;
  60381. protected _buildBlock(state: NodeMaterialBuildState): this;
  60382. }
  60383. }
  60384. declare module BABYLON {
  60385. /**
  60386. * Block used to replace a color by another one
  60387. */
  60388. export class ReplaceColorBlock extends NodeMaterialBlock {
  60389. /**
  60390. * Creates a new ReplaceColorBlock
  60391. * @param name defines the block name
  60392. */
  60393. constructor(name: string);
  60394. /**
  60395. * Gets the current class name
  60396. * @returns the class name
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * Gets the value input component
  60401. */
  60402. get value(): NodeMaterialConnectionPoint;
  60403. /**
  60404. * Gets the reference input component
  60405. */
  60406. get reference(): NodeMaterialConnectionPoint;
  60407. /**
  60408. * Gets the distance input component
  60409. */
  60410. get distance(): NodeMaterialConnectionPoint;
  60411. /**
  60412. * Gets the replacement input component
  60413. */
  60414. get replacement(): NodeMaterialConnectionPoint;
  60415. /**
  60416. * Gets the output component
  60417. */
  60418. get output(): NodeMaterialConnectionPoint;
  60419. protected _buildBlock(state: NodeMaterialBuildState): this;
  60420. }
  60421. }
  60422. declare module BABYLON {
  60423. /**
  60424. * Block used to posterize a value
  60425. * @see https://en.wikipedia.org/wiki/Posterization
  60426. */
  60427. export class PosterizeBlock extends NodeMaterialBlock {
  60428. /**
  60429. * Creates a new PosterizeBlock
  60430. * @param name defines the block name
  60431. */
  60432. constructor(name: string);
  60433. /**
  60434. * Gets the current class name
  60435. * @returns the class name
  60436. */
  60437. getClassName(): string;
  60438. /**
  60439. * Gets the value input component
  60440. */
  60441. get value(): NodeMaterialConnectionPoint;
  60442. /**
  60443. * Gets the steps input component
  60444. */
  60445. get steps(): NodeMaterialConnectionPoint;
  60446. /**
  60447. * Gets the output component
  60448. */
  60449. get output(): NodeMaterialConnectionPoint;
  60450. protected _buildBlock(state: NodeMaterialBuildState): this;
  60451. }
  60452. }
  60453. declare module BABYLON {
  60454. /**
  60455. * Operations supported by the Wave block
  60456. */
  60457. export enum WaveBlockKind {
  60458. /** SawTooth */
  60459. SawTooth = 0,
  60460. /** Square */
  60461. Square = 1,
  60462. /** Triangle */
  60463. Triangle = 2
  60464. }
  60465. /**
  60466. * Block used to apply wave operation to floats
  60467. */
  60468. export class WaveBlock extends NodeMaterialBlock {
  60469. /**
  60470. * Gets or sets the kibnd of wave to be applied by the block
  60471. */
  60472. kind: WaveBlockKind;
  60473. /**
  60474. * Creates a new WaveBlock
  60475. * @param name defines the block name
  60476. */
  60477. constructor(name: string);
  60478. /**
  60479. * Gets the current class name
  60480. * @returns the class name
  60481. */
  60482. getClassName(): string;
  60483. /**
  60484. * Gets the input component
  60485. */
  60486. get input(): NodeMaterialConnectionPoint;
  60487. /**
  60488. * Gets the output component
  60489. */
  60490. get output(): NodeMaterialConnectionPoint;
  60491. protected _buildBlock(state: NodeMaterialBuildState): this;
  60492. serialize(): any;
  60493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60494. }
  60495. }
  60496. declare module BABYLON {
  60497. /**
  60498. * Class used to store a color step for the GradientBlock
  60499. */
  60500. export class GradientBlockColorStep {
  60501. /**
  60502. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60503. */
  60504. step: number;
  60505. /**
  60506. * Gets or sets the color associated with this step
  60507. */
  60508. color: Color3;
  60509. /**
  60510. * Creates a new GradientBlockColorStep
  60511. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60512. * @param color defines the color associated with this step
  60513. */
  60514. constructor(
  60515. /**
  60516. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60517. */
  60518. step: number,
  60519. /**
  60520. * Gets or sets the color associated with this step
  60521. */
  60522. color: Color3);
  60523. }
  60524. /**
  60525. * Block used to return a color from a gradient based on an input value between 0 and 1
  60526. */
  60527. export class GradientBlock extends NodeMaterialBlock {
  60528. /**
  60529. * Gets or sets the list of color steps
  60530. */
  60531. colorSteps: GradientBlockColorStep[];
  60532. /**
  60533. * Creates a new GradientBlock
  60534. * @param name defines the block name
  60535. */
  60536. constructor(name: string);
  60537. /**
  60538. * Gets the current class name
  60539. * @returns the class name
  60540. */
  60541. getClassName(): string;
  60542. /**
  60543. * Gets the gradient input component
  60544. */
  60545. get gradient(): NodeMaterialConnectionPoint;
  60546. /**
  60547. * Gets the output component
  60548. */
  60549. get output(): NodeMaterialConnectionPoint;
  60550. private _writeColorConstant;
  60551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60552. serialize(): any;
  60553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60554. protected _dumpPropertiesCode(): string;
  60555. }
  60556. }
  60557. declare module BABYLON {
  60558. /**
  60559. * Block used to normalize lerp between 2 values
  60560. */
  60561. export class NLerpBlock extends NodeMaterialBlock {
  60562. /**
  60563. * Creates a new NLerpBlock
  60564. * @param name defines the block name
  60565. */
  60566. constructor(name: string);
  60567. /**
  60568. * Gets the current class name
  60569. * @returns the class name
  60570. */
  60571. getClassName(): string;
  60572. /**
  60573. * Gets the left operand input component
  60574. */
  60575. get left(): NodeMaterialConnectionPoint;
  60576. /**
  60577. * Gets the right operand input component
  60578. */
  60579. get right(): NodeMaterialConnectionPoint;
  60580. /**
  60581. * Gets the gradient operand input component
  60582. */
  60583. get gradient(): NodeMaterialConnectionPoint;
  60584. /**
  60585. * Gets the output component
  60586. */
  60587. get output(): NodeMaterialConnectionPoint;
  60588. protected _buildBlock(state: NodeMaterialBuildState): this;
  60589. }
  60590. }
  60591. declare module BABYLON {
  60592. /**
  60593. * block used to Generate a Worley Noise 3D Noise Pattern
  60594. */
  60595. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60596. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60597. manhattanDistance: boolean;
  60598. /**
  60599. * Creates a new WorleyNoise3DBlock
  60600. * @param name defines the block name
  60601. */
  60602. constructor(name: string);
  60603. /**
  60604. * Gets the current class name
  60605. * @returns the class name
  60606. */
  60607. getClassName(): string;
  60608. /**
  60609. * Gets the seed input component
  60610. */
  60611. get seed(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the jitter input component
  60614. */
  60615. get jitter(): NodeMaterialConnectionPoint;
  60616. /**
  60617. * Gets the output component
  60618. */
  60619. get output(): NodeMaterialConnectionPoint;
  60620. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60621. /**
  60622. * Exposes the properties to the UI?
  60623. */
  60624. protected _dumpPropertiesCode(): string;
  60625. /**
  60626. * Exposes the properties to the Seralize?
  60627. */
  60628. serialize(): any;
  60629. /**
  60630. * Exposes the properties to the deseralize?
  60631. */
  60632. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60633. }
  60634. }
  60635. declare module BABYLON {
  60636. /**
  60637. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60638. */
  60639. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60640. /**
  60641. * Creates a new SimplexPerlin3DBlock
  60642. * @param name defines the block name
  60643. */
  60644. constructor(name: string);
  60645. /**
  60646. * Gets the current class name
  60647. * @returns the class name
  60648. */
  60649. getClassName(): string;
  60650. /**
  60651. * Gets the seed operand input component
  60652. */
  60653. get seed(): NodeMaterialConnectionPoint;
  60654. /**
  60655. * Gets the output component
  60656. */
  60657. get output(): NodeMaterialConnectionPoint;
  60658. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60659. }
  60660. }
  60661. declare module BABYLON {
  60662. /**
  60663. * Block used to blend normals
  60664. */
  60665. export class NormalBlendBlock extends NodeMaterialBlock {
  60666. /**
  60667. * Creates a new NormalBlendBlock
  60668. * @param name defines the block name
  60669. */
  60670. constructor(name: string);
  60671. /**
  60672. * Gets the current class name
  60673. * @returns the class name
  60674. */
  60675. getClassName(): string;
  60676. /**
  60677. * Gets the first input component
  60678. */
  60679. get normalMap0(): NodeMaterialConnectionPoint;
  60680. /**
  60681. * Gets the second input component
  60682. */
  60683. get normalMap1(): NodeMaterialConnectionPoint;
  60684. /**
  60685. * Gets the output component
  60686. */
  60687. get output(): NodeMaterialConnectionPoint;
  60688. protected _buildBlock(state: NodeMaterialBuildState): this;
  60689. }
  60690. }
  60691. declare module BABYLON {
  60692. /**
  60693. * Block used to rotate a 2d vector by a given angle
  60694. */
  60695. export class Rotate2dBlock extends NodeMaterialBlock {
  60696. /**
  60697. * Creates a new Rotate2dBlock
  60698. * @param name defines the block name
  60699. */
  60700. constructor(name: string);
  60701. /**
  60702. * Gets the current class name
  60703. * @returns the class name
  60704. */
  60705. getClassName(): string;
  60706. /**
  60707. * Gets the input vector
  60708. */
  60709. get input(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the input angle
  60712. */
  60713. get angle(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the output component
  60716. */
  60717. get output(): NodeMaterialConnectionPoint;
  60718. autoConfigure(material: NodeMaterial): void;
  60719. protected _buildBlock(state: NodeMaterialBuildState): this;
  60720. }
  60721. }
  60722. declare module BABYLON {
  60723. /**
  60724. * Block used to get the reflected vector from a direction and a normal
  60725. */
  60726. export class ReflectBlock extends NodeMaterialBlock {
  60727. /**
  60728. * Creates a new ReflectBlock
  60729. * @param name defines the block name
  60730. */
  60731. constructor(name: string);
  60732. /**
  60733. * Gets the current class name
  60734. * @returns the class name
  60735. */
  60736. getClassName(): string;
  60737. /**
  60738. * Gets the incident component
  60739. */
  60740. get incident(): NodeMaterialConnectionPoint;
  60741. /**
  60742. * Gets the normal component
  60743. */
  60744. get normal(): NodeMaterialConnectionPoint;
  60745. /**
  60746. * Gets the output component
  60747. */
  60748. get output(): NodeMaterialConnectionPoint;
  60749. protected _buildBlock(state: NodeMaterialBuildState): this;
  60750. }
  60751. }
  60752. declare module BABYLON {
  60753. /**
  60754. * Block used to get the refracted vector from a direction and a normal
  60755. */
  60756. export class RefractBlock extends NodeMaterialBlock {
  60757. /**
  60758. * Creates a new RefractBlock
  60759. * @param name defines the block name
  60760. */
  60761. constructor(name: string);
  60762. /**
  60763. * Gets the current class name
  60764. * @returns the class name
  60765. */
  60766. getClassName(): string;
  60767. /**
  60768. * Gets the incident component
  60769. */
  60770. get incident(): NodeMaterialConnectionPoint;
  60771. /**
  60772. * Gets the normal component
  60773. */
  60774. get normal(): NodeMaterialConnectionPoint;
  60775. /**
  60776. * Gets the index of refraction component
  60777. */
  60778. get ior(): NodeMaterialConnectionPoint;
  60779. /**
  60780. * Gets the output component
  60781. */
  60782. get output(): NodeMaterialConnectionPoint;
  60783. protected _buildBlock(state: NodeMaterialBuildState): this;
  60784. }
  60785. }
  60786. declare module BABYLON {
  60787. /**
  60788. * Block used to desaturate a color
  60789. */
  60790. export class DesaturateBlock extends NodeMaterialBlock {
  60791. /**
  60792. * Creates a new DesaturateBlock
  60793. * @param name defines the block name
  60794. */
  60795. constructor(name: string);
  60796. /**
  60797. * Gets the current class name
  60798. * @returns the class name
  60799. */
  60800. getClassName(): string;
  60801. /**
  60802. * Gets the color operand input component
  60803. */
  60804. get color(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the level operand input component
  60807. */
  60808. get level(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the output component
  60811. */
  60812. get output(): NodeMaterialConnectionPoint;
  60813. protected _buildBlock(state: NodeMaterialBuildState): this;
  60814. }
  60815. }
  60816. declare module BABYLON {
  60817. /**
  60818. * Effect Render Options
  60819. */
  60820. export interface IEffectRendererOptions {
  60821. /**
  60822. * Defines the vertices positions.
  60823. */
  60824. positions?: number[];
  60825. /**
  60826. * Defines the indices.
  60827. */
  60828. indices?: number[];
  60829. }
  60830. /**
  60831. * Helper class to render one or more effects.
  60832. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60833. */
  60834. export class EffectRenderer {
  60835. private engine;
  60836. private static _DefaultOptions;
  60837. private _vertexBuffers;
  60838. private _indexBuffer;
  60839. private _fullscreenViewport;
  60840. /**
  60841. * Creates an effect renderer
  60842. * @param engine the engine to use for rendering
  60843. * @param options defines the options of the effect renderer
  60844. */
  60845. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60846. /**
  60847. * Sets the current viewport in normalized coordinates 0-1
  60848. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60849. */
  60850. setViewport(viewport?: Viewport): void;
  60851. /**
  60852. * Binds the embedded attributes buffer to the effect.
  60853. * @param effect Defines the effect to bind the attributes for
  60854. */
  60855. bindBuffers(effect: Effect): void;
  60856. /**
  60857. * Sets the current effect wrapper to use during draw.
  60858. * The effect needs to be ready before calling this api.
  60859. * This also sets the default full screen position attribute.
  60860. * @param effectWrapper Defines the effect to draw with
  60861. */
  60862. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60863. /**
  60864. * Draws a full screen quad.
  60865. */
  60866. draw(): void;
  60867. private isRenderTargetTexture;
  60868. /**
  60869. * renders one or more effects to a specified texture
  60870. * @param effectWrapper the effect to renderer
  60871. * @param outputTexture texture to draw to, if null it will render to the screen.
  60872. */
  60873. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60874. /**
  60875. * Disposes of the effect renderer
  60876. */
  60877. dispose(): void;
  60878. }
  60879. /**
  60880. * Options to create an EffectWrapper
  60881. */
  60882. interface EffectWrapperCreationOptions {
  60883. /**
  60884. * Engine to use to create the effect
  60885. */
  60886. engine: ThinEngine;
  60887. /**
  60888. * Fragment shader for the effect
  60889. */
  60890. fragmentShader: string;
  60891. /**
  60892. * Vertex shader for the effect
  60893. */
  60894. vertexShader?: string;
  60895. /**
  60896. * Attributes to use in the shader
  60897. */
  60898. attributeNames?: Array<string>;
  60899. /**
  60900. * Uniforms to use in the shader
  60901. */
  60902. uniformNames?: Array<string>;
  60903. /**
  60904. * Texture sampler names to use in the shader
  60905. */
  60906. samplerNames?: Array<string>;
  60907. /**
  60908. * The friendly name of the effect displayed in Spector.
  60909. */
  60910. name?: string;
  60911. }
  60912. /**
  60913. * Wraps an effect to be used for rendering
  60914. */
  60915. export class EffectWrapper {
  60916. /**
  60917. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60918. */
  60919. onApplyObservable: Observable<{}>;
  60920. /**
  60921. * The underlying effect
  60922. */
  60923. effect: Effect;
  60924. /**
  60925. * Creates an effect to be renderer
  60926. * @param creationOptions options to create the effect
  60927. */
  60928. constructor(creationOptions: EffectWrapperCreationOptions);
  60929. /**
  60930. * Disposes of the effect wrapper
  60931. */
  60932. dispose(): void;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /**
  60937. * Helper class to push actions to a pool of workers.
  60938. */
  60939. export class WorkerPool implements IDisposable {
  60940. private _workerInfos;
  60941. private _pendingActions;
  60942. /**
  60943. * Constructor
  60944. * @param workers Array of workers to use for actions
  60945. */
  60946. constructor(workers: Array<Worker>);
  60947. /**
  60948. * Terminates all workers and clears any pending actions.
  60949. */
  60950. dispose(): void;
  60951. /**
  60952. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60953. * pended until a worker has completed its action.
  60954. * @param action The action to perform. Call onComplete when the action is complete.
  60955. */
  60956. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60957. private _execute;
  60958. }
  60959. }
  60960. declare module BABYLON {
  60961. /**
  60962. * Configuration for Draco compression
  60963. */
  60964. export interface IDracoCompressionConfiguration {
  60965. /**
  60966. * Configuration for the decoder.
  60967. */
  60968. decoder: {
  60969. /**
  60970. * The url to the WebAssembly module.
  60971. */
  60972. wasmUrl?: string;
  60973. /**
  60974. * The url to the WebAssembly binary.
  60975. */
  60976. wasmBinaryUrl?: string;
  60977. /**
  60978. * The url to the fallback JavaScript module.
  60979. */
  60980. fallbackUrl?: string;
  60981. };
  60982. }
  60983. /**
  60984. * Draco compression (https://google.github.io/draco/)
  60985. *
  60986. * This class wraps the Draco module.
  60987. *
  60988. * **Encoder**
  60989. *
  60990. * The encoder is not currently implemented.
  60991. *
  60992. * **Decoder**
  60993. *
  60994. * 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.
  60995. *
  60996. * To update the configuration, use the following code:
  60997. * ```javascript
  60998. * DracoCompression.Configuration = {
  60999. * decoder: {
  61000. * wasmUrl: "<url to the WebAssembly library>",
  61001. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61002. * fallbackUrl: "<url to the fallback JavaScript library>",
  61003. * }
  61004. * };
  61005. * ```
  61006. *
  61007. * 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.
  61008. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61009. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61010. *
  61011. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61012. * ```javascript
  61013. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61014. * ```
  61015. *
  61016. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61017. */
  61018. export class DracoCompression implements IDisposable {
  61019. private _workerPoolPromise?;
  61020. private _decoderModulePromise?;
  61021. /**
  61022. * The configuration. Defaults to the following urls:
  61023. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61024. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61025. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61026. */
  61027. static Configuration: IDracoCompressionConfiguration;
  61028. /**
  61029. * Returns true if the decoder configuration is available.
  61030. */
  61031. static get DecoderAvailable(): boolean;
  61032. /**
  61033. * Default number of workers to create when creating the draco compression object.
  61034. */
  61035. static DefaultNumWorkers: number;
  61036. private static GetDefaultNumWorkers;
  61037. private static _Default;
  61038. /**
  61039. * Default instance for the draco compression object.
  61040. */
  61041. static get Default(): DracoCompression;
  61042. /**
  61043. * Constructor
  61044. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61045. */
  61046. constructor(numWorkers?: number);
  61047. /**
  61048. * Stop all async operations and release resources.
  61049. */
  61050. dispose(): void;
  61051. /**
  61052. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61053. * @returns a promise that resolves when ready
  61054. */
  61055. whenReadyAsync(): Promise<void>;
  61056. /**
  61057. * Decode Draco compressed mesh data to vertex data.
  61058. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61059. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61060. * @returns A promise that resolves with the decoded vertex data
  61061. */
  61062. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61063. [kind: string]: number;
  61064. }): Promise<VertexData>;
  61065. }
  61066. }
  61067. declare module BABYLON {
  61068. /**
  61069. * Class for building Constructive Solid Geometry
  61070. */
  61071. export class CSG {
  61072. private polygons;
  61073. /**
  61074. * The world matrix
  61075. */
  61076. matrix: Matrix;
  61077. /**
  61078. * Stores the position
  61079. */
  61080. position: Vector3;
  61081. /**
  61082. * Stores the rotation
  61083. */
  61084. rotation: Vector3;
  61085. /**
  61086. * Stores the rotation quaternion
  61087. */
  61088. rotationQuaternion: Nullable<Quaternion>;
  61089. /**
  61090. * Stores the scaling vector
  61091. */
  61092. scaling: Vector3;
  61093. /**
  61094. * Convert the Mesh to CSG
  61095. * @param mesh The Mesh to convert to CSG
  61096. * @returns A new CSG from the Mesh
  61097. */
  61098. static FromMesh(mesh: Mesh): CSG;
  61099. /**
  61100. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61101. * @param polygons Polygons used to construct a CSG solid
  61102. */
  61103. private static FromPolygons;
  61104. /**
  61105. * Clones, or makes a deep copy, of the CSG
  61106. * @returns A new CSG
  61107. */
  61108. clone(): CSG;
  61109. /**
  61110. * Unions this CSG with another CSG
  61111. * @param csg The CSG to union against this CSG
  61112. * @returns The unioned CSG
  61113. */
  61114. union(csg: CSG): CSG;
  61115. /**
  61116. * Unions this CSG with another CSG in place
  61117. * @param csg The CSG to union against this CSG
  61118. */
  61119. unionInPlace(csg: CSG): void;
  61120. /**
  61121. * Subtracts this CSG with another CSG
  61122. * @param csg The CSG to subtract against this CSG
  61123. * @returns A new CSG
  61124. */
  61125. subtract(csg: CSG): CSG;
  61126. /**
  61127. * Subtracts this CSG with another CSG in place
  61128. * @param csg The CSG to subtact against this CSG
  61129. */
  61130. subtractInPlace(csg: CSG): void;
  61131. /**
  61132. * Intersect this CSG with another CSG
  61133. * @param csg The CSG to intersect against this CSG
  61134. * @returns A new CSG
  61135. */
  61136. intersect(csg: CSG): CSG;
  61137. /**
  61138. * Intersects this CSG with another CSG in place
  61139. * @param csg The CSG to intersect against this CSG
  61140. */
  61141. intersectInPlace(csg: CSG): void;
  61142. /**
  61143. * Return a new CSG solid with solid and empty space switched. This solid is
  61144. * not modified.
  61145. * @returns A new CSG solid with solid and empty space switched
  61146. */
  61147. inverse(): CSG;
  61148. /**
  61149. * Inverses the CSG in place
  61150. */
  61151. inverseInPlace(): void;
  61152. /**
  61153. * This is used to keep meshes transformations so they can be restored
  61154. * when we build back a Babylon Mesh
  61155. * NB : All CSG operations are performed in world coordinates
  61156. * @param csg The CSG to copy the transform attributes from
  61157. * @returns This CSG
  61158. */
  61159. copyTransformAttributes(csg: CSG): CSG;
  61160. /**
  61161. * Build Raw mesh from CSG
  61162. * Coordinates here are in world space
  61163. * @param name The name of the mesh geometry
  61164. * @param scene The Scene
  61165. * @param keepSubMeshes Specifies if the submeshes should be kept
  61166. * @returns A new Mesh
  61167. */
  61168. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61169. /**
  61170. * Build Mesh from CSG taking material and transforms into account
  61171. * @param name The name of the Mesh
  61172. * @param material The material of the Mesh
  61173. * @param scene The Scene
  61174. * @param keepSubMeshes Specifies if submeshes should be kept
  61175. * @returns The new Mesh
  61176. */
  61177. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61178. }
  61179. }
  61180. declare module BABYLON {
  61181. /**
  61182. * Class used to create a trail following a mesh
  61183. */
  61184. export class TrailMesh extends Mesh {
  61185. private _generator;
  61186. private _autoStart;
  61187. private _running;
  61188. private _diameter;
  61189. private _length;
  61190. private _sectionPolygonPointsCount;
  61191. private _sectionVectors;
  61192. private _sectionNormalVectors;
  61193. private _beforeRenderObserver;
  61194. /**
  61195. * @constructor
  61196. * @param name The value used by scene.getMeshByName() to do a lookup.
  61197. * @param generator The mesh or transform node to generate a trail.
  61198. * @param scene The scene to add this mesh to.
  61199. * @param diameter Diameter of trailing mesh. Default is 1.
  61200. * @param length Length of trailing mesh. Default is 60.
  61201. * @param autoStart Automatically start trailing mesh. Default true.
  61202. */
  61203. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61204. /**
  61205. * "TrailMesh"
  61206. * @returns "TrailMesh"
  61207. */
  61208. getClassName(): string;
  61209. private _createMesh;
  61210. /**
  61211. * Start trailing mesh.
  61212. */
  61213. start(): void;
  61214. /**
  61215. * Stop trailing mesh.
  61216. */
  61217. stop(): void;
  61218. /**
  61219. * Update trailing mesh geometry.
  61220. */
  61221. update(): void;
  61222. /**
  61223. * Returns a new TrailMesh object.
  61224. * @param name is a string, the name given to the new mesh
  61225. * @param newGenerator use new generator object for cloned trail mesh
  61226. * @returns a new mesh
  61227. */
  61228. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61229. /**
  61230. * Serializes this trail mesh
  61231. * @param serializationObject object to write serialization to
  61232. */
  61233. serialize(serializationObject: any): void;
  61234. /**
  61235. * Parses a serialized trail mesh
  61236. * @param parsedMesh the serialized mesh
  61237. * @param scene the scene to create the trail mesh in
  61238. * @returns the created trail mesh
  61239. */
  61240. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61241. }
  61242. }
  61243. declare module BABYLON {
  61244. /**
  61245. * Class containing static functions to help procedurally build meshes
  61246. */
  61247. export class TiledBoxBuilder {
  61248. /**
  61249. * Creates a box mesh
  61250. * 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)
  61251. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61253. * * 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
  61254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61255. * @param name defines the name of the mesh
  61256. * @param options defines the options used to create the mesh
  61257. * @param scene defines the hosting scene
  61258. * @returns the box mesh
  61259. */
  61260. static CreateTiledBox(name: string, options: {
  61261. pattern?: number;
  61262. width?: number;
  61263. height?: number;
  61264. depth?: number;
  61265. tileSize?: number;
  61266. tileWidth?: number;
  61267. tileHeight?: number;
  61268. alignHorizontal?: number;
  61269. alignVertical?: number;
  61270. faceUV?: Vector4[];
  61271. faceColors?: Color4[];
  61272. sideOrientation?: number;
  61273. updatable?: boolean;
  61274. }, scene?: Nullable<Scene>): Mesh;
  61275. }
  61276. }
  61277. declare module BABYLON {
  61278. /**
  61279. * Class containing static functions to help procedurally build meshes
  61280. */
  61281. export class TorusKnotBuilder {
  61282. /**
  61283. * Creates a torus knot mesh
  61284. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61285. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61286. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61287. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61289. * * 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
  61290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61291. * @param name defines the name of the mesh
  61292. * @param options defines the options used to create the mesh
  61293. * @param scene defines the hosting scene
  61294. * @returns the torus knot mesh
  61295. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61296. */
  61297. static CreateTorusKnot(name: string, options: {
  61298. radius?: number;
  61299. tube?: number;
  61300. radialSegments?: number;
  61301. tubularSegments?: number;
  61302. p?: number;
  61303. q?: number;
  61304. updatable?: boolean;
  61305. sideOrientation?: number;
  61306. frontUVs?: Vector4;
  61307. backUVs?: Vector4;
  61308. }, scene: any): Mesh;
  61309. }
  61310. }
  61311. declare module BABYLON {
  61312. /**
  61313. * Polygon
  61314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61315. */
  61316. export class Polygon {
  61317. /**
  61318. * Creates a rectangle
  61319. * @param xmin bottom X coord
  61320. * @param ymin bottom Y coord
  61321. * @param xmax top X coord
  61322. * @param ymax top Y coord
  61323. * @returns points that make the resulting rectation
  61324. */
  61325. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61326. /**
  61327. * Creates a circle
  61328. * @param radius radius of circle
  61329. * @param cx scale in x
  61330. * @param cy scale in y
  61331. * @param numberOfSides number of sides that make up the circle
  61332. * @returns points that make the resulting circle
  61333. */
  61334. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61335. /**
  61336. * Creates a polygon from input string
  61337. * @param input Input polygon data
  61338. * @returns the parsed points
  61339. */
  61340. static Parse(input: string): Vector2[];
  61341. /**
  61342. * Starts building a polygon from x and y coordinates
  61343. * @param x x coordinate
  61344. * @param y y coordinate
  61345. * @returns the started path2
  61346. */
  61347. static StartingAt(x: number, y: number): Path2;
  61348. }
  61349. /**
  61350. * Builds a polygon
  61351. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61352. */
  61353. export class PolygonMeshBuilder {
  61354. private _points;
  61355. private _outlinepoints;
  61356. private _holes;
  61357. private _name;
  61358. private _scene;
  61359. private _epoints;
  61360. private _eholes;
  61361. private _addToepoint;
  61362. /**
  61363. * Babylon reference to the earcut plugin.
  61364. */
  61365. bjsEarcut: any;
  61366. /**
  61367. * Creates a PolygonMeshBuilder
  61368. * @param name name of the builder
  61369. * @param contours Path of the polygon
  61370. * @param scene scene to add to when creating the mesh
  61371. * @param earcutInjection can be used to inject your own earcut reference
  61372. */
  61373. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61374. /**
  61375. * Adds a whole within the polygon
  61376. * @param hole Array of points defining the hole
  61377. * @returns this
  61378. */
  61379. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61380. /**
  61381. * Creates the polygon
  61382. * @param updatable If the mesh should be updatable
  61383. * @param depth The depth of the mesh created
  61384. * @returns the created mesh
  61385. */
  61386. build(updatable?: boolean, depth?: number): Mesh;
  61387. /**
  61388. * Creates the polygon
  61389. * @param depth The depth of the mesh created
  61390. * @returns the created VertexData
  61391. */
  61392. buildVertexData(depth?: number): VertexData;
  61393. /**
  61394. * Adds a side to the polygon
  61395. * @param positions points that make the polygon
  61396. * @param normals normals of the polygon
  61397. * @param uvs uvs of the polygon
  61398. * @param indices indices of the polygon
  61399. * @param bounds bounds of the polygon
  61400. * @param points points of the polygon
  61401. * @param depth depth of the polygon
  61402. * @param flip flip of the polygon
  61403. */
  61404. private addSide;
  61405. }
  61406. }
  61407. declare module BABYLON {
  61408. /**
  61409. * Class containing static functions to help procedurally build meshes
  61410. */
  61411. export class PolygonBuilder {
  61412. /**
  61413. * Creates a polygon mesh
  61414. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61415. * * 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
  61416. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61418. * * 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)
  61419. * * Remember you can only change the shape positions, not their number when updating a polygon
  61420. * @param name defines the name of the mesh
  61421. * @param options defines the options used to create the mesh
  61422. * @param scene defines the hosting scene
  61423. * @param earcutInjection can be used to inject your own earcut reference
  61424. * @returns the polygon mesh
  61425. */
  61426. static CreatePolygon(name: string, options: {
  61427. shape: Vector3[];
  61428. holes?: Vector3[][];
  61429. depth?: number;
  61430. faceUV?: Vector4[];
  61431. faceColors?: Color4[];
  61432. updatable?: boolean;
  61433. sideOrientation?: number;
  61434. frontUVs?: Vector4;
  61435. backUVs?: Vector4;
  61436. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61437. /**
  61438. * Creates an extruded polygon mesh, with depth in the Y direction.
  61439. * * 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)
  61440. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61441. * @param name defines the name of the mesh
  61442. * @param options defines the options used to create the mesh
  61443. * @param scene defines the hosting scene
  61444. * @param earcutInjection can be used to inject your own earcut reference
  61445. * @returns the polygon mesh
  61446. */
  61447. static ExtrudePolygon(name: string, options: {
  61448. shape: Vector3[];
  61449. holes?: Vector3[][];
  61450. depth?: number;
  61451. faceUV?: Vector4[];
  61452. faceColors?: Color4[];
  61453. updatable?: boolean;
  61454. sideOrientation?: number;
  61455. frontUVs?: Vector4;
  61456. backUVs?: Vector4;
  61457. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61458. }
  61459. }
  61460. declare module BABYLON {
  61461. /**
  61462. * Class containing static functions to help procedurally build meshes
  61463. */
  61464. export class LatheBuilder {
  61465. /**
  61466. * Creates lathe mesh.
  61467. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61468. * * 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
  61469. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61470. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61471. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61472. * * 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
  61473. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61474. * * 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
  61475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61476. * * 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
  61477. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61479. * @param name defines the name of the mesh
  61480. * @param options defines the options used to create the mesh
  61481. * @param scene defines the hosting scene
  61482. * @returns the lathe mesh
  61483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61484. */
  61485. static CreateLathe(name: string, options: {
  61486. shape: Vector3[];
  61487. radius?: number;
  61488. tessellation?: number;
  61489. clip?: number;
  61490. arc?: number;
  61491. closed?: boolean;
  61492. updatable?: boolean;
  61493. sideOrientation?: number;
  61494. frontUVs?: Vector4;
  61495. backUVs?: Vector4;
  61496. cap?: number;
  61497. invertUV?: boolean;
  61498. }, scene?: Nullable<Scene>): Mesh;
  61499. }
  61500. }
  61501. declare module BABYLON {
  61502. /**
  61503. * Class containing static functions to help procedurally build meshes
  61504. */
  61505. export class TiledPlaneBuilder {
  61506. /**
  61507. * Creates a tiled plane mesh
  61508. * * The parameter `pattern` will, depending on value, do nothing or
  61509. * * * flip (reflect about central vertical) alternate tiles across and up
  61510. * * * flip every tile on alternate rows
  61511. * * * rotate (180 degs) alternate tiles across and up
  61512. * * * rotate every tile on alternate rows
  61513. * * * flip and rotate alternate tiles across and up
  61514. * * * flip and rotate every tile on alternate rows
  61515. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61516. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61517. * * 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
  61518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61519. * * 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)
  61520. * * 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)
  61521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61522. * @param name defines the name of the mesh
  61523. * @param options defines the options used to create the mesh
  61524. * @param scene defines the hosting scene
  61525. * @returns the box mesh
  61526. */
  61527. static CreateTiledPlane(name: string, options: {
  61528. pattern?: number;
  61529. tileSize?: number;
  61530. tileWidth?: number;
  61531. tileHeight?: number;
  61532. size?: number;
  61533. width?: number;
  61534. height?: number;
  61535. alignHorizontal?: number;
  61536. alignVertical?: number;
  61537. sideOrientation?: number;
  61538. frontUVs?: Vector4;
  61539. backUVs?: Vector4;
  61540. updatable?: boolean;
  61541. }, scene?: Nullable<Scene>): Mesh;
  61542. }
  61543. }
  61544. declare module BABYLON {
  61545. /**
  61546. * Class containing static functions to help procedurally build meshes
  61547. */
  61548. export class TubeBuilder {
  61549. /**
  61550. * Creates a tube mesh.
  61551. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61552. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61553. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61554. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61555. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61556. * * 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)
  61557. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61558. * * 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
  61559. * * 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
  61560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61561. * * 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
  61562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61564. * @param name defines the name of the mesh
  61565. * @param options defines the options used to create the mesh
  61566. * @param scene defines the hosting scene
  61567. * @returns the tube mesh
  61568. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61569. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61570. */
  61571. static CreateTube(name: string, options: {
  61572. path: Vector3[];
  61573. radius?: number;
  61574. tessellation?: number;
  61575. radiusFunction?: {
  61576. (i: number, distance: number): number;
  61577. };
  61578. cap?: number;
  61579. arc?: number;
  61580. updatable?: boolean;
  61581. sideOrientation?: number;
  61582. frontUVs?: Vector4;
  61583. backUVs?: Vector4;
  61584. instance?: Mesh;
  61585. invertUV?: boolean;
  61586. }, scene?: Nullable<Scene>): Mesh;
  61587. }
  61588. }
  61589. declare module BABYLON {
  61590. /**
  61591. * Class containing static functions to help procedurally build meshes
  61592. */
  61593. export class IcoSphereBuilder {
  61594. /**
  61595. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61596. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61597. * * 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`)
  61598. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61599. * * 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
  61600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61601. * * 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
  61602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61603. * @param name defines the name of the mesh
  61604. * @param options defines the options used to create the mesh
  61605. * @param scene defines the hosting scene
  61606. * @returns the icosahedron mesh
  61607. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61608. */
  61609. static CreateIcoSphere(name: string, options: {
  61610. radius?: number;
  61611. radiusX?: number;
  61612. radiusY?: number;
  61613. radiusZ?: number;
  61614. flat?: boolean;
  61615. subdivisions?: number;
  61616. sideOrientation?: number;
  61617. frontUVs?: Vector4;
  61618. backUVs?: Vector4;
  61619. updatable?: boolean;
  61620. }, scene?: Nullable<Scene>): Mesh;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Class containing static functions to help procedurally build meshes
  61626. */
  61627. export class DecalBuilder {
  61628. /**
  61629. * Creates a decal mesh.
  61630. * 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
  61631. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61632. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61633. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61634. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61635. * @param name defines the name of the mesh
  61636. * @param sourceMesh defines the mesh where the decal must be applied
  61637. * @param options defines the options used to create the mesh
  61638. * @param scene defines the hosting scene
  61639. * @returns the decal mesh
  61640. * @see https://doc.babylonjs.com/how_to/decals
  61641. */
  61642. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61643. position?: Vector3;
  61644. normal?: Vector3;
  61645. size?: Vector3;
  61646. angle?: number;
  61647. }): Mesh;
  61648. }
  61649. }
  61650. declare module BABYLON {
  61651. /**
  61652. * Class containing static functions to help procedurally build meshes
  61653. */
  61654. export class MeshBuilder {
  61655. /**
  61656. * Creates a box mesh
  61657. * * The parameter `size` sets the size (float) of each box side (default 1)
  61658. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61659. * * 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)
  61660. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61662. * * 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
  61663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61664. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61665. * @param name defines the name of the mesh
  61666. * @param options defines the options used to create the mesh
  61667. * @param scene defines the hosting scene
  61668. * @returns the box mesh
  61669. */
  61670. static CreateBox(name: string, options: {
  61671. size?: number;
  61672. width?: number;
  61673. height?: number;
  61674. depth?: number;
  61675. faceUV?: Vector4[];
  61676. faceColors?: Color4[];
  61677. sideOrientation?: number;
  61678. frontUVs?: Vector4;
  61679. backUVs?: Vector4;
  61680. wrap?: boolean;
  61681. topBaseAt?: number;
  61682. bottomBaseAt?: number;
  61683. updatable?: boolean;
  61684. }, scene?: Nullable<Scene>): Mesh;
  61685. /**
  61686. * Creates a tiled box mesh
  61687. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61689. * @param name defines the name of the mesh
  61690. * @param options defines the options used to create the mesh
  61691. * @param scene defines the hosting scene
  61692. * @returns the tiled box mesh
  61693. */
  61694. static CreateTiledBox(name: string, options: {
  61695. pattern?: number;
  61696. size?: number;
  61697. width?: number;
  61698. height?: number;
  61699. depth: number;
  61700. tileSize?: number;
  61701. tileWidth?: number;
  61702. tileHeight?: number;
  61703. faceUV?: Vector4[];
  61704. faceColors?: Color4[];
  61705. alignHorizontal?: number;
  61706. alignVertical?: number;
  61707. sideOrientation?: number;
  61708. updatable?: boolean;
  61709. }, scene?: Nullable<Scene>): Mesh;
  61710. /**
  61711. * Creates a sphere mesh
  61712. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61713. * * 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`)
  61714. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61715. * * 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
  61716. * * 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)
  61717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61718. * * 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
  61719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61720. * @param name defines the name of the mesh
  61721. * @param options defines the options used to create the mesh
  61722. * @param scene defines the hosting scene
  61723. * @returns the sphere mesh
  61724. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61725. */
  61726. static CreateSphere(name: string, options: {
  61727. segments?: number;
  61728. diameter?: number;
  61729. diameterX?: number;
  61730. diameterY?: number;
  61731. diameterZ?: number;
  61732. arc?: number;
  61733. slice?: number;
  61734. sideOrientation?: number;
  61735. frontUVs?: Vector4;
  61736. backUVs?: Vector4;
  61737. updatable?: boolean;
  61738. }, scene?: Nullable<Scene>): Mesh;
  61739. /**
  61740. * Creates a plane polygonal mesh. By default, this is a disc
  61741. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61742. * * 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
  61743. * * 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
  61744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61745. * * 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
  61746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61747. * @param name defines the name of the mesh
  61748. * @param options defines the options used to create the mesh
  61749. * @param scene defines the hosting scene
  61750. * @returns the plane polygonal mesh
  61751. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61752. */
  61753. static CreateDisc(name: string, options: {
  61754. radius?: number;
  61755. tessellation?: number;
  61756. arc?: number;
  61757. updatable?: boolean;
  61758. sideOrientation?: number;
  61759. frontUVs?: Vector4;
  61760. backUVs?: Vector4;
  61761. }, scene?: Nullable<Scene>): Mesh;
  61762. /**
  61763. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61764. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61765. * * 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`)
  61766. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61767. * * 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
  61768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61769. * * 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
  61770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61771. * @param name defines the name of the mesh
  61772. * @param options defines the options used to create the mesh
  61773. * @param scene defines the hosting scene
  61774. * @returns the icosahedron mesh
  61775. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61776. */
  61777. static CreateIcoSphere(name: string, options: {
  61778. radius?: number;
  61779. radiusX?: number;
  61780. radiusY?: number;
  61781. radiusZ?: number;
  61782. flat?: boolean;
  61783. subdivisions?: number;
  61784. sideOrientation?: number;
  61785. frontUVs?: Vector4;
  61786. backUVs?: Vector4;
  61787. updatable?: boolean;
  61788. }, scene?: Nullable<Scene>): Mesh;
  61789. /**
  61790. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61791. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61792. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61793. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61794. * * 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
  61795. * * 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
  61796. * * 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
  61797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61798. * * 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
  61799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61800. * * 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
  61801. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61802. * * 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
  61803. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61805. * @param name defines the name of the mesh
  61806. * @param options defines the options used to create the mesh
  61807. * @param scene defines the hosting scene
  61808. * @returns the ribbon mesh
  61809. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61811. */
  61812. static CreateRibbon(name: string, options: {
  61813. pathArray: Vector3[][];
  61814. closeArray?: boolean;
  61815. closePath?: boolean;
  61816. offset?: number;
  61817. updatable?: boolean;
  61818. sideOrientation?: number;
  61819. frontUVs?: Vector4;
  61820. backUVs?: Vector4;
  61821. instance?: Mesh;
  61822. invertUV?: boolean;
  61823. uvs?: Vector2[];
  61824. colors?: Color4[];
  61825. }, scene?: Nullable<Scene>): Mesh;
  61826. /**
  61827. * Creates a cylinder or a cone mesh
  61828. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61829. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61830. * * 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.
  61831. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61832. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61833. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61834. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61835. * * 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).
  61836. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61837. * * 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).
  61838. * * 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
  61839. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61840. * * 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
  61841. * * 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.
  61842. * * If `enclose` is false, a ring surface is one element.
  61843. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61844. * * 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
  61845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61846. * * 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
  61847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61848. * @param name defines the name of the mesh
  61849. * @param options defines the options used to create the mesh
  61850. * @param scene defines the hosting scene
  61851. * @returns the cylinder mesh
  61852. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61853. */
  61854. static CreateCylinder(name: string, options: {
  61855. height?: number;
  61856. diameterTop?: number;
  61857. diameterBottom?: number;
  61858. diameter?: number;
  61859. tessellation?: number;
  61860. subdivisions?: number;
  61861. arc?: number;
  61862. faceColors?: Color4[];
  61863. faceUV?: Vector4[];
  61864. updatable?: boolean;
  61865. hasRings?: boolean;
  61866. enclose?: boolean;
  61867. cap?: number;
  61868. sideOrientation?: number;
  61869. frontUVs?: Vector4;
  61870. backUVs?: Vector4;
  61871. }, scene?: Nullable<Scene>): Mesh;
  61872. /**
  61873. * Creates a torus mesh
  61874. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61875. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61876. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61878. * * 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
  61879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61880. * @param name defines the name of the mesh
  61881. * @param options defines the options used to create the mesh
  61882. * @param scene defines the hosting scene
  61883. * @returns the torus mesh
  61884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61885. */
  61886. static CreateTorus(name: string, options: {
  61887. diameter?: number;
  61888. thickness?: number;
  61889. tessellation?: number;
  61890. updatable?: boolean;
  61891. sideOrientation?: number;
  61892. frontUVs?: Vector4;
  61893. backUVs?: Vector4;
  61894. }, scene?: Nullable<Scene>): Mesh;
  61895. /**
  61896. * Creates a torus knot mesh
  61897. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61898. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61899. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61900. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61902. * * 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
  61903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61904. * @param name defines the name of the mesh
  61905. * @param options defines the options used to create the mesh
  61906. * @param scene defines the hosting scene
  61907. * @returns the torus knot mesh
  61908. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61909. */
  61910. static CreateTorusKnot(name: string, options: {
  61911. radius?: number;
  61912. tube?: number;
  61913. radialSegments?: number;
  61914. tubularSegments?: number;
  61915. p?: number;
  61916. q?: number;
  61917. updatable?: boolean;
  61918. sideOrientation?: number;
  61919. frontUVs?: Vector4;
  61920. backUVs?: Vector4;
  61921. }, scene?: Nullable<Scene>): Mesh;
  61922. /**
  61923. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61924. * * 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
  61925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61926. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61927. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61928. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61930. * * 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
  61931. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61934. * @param name defines the name of the new line system
  61935. * @param options defines the options used to create the line system
  61936. * @param scene defines the hosting scene
  61937. * @returns a new line system mesh
  61938. */
  61939. static CreateLineSystem(name: string, options: {
  61940. lines: Vector3[][];
  61941. updatable?: boolean;
  61942. instance?: Nullable<LinesMesh>;
  61943. colors?: Nullable<Color4[][]>;
  61944. useVertexAlpha?: boolean;
  61945. }, scene: Nullable<Scene>): LinesMesh;
  61946. /**
  61947. * Creates a line mesh
  61948. * 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
  61949. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61950. * * The parameter `points` is an array successive Vector3
  61951. * * 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
  61952. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61953. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61954. * * When updating an instance, remember that only point positions can change, not the number of points
  61955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61957. * @param name defines the name of the new line system
  61958. * @param options defines the options used to create the line system
  61959. * @param scene defines the hosting scene
  61960. * @returns a new line mesh
  61961. */
  61962. static CreateLines(name: string, options: {
  61963. points: Vector3[];
  61964. updatable?: boolean;
  61965. instance?: Nullable<LinesMesh>;
  61966. colors?: Color4[];
  61967. useVertexAlpha?: boolean;
  61968. }, scene?: Nullable<Scene>): LinesMesh;
  61969. /**
  61970. * Creates a dashed line mesh
  61971. * * 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
  61972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61973. * * The parameter `points` is an array successive Vector3
  61974. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61975. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61976. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61977. * * 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
  61978. * * When updating an instance, remember that only point positions can change, not the number of points
  61979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61980. * @param name defines the name of the mesh
  61981. * @param options defines the options used to create the mesh
  61982. * @param scene defines the hosting scene
  61983. * @returns the dashed line mesh
  61984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61985. */
  61986. static CreateDashedLines(name: string, options: {
  61987. points: Vector3[];
  61988. dashSize?: number;
  61989. gapSize?: number;
  61990. dashNb?: number;
  61991. updatable?: boolean;
  61992. instance?: LinesMesh;
  61993. }, scene?: Nullable<Scene>): LinesMesh;
  61994. /**
  61995. * 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.
  61996. * * 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.
  61997. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61998. * * 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.
  61999. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62000. * * 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
  62001. * * 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
  62002. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62004. * * 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
  62005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62007. * @param name defines the name of the mesh
  62008. * @param options defines the options used to create the mesh
  62009. * @param scene defines the hosting scene
  62010. * @returns the extruded shape mesh
  62011. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62013. */
  62014. static ExtrudeShape(name: string, options: {
  62015. shape: Vector3[];
  62016. path: Vector3[];
  62017. scale?: number;
  62018. rotation?: number;
  62019. cap?: number;
  62020. updatable?: boolean;
  62021. sideOrientation?: number;
  62022. frontUVs?: Vector4;
  62023. backUVs?: Vector4;
  62024. instance?: Mesh;
  62025. invertUV?: boolean;
  62026. }, scene?: Nullable<Scene>): Mesh;
  62027. /**
  62028. * Creates an custom extruded shape mesh.
  62029. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62030. * * 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.
  62031. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62032. * * 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
  62033. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62034. * * 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
  62035. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62036. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62037. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62038. * * 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
  62039. * * 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
  62040. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62042. * * 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
  62043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62045. * @param name defines the name of the mesh
  62046. * @param options defines the options used to create the mesh
  62047. * @param scene defines the hosting scene
  62048. * @returns the custom extruded shape mesh
  62049. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62050. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62052. */
  62053. static ExtrudeShapeCustom(name: string, options: {
  62054. shape: Vector3[];
  62055. path: Vector3[];
  62056. scaleFunction?: any;
  62057. rotationFunction?: any;
  62058. ribbonCloseArray?: boolean;
  62059. ribbonClosePath?: boolean;
  62060. cap?: number;
  62061. updatable?: boolean;
  62062. sideOrientation?: number;
  62063. frontUVs?: Vector4;
  62064. backUVs?: Vector4;
  62065. instance?: Mesh;
  62066. invertUV?: boolean;
  62067. }, scene?: Nullable<Scene>): Mesh;
  62068. /**
  62069. * Creates lathe mesh.
  62070. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62071. * * 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
  62072. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62073. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62074. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62075. * * 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
  62076. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62077. * * 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
  62078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62079. * * 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
  62080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62082. * @param name defines the name of the mesh
  62083. * @param options defines the options used to create the mesh
  62084. * @param scene defines the hosting scene
  62085. * @returns the lathe mesh
  62086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62087. */
  62088. static CreateLathe(name: string, options: {
  62089. shape: Vector3[];
  62090. radius?: number;
  62091. tessellation?: number;
  62092. clip?: number;
  62093. arc?: number;
  62094. closed?: boolean;
  62095. updatable?: boolean;
  62096. sideOrientation?: number;
  62097. frontUVs?: Vector4;
  62098. backUVs?: Vector4;
  62099. cap?: number;
  62100. invertUV?: boolean;
  62101. }, scene?: Nullable<Scene>): Mesh;
  62102. /**
  62103. * Creates a tiled plane mesh
  62104. * * You can set a limited pattern arrangement with the tiles
  62105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62106. * * 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
  62107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62108. * @param name defines the name of the mesh
  62109. * @param options defines the options used to create the mesh
  62110. * @param scene defines the hosting scene
  62111. * @returns the plane mesh
  62112. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62113. */
  62114. static CreateTiledPlane(name: string, options: {
  62115. pattern?: number;
  62116. tileSize?: number;
  62117. tileWidth?: number;
  62118. tileHeight?: number;
  62119. size?: number;
  62120. width?: number;
  62121. height?: number;
  62122. alignHorizontal?: number;
  62123. alignVertical?: number;
  62124. sideOrientation?: number;
  62125. frontUVs?: Vector4;
  62126. backUVs?: Vector4;
  62127. updatable?: boolean;
  62128. }, scene?: Nullable<Scene>): Mesh;
  62129. /**
  62130. * Creates a plane mesh
  62131. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62132. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62133. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62135. * * 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
  62136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62137. * @param name defines the name of the mesh
  62138. * @param options defines the options used to create the mesh
  62139. * @param scene defines the hosting scene
  62140. * @returns the plane mesh
  62141. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62142. */
  62143. static CreatePlane(name: string, options: {
  62144. size?: number;
  62145. width?: number;
  62146. height?: number;
  62147. sideOrientation?: number;
  62148. frontUVs?: Vector4;
  62149. backUVs?: Vector4;
  62150. updatable?: boolean;
  62151. sourcePlane?: Plane;
  62152. }, scene?: Nullable<Scene>): Mesh;
  62153. /**
  62154. * Creates a ground mesh
  62155. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62156. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62158. * @param name defines the name of the mesh
  62159. * @param options defines the options used to create the mesh
  62160. * @param scene defines the hosting scene
  62161. * @returns the ground mesh
  62162. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62163. */
  62164. static CreateGround(name: string, options: {
  62165. width?: number;
  62166. height?: number;
  62167. subdivisions?: number;
  62168. subdivisionsX?: number;
  62169. subdivisionsY?: number;
  62170. updatable?: boolean;
  62171. }, scene?: Nullable<Scene>): Mesh;
  62172. /**
  62173. * Creates a tiled ground mesh
  62174. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62175. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62176. * * 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
  62177. * * 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
  62178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62179. * @param name defines the name of the mesh
  62180. * @param options defines the options used to create the mesh
  62181. * @param scene defines the hosting scene
  62182. * @returns the tiled ground mesh
  62183. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62184. */
  62185. static CreateTiledGround(name: string, options: {
  62186. xmin: number;
  62187. zmin: number;
  62188. xmax: number;
  62189. zmax: number;
  62190. subdivisions?: {
  62191. w: number;
  62192. h: number;
  62193. };
  62194. precision?: {
  62195. w: number;
  62196. h: number;
  62197. };
  62198. updatable?: boolean;
  62199. }, scene?: Nullable<Scene>): Mesh;
  62200. /**
  62201. * Creates a ground mesh from a height map
  62202. * * The parameter `url` sets the URL of the height map image resource.
  62203. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62204. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62205. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62206. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62207. * * 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.
  62208. * * 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).
  62209. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62211. * @param name defines the name of the mesh
  62212. * @param url defines the url to the height map
  62213. * @param options defines the options used to create the mesh
  62214. * @param scene defines the hosting scene
  62215. * @returns the ground mesh
  62216. * @see https://doc.babylonjs.com/babylon101/height_map
  62217. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62218. */
  62219. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62220. width?: number;
  62221. height?: number;
  62222. subdivisions?: number;
  62223. minHeight?: number;
  62224. maxHeight?: number;
  62225. colorFilter?: Color3;
  62226. alphaFilter?: number;
  62227. updatable?: boolean;
  62228. onReady?: (mesh: GroundMesh) => void;
  62229. }, scene?: Nullable<Scene>): GroundMesh;
  62230. /**
  62231. * Creates a polygon mesh
  62232. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62233. * * 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
  62234. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62236. * * 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)
  62237. * * Remember you can only change the shape positions, not their number when updating a polygon
  62238. * @param name defines the name of the mesh
  62239. * @param options defines the options used to create the mesh
  62240. * @param scene defines the hosting scene
  62241. * @param earcutInjection can be used to inject your own earcut reference
  62242. * @returns the polygon mesh
  62243. */
  62244. static CreatePolygon(name: string, options: {
  62245. shape: Vector3[];
  62246. holes?: Vector3[][];
  62247. depth?: number;
  62248. faceUV?: Vector4[];
  62249. faceColors?: Color4[];
  62250. updatable?: boolean;
  62251. sideOrientation?: number;
  62252. frontUVs?: Vector4;
  62253. backUVs?: Vector4;
  62254. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62255. /**
  62256. * Creates an extruded polygon mesh, with depth in the Y direction.
  62257. * * 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)
  62258. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62259. * @param name defines the name of the mesh
  62260. * @param options defines the options used to create the mesh
  62261. * @param scene defines the hosting scene
  62262. * @param earcutInjection can be used to inject your own earcut reference
  62263. * @returns the polygon mesh
  62264. */
  62265. static ExtrudePolygon(name: string, options: {
  62266. shape: Vector3[];
  62267. holes?: Vector3[][];
  62268. depth?: number;
  62269. faceUV?: Vector4[];
  62270. faceColors?: Color4[];
  62271. updatable?: boolean;
  62272. sideOrientation?: number;
  62273. frontUVs?: Vector4;
  62274. backUVs?: Vector4;
  62275. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62276. /**
  62277. * Creates a tube mesh.
  62278. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62279. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62280. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62281. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62282. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62283. * * 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)
  62284. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62285. * * 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
  62286. * * 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
  62287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62288. * * 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
  62289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62291. * @param name defines the name of the mesh
  62292. * @param options defines the options used to create the mesh
  62293. * @param scene defines the hosting scene
  62294. * @returns the tube mesh
  62295. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62296. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62297. */
  62298. static CreateTube(name: string, options: {
  62299. path: Vector3[];
  62300. radius?: number;
  62301. tessellation?: number;
  62302. radiusFunction?: {
  62303. (i: number, distance: number): number;
  62304. };
  62305. cap?: number;
  62306. arc?: number;
  62307. updatable?: boolean;
  62308. sideOrientation?: number;
  62309. frontUVs?: Vector4;
  62310. backUVs?: Vector4;
  62311. instance?: Mesh;
  62312. invertUV?: boolean;
  62313. }, scene?: Nullable<Scene>): Mesh;
  62314. /**
  62315. * Creates a polyhedron mesh
  62316. * * 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
  62317. * * The parameter `size` (positive float, default 1) sets the polygon size
  62318. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62319. * * 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`
  62320. * * 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
  62321. * * 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)`)
  62322. * * 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
  62323. * * 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
  62324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62325. * * 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
  62326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62327. * @param name defines the name of the mesh
  62328. * @param options defines the options used to create the mesh
  62329. * @param scene defines the hosting scene
  62330. * @returns the polyhedron mesh
  62331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62332. */
  62333. static CreatePolyhedron(name: string, options: {
  62334. type?: number;
  62335. size?: number;
  62336. sizeX?: number;
  62337. sizeY?: number;
  62338. sizeZ?: number;
  62339. custom?: any;
  62340. faceUV?: Vector4[];
  62341. faceColors?: Color4[];
  62342. flat?: boolean;
  62343. updatable?: boolean;
  62344. sideOrientation?: number;
  62345. frontUVs?: Vector4;
  62346. backUVs?: Vector4;
  62347. }, scene?: Nullable<Scene>): Mesh;
  62348. /**
  62349. * Creates a decal mesh.
  62350. * 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
  62351. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62352. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62353. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62354. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62355. * @param name defines the name of the mesh
  62356. * @param sourceMesh defines the mesh where the decal must be applied
  62357. * @param options defines the options used to create the mesh
  62358. * @param scene defines the hosting scene
  62359. * @returns the decal mesh
  62360. * @see https://doc.babylonjs.com/how_to/decals
  62361. */
  62362. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62363. position?: Vector3;
  62364. normal?: Vector3;
  62365. size?: Vector3;
  62366. angle?: number;
  62367. }): Mesh;
  62368. }
  62369. }
  62370. declare module BABYLON {
  62371. /**
  62372. * A simplifier interface for future simplification implementations
  62373. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62374. */
  62375. export interface ISimplifier {
  62376. /**
  62377. * Simplification of a given mesh according to the given settings.
  62378. * Since this requires computation, it is assumed that the function runs async.
  62379. * @param settings The settings of the simplification, including quality and distance
  62380. * @param successCallback A callback that will be called after the mesh was simplified.
  62381. * @param errorCallback in case of an error, this callback will be called. optional.
  62382. */
  62383. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62384. }
  62385. /**
  62386. * Expected simplification settings.
  62387. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62388. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62389. */
  62390. export interface ISimplificationSettings {
  62391. /**
  62392. * Gets or sets the expected quality
  62393. */
  62394. quality: number;
  62395. /**
  62396. * Gets or sets the distance when this optimized version should be used
  62397. */
  62398. distance: number;
  62399. /**
  62400. * Gets an already optimized mesh
  62401. */
  62402. optimizeMesh?: boolean;
  62403. }
  62404. /**
  62405. * Class used to specify simplification options
  62406. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62407. */
  62408. export class SimplificationSettings implements ISimplificationSettings {
  62409. /** expected quality */
  62410. quality: number;
  62411. /** distance when this optimized version should be used */
  62412. distance: number;
  62413. /** already optimized mesh */
  62414. optimizeMesh?: boolean | undefined;
  62415. /**
  62416. * Creates a SimplificationSettings
  62417. * @param quality expected quality
  62418. * @param distance distance when this optimized version should be used
  62419. * @param optimizeMesh already optimized mesh
  62420. */
  62421. constructor(
  62422. /** expected quality */
  62423. quality: number,
  62424. /** distance when this optimized version should be used */
  62425. distance: number,
  62426. /** already optimized mesh */
  62427. optimizeMesh?: boolean | undefined);
  62428. }
  62429. /**
  62430. * Interface used to define a simplification task
  62431. */
  62432. export interface ISimplificationTask {
  62433. /**
  62434. * Array of settings
  62435. */
  62436. settings: Array<ISimplificationSettings>;
  62437. /**
  62438. * Simplification type
  62439. */
  62440. simplificationType: SimplificationType;
  62441. /**
  62442. * Mesh to simplify
  62443. */
  62444. mesh: Mesh;
  62445. /**
  62446. * Callback called on success
  62447. */
  62448. successCallback?: () => void;
  62449. /**
  62450. * Defines if parallel processing can be used
  62451. */
  62452. parallelProcessing: boolean;
  62453. }
  62454. /**
  62455. * Queue used to order the simplification tasks
  62456. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62457. */
  62458. export class SimplificationQueue {
  62459. private _simplificationArray;
  62460. /**
  62461. * Gets a boolean indicating that the process is still running
  62462. */
  62463. running: boolean;
  62464. /**
  62465. * Creates a new queue
  62466. */
  62467. constructor();
  62468. /**
  62469. * Adds a new simplification task
  62470. * @param task defines a task to add
  62471. */
  62472. addTask(task: ISimplificationTask): void;
  62473. /**
  62474. * Execute next task
  62475. */
  62476. executeNext(): void;
  62477. /**
  62478. * Execute a simplification task
  62479. * @param task defines the task to run
  62480. */
  62481. runSimplification(task: ISimplificationTask): void;
  62482. private getSimplifier;
  62483. }
  62484. /**
  62485. * The implemented types of simplification
  62486. * At the moment only Quadratic Error Decimation is implemented
  62487. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62488. */
  62489. export enum SimplificationType {
  62490. /** Quadratic error decimation */
  62491. QUADRATIC = 0
  62492. }
  62493. /**
  62494. * An implementation of the Quadratic Error simplification algorithm.
  62495. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62496. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62497. * @author RaananW
  62498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62499. */
  62500. export class QuadraticErrorSimplification implements ISimplifier {
  62501. private _mesh;
  62502. private triangles;
  62503. private vertices;
  62504. private references;
  62505. private _reconstructedMesh;
  62506. /** Gets or sets the number pf sync interations */
  62507. syncIterations: number;
  62508. /** Gets or sets the aggressiveness of the simplifier */
  62509. aggressiveness: number;
  62510. /** Gets or sets the number of allowed iterations for decimation */
  62511. decimationIterations: number;
  62512. /** Gets or sets the espilon to use for bounding box computation */
  62513. boundingBoxEpsilon: number;
  62514. /**
  62515. * Creates a new QuadraticErrorSimplification
  62516. * @param _mesh defines the target mesh
  62517. */
  62518. constructor(_mesh: Mesh);
  62519. /**
  62520. * Simplification of a given mesh according to the given settings.
  62521. * Since this requires computation, it is assumed that the function runs async.
  62522. * @param settings The settings of the simplification, including quality and distance
  62523. * @param successCallback A callback that will be called after the mesh was simplified.
  62524. */
  62525. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62526. private runDecimation;
  62527. private initWithMesh;
  62528. private init;
  62529. private reconstructMesh;
  62530. private initDecimatedMesh;
  62531. private isFlipped;
  62532. private updateTriangles;
  62533. private identifyBorder;
  62534. private updateMesh;
  62535. private vertexError;
  62536. private calculateError;
  62537. }
  62538. }
  62539. declare module BABYLON {
  62540. interface Scene {
  62541. /** @hidden (Backing field) */
  62542. _simplificationQueue: SimplificationQueue;
  62543. /**
  62544. * Gets or sets the simplification queue attached to the scene
  62545. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62546. */
  62547. simplificationQueue: SimplificationQueue;
  62548. }
  62549. interface Mesh {
  62550. /**
  62551. * Simplify the mesh according to the given array of settings.
  62552. * Function will return immediately and will simplify async
  62553. * @param settings a collection of simplification settings
  62554. * @param parallelProcessing should all levels calculate parallel or one after the other
  62555. * @param simplificationType the type of simplification to run
  62556. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62557. * @returns the current mesh
  62558. */
  62559. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62560. }
  62561. /**
  62562. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62563. * created in a scene
  62564. */
  62565. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62566. /**
  62567. * The component name helpfull to identify the component in the list of scene components.
  62568. */
  62569. readonly name: string;
  62570. /**
  62571. * The scene the component belongs to.
  62572. */
  62573. scene: Scene;
  62574. /**
  62575. * Creates a new instance of the component for the given scene
  62576. * @param scene Defines the scene to register the component in
  62577. */
  62578. constructor(scene: Scene);
  62579. /**
  62580. * Registers the component in a given scene
  62581. */
  62582. register(): void;
  62583. /**
  62584. * Rebuilds the elements related to this component in case of
  62585. * context lost for instance.
  62586. */
  62587. rebuild(): void;
  62588. /**
  62589. * Disposes the component and the associated ressources
  62590. */
  62591. dispose(): void;
  62592. private _beforeCameraUpdate;
  62593. }
  62594. }
  62595. declare module BABYLON {
  62596. /**
  62597. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62598. */
  62599. export interface INavigationEnginePlugin {
  62600. /**
  62601. * plugin name
  62602. */
  62603. name: string;
  62604. /**
  62605. * Creates a navigation mesh
  62606. * @param meshes array of all the geometry used to compute the navigatio mesh
  62607. * @param parameters bunch of parameters used to filter geometry
  62608. */
  62609. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62610. /**
  62611. * Create a navigation mesh debug mesh
  62612. * @param scene is where the mesh will be added
  62613. * @returns debug display mesh
  62614. */
  62615. createDebugNavMesh(scene: Scene): Mesh;
  62616. /**
  62617. * Get a navigation mesh constrained position, closest to the parameter position
  62618. * @param position world position
  62619. * @returns the closest point to position constrained by the navigation mesh
  62620. */
  62621. getClosestPoint(position: Vector3): Vector3;
  62622. /**
  62623. * Get a navigation mesh constrained position, closest to the parameter position
  62624. * @param position world position
  62625. * @param result output the closest point to position constrained by the navigation mesh
  62626. */
  62627. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62628. /**
  62629. * Get a navigation mesh constrained position, within a particular radius
  62630. * @param position world position
  62631. * @param maxRadius the maximum distance to the constrained world position
  62632. * @returns the closest point to position constrained by the navigation mesh
  62633. */
  62634. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62635. /**
  62636. * Get a navigation mesh constrained position, within a particular radius
  62637. * @param position world position
  62638. * @param maxRadius the maximum distance to the constrained world position
  62639. * @param result output the closest point to position constrained by the navigation mesh
  62640. */
  62641. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62642. /**
  62643. * Compute the final position from a segment made of destination-position
  62644. * @param position world position
  62645. * @param destination world position
  62646. * @returns the resulting point along the navmesh
  62647. */
  62648. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62649. /**
  62650. * Compute the final position from a segment made of destination-position
  62651. * @param position world position
  62652. * @param destination world position
  62653. * @param result output the resulting point along the navmesh
  62654. */
  62655. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62656. /**
  62657. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62658. * @param start world position
  62659. * @param end world position
  62660. * @returns array containing world position composing the path
  62661. */
  62662. computePath(start: Vector3, end: Vector3): Vector3[];
  62663. /**
  62664. * If this plugin is supported
  62665. * @returns true if plugin is supported
  62666. */
  62667. isSupported(): boolean;
  62668. /**
  62669. * Create a new Crowd so you can add agents
  62670. * @param maxAgents the maximum agent count in the crowd
  62671. * @param maxAgentRadius the maximum radius an agent can have
  62672. * @param scene to attach the crowd to
  62673. * @returns the crowd you can add agents to
  62674. */
  62675. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62676. /**
  62677. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62678. * The queries will try to find a solution within those bounds
  62679. * default is (1,1,1)
  62680. * @param extent x,y,z value that define the extent around the queries point of reference
  62681. */
  62682. setDefaultQueryExtent(extent: Vector3): void;
  62683. /**
  62684. * Get the Bounding box extent specified by setDefaultQueryExtent
  62685. * @returns the box extent values
  62686. */
  62687. getDefaultQueryExtent(): Vector3;
  62688. /**
  62689. * build the navmesh from a previously saved state using getNavmeshData
  62690. * @param data the Uint8Array returned by getNavmeshData
  62691. */
  62692. buildFromNavmeshData(data: Uint8Array): void;
  62693. /**
  62694. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62695. * @returns data the Uint8Array that can be saved and reused
  62696. */
  62697. getNavmeshData(): Uint8Array;
  62698. /**
  62699. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62700. * @param result output the box extent values
  62701. */
  62702. getDefaultQueryExtentToRef(result: Vector3): void;
  62703. /**
  62704. * Release all resources
  62705. */
  62706. dispose(): void;
  62707. }
  62708. /**
  62709. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62710. */
  62711. export interface ICrowd {
  62712. /**
  62713. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62714. * You can attach anything to that node. The node position is updated in the scene update tick.
  62715. * @param pos world position that will be constrained by the navigation mesh
  62716. * @param parameters agent parameters
  62717. * @param transform hooked to the agent that will be update by the scene
  62718. * @returns agent index
  62719. */
  62720. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62721. /**
  62722. * Returns the agent position in world space
  62723. * @param index agent index returned by addAgent
  62724. * @returns world space position
  62725. */
  62726. getAgentPosition(index: number): Vector3;
  62727. /**
  62728. * Gets the agent position result in world space
  62729. * @param index agent index returned by addAgent
  62730. * @param result output world space position
  62731. */
  62732. getAgentPositionToRef(index: number, result: Vector3): void;
  62733. /**
  62734. * Gets the agent velocity in world space
  62735. * @param index agent index returned by addAgent
  62736. * @returns world space velocity
  62737. */
  62738. getAgentVelocity(index: number): Vector3;
  62739. /**
  62740. * Gets the agent velocity result in world space
  62741. * @param index agent index returned by addAgent
  62742. * @param result output world space velocity
  62743. */
  62744. getAgentVelocityToRef(index: number, result: Vector3): void;
  62745. /**
  62746. * remove a particular agent previously created
  62747. * @param index agent index returned by addAgent
  62748. */
  62749. removeAgent(index: number): void;
  62750. /**
  62751. * get the list of all agents attached to this crowd
  62752. * @returns list of agent indices
  62753. */
  62754. getAgents(): number[];
  62755. /**
  62756. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62757. * @param deltaTime in seconds
  62758. */
  62759. update(deltaTime: number): void;
  62760. /**
  62761. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62762. * @param index agent index returned by addAgent
  62763. * @param destination targeted world position
  62764. */
  62765. agentGoto(index: number, destination: Vector3): void;
  62766. /**
  62767. * Teleport the agent to a new position
  62768. * @param index agent index returned by addAgent
  62769. * @param destination targeted world position
  62770. */
  62771. agentTeleport(index: number, destination: Vector3): void;
  62772. /**
  62773. * Update agent parameters
  62774. * @param index agent index returned by addAgent
  62775. * @param parameters agent parameters
  62776. */
  62777. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62778. /**
  62779. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62780. * The queries will try to find a solution within those bounds
  62781. * default is (1,1,1)
  62782. * @param extent x,y,z value that define the extent around the queries point of reference
  62783. */
  62784. setDefaultQueryExtent(extent: Vector3): void;
  62785. /**
  62786. * Get the Bounding box extent specified by setDefaultQueryExtent
  62787. * @returns the box extent values
  62788. */
  62789. getDefaultQueryExtent(): Vector3;
  62790. /**
  62791. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62792. * @param result output the box extent values
  62793. */
  62794. getDefaultQueryExtentToRef(result: Vector3): void;
  62795. /**
  62796. * Release all resources
  62797. */
  62798. dispose(): void;
  62799. }
  62800. /**
  62801. * Configures an agent
  62802. */
  62803. export interface IAgentParameters {
  62804. /**
  62805. * Agent radius. [Limit: >= 0]
  62806. */
  62807. radius: number;
  62808. /**
  62809. * Agent height. [Limit: > 0]
  62810. */
  62811. height: number;
  62812. /**
  62813. * Maximum allowed acceleration. [Limit: >= 0]
  62814. */
  62815. maxAcceleration: number;
  62816. /**
  62817. * Maximum allowed speed. [Limit: >= 0]
  62818. */
  62819. maxSpeed: number;
  62820. /**
  62821. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62822. */
  62823. collisionQueryRange: number;
  62824. /**
  62825. * The path visibility optimization range. [Limit: > 0]
  62826. */
  62827. pathOptimizationRange: number;
  62828. /**
  62829. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62830. */
  62831. separationWeight: number;
  62832. }
  62833. /**
  62834. * Configures the navigation mesh creation
  62835. */
  62836. export interface INavMeshParameters {
  62837. /**
  62838. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62839. */
  62840. cs: number;
  62841. /**
  62842. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62843. */
  62844. ch: number;
  62845. /**
  62846. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62847. */
  62848. walkableSlopeAngle: number;
  62849. /**
  62850. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62851. * be considered walkable. [Limit: >= 3] [Units: vx]
  62852. */
  62853. walkableHeight: number;
  62854. /**
  62855. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62856. */
  62857. walkableClimb: number;
  62858. /**
  62859. * The distance to erode/shrink the walkable area of the heightfield away from
  62860. * obstructions. [Limit: >=0] [Units: vx]
  62861. */
  62862. walkableRadius: number;
  62863. /**
  62864. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62865. */
  62866. maxEdgeLen: number;
  62867. /**
  62868. * The maximum distance a simplfied contour's border edges should deviate
  62869. * the original raw contour. [Limit: >=0] [Units: vx]
  62870. */
  62871. maxSimplificationError: number;
  62872. /**
  62873. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62874. */
  62875. minRegionArea: number;
  62876. /**
  62877. * Any regions with a span count smaller than this value will, if possible,
  62878. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62879. */
  62880. mergeRegionArea: number;
  62881. /**
  62882. * The maximum number of vertices allowed for polygons generated during the
  62883. * contour to polygon conversion process. [Limit: >= 3]
  62884. */
  62885. maxVertsPerPoly: number;
  62886. /**
  62887. * Sets the sampling distance to use when generating the detail mesh.
  62888. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62889. */
  62890. detailSampleDist: number;
  62891. /**
  62892. * The maximum distance the detail mesh surface should deviate from heightfield
  62893. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62894. */
  62895. detailSampleMaxError: number;
  62896. }
  62897. }
  62898. declare module BABYLON {
  62899. /**
  62900. * RecastJS navigation plugin
  62901. */
  62902. export class RecastJSPlugin implements INavigationEnginePlugin {
  62903. /**
  62904. * Reference to the Recast library
  62905. */
  62906. bjsRECAST: any;
  62907. /**
  62908. * plugin name
  62909. */
  62910. name: string;
  62911. /**
  62912. * the first navmesh created. We might extend this to support multiple navmeshes
  62913. */
  62914. navMesh: any;
  62915. /**
  62916. * Initializes the recastJS plugin
  62917. * @param recastInjection can be used to inject your own recast reference
  62918. */
  62919. constructor(recastInjection?: any);
  62920. /**
  62921. * Creates a navigation mesh
  62922. * @param meshes array of all the geometry used to compute the navigatio mesh
  62923. * @param parameters bunch of parameters used to filter geometry
  62924. */
  62925. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62926. /**
  62927. * Create a navigation mesh debug mesh
  62928. * @param scene is where the mesh will be added
  62929. * @returns debug display mesh
  62930. */
  62931. createDebugNavMesh(scene: Scene): Mesh;
  62932. /**
  62933. * Get a navigation mesh constrained position, closest to the parameter position
  62934. * @param position world position
  62935. * @returns the closest point to position constrained by the navigation mesh
  62936. */
  62937. getClosestPoint(position: Vector3): Vector3;
  62938. /**
  62939. * Get a navigation mesh constrained position, closest to the parameter position
  62940. * @param position world position
  62941. * @param result output the closest point to position constrained by the navigation mesh
  62942. */
  62943. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62944. /**
  62945. * Get a navigation mesh constrained position, within a particular radius
  62946. * @param position world position
  62947. * @param maxRadius the maximum distance to the constrained world position
  62948. * @returns the closest point to position constrained by the navigation mesh
  62949. */
  62950. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62951. /**
  62952. * Get a navigation mesh constrained position, within a particular radius
  62953. * @param position world position
  62954. * @param maxRadius the maximum distance to the constrained world position
  62955. * @param result output the closest point to position constrained by the navigation mesh
  62956. */
  62957. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62958. /**
  62959. * Compute the final position from a segment made of destination-position
  62960. * @param position world position
  62961. * @param destination world position
  62962. * @returns the resulting point along the navmesh
  62963. */
  62964. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62965. /**
  62966. * Compute the final position from a segment made of destination-position
  62967. * @param position world position
  62968. * @param destination world position
  62969. * @param result output the resulting point along the navmesh
  62970. */
  62971. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62972. /**
  62973. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62974. * @param start world position
  62975. * @param end world position
  62976. * @returns array containing world position composing the path
  62977. */
  62978. computePath(start: Vector3, end: Vector3): Vector3[];
  62979. /**
  62980. * Create a new Crowd so you can add agents
  62981. * @param maxAgents the maximum agent count in the crowd
  62982. * @param maxAgentRadius the maximum radius an agent can have
  62983. * @param scene to attach the crowd to
  62984. * @returns the crowd you can add agents to
  62985. */
  62986. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62987. /**
  62988. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62989. * The queries will try to find a solution within those bounds
  62990. * default is (1,1,1)
  62991. * @param extent x,y,z value that define the extent around the queries point of reference
  62992. */
  62993. setDefaultQueryExtent(extent: Vector3): void;
  62994. /**
  62995. * Get the Bounding box extent specified by setDefaultQueryExtent
  62996. * @returns the box extent values
  62997. */
  62998. getDefaultQueryExtent(): Vector3;
  62999. /**
  63000. * build the navmesh from a previously saved state using getNavmeshData
  63001. * @param data the Uint8Array returned by getNavmeshData
  63002. */
  63003. buildFromNavmeshData(data: Uint8Array): void;
  63004. /**
  63005. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  63006. * @returns data the Uint8Array that can be saved and reused
  63007. */
  63008. getNavmeshData(): Uint8Array;
  63009. /**
  63010. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63011. * @param result output the box extent values
  63012. */
  63013. getDefaultQueryExtentToRef(result: Vector3): void;
  63014. /**
  63015. * Disposes
  63016. */
  63017. dispose(): void;
  63018. /**
  63019. * If this plugin is supported
  63020. * @returns true if plugin is supported
  63021. */
  63022. isSupported(): boolean;
  63023. }
  63024. /**
  63025. * Recast detour crowd implementation
  63026. */
  63027. export class RecastJSCrowd implements ICrowd {
  63028. /**
  63029. * Recast/detour plugin
  63030. */
  63031. bjsRECASTPlugin: RecastJSPlugin;
  63032. /**
  63033. * Link to the detour crowd
  63034. */
  63035. recastCrowd: any;
  63036. /**
  63037. * One transform per agent
  63038. */
  63039. transforms: TransformNode[];
  63040. /**
  63041. * All agents created
  63042. */
  63043. agents: number[];
  63044. /**
  63045. * Link to the scene is kept to unregister the crowd from the scene
  63046. */
  63047. private _scene;
  63048. /**
  63049. * Observer for crowd updates
  63050. */
  63051. private _onBeforeAnimationsObserver;
  63052. /**
  63053. * Constructor
  63054. * @param plugin recastJS plugin
  63055. * @param maxAgents the maximum agent count in the crowd
  63056. * @param maxAgentRadius the maximum radius an agent can have
  63057. * @param scene to attach the crowd to
  63058. * @returns the crowd you can add agents to
  63059. */
  63060. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63061. /**
  63062. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63063. * You can attach anything to that node. The node position is updated in the scene update tick.
  63064. * @param pos world position that will be constrained by the navigation mesh
  63065. * @param parameters agent parameters
  63066. * @param transform hooked to the agent that will be update by the scene
  63067. * @returns agent index
  63068. */
  63069. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63070. /**
  63071. * Returns the agent position in world space
  63072. * @param index agent index returned by addAgent
  63073. * @returns world space position
  63074. */
  63075. getAgentPosition(index: number): Vector3;
  63076. /**
  63077. * Returns the agent position result in world space
  63078. * @param index agent index returned by addAgent
  63079. * @param result output world space position
  63080. */
  63081. getAgentPositionToRef(index: number, result: Vector3): void;
  63082. /**
  63083. * Returns the agent velocity in world space
  63084. * @param index agent index returned by addAgent
  63085. * @returns world space velocity
  63086. */
  63087. getAgentVelocity(index: number): Vector3;
  63088. /**
  63089. * Returns the agent velocity result in world space
  63090. * @param index agent index returned by addAgent
  63091. * @param result output world space velocity
  63092. */
  63093. getAgentVelocityToRef(index: number, result: Vector3): void;
  63094. /**
  63095. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63096. * @param index agent index returned by addAgent
  63097. * @param destination targeted world position
  63098. */
  63099. agentGoto(index: number, destination: Vector3): void;
  63100. /**
  63101. * Teleport the agent to a new position
  63102. * @param index agent index returned by addAgent
  63103. * @param destination targeted world position
  63104. */
  63105. agentTeleport(index: number, destination: Vector3): void;
  63106. /**
  63107. * Update agent parameters
  63108. * @param index agent index returned by addAgent
  63109. * @param parameters agent parameters
  63110. */
  63111. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  63112. /**
  63113. * remove a particular agent previously created
  63114. * @param index agent index returned by addAgent
  63115. */
  63116. removeAgent(index: number): void;
  63117. /**
  63118. * get the list of all agents attached to this crowd
  63119. * @returns list of agent indices
  63120. */
  63121. getAgents(): number[];
  63122. /**
  63123. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63124. * @param deltaTime in seconds
  63125. */
  63126. update(deltaTime: number): void;
  63127. /**
  63128. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63129. * The queries will try to find a solution within those bounds
  63130. * default is (1,1,1)
  63131. * @param extent x,y,z value that define the extent around the queries point of reference
  63132. */
  63133. setDefaultQueryExtent(extent: Vector3): void;
  63134. /**
  63135. * Get the Bounding box extent specified by setDefaultQueryExtent
  63136. * @returns the box extent values
  63137. */
  63138. getDefaultQueryExtent(): Vector3;
  63139. /**
  63140. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63141. * @param result output the box extent values
  63142. */
  63143. getDefaultQueryExtentToRef(result: Vector3): void;
  63144. /**
  63145. * Release all resources
  63146. */
  63147. dispose(): void;
  63148. }
  63149. }
  63150. declare module BABYLON {
  63151. /**
  63152. * Class used to enable access to IndexedDB
  63153. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63154. */
  63155. export class Database implements IOfflineProvider {
  63156. private _callbackManifestChecked;
  63157. private _currentSceneUrl;
  63158. private _db;
  63159. private _enableSceneOffline;
  63160. private _enableTexturesOffline;
  63161. private _manifestVersionFound;
  63162. private _mustUpdateRessources;
  63163. private _hasReachedQuota;
  63164. private _isSupported;
  63165. private _idbFactory;
  63166. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63167. private static IsUASupportingBlobStorage;
  63168. /**
  63169. * Gets a boolean indicating if Database storate is enabled (off by default)
  63170. */
  63171. static IDBStorageEnabled: boolean;
  63172. /**
  63173. * Gets a boolean indicating if scene must be saved in the database
  63174. */
  63175. get enableSceneOffline(): boolean;
  63176. /**
  63177. * Gets a boolean indicating if textures must be saved in the database
  63178. */
  63179. get enableTexturesOffline(): boolean;
  63180. /**
  63181. * Creates a new Database
  63182. * @param urlToScene defines the url to load the scene
  63183. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63184. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63185. */
  63186. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63187. private static _ParseURL;
  63188. private static _ReturnFullUrlLocation;
  63189. private _checkManifestFile;
  63190. /**
  63191. * Open the database and make it available
  63192. * @param successCallback defines the callback to call on success
  63193. * @param errorCallback defines the callback to call on error
  63194. */
  63195. open(successCallback: () => void, errorCallback: () => void): void;
  63196. /**
  63197. * Loads an image from the database
  63198. * @param url defines the url to load from
  63199. * @param image defines the target DOM image
  63200. */
  63201. loadImage(url: string, image: HTMLImageElement): void;
  63202. private _loadImageFromDBAsync;
  63203. private _saveImageIntoDBAsync;
  63204. private _checkVersionFromDB;
  63205. private _loadVersionFromDBAsync;
  63206. private _saveVersionIntoDBAsync;
  63207. /**
  63208. * Loads a file from database
  63209. * @param url defines the URL to load from
  63210. * @param sceneLoaded defines a callback to call on success
  63211. * @param progressCallBack defines a callback to call when progress changed
  63212. * @param errorCallback defines a callback to call on error
  63213. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63214. */
  63215. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63216. private _loadFileAsync;
  63217. private _saveFileAsync;
  63218. /**
  63219. * Validates if xhr data is correct
  63220. * @param xhr defines the request to validate
  63221. * @param dataType defines the expected data type
  63222. * @returns true if data is correct
  63223. */
  63224. private static _ValidateXHRData;
  63225. }
  63226. }
  63227. declare module BABYLON {
  63228. /** @hidden */
  63229. export var gpuUpdateParticlesPixelShader: {
  63230. name: string;
  63231. shader: string;
  63232. };
  63233. }
  63234. declare module BABYLON {
  63235. /** @hidden */
  63236. export var gpuUpdateParticlesVertexShader: {
  63237. name: string;
  63238. shader: string;
  63239. };
  63240. }
  63241. declare module BABYLON {
  63242. /** @hidden */
  63243. export var clipPlaneFragmentDeclaration2: {
  63244. name: string;
  63245. shader: string;
  63246. };
  63247. }
  63248. declare module BABYLON {
  63249. /** @hidden */
  63250. export var gpuRenderParticlesPixelShader: {
  63251. name: string;
  63252. shader: string;
  63253. };
  63254. }
  63255. declare module BABYLON {
  63256. /** @hidden */
  63257. export var clipPlaneVertexDeclaration2: {
  63258. name: string;
  63259. shader: string;
  63260. };
  63261. }
  63262. declare module BABYLON {
  63263. /** @hidden */
  63264. export var gpuRenderParticlesVertexShader: {
  63265. name: string;
  63266. shader: string;
  63267. };
  63268. }
  63269. declare module BABYLON {
  63270. /**
  63271. * This represents a GPU particle system in Babylon
  63272. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63273. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63274. */
  63275. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63276. /**
  63277. * The layer mask we are rendering the particles through.
  63278. */
  63279. layerMask: number;
  63280. private _capacity;
  63281. private _activeCount;
  63282. private _currentActiveCount;
  63283. private _accumulatedCount;
  63284. private _renderEffect;
  63285. private _updateEffect;
  63286. private _buffer0;
  63287. private _buffer1;
  63288. private _spriteBuffer;
  63289. private _updateVAO;
  63290. private _renderVAO;
  63291. private _targetIndex;
  63292. private _sourceBuffer;
  63293. private _targetBuffer;
  63294. private _engine;
  63295. private _currentRenderId;
  63296. private _started;
  63297. private _stopped;
  63298. private _timeDelta;
  63299. private _randomTexture;
  63300. private _randomTexture2;
  63301. private _attributesStrideSize;
  63302. private _updateEffectOptions;
  63303. private _randomTextureSize;
  63304. private _actualFrame;
  63305. private readonly _rawTextureWidth;
  63306. /**
  63307. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63308. */
  63309. static get IsSupported(): boolean;
  63310. /**
  63311. * An event triggered when the system is disposed.
  63312. */
  63313. onDisposeObservable: Observable<GPUParticleSystem>;
  63314. /**
  63315. * Gets the maximum number of particles active at the same time.
  63316. * @returns The max number of active particles.
  63317. */
  63318. getCapacity(): number;
  63319. /**
  63320. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63321. * to override the particles.
  63322. */
  63323. forceDepthWrite: boolean;
  63324. /**
  63325. * Gets or set the number of active particles
  63326. */
  63327. get activeParticleCount(): number;
  63328. set activeParticleCount(value: number);
  63329. private _preWarmDone;
  63330. /**
  63331. * Specifies if the particles are updated in emitter local space or world space.
  63332. * This is always false for GPU particles
  63333. */
  63334. get isLocal(): boolean;
  63335. set isLocal(value: boolean);
  63336. /**
  63337. * Is this system ready to be used/rendered
  63338. * @return true if the system is ready
  63339. */
  63340. isReady(): boolean;
  63341. /**
  63342. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63343. * @returns True if it has been started, otherwise false.
  63344. */
  63345. isStarted(): boolean;
  63346. /**
  63347. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63348. * @returns True if it has been stopped, otherwise false.
  63349. */
  63350. isStopped(): boolean;
  63351. /**
  63352. * Gets a boolean indicating that the system is stopping
  63353. * @returns true if the system is currently stopping
  63354. */
  63355. isStopping(): boolean;
  63356. /**
  63357. * Gets the number of particles active at the same time.
  63358. * @returns The number of active particles.
  63359. */
  63360. getActiveCount(): number;
  63361. /**
  63362. * Starts the particle system and begins to emit
  63363. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63364. */
  63365. start(delay?: number): void;
  63366. /**
  63367. * Stops the particle system.
  63368. */
  63369. stop(): void;
  63370. /**
  63371. * Remove all active particles
  63372. */
  63373. reset(): void;
  63374. /**
  63375. * Returns the string "GPUParticleSystem"
  63376. * @returns a string containing the class name
  63377. */
  63378. getClassName(): string;
  63379. private _colorGradientsTexture;
  63380. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63381. /**
  63382. * Adds a new color gradient
  63383. * @param gradient defines the gradient to use (between 0 and 1)
  63384. * @param color1 defines the color to affect to the specified gradient
  63385. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63386. * @returns the current particle system
  63387. */
  63388. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63389. private _refreshColorGradient;
  63390. /** Force the system to rebuild all gradients that need to be resync */
  63391. forceRefreshGradients(): void;
  63392. /**
  63393. * Remove a specific color gradient
  63394. * @param gradient defines the gradient to remove
  63395. * @returns the current particle system
  63396. */
  63397. removeColorGradient(gradient: number): GPUParticleSystem;
  63398. private _angularSpeedGradientsTexture;
  63399. private _sizeGradientsTexture;
  63400. private _velocityGradientsTexture;
  63401. private _limitVelocityGradientsTexture;
  63402. private _dragGradientsTexture;
  63403. private _addFactorGradient;
  63404. /**
  63405. * Adds a new size gradient
  63406. * @param gradient defines the gradient to use (between 0 and 1)
  63407. * @param factor defines the size factor to affect to the specified gradient
  63408. * @returns the current particle system
  63409. */
  63410. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63411. /**
  63412. * Remove a specific size gradient
  63413. * @param gradient defines the gradient to remove
  63414. * @returns the current particle system
  63415. */
  63416. removeSizeGradient(gradient: number): GPUParticleSystem;
  63417. private _refreshFactorGradient;
  63418. /**
  63419. * Adds a new angular speed gradient
  63420. * @param gradient defines the gradient to use (between 0 and 1)
  63421. * @param factor defines the angular speed to affect to the specified gradient
  63422. * @returns the current particle system
  63423. */
  63424. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63425. /**
  63426. * Remove a specific angular speed gradient
  63427. * @param gradient defines the gradient to remove
  63428. * @returns the current particle system
  63429. */
  63430. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63431. /**
  63432. * Adds a new velocity gradient
  63433. * @param gradient defines the gradient to use (between 0 and 1)
  63434. * @param factor defines the velocity to affect to the specified gradient
  63435. * @returns the current particle system
  63436. */
  63437. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63438. /**
  63439. * Remove a specific velocity gradient
  63440. * @param gradient defines the gradient to remove
  63441. * @returns the current particle system
  63442. */
  63443. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63444. /**
  63445. * Adds a new limit velocity gradient
  63446. * @param gradient defines the gradient to use (between 0 and 1)
  63447. * @param factor defines the limit velocity value to affect to the specified gradient
  63448. * @returns the current particle system
  63449. */
  63450. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63451. /**
  63452. * Remove a specific limit velocity gradient
  63453. * @param gradient defines the gradient to remove
  63454. * @returns the current particle system
  63455. */
  63456. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63457. /**
  63458. * Adds a new drag gradient
  63459. * @param gradient defines the gradient to use (between 0 and 1)
  63460. * @param factor defines the drag value to affect to the specified gradient
  63461. * @returns the current particle system
  63462. */
  63463. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63464. /**
  63465. * Remove a specific drag gradient
  63466. * @param gradient defines the gradient to remove
  63467. * @returns the current particle system
  63468. */
  63469. removeDragGradient(gradient: number): GPUParticleSystem;
  63470. /**
  63471. * Not supported by GPUParticleSystem
  63472. * @param gradient defines the gradient to use (between 0 and 1)
  63473. * @param factor defines the emit rate value to affect to the specified gradient
  63474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63475. * @returns the current particle system
  63476. */
  63477. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63478. /**
  63479. * Not supported by GPUParticleSystem
  63480. * @param gradient defines the gradient to remove
  63481. * @returns the current particle system
  63482. */
  63483. removeEmitRateGradient(gradient: number): IParticleSystem;
  63484. /**
  63485. * Not supported by GPUParticleSystem
  63486. * @param gradient defines the gradient to use (between 0 and 1)
  63487. * @param factor defines the start size value to affect to the specified gradient
  63488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63489. * @returns the current particle system
  63490. */
  63491. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63492. /**
  63493. * Not supported by GPUParticleSystem
  63494. * @param gradient defines the gradient to remove
  63495. * @returns the current particle system
  63496. */
  63497. removeStartSizeGradient(gradient: number): IParticleSystem;
  63498. /**
  63499. * Not supported by GPUParticleSystem
  63500. * @param gradient defines the gradient to use (between 0 and 1)
  63501. * @param min defines the color remap minimal range
  63502. * @param max defines the color remap maximal range
  63503. * @returns the current particle system
  63504. */
  63505. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63506. /**
  63507. * Not supported by GPUParticleSystem
  63508. * @param gradient defines the gradient to remove
  63509. * @returns the current particle system
  63510. */
  63511. removeColorRemapGradient(): IParticleSystem;
  63512. /**
  63513. * Not supported by GPUParticleSystem
  63514. * @param gradient defines the gradient to use (between 0 and 1)
  63515. * @param min defines the alpha remap minimal range
  63516. * @param max defines the alpha remap maximal range
  63517. * @returns the current particle system
  63518. */
  63519. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63520. /**
  63521. * Not supported by GPUParticleSystem
  63522. * @param gradient defines the gradient to remove
  63523. * @returns the current particle system
  63524. */
  63525. removeAlphaRemapGradient(): IParticleSystem;
  63526. /**
  63527. * Not supported by GPUParticleSystem
  63528. * @param gradient defines the gradient to use (between 0 and 1)
  63529. * @param color defines the color to affect to the specified gradient
  63530. * @returns the current particle system
  63531. */
  63532. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63533. /**
  63534. * Not supported by GPUParticleSystem
  63535. * @param gradient defines the gradient to remove
  63536. * @returns the current particle system
  63537. */
  63538. removeRampGradient(): IParticleSystem;
  63539. /**
  63540. * Not supported by GPUParticleSystem
  63541. * @returns the list of ramp gradients
  63542. */
  63543. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63544. /**
  63545. * Not supported by GPUParticleSystem
  63546. * Gets or sets a boolean indicating that ramp gradients must be used
  63547. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63548. */
  63549. get useRampGradients(): boolean;
  63550. set useRampGradients(value: boolean);
  63551. /**
  63552. * Not supported by GPUParticleSystem
  63553. * @param gradient defines the gradient to use (between 0 and 1)
  63554. * @param factor defines the life time factor to affect to the specified gradient
  63555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63556. * @returns the current particle system
  63557. */
  63558. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63559. /**
  63560. * Not supported by GPUParticleSystem
  63561. * @param gradient defines the gradient to remove
  63562. * @returns the current particle system
  63563. */
  63564. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63565. /**
  63566. * Instantiates a GPU particle system.
  63567. * 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.
  63568. * @param name The name of the particle system
  63569. * @param options The options used to create the system
  63570. * @param scene The scene the particle system belongs to
  63571. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63572. */
  63573. constructor(name: string, options: Partial<{
  63574. capacity: number;
  63575. randomTextureSize: number;
  63576. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63577. protected _reset(): void;
  63578. private _createUpdateVAO;
  63579. private _createRenderVAO;
  63580. private _initialize;
  63581. /** @hidden */
  63582. _recreateUpdateEffect(): void;
  63583. /** @hidden */
  63584. _recreateRenderEffect(): void;
  63585. /**
  63586. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63587. * @param preWarm defines if we are in the pre-warmimg phase
  63588. */
  63589. animate(preWarm?: boolean): void;
  63590. private _createFactorGradientTexture;
  63591. private _createSizeGradientTexture;
  63592. private _createAngularSpeedGradientTexture;
  63593. private _createVelocityGradientTexture;
  63594. private _createLimitVelocityGradientTexture;
  63595. private _createDragGradientTexture;
  63596. private _createColorGradientTexture;
  63597. /**
  63598. * Renders the particle system in its current state
  63599. * @param preWarm defines if the system should only update the particles but not render them
  63600. * @returns the current number of particles
  63601. */
  63602. render(preWarm?: boolean): number;
  63603. /**
  63604. * Rebuilds the particle system
  63605. */
  63606. rebuild(): void;
  63607. private _releaseBuffers;
  63608. private _releaseVAOs;
  63609. /**
  63610. * Disposes the particle system and free the associated resources
  63611. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63612. */
  63613. dispose(disposeTexture?: boolean): void;
  63614. /**
  63615. * Clones the particle system.
  63616. * @param name The name of the cloned object
  63617. * @param newEmitter The new emitter to use
  63618. * @returns the cloned particle system
  63619. */
  63620. clone(name: string, newEmitter: any): GPUParticleSystem;
  63621. /**
  63622. * Serializes the particle system to a JSON object
  63623. * @param serializeTexture defines if the texture must be serialized as well
  63624. * @returns the JSON object
  63625. */
  63626. serialize(serializeTexture?: boolean): any;
  63627. /**
  63628. * Parses a JSON object to create a GPU particle system.
  63629. * @param parsedParticleSystem The JSON object to parse
  63630. * @param scene The scene to create the particle system in
  63631. * @param rootUrl The root url to use to load external dependencies like texture
  63632. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63633. * @returns the parsed GPU particle system
  63634. */
  63635. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63636. }
  63637. }
  63638. declare module BABYLON {
  63639. /**
  63640. * Represents a set of particle systems working together to create a specific effect
  63641. */
  63642. export class ParticleSystemSet implements IDisposable {
  63643. /**
  63644. * Gets or sets base Assets URL
  63645. */
  63646. static BaseAssetsUrl: string;
  63647. private _emitterCreationOptions;
  63648. private _emitterNode;
  63649. /**
  63650. * Gets the particle system list
  63651. */
  63652. systems: IParticleSystem[];
  63653. /**
  63654. * Gets the emitter node used with this set
  63655. */
  63656. get emitterNode(): Nullable<TransformNode>;
  63657. /**
  63658. * Creates a new emitter mesh as a sphere
  63659. * @param options defines the options used to create the sphere
  63660. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63661. * @param scene defines the hosting scene
  63662. */
  63663. setEmitterAsSphere(options: {
  63664. diameter: number;
  63665. segments: number;
  63666. color: Color3;
  63667. }, renderingGroupId: number, scene: Scene): void;
  63668. /**
  63669. * Starts all particle systems of the set
  63670. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63671. */
  63672. start(emitter?: AbstractMesh): void;
  63673. /**
  63674. * Release all associated resources
  63675. */
  63676. dispose(): void;
  63677. /**
  63678. * Serialize the set into a JSON compatible object
  63679. * @param serializeTexture defines if the texture must be serialized as well
  63680. * @returns a JSON compatible representation of the set
  63681. */
  63682. serialize(serializeTexture?: boolean): any;
  63683. /**
  63684. * Parse a new ParticleSystemSet from a serialized source
  63685. * @param data defines a JSON compatible representation of the set
  63686. * @param scene defines the hosting scene
  63687. * @param gpu defines if we want GPU particles or CPU particles
  63688. * @returns a new ParticleSystemSet
  63689. */
  63690. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63691. }
  63692. }
  63693. declare module BABYLON {
  63694. /**
  63695. * This class is made for on one-liner static method to help creating particle system set.
  63696. */
  63697. export class ParticleHelper {
  63698. /**
  63699. * Gets or sets base Assets URL
  63700. */
  63701. static BaseAssetsUrl: string;
  63702. /** Define the Url to load snippets */
  63703. static SnippetUrl: string;
  63704. /**
  63705. * Create a default particle system that you can tweak
  63706. * @param emitter defines the emitter to use
  63707. * @param capacity defines the system capacity (default is 500 particles)
  63708. * @param scene defines the hosting scene
  63709. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63710. * @returns the new Particle system
  63711. */
  63712. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63713. /**
  63714. * This is the main static method (one-liner) of this helper to create different particle systems
  63715. * @param type This string represents the type to the particle system to create
  63716. * @param scene The scene where the particle system should live
  63717. * @param gpu If the system will use gpu
  63718. * @returns the ParticleSystemSet created
  63719. */
  63720. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63721. /**
  63722. * Static function used to export a particle system to a ParticleSystemSet variable.
  63723. * Please note that the emitter shape is not exported
  63724. * @param systems defines the particle systems to export
  63725. * @returns the created particle system set
  63726. */
  63727. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63728. /**
  63729. * Creates a particle system from a snippet saved in a remote file
  63730. * @param name defines the name of the particle system to create
  63731. * @param url defines the url to load from
  63732. * @param scene defines the hosting scene
  63733. * @param gpu If the system will use gpu
  63734. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63735. * @returns a promise that will resolve to the new particle system
  63736. */
  63737. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63738. /**
  63739. * Creates a particle system from a snippet saved by the particle system editor
  63740. * @param snippetId defines the snippet to load
  63741. * @param scene defines the hosting scene
  63742. * @param gpu If the system will use gpu
  63743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63744. * @returns a promise that will resolve to the new particle system
  63745. */
  63746. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63747. }
  63748. }
  63749. declare module BABYLON {
  63750. interface Engine {
  63751. /**
  63752. * Create an effect to use with particle systems.
  63753. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63754. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63755. * @param uniformsNames defines a list of attribute names
  63756. * @param samplers defines an array of string used to represent textures
  63757. * @param defines defines the string containing the defines to use to compile the shaders
  63758. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63759. * @param onCompiled defines a function to call when the effect creation is successful
  63760. * @param onError defines a function to call when the effect creation has failed
  63761. * @returns the new Effect
  63762. */
  63763. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63764. }
  63765. interface Mesh {
  63766. /**
  63767. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63768. * @returns an array of IParticleSystem
  63769. */
  63770. getEmittedParticleSystems(): IParticleSystem[];
  63771. /**
  63772. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63773. * @returns an array of IParticleSystem
  63774. */
  63775. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63776. }
  63777. /**
  63778. * @hidden
  63779. */
  63780. export var _IDoNeedToBeInTheBuild: number;
  63781. }
  63782. declare module BABYLON {
  63783. /** Defines the 4 color options */
  63784. export enum PointColor {
  63785. /** color value */
  63786. Color = 2,
  63787. /** uv value */
  63788. UV = 1,
  63789. /** random value */
  63790. Random = 0,
  63791. /** stated value */
  63792. Stated = 3
  63793. }
  63794. /**
  63795. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63796. * 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.
  63797. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63799. *
  63800. * Full documentation here : TO BE ENTERED
  63801. */
  63802. export class PointsCloudSystem implements IDisposable {
  63803. /**
  63804. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63805. * Example : var p = SPS.particles[i];
  63806. */
  63807. particles: CloudPoint[];
  63808. /**
  63809. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63810. */
  63811. nbParticles: number;
  63812. /**
  63813. * This a counter for your own usage. It's not set by any SPS functions.
  63814. */
  63815. counter: number;
  63816. /**
  63817. * The PCS name. This name is also given to the underlying mesh.
  63818. */
  63819. name: string;
  63820. /**
  63821. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63822. */
  63823. mesh: Mesh;
  63824. /**
  63825. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63826. * Please read :
  63827. */
  63828. vars: any;
  63829. /**
  63830. * @hidden
  63831. */
  63832. _size: number;
  63833. private _scene;
  63834. private _promises;
  63835. private _positions;
  63836. private _indices;
  63837. private _normals;
  63838. private _colors;
  63839. private _uvs;
  63840. private _indices32;
  63841. private _positions32;
  63842. private _colors32;
  63843. private _uvs32;
  63844. private _updatable;
  63845. private _isVisibilityBoxLocked;
  63846. private _alwaysVisible;
  63847. private _groups;
  63848. private _groupCounter;
  63849. private _computeParticleColor;
  63850. private _computeParticleTexture;
  63851. private _computeParticleRotation;
  63852. private _computeBoundingBox;
  63853. private _isReady;
  63854. /**
  63855. * Creates a PCS (Points Cloud System) object
  63856. * @param name (String) is the PCS name, this will be the underlying mesh name
  63857. * @param pointSize (number) is the size for each point
  63858. * @param scene (Scene) is the scene in which the PCS is added
  63859. * @param options defines the options of the PCS e.g.
  63860. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63861. */
  63862. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63863. updatable?: boolean;
  63864. });
  63865. /**
  63866. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63867. * If no points were added to the PCS, the returned mesh is just a single point.
  63868. * @returns a promise for the created mesh
  63869. */
  63870. buildMeshAsync(): Promise<Mesh>;
  63871. /**
  63872. * @hidden
  63873. */
  63874. private _buildMesh;
  63875. private _addParticle;
  63876. private _randomUnitVector;
  63877. private _getColorIndicesForCoord;
  63878. private _setPointsColorOrUV;
  63879. private _colorFromTexture;
  63880. private _calculateDensity;
  63881. /**
  63882. * Adds points to the PCS in random positions within a unit sphere
  63883. * @param nb (positive integer) the number of particles to be created from this model
  63884. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63885. * @returns the number of groups in the system
  63886. */
  63887. addPoints(nb: number, pointFunction?: any): number;
  63888. /**
  63889. * Adds points to the PCS from the surface of the model shape
  63890. * @param mesh is any Mesh object that will be used as a surface model for the points
  63891. * @param nb (positive integer) the number of particles to be created from this model
  63892. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63893. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63894. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63895. * @returns the number of groups in the system
  63896. */
  63897. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63898. /**
  63899. * Adds points to the PCS inside the model shape
  63900. * @param mesh is any Mesh object that will be used as a surface model for the points
  63901. * @param nb (positive integer) the number of particles to be created from this model
  63902. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63903. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63904. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63905. * @returns the number of groups in the system
  63906. */
  63907. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63908. /**
  63909. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63910. * This method calls `updateParticle()` for each particle of the SPS.
  63911. * For an animated SPS, it is usually called within the render loop.
  63912. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63913. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63914. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63915. * @returns the PCS.
  63916. */
  63917. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63918. /**
  63919. * Disposes the PCS.
  63920. */
  63921. dispose(): void;
  63922. /**
  63923. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63924. * doc :
  63925. * @returns the PCS.
  63926. */
  63927. refreshVisibleSize(): PointsCloudSystem;
  63928. /**
  63929. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63930. * @param size the size (float) of the visibility box
  63931. * note : this doesn't lock the PCS mesh bounding box.
  63932. * doc :
  63933. */
  63934. setVisibilityBox(size: number): void;
  63935. /**
  63936. * Gets whether the PCS is always visible or not
  63937. * doc :
  63938. */
  63939. get isAlwaysVisible(): boolean;
  63940. /**
  63941. * Sets the PCS as always visible or not
  63942. * doc :
  63943. */
  63944. set isAlwaysVisible(val: boolean);
  63945. /**
  63946. * Tells to `setParticles()` to compute the particle rotations or not
  63947. * Default value : false. The PCS is faster when it's set to false
  63948. * Note : particle rotations are only applied to parent particles
  63949. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63950. */
  63951. set computeParticleRotation(val: boolean);
  63952. /**
  63953. * Tells to `setParticles()` to compute the particle colors or not.
  63954. * Default value : true. The PCS is faster when it's set to false.
  63955. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63956. */
  63957. set computeParticleColor(val: boolean);
  63958. set computeParticleTexture(val: boolean);
  63959. /**
  63960. * Gets if `setParticles()` computes the particle colors or not.
  63961. * Default value : false. The PCS is faster when it's set to false.
  63962. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63963. */
  63964. get computeParticleColor(): boolean;
  63965. /**
  63966. * Gets if `setParticles()` computes the particle textures or not.
  63967. * Default value : false. The PCS is faster when it's set to false.
  63968. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63969. */
  63970. get computeParticleTexture(): boolean;
  63971. /**
  63972. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63973. */
  63974. set computeBoundingBox(val: boolean);
  63975. /**
  63976. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63977. */
  63978. get computeBoundingBox(): boolean;
  63979. /**
  63980. * This function does nothing. It may be overwritten to set all the particle first values.
  63981. * The PCS doesn't call this function, you may have to call it by your own.
  63982. * doc :
  63983. */
  63984. initParticles(): void;
  63985. /**
  63986. * This function does nothing. It may be overwritten to recycle a particle
  63987. * The PCS doesn't call this function, you can to call it
  63988. * doc :
  63989. * @param particle The particle to recycle
  63990. * @returns the recycled particle
  63991. */
  63992. recycleParticle(particle: CloudPoint): CloudPoint;
  63993. /**
  63994. * Updates a particle : this function should be overwritten by the user.
  63995. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63996. * doc :
  63997. * @example : just set a particle position or velocity and recycle conditions
  63998. * @param particle The particle to update
  63999. * @returns the updated particle
  64000. */
  64001. updateParticle(particle: CloudPoint): CloudPoint;
  64002. /**
  64003. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64004. * This does nothing and may be overwritten by the user.
  64005. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64006. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64007. * @param update the boolean update value actually passed to setParticles()
  64008. */
  64009. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64010. /**
  64011. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64012. * This will be passed three parameters.
  64013. * This does nothing and may be overwritten by the user.
  64014. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64015. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64016. * @param update the boolean update value actually passed to setParticles()
  64017. */
  64018. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64019. }
  64020. }
  64021. declare module BABYLON {
  64022. /**
  64023. * Represents one particle of a points cloud system.
  64024. */
  64025. export class CloudPoint {
  64026. /**
  64027. * particle global index
  64028. */
  64029. idx: number;
  64030. /**
  64031. * The color of the particle
  64032. */
  64033. color: Nullable<Color4>;
  64034. /**
  64035. * The world space position of the particle.
  64036. */
  64037. position: Vector3;
  64038. /**
  64039. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64040. */
  64041. rotation: Vector3;
  64042. /**
  64043. * The world space rotation quaternion of the particle.
  64044. */
  64045. rotationQuaternion: Nullable<Quaternion>;
  64046. /**
  64047. * The uv of the particle.
  64048. */
  64049. uv: Nullable<Vector2>;
  64050. /**
  64051. * The current speed of the particle.
  64052. */
  64053. velocity: Vector3;
  64054. /**
  64055. * The pivot point in the particle local space.
  64056. */
  64057. pivot: Vector3;
  64058. /**
  64059. * Must the particle be translated from its pivot point in its local space ?
  64060. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64061. * Default : false
  64062. */
  64063. translateFromPivot: boolean;
  64064. /**
  64065. * Index of this particle in the global "positions" array (Internal use)
  64066. * @hidden
  64067. */
  64068. _pos: number;
  64069. /**
  64070. * @hidden Index of this particle in the global "indices" array (Internal use)
  64071. */
  64072. _ind: number;
  64073. /**
  64074. * Group this particle belongs to
  64075. */
  64076. _group: PointsGroup;
  64077. /**
  64078. * Group id of this particle
  64079. */
  64080. groupId: number;
  64081. /**
  64082. * Index of the particle in its group id (Internal use)
  64083. */
  64084. idxInGroup: number;
  64085. /**
  64086. * @hidden Particle BoundingInfo object (Internal use)
  64087. */
  64088. _boundingInfo: BoundingInfo;
  64089. /**
  64090. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64091. */
  64092. _pcs: PointsCloudSystem;
  64093. /**
  64094. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64095. */
  64096. _stillInvisible: boolean;
  64097. /**
  64098. * @hidden Last computed particle rotation matrix
  64099. */
  64100. _rotationMatrix: number[];
  64101. /**
  64102. * Parent particle Id, if any.
  64103. * Default null.
  64104. */
  64105. parentId: Nullable<number>;
  64106. /**
  64107. * @hidden Internal global position in the PCS.
  64108. */
  64109. _globalPosition: Vector3;
  64110. /**
  64111. * Creates a Point Cloud object.
  64112. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64113. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64114. * @param group (PointsGroup) is the group the particle belongs to
  64115. * @param groupId (integer) is the group identifier in the PCS.
  64116. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64117. * @param pcs defines the PCS it is associated to
  64118. */
  64119. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64120. /**
  64121. * get point size
  64122. */
  64123. get size(): Vector3;
  64124. /**
  64125. * Set point size
  64126. */
  64127. set size(scale: Vector3);
  64128. /**
  64129. * Legacy support, changed quaternion to rotationQuaternion
  64130. */
  64131. get quaternion(): Nullable<Quaternion>;
  64132. /**
  64133. * Legacy support, changed quaternion to rotationQuaternion
  64134. */
  64135. set quaternion(q: Nullable<Quaternion>);
  64136. /**
  64137. * Returns a boolean. True if the particle intersects a mesh, else false
  64138. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64139. * @param target is the object (point or mesh) what the intersection is computed against
  64140. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64141. * @returns true if it intersects
  64142. */
  64143. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64144. /**
  64145. * get the rotation matrix of the particle
  64146. * @hidden
  64147. */
  64148. getRotationMatrix(m: Matrix): void;
  64149. }
  64150. /**
  64151. * Represents a group of points in a points cloud system
  64152. * * PCS internal tool, don't use it manually.
  64153. */
  64154. export class PointsGroup {
  64155. /**
  64156. * The group id
  64157. * @hidden
  64158. */
  64159. groupID: number;
  64160. /**
  64161. * image data for group (internal use)
  64162. * @hidden
  64163. */
  64164. _groupImageData: Nullable<ArrayBufferView>;
  64165. /**
  64166. * Image Width (internal use)
  64167. * @hidden
  64168. */
  64169. _groupImgWidth: number;
  64170. /**
  64171. * Image Height (internal use)
  64172. * @hidden
  64173. */
  64174. _groupImgHeight: number;
  64175. /**
  64176. * Custom position function (internal use)
  64177. * @hidden
  64178. */
  64179. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64180. /**
  64181. * density per facet for surface points
  64182. * @hidden
  64183. */
  64184. _groupDensity: number[];
  64185. /**
  64186. * Only when points are colored by texture carries pointer to texture list array
  64187. * @hidden
  64188. */
  64189. _textureNb: number;
  64190. /**
  64191. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64192. * PCS internal tool, don't use it manually.
  64193. * @hidden
  64194. */
  64195. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64196. }
  64197. }
  64198. declare module BABYLON {
  64199. interface Scene {
  64200. /** @hidden (Backing field) */
  64201. _physicsEngine: Nullable<IPhysicsEngine>;
  64202. /** @hidden */
  64203. _physicsTimeAccumulator: number;
  64204. /**
  64205. * Gets the current physics engine
  64206. * @returns a IPhysicsEngine or null if none attached
  64207. */
  64208. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64209. /**
  64210. * Enables physics to the current scene
  64211. * @param gravity defines the scene's gravity for the physics engine
  64212. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64213. * @return a boolean indicating if the physics engine was initialized
  64214. */
  64215. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64216. /**
  64217. * Disables and disposes the physics engine associated with the scene
  64218. */
  64219. disablePhysicsEngine(): void;
  64220. /**
  64221. * Gets a boolean indicating if there is an active physics engine
  64222. * @returns a boolean indicating if there is an active physics engine
  64223. */
  64224. isPhysicsEnabled(): boolean;
  64225. /**
  64226. * Deletes a physics compound impostor
  64227. * @param compound defines the compound to delete
  64228. */
  64229. deleteCompoundImpostor(compound: any): void;
  64230. /**
  64231. * An event triggered when physic simulation is about to be run
  64232. */
  64233. onBeforePhysicsObservable: Observable<Scene>;
  64234. /**
  64235. * An event triggered when physic simulation has been done
  64236. */
  64237. onAfterPhysicsObservable: Observable<Scene>;
  64238. }
  64239. interface AbstractMesh {
  64240. /** @hidden */
  64241. _physicsImpostor: Nullable<PhysicsImpostor>;
  64242. /**
  64243. * Gets or sets impostor used for physic simulation
  64244. * @see http://doc.babylonjs.com/features/physics_engine
  64245. */
  64246. physicsImpostor: Nullable<PhysicsImpostor>;
  64247. /**
  64248. * Gets the current physics impostor
  64249. * @see http://doc.babylonjs.com/features/physics_engine
  64250. * @returns a physics impostor or null
  64251. */
  64252. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64253. /** Apply a physic impulse to the mesh
  64254. * @param force defines the force to apply
  64255. * @param contactPoint defines where to apply the force
  64256. * @returns the current mesh
  64257. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64258. */
  64259. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64260. /**
  64261. * Creates a physic joint between two meshes
  64262. * @param otherMesh defines the other mesh to use
  64263. * @param pivot1 defines the pivot to use on this mesh
  64264. * @param pivot2 defines the pivot to use on the other mesh
  64265. * @param options defines additional options (can be plugin dependent)
  64266. * @returns the current mesh
  64267. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64268. */
  64269. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64270. /** @hidden */
  64271. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64272. }
  64273. /**
  64274. * Defines the physics engine scene component responsible to manage a physics engine
  64275. */
  64276. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64277. /**
  64278. * The component name helpful to identify the component in the list of scene components.
  64279. */
  64280. readonly name: string;
  64281. /**
  64282. * The scene the component belongs to.
  64283. */
  64284. scene: Scene;
  64285. /**
  64286. * Creates a new instance of the component for the given scene
  64287. * @param scene Defines the scene to register the component in
  64288. */
  64289. constructor(scene: Scene);
  64290. /**
  64291. * Registers the component in a given scene
  64292. */
  64293. register(): void;
  64294. /**
  64295. * Rebuilds the elements related to this component in case of
  64296. * context lost for instance.
  64297. */
  64298. rebuild(): void;
  64299. /**
  64300. * Disposes the component and the associated ressources
  64301. */
  64302. dispose(): void;
  64303. }
  64304. }
  64305. declare module BABYLON {
  64306. /**
  64307. * A helper for physics simulations
  64308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64309. */
  64310. export class PhysicsHelper {
  64311. private _scene;
  64312. private _physicsEngine;
  64313. /**
  64314. * Initializes the Physics helper
  64315. * @param scene Babylon.js scene
  64316. */
  64317. constructor(scene: Scene);
  64318. /**
  64319. * Applies a radial explosion impulse
  64320. * @param origin the origin of the explosion
  64321. * @param radiusOrEventOptions the radius or the options of radial explosion
  64322. * @param strength the explosion strength
  64323. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64324. * @returns A physics radial explosion event, or null
  64325. */
  64326. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64327. /**
  64328. * Applies a radial explosion force
  64329. * @param origin the origin of the explosion
  64330. * @param radiusOrEventOptions the radius or the options of radial explosion
  64331. * @param strength the explosion strength
  64332. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64333. * @returns A physics radial explosion event, or null
  64334. */
  64335. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64336. /**
  64337. * Creates a gravitational field
  64338. * @param origin the origin of the explosion
  64339. * @param radiusOrEventOptions the radius or the options of radial explosion
  64340. * @param strength the explosion strength
  64341. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64342. * @returns A physics gravitational field event, or null
  64343. */
  64344. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64345. /**
  64346. * Creates a physics updraft event
  64347. * @param origin the origin of the updraft
  64348. * @param radiusOrEventOptions the radius or the options of the updraft
  64349. * @param strength the strength of the updraft
  64350. * @param height the height of the updraft
  64351. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64352. * @returns A physics updraft event, or null
  64353. */
  64354. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64355. /**
  64356. * Creates a physics vortex event
  64357. * @param origin the of the vortex
  64358. * @param radiusOrEventOptions the radius or the options of the vortex
  64359. * @param strength the strength of the vortex
  64360. * @param height the height of the vortex
  64361. * @returns a Physics vortex event, or null
  64362. * A physics vortex event or null
  64363. */
  64364. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64365. }
  64366. /**
  64367. * Represents a physics radial explosion event
  64368. */
  64369. class PhysicsRadialExplosionEvent {
  64370. private _scene;
  64371. private _options;
  64372. private _sphere;
  64373. private _dataFetched;
  64374. /**
  64375. * Initializes a radial explosioin event
  64376. * @param _scene BabylonJS scene
  64377. * @param _options The options for the vortex event
  64378. */
  64379. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64380. /**
  64381. * Returns the data related to the radial explosion event (sphere).
  64382. * @returns The radial explosion event data
  64383. */
  64384. getData(): PhysicsRadialExplosionEventData;
  64385. /**
  64386. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64387. * @param impostor A physics imposter
  64388. * @param origin the origin of the explosion
  64389. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64390. */
  64391. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64392. /**
  64393. * Triggers affecterd impostors callbacks
  64394. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64395. */
  64396. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64397. /**
  64398. * Disposes the sphere.
  64399. * @param force Specifies if the sphere should be disposed by force
  64400. */
  64401. dispose(force?: boolean): void;
  64402. /*** Helpers ***/
  64403. private _prepareSphere;
  64404. private _intersectsWithSphere;
  64405. }
  64406. /**
  64407. * Represents a gravitational field event
  64408. */
  64409. class PhysicsGravitationalFieldEvent {
  64410. private _physicsHelper;
  64411. private _scene;
  64412. private _origin;
  64413. private _options;
  64414. private _tickCallback;
  64415. private _sphere;
  64416. private _dataFetched;
  64417. /**
  64418. * Initializes the physics gravitational field event
  64419. * @param _physicsHelper A physics helper
  64420. * @param _scene BabylonJS scene
  64421. * @param _origin The origin position of the gravitational field event
  64422. * @param _options The options for the vortex event
  64423. */
  64424. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64425. /**
  64426. * Returns the data related to the gravitational field event (sphere).
  64427. * @returns A gravitational field event
  64428. */
  64429. getData(): PhysicsGravitationalFieldEventData;
  64430. /**
  64431. * Enables the gravitational field.
  64432. */
  64433. enable(): void;
  64434. /**
  64435. * Disables the gravitational field.
  64436. */
  64437. disable(): void;
  64438. /**
  64439. * Disposes the sphere.
  64440. * @param force The force to dispose from the gravitational field event
  64441. */
  64442. dispose(force?: boolean): void;
  64443. private _tick;
  64444. }
  64445. /**
  64446. * Represents a physics updraft event
  64447. */
  64448. class PhysicsUpdraftEvent {
  64449. private _scene;
  64450. private _origin;
  64451. private _options;
  64452. private _physicsEngine;
  64453. private _originTop;
  64454. private _originDirection;
  64455. private _tickCallback;
  64456. private _cylinder;
  64457. private _cylinderPosition;
  64458. private _dataFetched;
  64459. /**
  64460. * Initializes the physics updraft event
  64461. * @param _scene BabylonJS scene
  64462. * @param _origin The origin position of the updraft
  64463. * @param _options The options for the updraft event
  64464. */
  64465. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64466. /**
  64467. * Returns the data related to the updraft event (cylinder).
  64468. * @returns A physics updraft event
  64469. */
  64470. getData(): PhysicsUpdraftEventData;
  64471. /**
  64472. * Enables the updraft.
  64473. */
  64474. enable(): void;
  64475. /**
  64476. * Disables the updraft.
  64477. */
  64478. disable(): void;
  64479. /**
  64480. * Disposes the cylinder.
  64481. * @param force Specifies if the updraft should be disposed by force
  64482. */
  64483. dispose(force?: boolean): void;
  64484. private getImpostorHitData;
  64485. private _tick;
  64486. /*** Helpers ***/
  64487. private _prepareCylinder;
  64488. private _intersectsWithCylinder;
  64489. }
  64490. /**
  64491. * Represents a physics vortex event
  64492. */
  64493. class PhysicsVortexEvent {
  64494. private _scene;
  64495. private _origin;
  64496. private _options;
  64497. private _physicsEngine;
  64498. private _originTop;
  64499. private _tickCallback;
  64500. private _cylinder;
  64501. private _cylinderPosition;
  64502. private _dataFetched;
  64503. /**
  64504. * Initializes the physics vortex event
  64505. * @param _scene The BabylonJS scene
  64506. * @param _origin The origin position of the vortex
  64507. * @param _options The options for the vortex event
  64508. */
  64509. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64510. /**
  64511. * Returns the data related to the vortex event (cylinder).
  64512. * @returns The physics vortex event data
  64513. */
  64514. getData(): PhysicsVortexEventData;
  64515. /**
  64516. * Enables the vortex.
  64517. */
  64518. enable(): void;
  64519. /**
  64520. * Disables the cortex.
  64521. */
  64522. disable(): void;
  64523. /**
  64524. * Disposes the sphere.
  64525. * @param force
  64526. */
  64527. dispose(force?: boolean): void;
  64528. private getImpostorHitData;
  64529. private _tick;
  64530. /*** Helpers ***/
  64531. private _prepareCylinder;
  64532. private _intersectsWithCylinder;
  64533. }
  64534. /**
  64535. * Options fot the radial explosion event
  64536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64537. */
  64538. export class PhysicsRadialExplosionEventOptions {
  64539. /**
  64540. * The radius of the sphere for the radial explosion.
  64541. */
  64542. radius: number;
  64543. /**
  64544. * The strenth of the explosion.
  64545. */
  64546. strength: number;
  64547. /**
  64548. * The strenght of the force in correspondence to the distance of the affected object
  64549. */
  64550. falloff: PhysicsRadialImpulseFalloff;
  64551. /**
  64552. * Sphere options for the radial explosion.
  64553. */
  64554. sphere: {
  64555. segments: number;
  64556. diameter: number;
  64557. };
  64558. /**
  64559. * Sphere options for the radial explosion.
  64560. */
  64561. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64562. }
  64563. /**
  64564. * Options fot the updraft event
  64565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64566. */
  64567. export class PhysicsUpdraftEventOptions {
  64568. /**
  64569. * The radius of the cylinder for the vortex
  64570. */
  64571. radius: number;
  64572. /**
  64573. * The strenth of the updraft.
  64574. */
  64575. strength: number;
  64576. /**
  64577. * The height of the cylinder for the updraft.
  64578. */
  64579. height: number;
  64580. /**
  64581. * The mode for the the updraft.
  64582. */
  64583. updraftMode: PhysicsUpdraftMode;
  64584. }
  64585. /**
  64586. * Options fot the vortex event
  64587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64588. */
  64589. export class PhysicsVortexEventOptions {
  64590. /**
  64591. * The radius of the cylinder for the vortex
  64592. */
  64593. radius: number;
  64594. /**
  64595. * The strenth of the vortex.
  64596. */
  64597. strength: number;
  64598. /**
  64599. * The height of the cylinder for the vortex.
  64600. */
  64601. height: number;
  64602. /**
  64603. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64604. */
  64605. centripetalForceThreshold: number;
  64606. /**
  64607. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64608. */
  64609. centripetalForceMultiplier: number;
  64610. /**
  64611. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64612. */
  64613. centrifugalForceMultiplier: number;
  64614. /**
  64615. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64616. */
  64617. updraftForceMultiplier: number;
  64618. }
  64619. /**
  64620. * The strenght of the force in correspondence to the distance of the affected object
  64621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64622. */
  64623. export enum PhysicsRadialImpulseFalloff {
  64624. /** Defines that impulse is constant in strength across it's whole radius */
  64625. Constant = 0,
  64626. /** Defines that impulse gets weaker if it's further from the origin */
  64627. Linear = 1
  64628. }
  64629. /**
  64630. * The strength of the force in correspondence to the distance of the affected object
  64631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64632. */
  64633. export enum PhysicsUpdraftMode {
  64634. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64635. Center = 0,
  64636. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64637. Perpendicular = 1
  64638. }
  64639. /**
  64640. * Interface for a physics hit data
  64641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64642. */
  64643. export interface PhysicsHitData {
  64644. /**
  64645. * The force applied at the contact point
  64646. */
  64647. force: Vector3;
  64648. /**
  64649. * The contact point
  64650. */
  64651. contactPoint: Vector3;
  64652. /**
  64653. * The distance from the origin to the contact point
  64654. */
  64655. distanceFromOrigin: number;
  64656. }
  64657. /**
  64658. * Interface for radial explosion event data
  64659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64660. */
  64661. export interface PhysicsRadialExplosionEventData {
  64662. /**
  64663. * A sphere used for the radial explosion event
  64664. */
  64665. sphere: Mesh;
  64666. }
  64667. /**
  64668. * Interface for gravitational field event data
  64669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64670. */
  64671. export interface PhysicsGravitationalFieldEventData {
  64672. /**
  64673. * A sphere mesh used for the gravitational field event
  64674. */
  64675. sphere: Mesh;
  64676. }
  64677. /**
  64678. * Interface for updraft event data
  64679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64680. */
  64681. export interface PhysicsUpdraftEventData {
  64682. /**
  64683. * A cylinder used for the updraft event
  64684. */
  64685. cylinder: Mesh;
  64686. }
  64687. /**
  64688. * Interface for vortex event data
  64689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64690. */
  64691. export interface PhysicsVortexEventData {
  64692. /**
  64693. * A cylinder used for the vortex event
  64694. */
  64695. cylinder: Mesh;
  64696. }
  64697. /**
  64698. * Interface for an affected physics impostor
  64699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64700. */
  64701. export interface PhysicsAffectedImpostorWithData {
  64702. /**
  64703. * The impostor affected by the effect
  64704. */
  64705. impostor: PhysicsImpostor;
  64706. /**
  64707. * The data about the hit/horce from the explosion
  64708. */
  64709. hitData: PhysicsHitData;
  64710. }
  64711. }
  64712. declare module BABYLON {
  64713. /** @hidden */
  64714. export var blackAndWhitePixelShader: {
  64715. name: string;
  64716. shader: string;
  64717. };
  64718. }
  64719. declare module BABYLON {
  64720. /**
  64721. * Post process used to render in black and white
  64722. */
  64723. export class BlackAndWhitePostProcess extends PostProcess {
  64724. /**
  64725. * Linear about to convert he result to black and white (default: 1)
  64726. */
  64727. degree: number;
  64728. /**
  64729. * Creates a black and white post process
  64730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64731. * @param name The name of the effect.
  64732. * @param options The required width/height ratio to downsize to before computing the render pass.
  64733. * @param camera The camera to apply the render pass to.
  64734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64735. * @param engine The engine which the post process will be applied. (default: current engine)
  64736. * @param reusable If the post process can be reused on the same frame. (default: false)
  64737. */
  64738. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64739. }
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * This represents a set of one or more post processes in Babylon.
  64744. * A post process can be used to apply a shader to a texture after it is rendered.
  64745. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64746. */
  64747. export class PostProcessRenderEffect {
  64748. private _postProcesses;
  64749. private _getPostProcesses;
  64750. private _singleInstance;
  64751. private _cameras;
  64752. private _indicesForCamera;
  64753. /**
  64754. * Name of the effect
  64755. * @hidden
  64756. */
  64757. _name: string;
  64758. /**
  64759. * Instantiates a post process render effect.
  64760. * A post process can be used to apply a shader to a texture after it is rendered.
  64761. * @param engine The engine the effect is tied to
  64762. * @param name The name of the effect
  64763. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64764. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64765. */
  64766. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64767. /**
  64768. * Checks if all the post processes in the effect are supported.
  64769. */
  64770. get isSupported(): boolean;
  64771. /**
  64772. * Updates the current state of the effect
  64773. * @hidden
  64774. */
  64775. _update(): void;
  64776. /**
  64777. * Attaches the effect on cameras
  64778. * @param cameras The camera to attach to.
  64779. * @hidden
  64780. */
  64781. _attachCameras(cameras: Camera): void;
  64782. /**
  64783. * Attaches the effect on cameras
  64784. * @param cameras The camera to attach to.
  64785. * @hidden
  64786. */
  64787. _attachCameras(cameras: Camera[]): void;
  64788. /**
  64789. * Detaches the effect on cameras
  64790. * @param cameras The camera to detatch from.
  64791. * @hidden
  64792. */
  64793. _detachCameras(cameras: Camera): void;
  64794. /**
  64795. * Detatches the effect on cameras
  64796. * @param cameras The camera to detatch from.
  64797. * @hidden
  64798. */
  64799. _detachCameras(cameras: Camera[]): void;
  64800. /**
  64801. * Enables the effect on given cameras
  64802. * @param cameras The camera to enable.
  64803. * @hidden
  64804. */
  64805. _enable(cameras: Camera): void;
  64806. /**
  64807. * Enables the effect on given cameras
  64808. * @param cameras The camera to enable.
  64809. * @hidden
  64810. */
  64811. _enable(cameras: Nullable<Camera[]>): void;
  64812. /**
  64813. * Disables the effect on the given cameras
  64814. * @param cameras The camera to disable.
  64815. * @hidden
  64816. */
  64817. _disable(cameras: Camera): void;
  64818. /**
  64819. * Disables the effect on the given cameras
  64820. * @param cameras The camera to disable.
  64821. * @hidden
  64822. */
  64823. _disable(cameras: Nullable<Camera[]>): void;
  64824. /**
  64825. * Gets a list of the post processes contained in the effect.
  64826. * @param camera The camera to get the post processes on.
  64827. * @returns The list of the post processes in the effect.
  64828. */
  64829. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64830. }
  64831. }
  64832. declare module BABYLON {
  64833. /** @hidden */
  64834. export var extractHighlightsPixelShader: {
  64835. name: string;
  64836. shader: string;
  64837. };
  64838. }
  64839. declare module BABYLON {
  64840. /**
  64841. * 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.
  64842. */
  64843. export class ExtractHighlightsPostProcess extends PostProcess {
  64844. /**
  64845. * The luminance threshold, pixels below this value will be set to black.
  64846. */
  64847. threshold: number;
  64848. /** @hidden */
  64849. _exposure: number;
  64850. /**
  64851. * Post process which has the input texture to be used when performing highlight extraction
  64852. * @hidden
  64853. */
  64854. _inputPostProcess: Nullable<PostProcess>;
  64855. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64856. }
  64857. }
  64858. declare module BABYLON {
  64859. /** @hidden */
  64860. export var bloomMergePixelShader: {
  64861. name: string;
  64862. shader: string;
  64863. };
  64864. }
  64865. declare module BABYLON {
  64866. /**
  64867. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64868. */
  64869. export class BloomMergePostProcess extends PostProcess {
  64870. /** Weight of the bloom to be added to the original input. */
  64871. weight: number;
  64872. /**
  64873. * Creates a new instance of @see BloomMergePostProcess
  64874. * @param name The name of the effect.
  64875. * @param originalFromInput Post process which's input will be used for the merge.
  64876. * @param blurred Blurred highlights post process which's output will be used.
  64877. * @param weight Weight of the bloom to be added to the original input.
  64878. * @param options The required width/height ratio to downsize to before computing the render pass.
  64879. * @param camera The camera to apply the render pass to.
  64880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64881. * @param engine The engine which the post process will be applied. (default: current engine)
  64882. * @param reusable If the post process can be reused on the same frame. (default: false)
  64883. * @param textureType Type of textures used when performing the post process. (default: 0)
  64884. * @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)
  64885. */
  64886. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64887. /** Weight of the bloom to be added to the original input. */
  64888. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64889. }
  64890. }
  64891. declare module BABYLON {
  64892. /**
  64893. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64894. */
  64895. export class BloomEffect extends PostProcessRenderEffect {
  64896. private bloomScale;
  64897. /**
  64898. * @hidden Internal
  64899. */
  64900. _effects: Array<PostProcess>;
  64901. /**
  64902. * @hidden Internal
  64903. */
  64904. _downscale: ExtractHighlightsPostProcess;
  64905. private _blurX;
  64906. private _blurY;
  64907. private _merge;
  64908. /**
  64909. * The luminance threshold to find bright areas of the image to bloom.
  64910. */
  64911. get threshold(): number;
  64912. set threshold(value: number);
  64913. /**
  64914. * The strength of the bloom.
  64915. */
  64916. get weight(): number;
  64917. set weight(value: number);
  64918. /**
  64919. * Specifies the size of the bloom blur kernel, relative to the final output size
  64920. */
  64921. get kernel(): number;
  64922. set kernel(value: number);
  64923. /**
  64924. * Creates a new instance of @see BloomEffect
  64925. * @param scene The scene the effect belongs to.
  64926. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64927. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64928. * @param bloomWeight The the strength of bloom.
  64929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64930. * @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)
  64931. */
  64932. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64933. /**
  64934. * Disposes each of the internal effects for a given camera.
  64935. * @param camera The camera to dispose the effect on.
  64936. */
  64937. disposeEffects(camera: Camera): void;
  64938. /**
  64939. * @hidden Internal
  64940. */
  64941. _updateEffects(): void;
  64942. /**
  64943. * Internal
  64944. * @returns if all the contained post processes are ready.
  64945. * @hidden
  64946. */
  64947. _isReady(): boolean;
  64948. }
  64949. }
  64950. declare module BABYLON {
  64951. /** @hidden */
  64952. export var chromaticAberrationPixelShader: {
  64953. name: string;
  64954. shader: string;
  64955. };
  64956. }
  64957. declare module BABYLON {
  64958. /**
  64959. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64960. */
  64961. export class ChromaticAberrationPostProcess extends PostProcess {
  64962. /**
  64963. * The amount of seperation of rgb channels (default: 30)
  64964. */
  64965. aberrationAmount: number;
  64966. /**
  64967. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64968. */
  64969. radialIntensity: number;
  64970. /**
  64971. * 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))
  64972. */
  64973. direction: Vector2;
  64974. /**
  64975. * 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))
  64976. */
  64977. centerPosition: Vector2;
  64978. /**
  64979. * Creates a new instance ChromaticAberrationPostProcess
  64980. * @param name The name of the effect.
  64981. * @param screenWidth The width of the screen to apply the effect on.
  64982. * @param screenHeight The height of the screen to apply the effect on.
  64983. * @param options The required width/height ratio to downsize to before computing the render pass.
  64984. * @param camera The camera to apply the render pass to.
  64985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64986. * @param engine The engine which the post process will be applied. (default: current engine)
  64987. * @param reusable If the post process can be reused on the same frame. (default: false)
  64988. * @param textureType Type of textures used when performing the post process. (default: 0)
  64989. * @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)
  64990. */
  64991. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64992. }
  64993. }
  64994. declare module BABYLON {
  64995. /** @hidden */
  64996. export var circleOfConfusionPixelShader: {
  64997. name: string;
  64998. shader: string;
  64999. };
  65000. }
  65001. declare module BABYLON {
  65002. /**
  65003. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65004. */
  65005. export class CircleOfConfusionPostProcess extends PostProcess {
  65006. /**
  65007. * 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.
  65008. */
  65009. lensSize: number;
  65010. /**
  65011. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65012. */
  65013. fStop: number;
  65014. /**
  65015. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65016. */
  65017. focusDistance: number;
  65018. /**
  65019. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65020. */
  65021. focalLength: number;
  65022. private _depthTexture;
  65023. /**
  65024. * Creates a new instance CircleOfConfusionPostProcess
  65025. * @param name The name of the effect.
  65026. * @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.
  65027. * @param options The required width/height ratio to downsize to before computing the render pass.
  65028. * @param camera The camera to apply the render pass to.
  65029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65030. * @param engine The engine which the post process will be applied. (default: current engine)
  65031. * @param reusable If the post process can be reused on the same frame. (default: false)
  65032. * @param textureType Type of textures used when performing the post process. (default: 0)
  65033. * @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)
  65034. */
  65035. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65036. /**
  65037. * 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.
  65038. */
  65039. set depthTexture(value: RenderTargetTexture);
  65040. }
  65041. }
  65042. declare module BABYLON {
  65043. /** @hidden */
  65044. export var colorCorrectionPixelShader: {
  65045. name: string;
  65046. shader: string;
  65047. };
  65048. }
  65049. declare module BABYLON {
  65050. /**
  65051. *
  65052. * This post-process allows the modification of rendered colors by using
  65053. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65054. *
  65055. * The object needs to be provided an url to a texture containing the color
  65056. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65057. * Use an image editing software to tweak the LUT to match your needs.
  65058. *
  65059. * For an example of a color LUT, see here:
  65060. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65061. * For explanations on color grading, see here:
  65062. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65063. *
  65064. */
  65065. export class ColorCorrectionPostProcess extends PostProcess {
  65066. private _colorTableTexture;
  65067. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65068. }
  65069. }
  65070. declare module BABYLON {
  65071. /** @hidden */
  65072. export var convolutionPixelShader: {
  65073. name: string;
  65074. shader: string;
  65075. };
  65076. }
  65077. declare module BABYLON {
  65078. /**
  65079. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65080. * input texture to perform effects such as edge detection or sharpening
  65081. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65082. */
  65083. export class ConvolutionPostProcess extends PostProcess {
  65084. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65085. kernel: number[];
  65086. /**
  65087. * Creates a new instance ConvolutionPostProcess
  65088. * @param name The name of the effect.
  65089. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65090. * @param options The required width/height ratio to downsize to before computing the render pass.
  65091. * @param camera The camera to apply the render pass to.
  65092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65093. * @param engine The engine which the post process will be applied. (default: current engine)
  65094. * @param reusable If the post process can be reused on the same frame. (default: false)
  65095. * @param textureType Type of textures used when performing the post process. (default: 0)
  65096. */
  65097. constructor(name: string,
  65098. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65099. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65100. /**
  65101. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65102. */
  65103. static EdgeDetect0Kernel: number[];
  65104. /**
  65105. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65106. */
  65107. static EdgeDetect1Kernel: number[];
  65108. /**
  65109. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65110. */
  65111. static EdgeDetect2Kernel: number[];
  65112. /**
  65113. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65114. */
  65115. static SharpenKernel: number[];
  65116. /**
  65117. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65118. */
  65119. static EmbossKernel: number[];
  65120. /**
  65121. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65122. */
  65123. static GaussianKernel: number[];
  65124. }
  65125. }
  65126. declare module BABYLON {
  65127. /**
  65128. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65129. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65130. * based on samples that have a large difference in distance than the center pixel.
  65131. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65132. */
  65133. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65134. direction: Vector2;
  65135. /**
  65136. * Creates a new instance CircleOfConfusionPostProcess
  65137. * @param name The name of the effect.
  65138. * @param scene The scene the effect belongs to.
  65139. * @param direction The direction the blur should be applied.
  65140. * @param kernel The size of the kernel used to blur.
  65141. * @param options The required width/height ratio to downsize to before computing the render pass.
  65142. * @param camera The camera to apply the render pass to.
  65143. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65144. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65146. * @param engine The engine which the post process will be applied. (default: current engine)
  65147. * @param reusable If the post process can be reused on the same frame. (default: false)
  65148. * @param textureType Type of textures used when performing the post process. (default: 0)
  65149. * @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)
  65150. */
  65151. 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);
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /** @hidden */
  65156. export var depthOfFieldMergePixelShader: {
  65157. name: string;
  65158. shader: string;
  65159. };
  65160. }
  65161. declare module BABYLON {
  65162. /**
  65163. * Options to be set when merging outputs from the default pipeline.
  65164. */
  65165. export class DepthOfFieldMergePostProcessOptions {
  65166. /**
  65167. * The original image to merge on top of
  65168. */
  65169. originalFromInput: PostProcess;
  65170. /**
  65171. * Parameters to perform the merge of the depth of field effect
  65172. */
  65173. depthOfField?: {
  65174. circleOfConfusion: PostProcess;
  65175. blurSteps: Array<PostProcess>;
  65176. };
  65177. /**
  65178. * Parameters to perform the merge of bloom effect
  65179. */
  65180. bloom?: {
  65181. blurred: PostProcess;
  65182. weight: number;
  65183. };
  65184. }
  65185. /**
  65186. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65187. */
  65188. export class DepthOfFieldMergePostProcess extends PostProcess {
  65189. private blurSteps;
  65190. /**
  65191. * Creates a new instance of DepthOfFieldMergePostProcess
  65192. * @param name The name of the effect.
  65193. * @param originalFromInput Post process which's input will be used for the merge.
  65194. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65195. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65196. * @param options The required width/height ratio to downsize to before computing the render pass.
  65197. * @param camera The camera to apply the render pass to.
  65198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65199. * @param engine The engine which the post process will be applied. (default: current engine)
  65200. * @param reusable If the post process can be reused on the same frame. (default: false)
  65201. * @param textureType Type of textures used when performing the post process. (default: 0)
  65202. * @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)
  65203. */
  65204. 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);
  65205. /**
  65206. * Updates the effect with the current post process compile time values and recompiles the shader.
  65207. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65208. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65209. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65210. * @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
  65211. * @param onCompiled Called when the shader has been compiled.
  65212. * @param onError Called if there is an error when compiling a shader.
  65213. */
  65214. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65215. }
  65216. }
  65217. declare module BABYLON {
  65218. /**
  65219. * Specifies the level of max blur that should be applied when using the depth of field effect
  65220. */
  65221. export enum DepthOfFieldEffectBlurLevel {
  65222. /**
  65223. * Subtle blur
  65224. */
  65225. Low = 0,
  65226. /**
  65227. * Medium blur
  65228. */
  65229. Medium = 1,
  65230. /**
  65231. * Large blur
  65232. */
  65233. High = 2
  65234. }
  65235. /**
  65236. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65237. */
  65238. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65239. private _circleOfConfusion;
  65240. /**
  65241. * @hidden Internal, blurs from high to low
  65242. */
  65243. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65244. private _depthOfFieldBlurY;
  65245. private _dofMerge;
  65246. /**
  65247. * @hidden Internal post processes in depth of field effect
  65248. */
  65249. _effects: Array<PostProcess>;
  65250. /**
  65251. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65252. */
  65253. set focalLength(value: number);
  65254. get focalLength(): number;
  65255. /**
  65256. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65257. */
  65258. set fStop(value: number);
  65259. get fStop(): number;
  65260. /**
  65261. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65262. */
  65263. set focusDistance(value: number);
  65264. get focusDistance(): number;
  65265. /**
  65266. * 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.
  65267. */
  65268. set lensSize(value: number);
  65269. get lensSize(): number;
  65270. /**
  65271. * Creates a new instance DepthOfFieldEffect
  65272. * @param scene The scene the effect belongs to.
  65273. * @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.
  65274. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65275. * @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)
  65276. */
  65277. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65278. /**
  65279. * Get the current class name of the current effet
  65280. * @returns "DepthOfFieldEffect"
  65281. */
  65282. getClassName(): string;
  65283. /**
  65284. * 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.
  65285. */
  65286. set depthTexture(value: RenderTargetTexture);
  65287. /**
  65288. * Disposes each of the internal effects for a given camera.
  65289. * @param camera The camera to dispose the effect on.
  65290. */
  65291. disposeEffects(camera: Camera): void;
  65292. /**
  65293. * @hidden Internal
  65294. */
  65295. _updateEffects(): void;
  65296. /**
  65297. * Internal
  65298. * @returns if all the contained post processes are ready.
  65299. * @hidden
  65300. */
  65301. _isReady(): boolean;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /** @hidden */
  65306. export var displayPassPixelShader: {
  65307. name: string;
  65308. shader: string;
  65309. };
  65310. }
  65311. declare module BABYLON {
  65312. /**
  65313. * DisplayPassPostProcess which produces an output the same as it's input
  65314. */
  65315. export class DisplayPassPostProcess extends PostProcess {
  65316. /**
  65317. * Creates the DisplayPassPostProcess
  65318. * @param name The name of the effect.
  65319. * @param options The required width/height ratio to downsize to before computing the render pass.
  65320. * @param camera The camera to apply the render pass to.
  65321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65322. * @param engine The engine which the post process will be applied. (default: current engine)
  65323. * @param reusable If the post process can be reused on the same frame. (default: false)
  65324. */
  65325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65326. }
  65327. }
  65328. declare module BABYLON {
  65329. /** @hidden */
  65330. export var filterPixelShader: {
  65331. name: string;
  65332. shader: string;
  65333. };
  65334. }
  65335. declare module BABYLON {
  65336. /**
  65337. * Applies a kernel filter to the image
  65338. */
  65339. export class FilterPostProcess extends PostProcess {
  65340. /** The matrix to be applied to the image */
  65341. kernelMatrix: Matrix;
  65342. /**
  65343. *
  65344. * @param name The name of the effect.
  65345. * @param kernelMatrix The matrix to be applied to the image
  65346. * @param options The required width/height ratio to downsize to before computing the render pass.
  65347. * @param camera The camera to apply the render pass to.
  65348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65349. * @param engine The engine which the post process will be applied. (default: current engine)
  65350. * @param reusable If the post process can be reused on the same frame. (default: false)
  65351. */
  65352. constructor(name: string,
  65353. /** The matrix to be applied to the image */
  65354. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65355. }
  65356. }
  65357. declare module BABYLON {
  65358. /** @hidden */
  65359. export var fxaaPixelShader: {
  65360. name: string;
  65361. shader: string;
  65362. };
  65363. }
  65364. declare module BABYLON {
  65365. /** @hidden */
  65366. export var fxaaVertexShader: {
  65367. name: string;
  65368. shader: string;
  65369. };
  65370. }
  65371. declare module BABYLON {
  65372. /**
  65373. * Fxaa post process
  65374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65375. */
  65376. export class FxaaPostProcess extends PostProcess {
  65377. /** @hidden */
  65378. texelWidth: number;
  65379. /** @hidden */
  65380. texelHeight: number;
  65381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65382. private _getDefines;
  65383. }
  65384. }
  65385. declare module BABYLON {
  65386. /** @hidden */
  65387. export var grainPixelShader: {
  65388. name: string;
  65389. shader: string;
  65390. };
  65391. }
  65392. declare module BABYLON {
  65393. /**
  65394. * The GrainPostProcess adds noise to the image at mid luminance levels
  65395. */
  65396. export class GrainPostProcess extends PostProcess {
  65397. /**
  65398. * The intensity of the grain added (default: 30)
  65399. */
  65400. intensity: number;
  65401. /**
  65402. * If the grain should be randomized on every frame
  65403. */
  65404. animated: boolean;
  65405. /**
  65406. * Creates a new instance of @see GrainPostProcess
  65407. * @param name The name of the effect.
  65408. * @param options The required width/height ratio to downsize to before computing the render pass.
  65409. * @param camera The camera to apply the render pass to.
  65410. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65411. * @param engine The engine which the post process will be applied. (default: current engine)
  65412. * @param reusable If the post process can be reused on the same frame. (default: false)
  65413. * @param textureType Type of textures used when performing the post process. (default: 0)
  65414. * @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)
  65415. */
  65416. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65417. }
  65418. }
  65419. declare module BABYLON {
  65420. /** @hidden */
  65421. export var highlightsPixelShader: {
  65422. name: string;
  65423. shader: string;
  65424. };
  65425. }
  65426. declare module BABYLON {
  65427. /**
  65428. * Extracts highlights from the image
  65429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65430. */
  65431. export class HighlightsPostProcess extends PostProcess {
  65432. /**
  65433. * Extracts highlights from the image
  65434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65435. * @param name The name of the effect.
  65436. * @param options The required width/height ratio to downsize to before computing the render pass.
  65437. * @param camera The camera to apply the render pass to.
  65438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65439. * @param engine The engine which the post process will be applied. (default: current engine)
  65440. * @param reusable If the post process can be reused on the same frame. (default: false)
  65441. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65442. */
  65443. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /** @hidden */
  65448. export var mrtFragmentDeclaration: {
  65449. name: string;
  65450. shader: string;
  65451. };
  65452. }
  65453. declare module BABYLON {
  65454. /** @hidden */
  65455. export var geometryPixelShader: {
  65456. name: string;
  65457. shader: string;
  65458. };
  65459. }
  65460. declare module BABYLON {
  65461. /** @hidden */
  65462. export var geometryVertexShader: {
  65463. name: string;
  65464. shader: string;
  65465. };
  65466. }
  65467. declare module BABYLON {
  65468. /** @hidden */
  65469. interface ISavedTransformationMatrix {
  65470. world: Matrix;
  65471. viewProjection: Matrix;
  65472. }
  65473. /**
  65474. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65475. */
  65476. export class GeometryBufferRenderer {
  65477. /**
  65478. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65479. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65480. */
  65481. static readonly POSITION_TEXTURE_TYPE: number;
  65482. /**
  65483. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65484. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65485. */
  65486. static readonly VELOCITY_TEXTURE_TYPE: number;
  65487. /**
  65488. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65489. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65490. */
  65491. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65492. /**
  65493. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65494. * in order to compute objects velocities when enableVelocity is set to "true"
  65495. * @hidden
  65496. */
  65497. _previousTransformationMatrices: {
  65498. [index: number]: ISavedTransformationMatrix;
  65499. };
  65500. /**
  65501. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65502. * in order to compute objects velocities when enableVelocity is set to "true"
  65503. * @hidden
  65504. */
  65505. _previousBonesTransformationMatrices: {
  65506. [index: number]: Float32Array;
  65507. };
  65508. /**
  65509. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65510. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65511. */
  65512. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65513. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65514. renderTransparentMeshes: boolean;
  65515. private _scene;
  65516. private _multiRenderTarget;
  65517. private _ratio;
  65518. private _enablePosition;
  65519. private _enableVelocity;
  65520. private _enableReflectivity;
  65521. private _positionIndex;
  65522. private _velocityIndex;
  65523. private _reflectivityIndex;
  65524. protected _effect: Effect;
  65525. protected _cachedDefines: string;
  65526. /**
  65527. * Set the render list (meshes to be rendered) used in the G buffer.
  65528. */
  65529. set renderList(meshes: Mesh[]);
  65530. /**
  65531. * Gets wether or not G buffer are supported by the running hardware.
  65532. * This requires draw buffer supports
  65533. */
  65534. get isSupported(): boolean;
  65535. /**
  65536. * Returns the index of the given texture type in the G-Buffer textures array
  65537. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65538. * @returns the index of the given texture type in the G-Buffer textures array
  65539. */
  65540. getTextureIndex(textureType: number): number;
  65541. /**
  65542. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65543. */
  65544. get enablePosition(): boolean;
  65545. /**
  65546. * Sets whether or not objects positions are enabled for the G buffer.
  65547. */
  65548. set enablePosition(enable: boolean);
  65549. /**
  65550. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65551. */
  65552. get enableVelocity(): boolean;
  65553. /**
  65554. * Sets wether or not objects velocities are enabled for the G buffer.
  65555. */
  65556. set enableVelocity(enable: boolean);
  65557. /**
  65558. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65559. */
  65560. get enableReflectivity(): boolean;
  65561. /**
  65562. * Sets wether or not objects roughness are enabled for the G buffer.
  65563. */
  65564. set enableReflectivity(enable: boolean);
  65565. /**
  65566. * Gets the scene associated with the buffer.
  65567. */
  65568. get scene(): Scene;
  65569. /**
  65570. * Gets the ratio used by the buffer during its creation.
  65571. * How big is the buffer related to the main canvas.
  65572. */
  65573. get ratio(): number;
  65574. /** @hidden */
  65575. static _SceneComponentInitialization: (scene: Scene) => void;
  65576. /**
  65577. * Creates a new G Buffer for the scene
  65578. * @param scene The scene the buffer belongs to
  65579. * @param ratio How big is the buffer related to the main canvas.
  65580. */
  65581. constructor(scene: Scene, ratio?: number);
  65582. /**
  65583. * Checks wether everything is ready to render a submesh to the G buffer.
  65584. * @param subMesh the submesh to check readiness for
  65585. * @param useInstances is the mesh drawn using instance or not
  65586. * @returns true if ready otherwise false
  65587. */
  65588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65589. /**
  65590. * Gets the current underlying G Buffer.
  65591. * @returns the buffer
  65592. */
  65593. getGBuffer(): MultiRenderTarget;
  65594. /**
  65595. * Gets the number of samples used to render the buffer (anti aliasing).
  65596. */
  65597. get samples(): number;
  65598. /**
  65599. * Sets the number of samples used to render the buffer (anti aliasing).
  65600. */
  65601. set samples(value: number);
  65602. /**
  65603. * Disposes the renderer and frees up associated resources.
  65604. */
  65605. dispose(): void;
  65606. protected _createRenderTargets(): void;
  65607. private _copyBonesTransformationMatrices;
  65608. }
  65609. }
  65610. declare module BABYLON {
  65611. interface Scene {
  65612. /** @hidden (Backing field) */
  65613. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65614. /**
  65615. * Gets or Sets the current geometry buffer associated to the scene.
  65616. */
  65617. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65618. /**
  65619. * Enables a GeometryBufferRender and associates it with the scene
  65620. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65621. * @returns the GeometryBufferRenderer
  65622. */
  65623. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65624. /**
  65625. * Disables the GeometryBufferRender associated with the scene
  65626. */
  65627. disableGeometryBufferRenderer(): void;
  65628. }
  65629. /**
  65630. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65631. * in several rendering techniques.
  65632. */
  65633. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65634. /**
  65635. * The component name helpful to identify the component in the list of scene components.
  65636. */
  65637. readonly name: string;
  65638. /**
  65639. * The scene the component belongs to.
  65640. */
  65641. scene: Scene;
  65642. /**
  65643. * Creates a new instance of the component for the given scene
  65644. * @param scene Defines the scene to register the component in
  65645. */
  65646. constructor(scene: Scene);
  65647. /**
  65648. * Registers the component in a given scene
  65649. */
  65650. register(): void;
  65651. /**
  65652. * Rebuilds the elements related to this component in case of
  65653. * context lost for instance.
  65654. */
  65655. rebuild(): void;
  65656. /**
  65657. * Disposes the component and the associated ressources
  65658. */
  65659. dispose(): void;
  65660. private _gatherRenderTargets;
  65661. }
  65662. }
  65663. declare module BABYLON {
  65664. /** @hidden */
  65665. export var motionBlurPixelShader: {
  65666. name: string;
  65667. shader: string;
  65668. };
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65673. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65674. * As an example, all you have to do is to create the post-process:
  65675. * var mb = new BABYLON.MotionBlurPostProcess(
  65676. * 'mb', // The name of the effect.
  65677. * scene, // The scene containing the objects to blur according to their velocity.
  65678. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65679. * camera // The camera to apply the render pass to.
  65680. * );
  65681. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65682. */
  65683. export class MotionBlurPostProcess extends PostProcess {
  65684. /**
  65685. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65686. */
  65687. motionStrength: number;
  65688. /**
  65689. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65690. */
  65691. get motionBlurSamples(): number;
  65692. /**
  65693. * Sets the number of iterations to be used for motion blur quality
  65694. */
  65695. set motionBlurSamples(samples: number);
  65696. private _motionBlurSamples;
  65697. private _geometryBufferRenderer;
  65698. /**
  65699. * Creates a new instance MotionBlurPostProcess
  65700. * @param name The name of the effect.
  65701. * @param scene The scene containing the objects to blur according to their velocity.
  65702. * @param options The required width/height ratio to downsize to before computing the render pass.
  65703. * @param camera The camera to apply the render pass to.
  65704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65705. * @param engine The engine which the post process will be applied. (default: current engine)
  65706. * @param reusable If the post process can be reused on the same frame. (default: false)
  65707. * @param textureType Type of textures used when performing the post process. (default: 0)
  65708. * @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)
  65709. */
  65710. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65711. /**
  65712. * Excludes the given skinned mesh from computing bones velocities.
  65713. * 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.
  65714. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65715. */
  65716. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65717. /**
  65718. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65719. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65720. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65721. */
  65722. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65723. /**
  65724. * Disposes the post process.
  65725. * @param camera The camera to dispose the post process on.
  65726. */
  65727. dispose(camera?: Camera): void;
  65728. }
  65729. }
  65730. declare module BABYLON {
  65731. /** @hidden */
  65732. export var refractionPixelShader: {
  65733. name: string;
  65734. shader: string;
  65735. };
  65736. }
  65737. declare module BABYLON {
  65738. /**
  65739. * Post process which applies a refractin texture
  65740. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65741. */
  65742. export class RefractionPostProcess extends PostProcess {
  65743. /** the base color of the refraction (used to taint the rendering) */
  65744. color: Color3;
  65745. /** simulated refraction depth */
  65746. depth: number;
  65747. /** the coefficient of the base color (0 to remove base color tainting) */
  65748. colorLevel: number;
  65749. private _refTexture;
  65750. private _ownRefractionTexture;
  65751. /**
  65752. * Gets or sets the refraction texture
  65753. * Please note that you are responsible for disposing the texture if you set it manually
  65754. */
  65755. get refractionTexture(): Texture;
  65756. set refractionTexture(value: Texture);
  65757. /**
  65758. * Initializes the RefractionPostProcess
  65759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65760. * @param name The name of the effect.
  65761. * @param refractionTextureUrl Url of the refraction texture to use
  65762. * @param color the base color of the refraction (used to taint the rendering)
  65763. * @param depth simulated refraction depth
  65764. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65765. * @param camera The camera to apply the render pass to.
  65766. * @param options The required width/height ratio to downsize to before computing the render pass.
  65767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65768. * @param engine The engine which the post process will be applied. (default: current engine)
  65769. * @param reusable If the post process can be reused on the same frame. (default: false)
  65770. */
  65771. constructor(name: string, refractionTextureUrl: string,
  65772. /** the base color of the refraction (used to taint the rendering) */
  65773. color: Color3,
  65774. /** simulated refraction depth */
  65775. depth: number,
  65776. /** the coefficient of the base color (0 to remove base color tainting) */
  65777. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65778. /**
  65779. * Disposes of the post process
  65780. * @param camera Camera to dispose post process on
  65781. */
  65782. dispose(camera: Camera): void;
  65783. }
  65784. }
  65785. declare module BABYLON {
  65786. /** @hidden */
  65787. export var sharpenPixelShader: {
  65788. name: string;
  65789. shader: string;
  65790. };
  65791. }
  65792. declare module BABYLON {
  65793. /**
  65794. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65795. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65796. */
  65797. export class SharpenPostProcess extends PostProcess {
  65798. /**
  65799. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65800. */
  65801. colorAmount: number;
  65802. /**
  65803. * How much sharpness should be applied (default: 0.3)
  65804. */
  65805. edgeAmount: number;
  65806. /**
  65807. * Creates a new instance ConvolutionPostProcess
  65808. * @param name The name of the effect.
  65809. * @param options The required width/height ratio to downsize to before computing the render pass.
  65810. * @param camera The camera to apply the render pass to.
  65811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65812. * @param engine The engine which the post process will be applied. (default: current engine)
  65813. * @param reusable If the post process can be reused on the same frame. (default: false)
  65814. * @param textureType Type of textures used when performing the post process. (default: 0)
  65815. * @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)
  65816. */
  65817. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65818. }
  65819. }
  65820. declare module BABYLON {
  65821. /**
  65822. * PostProcessRenderPipeline
  65823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65824. */
  65825. export class PostProcessRenderPipeline {
  65826. private engine;
  65827. private _renderEffects;
  65828. private _renderEffectsForIsolatedPass;
  65829. /**
  65830. * List of inspectable custom properties (used by the Inspector)
  65831. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65832. */
  65833. inspectableCustomProperties: IInspectable[];
  65834. /**
  65835. * @hidden
  65836. */
  65837. protected _cameras: Camera[];
  65838. /** @hidden */
  65839. _name: string;
  65840. /**
  65841. * Gets pipeline name
  65842. */
  65843. get name(): string;
  65844. /** Gets the list of attached cameras */
  65845. get cameras(): Camera[];
  65846. /**
  65847. * Initializes a PostProcessRenderPipeline
  65848. * @param engine engine to add the pipeline to
  65849. * @param name name of the pipeline
  65850. */
  65851. constructor(engine: Engine, name: string);
  65852. /**
  65853. * Gets the class name
  65854. * @returns "PostProcessRenderPipeline"
  65855. */
  65856. getClassName(): string;
  65857. /**
  65858. * If all the render effects in the pipeline are supported
  65859. */
  65860. get isSupported(): boolean;
  65861. /**
  65862. * Adds an effect to the pipeline
  65863. * @param renderEffect the effect to add
  65864. */
  65865. addEffect(renderEffect: PostProcessRenderEffect): void;
  65866. /** @hidden */
  65867. _rebuild(): void;
  65868. /** @hidden */
  65869. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65870. /** @hidden */
  65871. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65872. /** @hidden */
  65873. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65874. /** @hidden */
  65875. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65876. /** @hidden */
  65877. _attachCameras(cameras: Camera, unique: boolean): void;
  65878. /** @hidden */
  65879. _attachCameras(cameras: Camera[], unique: boolean): void;
  65880. /** @hidden */
  65881. _detachCameras(cameras: Camera): void;
  65882. /** @hidden */
  65883. _detachCameras(cameras: Nullable<Camera[]>): void;
  65884. /** @hidden */
  65885. _update(): void;
  65886. /** @hidden */
  65887. _reset(): void;
  65888. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65889. /**
  65890. * Disposes of the pipeline
  65891. */
  65892. dispose(): void;
  65893. }
  65894. }
  65895. declare module BABYLON {
  65896. /**
  65897. * PostProcessRenderPipelineManager class
  65898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65899. */
  65900. export class PostProcessRenderPipelineManager {
  65901. private _renderPipelines;
  65902. /**
  65903. * Initializes a PostProcessRenderPipelineManager
  65904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65905. */
  65906. constructor();
  65907. /**
  65908. * Gets the list of supported render pipelines
  65909. */
  65910. get supportedPipelines(): PostProcessRenderPipeline[];
  65911. /**
  65912. * Adds a pipeline to the manager
  65913. * @param renderPipeline The pipeline to add
  65914. */
  65915. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65916. /**
  65917. * Attaches a camera to the pipeline
  65918. * @param renderPipelineName The name of the pipeline to attach to
  65919. * @param cameras the camera to attach
  65920. * @param unique if the camera can be attached multiple times to the pipeline
  65921. */
  65922. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65923. /**
  65924. * Detaches a camera from the pipeline
  65925. * @param renderPipelineName The name of the pipeline to detach from
  65926. * @param cameras the camera to detach
  65927. */
  65928. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65929. /**
  65930. * Enables an effect by name on a pipeline
  65931. * @param renderPipelineName the name of the pipeline to enable the effect in
  65932. * @param renderEffectName the name of the effect to enable
  65933. * @param cameras the cameras that the effect should be enabled on
  65934. */
  65935. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65936. /**
  65937. * Disables an effect by name on a pipeline
  65938. * @param renderPipelineName the name of the pipeline to disable the effect in
  65939. * @param renderEffectName the name of the effect to disable
  65940. * @param cameras the cameras that the effect should be disabled on
  65941. */
  65942. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65943. /**
  65944. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65945. */
  65946. update(): void;
  65947. /** @hidden */
  65948. _rebuild(): void;
  65949. /**
  65950. * Disposes of the manager and pipelines
  65951. */
  65952. dispose(): void;
  65953. }
  65954. }
  65955. declare module BABYLON {
  65956. interface Scene {
  65957. /** @hidden (Backing field) */
  65958. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65959. /**
  65960. * Gets the postprocess render pipeline manager
  65961. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65962. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65963. */
  65964. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65965. }
  65966. /**
  65967. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65968. */
  65969. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65970. /**
  65971. * The component name helpfull to identify the component in the list of scene components.
  65972. */
  65973. readonly name: string;
  65974. /**
  65975. * The scene the component belongs to.
  65976. */
  65977. scene: Scene;
  65978. /**
  65979. * Creates a new instance of the component for the given scene
  65980. * @param scene Defines the scene to register the component in
  65981. */
  65982. constructor(scene: Scene);
  65983. /**
  65984. * Registers the component in a given scene
  65985. */
  65986. register(): void;
  65987. /**
  65988. * Rebuilds the elements related to this component in case of
  65989. * context lost for instance.
  65990. */
  65991. rebuild(): void;
  65992. /**
  65993. * Disposes the component and the associated ressources
  65994. */
  65995. dispose(): void;
  65996. private _gatherRenderTargets;
  65997. }
  65998. }
  65999. declare module BABYLON {
  66000. /**
  66001. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66002. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66003. */
  66004. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66005. private _scene;
  66006. private _camerasToBeAttached;
  66007. /**
  66008. * ID of the sharpen post process,
  66009. */
  66010. private readonly SharpenPostProcessId;
  66011. /**
  66012. * @ignore
  66013. * ID of the image processing post process;
  66014. */
  66015. readonly ImageProcessingPostProcessId: string;
  66016. /**
  66017. * @ignore
  66018. * ID of the Fast Approximate Anti-Aliasing post process;
  66019. */
  66020. readonly FxaaPostProcessId: string;
  66021. /**
  66022. * ID of the chromatic aberration post process,
  66023. */
  66024. private readonly ChromaticAberrationPostProcessId;
  66025. /**
  66026. * ID of the grain post process
  66027. */
  66028. private readonly GrainPostProcessId;
  66029. /**
  66030. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66031. */
  66032. sharpen: SharpenPostProcess;
  66033. private _sharpenEffect;
  66034. private bloom;
  66035. /**
  66036. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66037. */
  66038. depthOfField: DepthOfFieldEffect;
  66039. /**
  66040. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66041. */
  66042. fxaa: FxaaPostProcess;
  66043. /**
  66044. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66045. */
  66046. imageProcessing: ImageProcessingPostProcess;
  66047. /**
  66048. * Chromatic aberration post process which will shift rgb colors in the image
  66049. */
  66050. chromaticAberration: ChromaticAberrationPostProcess;
  66051. private _chromaticAberrationEffect;
  66052. /**
  66053. * Grain post process which add noise to the image
  66054. */
  66055. grain: GrainPostProcess;
  66056. private _grainEffect;
  66057. /**
  66058. * Glow post process which adds a glow to emissive areas of the image
  66059. */
  66060. private _glowLayer;
  66061. /**
  66062. * Animations which can be used to tweak settings over a period of time
  66063. */
  66064. animations: Animation[];
  66065. private _imageProcessingConfigurationObserver;
  66066. private _sharpenEnabled;
  66067. private _bloomEnabled;
  66068. private _depthOfFieldEnabled;
  66069. private _depthOfFieldBlurLevel;
  66070. private _fxaaEnabled;
  66071. private _imageProcessingEnabled;
  66072. private _defaultPipelineTextureType;
  66073. private _bloomScale;
  66074. private _chromaticAberrationEnabled;
  66075. private _grainEnabled;
  66076. private _buildAllowed;
  66077. /**
  66078. * Gets active scene
  66079. */
  66080. get scene(): Scene;
  66081. /**
  66082. * Enable or disable the sharpen process from the pipeline
  66083. */
  66084. set sharpenEnabled(enabled: boolean);
  66085. get sharpenEnabled(): boolean;
  66086. private _resizeObserver;
  66087. private _hardwareScaleLevel;
  66088. private _bloomKernel;
  66089. /**
  66090. * Specifies the size of the bloom blur kernel, relative to the final output size
  66091. */
  66092. get bloomKernel(): number;
  66093. set bloomKernel(value: number);
  66094. /**
  66095. * Specifies the weight of the bloom in the final rendering
  66096. */
  66097. private _bloomWeight;
  66098. /**
  66099. * Specifies the luma threshold for the area that will be blurred by the bloom
  66100. */
  66101. private _bloomThreshold;
  66102. private _hdr;
  66103. /**
  66104. * The strength of the bloom.
  66105. */
  66106. set bloomWeight(value: number);
  66107. get bloomWeight(): number;
  66108. /**
  66109. * The strength of the bloom.
  66110. */
  66111. set bloomThreshold(value: number);
  66112. get bloomThreshold(): number;
  66113. /**
  66114. * The scale of the bloom, lower value will provide better performance.
  66115. */
  66116. set bloomScale(value: number);
  66117. get bloomScale(): number;
  66118. /**
  66119. * Enable or disable the bloom from the pipeline
  66120. */
  66121. set bloomEnabled(enabled: boolean);
  66122. get bloomEnabled(): boolean;
  66123. private _rebuildBloom;
  66124. /**
  66125. * If the depth of field is enabled.
  66126. */
  66127. get depthOfFieldEnabled(): boolean;
  66128. set depthOfFieldEnabled(enabled: boolean);
  66129. /**
  66130. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66131. */
  66132. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66133. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66134. /**
  66135. * If the anti aliasing is enabled.
  66136. */
  66137. set fxaaEnabled(enabled: boolean);
  66138. get fxaaEnabled(): boolean;
  66139. private _samples;
  66140. /**
  66141. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66142. */
  66143. set samples(sampleCount: number);
  66144. get samples(): number;
  66145. /**
  66146. * If image processing is enabled.
  66147. */
  66148. set imageProcessingEnabled(enabled: boolean);
  66149. get imageProcessingEnabled(): boolean;
  66150. /**
  66151. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66152. */
  66153. set glowLayerEnabled(enabled: boolean);
  66154. get glowLayerEnabled(): boolean;
  66155. /**
  66156. * Gets the glow layer (or null if not defined)
  66157. */
  66158. get glowLayer(): Nullable<GlowLayer>;
  66159. /**
  66160. * Enable or disable the chromaticAberration process from the pipeline
  66161. */
  66162. set chromaticAberrationEnabled(enabled: boolean);
  66163. get chromaticAberrationEnabled(): boolean;
  66164. /**
  66165. * Enable or disable the grain process from the pipeline
  66166. */
  66167. set grainEnabled(enabled: boolean);
  66168. get grainEnabled(): boolean;
  66169. /**
  66170. * @constructor
  66171. * @param name - The rendering pipeline name (default: "")
  66172. * @param hdr - If high dynamic range textures should be used (default: true)
  66173. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66174. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66175. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66176. */
  66177. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66178. /**
  66179. * Get the class name
  66180. * @returns "DefaultRenderingPipeline"
  66181. */
  66182. getClassName(): string;
  66183. /**
  66184. * Force the compilation of the entire pipeline.
  66185. */
  66186. prepare(): void;
  66187. private _hasCleared;
  66188. private _prevPostProcess;
  66189. private _prevPrevPostProcess;
  66190. private _setAutoClearAndTextureSharing;
  66191. private _depthOfFieldSceneObserver;
  66192. private _buildPipeline;
  66193. private _disposePostProcesses;
  66194. /**
  66195. * Adds a camera to the pipeline
  66196. * @param camera the camera to be added
  66197. */
  66198. addCamera(camera: Camera): void;
  66199. /**
  66200. * Removes a camera from the pipeline
  66201. * @param camera the camera to remove
  66202. */
  66203. removeCamera(camera: Camera): void;
  66204. /**
  66205. * Dispose of the pipeline and stop all post processes
  66206. */
  66207. dispose(): void;
  66208. /**
  66209. * Serialize the rendering pipeline (Used when exporting)
  66210. * @returns the serialized object
  66211. */
  66212. serialize(): any;
  66213. /**
  66214. * Parse the serialized pipeline
  66215. * @param source Source pipeline.
  66216. * @param scene The scene to load the pipeline to.
  66217. * @param rootUrl The URL of the serialized pipeline.
  66218. * @returns An instantiated pipeline from the serialized object.
  66219. */
  66220. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66221. }
  66222. }
  66223. declare module BABYLON {
  66224. /** @hidden */
  66225. export var lensHighlightsPixelShader: {
  66226. name: string;
  66227. shader: string;
  66228. };
  66229. }
  66230. declare module BABYLON {
  66231. /** @hidden */
  66232. export var depthOfFieldPixelShader: {
  66233. name: string;
  66234. shader: string;
  66235. };
  66236. }
  66237. declare module BABYLON {
  66238. /**
  66239. * BABYLON.JS Chromatic Aberration GLSL Shader
  66240. * Author: Olivier Guyot
  66241. * Separates very slightly R, G and B colors on the edges of the screen
  66242. * Inspired by Francois Tarlier & Martins Upitis
  66243. */
  66244. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66245. /**
  66246. * @ignore
  66247. * The chromatic aberration PostProcess id in the pipeline
  66248. */
  66249. LensChromaticAberrationEffect: string;
  66250. /**
  66251. * @ignore
  66252. * The highlights enhancing PostProcess id in the pipeline
  66253. */
  66254. HighlightsEnhancingEffect: string;
  66255. /**
  66256. * @ignore
  66257. * The depth-of-field PostProcess id in the pipeline
  66258. */
  66259. LensDepthOfFieldEffect: string;
  66260. private _scene;
  66261. private _depthTexture;
  66262. private _grainTexture;
  66263. private _chromaticAberrationPostProcess;
  66264. private _highlightsPostProcess;
  66265. private _depthOfFieldPostProcess;
  66266. private _edgeBlur;
  66267. private _grainAmount;
  66268. private _chromaticAberration;
  66269. private _distortion;
  66270. private _highlightsGain;
  66271. private _highlightsThreshold;
  66272. private _dofDistance;
  66273. private _dofAperture;
  66274. private _dofDarken;
  66275. private _dofPentagon;
  66276. private _blurNoise;
  66277. /**
  66278. * @constructor
  66279. *
  66280. * Effect parameters are as follow:
  66281. * {
  66282. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66283. * edge_blur: number; // from 0 to x (1 for realism)
  66284. * distortion: number; // from 0 to x (1 for realism)
  66285. * grain_amount: number; // from 0 to 1
  66286. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66287. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66288. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66289. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66290. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66291. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66292. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66293. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66294. * }
  66295. * Note: if an effect parameter is unset, effect is disabled
  66296. *
  66297. * @param name The rendering pipeline name
  66298. * @param parameters - An object containing all parameters (see above)
  66299. * @param scene The scene linked to this pipeline
  66300. * @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)
  66301. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66302. */
  66303. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66304. /**
  66305. * Get the class name
  66306. * @returns "LensRenderingPipeline"
  66307. */
  66308. getClassName(): string;
  66309. /**
  66310. * Gets associated scene
  66311. */
  66312. get scene(): Scene;
  66313. /**
  66314. * Gets or sets the edge blur
  66315. */
  66316. get edgeBlur(): number;
  66317. set edgeBlur(value: number);
  66318. /**
  66319. * Gets or sets the grain amount
  66320. */
  66321. get grainAmount(): number;
  66322. set grainAmount(value: number);
  66323. /**
  66324. * Gets or sets the chromatic aberration amount
  66325. */
  66326. get chromaticAberration(): number;
  66327. set chromaticAberration(value: number);
  66328. /**
  66329. * Gets or sets the depth of field aperture
  66330. */
  66331. get dofAperture(): number;
  66332. set dofAperture(value: number);
  66333. /**
  66334. * Gets or sets the edge distortion
  66335. */
  66336. get edgeDistortion(): number;
  66337. set edgeDistortion(value: number);
  66338. /**
  66339. * Gets or sets the depth of field distortion
  66340. */
  66341. get dofDistortion(): number;
  66342. set dofDistortion(value: number);
  66343. /**
  66344. * Gets or sets the darken out of focus amount
  66345. */
  66346. get darkenOutOfFocus(): number;
  66347. set darkenOutOfFocus(value: number);
  66348. /**
  66349. * Gets or sets a boolean indicating if blur noise is enabled
  66350. */
  66351. get blurNoise(): boolean;
  66352. set blurNoise(value: boolean);
  66353. /**
  66354. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66355. */
  66356. get pentagonBokeh(): boolean;
  66357. set pentagonBokeh(value: boolean);
  66358. /**
  66359. * Gets or sets the highlight grain amount
  66360. */
  66361. get highlightsGain(): number;
  66362. set highlightsGain(value: number);
  66363. /**
  66364. * Gets or sets the highlight threshold
  66365. */
  66366. get highlightsThreshold(): number;
  66367. set highlightsThreshold(value: number);
  66368. /**
  66369. * Sets the amount of blur at the edges
  66370. * @param amount blur amount
  66371. */
  66372. setEdgeBlur(amount: number): void;
  66373. /**
  66374. * Sets edge blur to 0
  66375. */
  66376. disableEdgeBlur(): void;
  66377. /**
  66378. * Sets the amout of grain
  66379. * @param amount Amount of grain
  66380. */
  66381. setGrainAmount(amount: number): void;
  66382. /**
  66383. * Set grain amount to 0
  66384. */
  66385. disableGrain(): void;
  66386. /**
  66387. * Sets the chromatic aberration amount
  66388. * @param amount amount of chromatic aberration
  66389. */
  66390. setChromaticAberration(amount: number): void;
  66391. /**
  66392. * Sets chromatic aberration amount to 0
  66393. */
  66394. disableChromaticAberration(): void;
  66395. /**
  66396. * Sets the EdgeDistortion amount
  66397. * @param amount amount of EdgeDistortion
  66398. */
  66399. setEdgeDistortion(amount: number): void;
  66400. /**
  66401. * Sets edge distortion to 0
  66402. */
  66403. disableEdgeDistortion(): void;
  66404. /**
  66405. * Sets the FocusDistance amount
  66406. * @param amount amount of FocusDistance
  66407. */
  66408. setFocusDistance(amount: number): void;
  66409. /**
  66410. * Disables depth of field
  66411. */
  66412. disableDepthOfField(): void;
  66413. /**
  66414. * Sets the Aperture amount
  66415. * @param amount amount of Aperture
  66416. */
  66417. setAperture(amount: number): void;
  66418. /**
  66419. * Sets the DarkenOutOfFocus amount
  66420. * @param amount amount of DarkenOutOfFocus
  66421. */
  66422. setDarkenOutOfFocus(amount: number): void;
  66423. private _pentagonBokehIsEnabled;
  66424. /**
  66425. * Creates a pentagon bokeh effect
  66426. */
  66427. enablePentagonBokeh(): void;
  66428. /**
  66429. * Disables the pentagon bokeh effect
  66430. */
  66431. disablePentagonBokeh(): void;
  66432. /**
  66433. * Enables noise blur
  66434. */
  66435. enableNoiseBlur(): void;
  66436. /**
  66437. * Disables noise blur
  66438. */
  66439. disableNoiseBlur(): void;
  66440. /**
  66441. * Sets the HighlightsGain amount
  66442. * @param amount amount of HighlightsGain
  66443. */
  66444. setHighlightsGain(amount: number): void;
  66445. /**
  66446. * Sets the HighlightsThreshold amount
  66447. * @param amount amount of HighlightsThreshold
  66448. */
  66449. setHighlightsThreshold(amount: number): void;
  66450. /**
  66451. * Disables highlights
  66452. */
  66453. disableHighlights(): void;
  66454. /**
  66455. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66456. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66457. */
  66458. dispose(disableDepthRender?: boolean): void;
  66459. private _createChromaticAberrationPostProcess;
  66460. private _createHighlightsPostProcess;
  66461. private _createDepthOfFieldPostProcess;
  66462. private _createGrainTexture;
  66463. }
  66464. }
  66465. declare module BABYLON {
  66466. /** @hidden */
  66467. export var ssao2PixelShader: {
  66468. name: string;
  66469. shader: string;
  66470. };
  66471. }
  66472. declare module BABYLON {
  66473. /** @hidden */
  66474. export var ssaoCombinePixelShader: {
  66475. name: string;
  66476. shader: string;
  66477. };
  66478. }
  66479. declare module BABYLON {
  66480. /**
  66481. * Render pipeline to produce ssao effect
  66482. */
  66483. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66484. /**
  66485. * @ignore
  66486. * The PassPostProcess id in the pipeline that contains the original scene color
  66487. */
  66488. SSAOOriginalSceneColorEffect: string;
  66489. /**
  66490. * @ignore
  66491. * The SSAO PostProcess id in the pipeline
  66492. */
  66493. SSAORenderEffect: string;
  66494. /**
  66495. * @ignore
  66496. * The horizontal blur PostProcess id in the pipeline
  66497. */
  66498. SSAOBlurHRenderEffect: string;
  66499. /**
  66500. * @ignore
  66501. * The vertical blur PostProcess id in the pipeline
  66502. */
  66503. SSAOBlurVRenderEffect: string;
  66504. /**
  66505. * @ignore
  66506. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66507. */
  66508. SSAOCombineRenderEffect: string;
  66509. /**
  66510. * The output strength of the SSAO post-process. Default value is 1.0.
  66511. */
  66512. totalStrength: number;
  66513. /**
  66514. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66515. */
  66516. maxZ: number;
  66517. /**
  66518. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66519. */
  66520. minZAspect: number;
  66521. private _samples;
  66522. /**
  66523. * Number of samples used for the SSAO calculations. Default value is 8
  66524. */
  66525. set samples(n: number);
  66526. get samples(): number;
  66527. private _textureSamples;
  66528. /**
  66529. * Number of samples to use for antialiasing
  66530. */
  66531. set textureSamples(n: number);
  66532. get textureSamples(): number;
  66533. /**
  66534. * Ratio object used for SSAO ratio and blur ratio
  66535. */
  66536. private _ratio;
  66537. /**
  66538. * Dynamically generated sphere sampler.
  66539. */
  66540. private _sampleSphere;
  66541. /**
  66542. * Blur filter offsets
  66543. */
  66544. private _samplerOffsets;
  66545. private _expensiveBlur;
  66546. /**
  66547. * If bilateral blur should be used
  66548. */
  66549. set expensiveBlur(b: boolean);
  66550. get expensiveBlur(): boolean;
  66551. /**
  66552. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66553. */
  66554. radius: number;
  66555. /**
  66556. * The base color of the SSAO post-process
  66557. * The final result is "base + ssao" between [0, 1]
  66558. */
  66559. base: number;
  66560. /**
  66561. * Support test.
  66562. */
  66563. static get IsSupported(): boolean;
  66564. private _scene;
  66565. private _depthTexture;
  66566. private _normalTexture;
  66567. private _randomTexture;
  66568. private _originalColorPostProcess;
  66569. private _ssaoPostProcess;
  66570. private _blurHPostProcess;
  66571. private _blurVPostProcess;
  66572. private _ssaoCombinePostProcess;
  66573. /**
  66574. * Gets active scene
  66575. */
  66576. get scene(): Scene;
  66577. /**
  66578. * @constructor
  66579. * @param name The rendering pipeline name
  66580. * @param scene The scene linked to this pipeline
  66581. * @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 }
  66582. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66583. */
  66584. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66585. /**
  66586. * Get the class name
  66587. * @returns "SSAO2RenderingPipeline"
  66588. */
  66589. getClassName(): string;
  66590. /**
  66591. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66592. */
  66593. dispose(disableGeometryBufferRenderer?: boolean): void;
  66594. private _createBlurPostProcess;
  66595. /** @hidden */
  66596. _rebuild(): void;
  66597. private _bits;
  66598. private _radicalInverse_VdC;
  66599. private _hammersley;
  66600. private _hemisphereSample_uniform;
  66601. private _generateHemisphere;
  66602. private _createSSAOPostProcess;
  66603. private _createSSAOCombinePostProcess;
  66604. private _createRandomTexture;
  66605. /**
  66606. * Serialize the rendering pipeline (Used when exporting)
  66607. * @returns the serialized object
  66608. */
  66609. serialize(): any;
  66610. /**
  66611. * Parse the serialized pipeline
  66612. * @param source Source pipeline.
  66613. * @param scene The scene to load the pipeline to.
  66614. * @param rootUrl The URL of the serialized pipeline.
  66615. * @returns An instantiated pipeline from the serialized object.
  66616. */
  66617. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66618. }
  66619. }
  66620. declare module BABYLON {
  66621. /** @hidden */
  66622. export var ssaoPixelShader: {
  66623. name: string;
  66624. shader: string;
  66625. };
  66626. }
  66627. declare module BABYLON {
  66628. /**
  66629. * Render pipeline to produce ssao effect
  66630. */
  66631. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66632. /**
  66633. * @ignore
  66634. * The PassPostProcess id in the pipeline that contains the original scene color
  66635. */
  66636. SSAOOriginalSceneColorEffect: string;
  66637. /**
  66638. * @ignore
  66639. * The SSAO PostProcess id in the pipeline
  66640. */
  66641. SSAORenderEffect: string;
  66642. /**
  66643. * @ignore
  66644. * The horizontal blur PostProcess id in the pipeline
  66645. */
  66646. SSAOBlurHRenderEffect: string;
  66647. /**
  66648. * @ignore
  66649. * The vertical blur PostProcess id in the pipeline
  66650. */
  66651. SSAOBlurVRenderEffect: string;
  66652. /**
  66653. * @ignore
  66654. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66655. */
  66656. SSAOCombineRenderEffect: string;
  66657. /**
  66658. * The output strength of the SSAO post-process. Default value is 1.0.
  66659. */
  66660. totalStrength: number;
  66661. /**
  66662. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66663. */
  66664. radius: number;
  66665. /**
  66666. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66667. * Must not be equal to fallOff and superior to fallOff.
  66668. * Default value is 0.0075
  66669. */
  66670. area: number;
  66671. /**
  66672. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66673. * Must not be equal to area and inferior to area.
  66674. * Default value is 0.000001
  66675. */
  66676. fallOff: number;
  66677. /**
  66678. * The base color of the SSAO post-process
  66679. * The final result is "base + ssao" between [0, 1]
  66680. */
  66681. base: number;
  66682. private _scene;
  66683. private _depthTexture;
  66684. private _randomTexture;
  66685. private _originalColorPostProcess;
  66686. private _ssaoPostProcess;
  66687. private _blurHPostProcess;
  66688. private _blurVPostProcess;
  66689. private _ssaoCombinePostProcess;
  66690. private _firstUpdate;
  66691. /**
  66692. * Gets active scene
  66693. */
  66694. get scene(): Scene;
  66695. /**
  66696. * @constructor
  66697. * @param name - The rendering pipeline name
  66698. * @param scene - The scene linked to this pipeline
  66699. * @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 }
  66700. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66701. */
  66702. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66703. /**
  66704. * Get the class name
  66705. * @returns "SSAORenderingPipeline"
  66706. */
  66707. getClassName(): string;
  66708. /**
  66709. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66710. */
  66711. dispose(disableDepthRender?: boolean): void;
  66712. private _createBlurPostProcess;
  66713. /** @hidden */
  66714. _rebuild(): void;
  66715. private _createSSAOPostProcess;
  66716. private _createSSAOCombinePostProcess;
  66717. private _createRandomTexture;
  66718. }
  66719. }
  66720. declare module BABYLON {
  66721. /** @hidden */
  66722. export var screenSpaceReflectionPixelShader: {
  66723. name: string;
  66724. shader: string;
  66725. };
  66726. }
  66727. declare module BABYLON {
  66728. /**
  66729. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66730. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66731. */
  66732. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66733. /**
  66734. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66735. */
  66736. threshold: number;
  66737. /**
  66738. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66739. */
  66740. strength: number;
  66741. /**
  66742. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66743. */
  66744. reflectionSpecularFalloffExponent: number;
  66745. /**
  66746. * 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]
  66747. */
  66748. step: number;
  66749. /**
  66750. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66751. */
  66752. roughnessFactor: number;
  66753. private _geometryBufferRenderer;
  66754. private _enableSmoothReflections;
  66755. private _reflectionSamples;
  66756. private _smoothSteps;
  66757. /**
  66758. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66759. * @param name The name of the effect.
  66760. * @param scene The scene containing the objects to calculate reflections.
  66761. * @param options The required width/height ratio to downsize to before computing the render pass.
  66762. * @param camera The camera to apply the render pass to.
  66763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66764. * @param engine The engine which the post process will be applied. (default: current engine)
  66765. * @param reusable If the post process can be reused on the same frame. (default: false)
  66766. * @param textureType Type of textures used when performing the post process. (default: 0)
  66767. * @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)
  66768. */
  66769. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66770. /**
  66771. * Gets wether or not smoothing reflections is enabled.
  66772. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66773. */
  66774. get enableSmoothReflections(): boolean;
  66775. /**
  66776. * Sets wether or not smoothing reflections is enabled.
  66777. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66778. */
  66779. set enableSmoothReflections(enabled: boolean);
  66780. /**
  66781. * Gets the number of samples taken while computing reflections. More samples count is high,
  66782. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66783. */
  66784. get reflectionSamples(): number;
  66785. /**
  66786. * Sets the number of samples taken while computing reflections. More samples count is high,
  66787. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66788. */
  66789. set reflectionSamples(samples: number);
  66790. /**
  66791. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66792. * more the post-process will require GPU power and can generate a drop in FPS.
  66793. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66794. */
  66795. get smoothSteps(): number;
  66796. set smoothSteps(steps: number);
  66797. private _updateEffectDefines;
  66798. }
  66799. }
  66800. declare module BABYLON {
  66801. /** @hidden */
  66802. export var standardPixelShader: {
  66803. name: string;
  66804. shader: string;
  66805. };
  66806. }
  66807. declare module BABYLON {
  66808. /**
  66809. * Standard rendering pipeline
  66810. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66811. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66812. */
  66813. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66814. /**
  66815. * Public members
  66816. */
  66817. /**
  66818. * Post-process which contains the original scene color before the pipeline applies all the effects
  66819. */
  66820. originalPostProcess: Nullable<PostProcess>;
  66821. /**
  66822. * Post-process used to down scale an image x4
  66823. */
  66824. downSampleX4PostProcess: Nullable<PostProcess>;
  66825. /**
  66826. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66827. */
  66828. brightPassPostProcess: Nullable<PostProcess>;
  66829. /**
  66830. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66831. */
  66832. blurHPostProcesses: PostProcess[];
  66833. /**
  66834. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66835. */
  66836. blurVPostProcesses: PostProcess[];
  66837. /**
  66838. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66839. */
  66840. textureAdderPostProcess: Nullable<PostProcess>;
  66841. /**
  66842. * Post-process used to create volumetric lighting effect
  66843. */
  66844. volumetricLightPostProcess: Nullable<PostProcess>;
  66845. /**
  66846. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66847. */
  66848. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66849. /**
  66850. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66851. */
  66852. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66853. /**
  66854. * Post-process used to merge the volumetric light effect and the real scene color
  66855. */
  66856. volumetricLightMergePostProces: Nullable<PostProcess>;
  66857. /**
  66858. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66859. */
  66860. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66861. /**
  66862. * Base post-process used to calculate the average luminance of the final image for HDR
  66863. */
  66864. luminancePostProcess: Nullable<PostProcess>;
  66865. /**
  66866. * Post-processes used to create down sample post-processes in order to get
  66867. * the average luminance of the final image for HDR
  66868. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66869. */
  66870. luminanceDownSamplePostProcesses: PostProcess[];
  66871. /**
  66872. * Post-process used to create a HDR effect (light adaptation)
  66873. */
  66874. hdrPostProcess: Nullable<PostProcess>;
  66875. /**
  66876. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66877. */
  66878. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66879. /**
  66880. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66881. */
  66882. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66883. /**
  66884. * Post-process used to merge the final HDR post-process and the real scene color
  66885. */
  66886. hdrFinalPostProcess: Nullable<PostProcess>;
  66887. /**
  66888. * Post-process used to create a lens flare effect
  66889. */
  66890. lensFlarePostProcess: Nullable<PostProcess>;
  66891. /**
  66892. * Post-process that merges the result of the lens flare post-process and the real scene color
  66893. */
  66894. lensFlareComposePostProcess: Nullable<PostProcess>;
  66895. /**
  66896. * Post-process used to create a motion blur effect
  66897. */
  66898. motionBlurPostProcess: Nullable<PostProcess>;
  66899. /**
  66900. * Post-process used to create a depth of field effect
  66901. */
  66902. depthOfFieldPostProcess: Nullable<PostProcess>;
  66903. /**
  66904. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66905. */
  66906. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66907. /**
  66908. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66909. */
  66910. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66911. /**
  66912. * Represents the brightness threshold in order to configure the illuminated surfaces
  66913. */
  66914. brightThreshold: number;
  66915. /**
  66916. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66917. */
  66918. blurWidth: number;
  66919. /**
  66920. * Sets if the blur for highlighted surfaces must be only horizontal
  66921. */
  66922. horizontalBlur: boolean;
  66923. /**
  66924. * Gets the overall exposure used by the pipeline
  66925. */
  66926. get exposure(): number;
  66927. /**
  66928. * Sets the overall exposure used by the pipeline
  66929. */
  66930. set exposure(value: number);
  66931. /**
  66932. * Texture used typically to simulate "dirty" on camera lens
  66933. */
  66934. lensTexture: Nullable<Texture>;
  66935. /**
  66936. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66937. */
  66938. volumetricLightCoefficient: number;
  66939. /**
  66940. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66941. */
  66942. volumetricLightPower: number;
  66943. /**
  66944. * Used the set the blur intensity to smooth the volumetric lights
  66945. */
  66946. volumetricLightBlurScale: number;
  66947. /**
  66948. * Light (spot or directional) used to generate the volumetric lights rays
  66949. * The source light must have a shadow generate so the pipeline can get its
  66950. * depth map
  66951. */
  66952. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66953. /**
  66954. * For eye adaptation, represents the minimum luminance the eye can see
  66955. */
  66956. hdrMinimumLuminance: number;
  66957. /**
  66958. * For eye adaptation, represents the decrease luminance speed
  66959. */
  66960. hdrDecreaseRate: number;
  66961. /**
  66962. * For eye adaptation, represents the increase luminance speed
  66963. */
  66964. hdrIncreaseRate: number;
  66965. /**
  66966. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66967. */
  66968. get hdrAutoExposure(): boolean;
  66969. /**
  66970. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66971. */
  66972. set hdrAutoExposure(value: boolean);
  66973. /**
  66974. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66975. */
  66976. lensColorTexture: Nullable<Texture>;
  66977. /**
  66978. * The overall strengh for the lens flare effect
  66979. */
  66980. lensFlareStrength: number;
  66981. /**
  66982. * Dispersion coefficient for lens flare ghosts
  66983. */
  66984. lensFlareGhostDispersal: number;
  66985. /**
  66986. * Main lens flare halo width
  66987. */
  66988. lensFlareHaloWidth: number;
  66989. /**
  66990. * Based on the lens distortion effect, defines how much the lens flare result
  66991. * is distorted
  66992. */
  66993. lensFlareDistortionStrength: number;
  66994. /**
  66995. * Configures the blur intensity used for for lens flare (halo)
  66996. */
  66997. lensFlareBlurWidth: number;
  66998. /**
  66999. * Lens star texture must be used to simulate rays on the flares and is available
  67000. * in the documentation
  67001. */
  67002. lensStarTexture: Nullable<Texture>;
  67003. /**
  67004. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67005. * flare effect by taking account of the dirt texture
  67006. */
  67007. lensFlareDirtTexture: Nullable<Texture>;
  67008. /**
  67009. * Represents the focal length for the depth of field effect
  67010. */
  67011. depthOfFieldDistance: number;
  67012. /**
  67013. * Represents the blur intensity for the blurred part of the depth of field effect
  67014. */
  67015. depthOfFieldBlurWidth: number;
  67016. /**
  67017. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67018. */
  67019. get motionStrength(): number;
  67020. /**
  67021. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67022. */
  67023. set motionStrength(strength: number);
  67024. /**
  67025. * Gets wether or not the motion blur post-process is object based or screen based.
  67026. */
  67027. get objectBasedMotionBlur(): boolean;
  67028. /**
  67029. * Sets wether or not the motion blur post-process should be object based or screen based
  67030. */
  67031. set objectBasedMotionBlur(value: boolean);
  67032. /**
  67033. * List of animations for the pipeline (IAnimatable implementation)
  67034. */
  67035. animations: Animation[];
  67036. /**
  67037. * Private members
  67038. */
  67039. private _scene;
  67040. private _currentDepthOfFieldSource;
  67041. private _basePostProcess;
  67042. private _fixedExposure;
  67043. private _currentExposure;
  67044. private _hdrAutoExposure;
  67045. private _hdrCurrentLuminance;
  67046. private _motionStrength;
  67047. private _isObjectBasedMotionBlur;
  67048. private _floatTextureType;
  67049. private _camerasToBeAttached;
  67050. private _ratio;
  67051. private _bloomEnabled;
  67052. private _depthOfFieldEnabled;
  67053. private _vlsEnabled;
  67054. private _lensFlareEnabled;
  67055. private _hdrEnabled;
  67056. private _motionBlurEnabled;
  67057. private _fxaaEnabled;
  67058. private _screenSpaceReflectionsEnabled;
  67059. private _motionBlurSamples;
  67060. private _volumetricLightStepsCount;
  67061. private _samples;
  67062. /**
  67063. * @ignore
  67064. * Specifies if the bloom pipeline is enabled
  67065. */
  67066. get BloomEnabled(): boolean;
  67067. set BloomEnabled(enabled: boolean);
  67068. /**
  67069. * @ignore
  67070. * Specifies if the depth of field pipeline is enabed
  67071. */
  67072. get DepthOfFieldEnabled(): boolean;
  67073. set DepthOfFieldEnabled(enabled: boolean);
  67074. /**
  67075. * @ignore
  67076. * Specifies if the lens flare pipeline is enabed
  67077. */
  67078. get LensFlareEnabled(): boolean;
  67079. set LensFlareEnabled(enabled: boolean);
  67080. /**
  67081. * @ignore
  67082. * Specifies if the HDR pipeline is enabled
  67083. */
  67084. get HDREnabled(): boolean;
  67085. set HDREnabled(enabled: boolean);
  67086. /**
  67087. * @ignore
  67088. * Specifies if the volumetric lights scattering effect is enabled
  67089. */
  67090. get VLSEnabled(): boolean;
  67091. set VLSEnabled(enabled: boolean);
  67092. /**
  67093. * @ignore
  67094. * Specifies if the motion blur effect is enabled
  67095. */
  67096. get MotionBlurEnabled(): boolean;
  67097. set MotionBlurEnabled(enabled: boolean);
  67098. /**
  67099. * Specifies if anti-aliasing is enabled
  67100. */
  67101. get fxaaEnabled(): boolean;
  67102. set fxaaEnabled(enabled: boolean);
  67103. /**
  67104. * Specifies if screen space reflections are enabled.
  67105. */
  67106. get screenSpaceReflectionsEnabled(): boolean;
  67107. set screenSpaceReflectionsEnabled(enabled: boolean);
  67108. /**
  67109. * Specifies the number of steps used to calculate the volumetric lights
  67110. * Typically in interval [50, 200]
  67111. */
  67112. get volumetricLightStepsCount(): number;
  67113. set volumetricLightStepsCount(count: number);
  67114. /**
  67115. * Specifies the number of samples used for the motion blur effect
  67116. * Typically in interval [16, 64]
  67117. */
  67118. get motionBlurSamples(): number;
  67119. set motionBlurSamples(samples: number);
  67120. /**
  67121. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67122. */
  67123. get samples(): number;
  67124. set samples(sampleCount: number);
  67125. /**
  67126. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67127. * @constructor
  67128. * @param name The rendering pipeline name
  67129. * @param scene The scene linked to this pipeline
  67130. * @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)
  67131. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67132. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67133. */
  67134. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67135. private _buildPipeline;
  67136. private _createDownSampleX4PostProcess;
  67137. private _createBrightPassPostProcess;
  67138. private _createBlurPostProcesses;
  67139. private _createTextureAdderPostProcess;
  67140. private _createVolumetricLightPostProcess;
  67141. private _createLuminancePostProcesses;
  67142. private _createHdrPostProcess;
  67143. private _createLensFlarePostProcess;
  67144. private _createDepthOfFieldPostProcess;
  67145. private _createMotionBlurPostProcess;
  67146. private _getDepthTexture;
  67147. private _disposePostProcesses;
  67148. /**
  67149. * Dispose of the pipeline and stop all post processes
  67150. */
  67151. dispose(): void;
  67152. /**
  67153. * Serialize the rendering pipeline (Used when exporting)
  67154. * @returns the serialized object
  67155. */
  67156. serialize(): any;
  67157. /**
  67158. * Parse the serialized pipeline
  67159. * @param source Source pipeline.
  67160. * @param scene The scene to load the pipeline to.
  67161. * @param rootUrl The URL of the serialized pipeline.
  67162. * @returns An instantiated pipeline from the serialized object.
  67163. */
  67164. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67165. /**
  67166. * Luminance steps
  67167. */
  67168. static LuminanceSteps: number;
  67169. }
  67170. }
  67171. declare module BABYLON {
  67172. /** @hidden */
  67173. export var tonemapPixelShader: {
  67174. name: string;
  67175. shader: string;
  67176. };
  67177. }
  67178. declare module BABYLON {
  67179. /** Defines operator used for tonemapping */
  67180. export enum TonemappingOperator {
  67181. /** Hable */
  67182. Hable = 0,
  67183. /** Reinhard */
  67184. Reinhard = 1,
  67185. /** HejiDawson */
  67186. HejiDawson = 2,
  67187. /** Photographic */
  67188. Photographic = 3
  67189. }
  67190. /**
  67191. * Defines a post process to apply tone mapping
  67192. */
  67193. export class TonemapPostProcess extends PostProcess {
  67194. private _operator;
  67195. /** Defines the required exposure adjustement */
  67196. exposureAdjustment: number;
  67197. /**
  67198. * Creates a new TonemapPostProcess
  67199. * @param name defines the name of the postprocess
  67200. * @param _operator defines the operator to use
  67201. * @param exposureAdjustment defines the required exposure adjustement
  67202. * @param camera defines the camera to use (can be null)
  67203. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67204. * @param engine defines the hosting engine (can be ignore if camera is set)
  67205. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67206. */
  67207. constructor(name: string, _operator: TonemappingOperator,
  67208. /** Defines the required exposure adjustement */
  67209. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /** @hidden */
  67214. export var volumetricLightScatteringPixelShader: {
  67215. name: string;
  67216. shader: string;
  67217. };
  67218. }
  67219. declare module BABYLON {
  67220. /** @hidden */
  67221. export var volumetricLightScatteringPassVertexShader: {
  67222. name: string;
  67223. shader: string;
  67224. };
  67225. }
  67226. declare module BABYLON {
  67227. /** @hidden */
  67228. export var volumetricLightScatteringPassPixelShader: {
  67229. name: string;
  67230. shader: string;
  67231. };
  67232. }
  67233. declare module BABYLON {
  67234. /**
  67235. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67236. */
  67237. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67238. private _volumetricLightScatteringPass;
  67239. private _volumetricLightScatteringRTT;
  67240. private _viewPort;
  67241. private _screenCoordinates;
  67242. private _cachedDefines;
  67243. /**
  67244. * If not undefined, the mesh position is computed from the attached node position
  67245. */
  67246. attachedNode: {
  67247. position: Vector3;
  67248. };
  67249. /**
  67250. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67251. */
  67252. customMeshPosition: Vector3;
  67253. /**
  67254. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67255. */
  67256. useCustomMeshPosition: boolean;
  67257. /**
  67258. * If the post-process should inverse the light scattering direction
  67259. */
  67260. invert: boolean;
  67261. /**
  67262. * The internal mesh used by the post-process
  67263. */
  67264. mesh: Mesh;
  67265. /**
  67266. * @hidden
  67267. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67268. */
  67269. get useDiffuseColor(): boolean;
  67270. set useDiffuseColor(useDiffuseColor: boolean);
  67271. /**
  67272. * Array containing the excluded meshes not rendered in the internal pass
  67273. */
  67274. excludedMeshes: AbstractMesh[];
  67275. /**
  67276. * Controls the overall intensity of the post-process
  67277. */
  67278. exposure: number;
  67279. /**
  67280. * Dissipates each sample's contribution in range [0, 1]
  67281. */
  67282. decay: number;
  67283. /**
  67284. * Controls the overall intensity of each sample
  67285. */
  67286. weight: number;
  67287. /**
  67288. * Controls the density of each sample
  67289. */
  67290. density: number;
  67291. /**
  67292. * @constructor
  67293. * @param name The post-process name
  67294. * @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)
  67295. * @param camera The camera that the post-process will be attached to
  67296. * @param mesh The mesh used to create the light scattering
  67297. * @param samples The post-process quality, default 100
  67298. * @param samplingModeThe post-process filtering mode
  67299. * @param engine The babylon engine
  67300. * @param reusable If the post-process is reusable
  67301. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67302. */
  67303. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67304. /**
  67305. * Returns the string "VolumetricLightScatteringPostProcess"
  67306. * @returns "VolumetricLightScatteringPostProcess"
  67307. */
  67308. getClassName(): string;
  67309. private _isReady;
  67310. /**
  67311. * Sets the new light position for light scattering effect
  67312. * @param position The new custom light position
  67313. */
  67314. setCustomMeshPosition(position: Vector3): void;
  67315. /**
  67316. * Returns the light position for light scattering effect
  67317. * @return Vector3 The custom light position
  67318. */
  67319. getCustomMeshPosition(): Vector3;
  67320. /**
  67321. * Disposes the internal assets and detaches the post-process from the camera
  67322. */
  67323. dispose(camera: Camera): void;
  67324. /**
  67325. * Returns the render target texture used by the post-process
  67326. * @return the render target texture used by the post-process
  67327. */
  67328. getPass(): RenderTargetTexture;
  67329. private _meshExcluded;
  67330. private _createPass;
  67331. private _updateMeshScreenCoordinates;
  67332. /**
  67333. * Creates a default mesh for the Volumeric Light Scattering post-process
  67334. * @param name The mesh name
  67335. * @param scene The scene where to create the mesh
  67336. * @return the default mesh
  67337. */
  67338. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67339. }
  67340. }
  67341. declare module BABYLON {
  67342. interface Scene {
  67343. /** @hidden (Backing field) */
  67344. _boundingBoxRenderer: BoundingBoxRenderer;
  67345. /** @hidden (Backing field) */
  67346. _forceShowBoundingBoxes: boolean;
  67347. /**
  67348. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67349. */
  67350. forceShowBoundingBoxes: boolean;
  67351. /**
  67352. * Gets the bounding box renderer associated with the scene
  67353. * @returns a BoundingBoxRenderer
  67354. */
  67355. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67356. }
  67357. interface AbstractMesh {
  67358. /** @hidden (Backing field) */
  67359. _showBoundingBox: boolean;
  67360. /**
  67361. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67362. */
  67363. showBoundingBox: boolean;
  67364. }
  67365. /**
  67366. * Component responsible of rendering the bounding box of the meshes in a scene.
  67367. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67368. */
  67369. export class BoundingBoxRenderer implements ISceneComponent {
  67370. /**
  67371. * The component name helpfull to identify the component in the list of scene components.
  67372. */
  67373. readonly name: string;
  67374. /**
  67375. * The scene the component belongs to.
  67376. */
  67377. scene: Scene;
  67378. /**
  67379. * Color of the bounding box lines placed in front of an object
  67380. */
  67381. frontColor: Color3;
  67382. /**
  67383. * Color of the bounding box lines placed behind an object
  67384. */
  67385. backColor: Color3;
  67386. /**
  67387. * Defines if the renderer should show the back lines or not
  67388. */
  67389. showBackLines: boolean;
  67390. /**
  67391. * @hidden
  67392. */
  67393. renderList: SmartArray<BoundingBox>;
  67394. private _colorShader;
  67395. private _vertexBuffers;
  67396. private _indexBuffer;
  67397. private _fillIndexBuffer;
  67398. private _fillIndexData;
  67399. /**
  67400. * Instantiates a new bounding box renderer in a scene.
  67401. * @param scene the scene the renderer renders in
  67402. */
  67403. constructor(scene: Scene);
  67404. /**
  67405. * Registers the component in a given scene
  67406. */
  67407. register(): void;
  67408. private _evaluateSubMesh;
  67409. private _activeMesh;
  67410. private _prepareRessources;
  67411. private _createIndexBuffer;
  67412. /**
  67413. * Rebuilds the elements related to this component in case of
  67414. * context lost for instance.
  67415. */
  67416. rebuild(): void;
  67417. /**
  67418. * @hidden
  67419. */
  67420. reset(): void;
  67421. /**
  67422. * Render the bounding boxes of a specific rendering group
  67423. * @param renderingGroupId defines the rendering group to render
  67424. */
  67425. render(renderingGroupId: number): void;
  67426. /**
  67427. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67428. * @param mesh Define the mesh to render the occlusion bounding box for
  67429. */
  67430. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67431. /**
  67432. * Dispose and release the resources attached to this renderer.
  67433. */
  67434. dispose(): void;
  67435. }
  67436. }
  67437. declare module BABYLON {
  67438. interface Scene {
  67439. /** @hidden (Backing field) */
  67440. _depthRenderer: {
  67441. [id: string]: DepthRenderer;
  67442. };
  67443. /**
  67444. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67445. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67446. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67447. * @returns the created depth renderer
  67448. */
  67449. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67450. /**
  67451. * Disables a depth renderer for a given camera
  67452. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67453. */
  67454. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67455. }
  67456. /**
  67457. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67458. * in several rendering techniques.
  67459. */
  67460. export class DepthRendererSceneComponent implements ISceneComponent {
  67461. /**
  67462. * The component name helpfull to identify the component in the list of scene components.
  67463. */
  67464. readonly name: string;
  67465. /**
  67466. * The scene the component belongs to.
  67467. */
  67468. scene: Scene;
  67469. /**
  67470. * Creates a new instance of the component for the given scene
  67471. * @param scene Defines the scene to register the component in
  67472. */
  67473. constructor(scene: Scene);
  67474. /**
  67475. * Registers the component in a given scene
  67476. */
  67477. register(): void;
  67478. /**
  67479. * Rebuilds the elements related to this component in case of
  67480. * context lost for instance.
  67481. */
  67482. rebuild(): void;
  67483. /**
  67484. * Disposes the component and the associated ressources
  67485. */
  67486. dispose(): void;
  67487. private _gatherRenderTargets;
  67488. private _gatherActiveCameraRenderTargets;
  67489. }
  67490. }
  67491. declare module BABYLON {
  67492. /** @hidden */
  67493. export var outlinePixelShader: {
  67494. name: string;
  67495. shader: string;
  67496. };
  67497. }
  67498. declare module BABYLON {
  67499. /** @hidden */
  67500. export var outlineVertexShader: {
  67501. name: string;
  67502. shader: string;
  67503. };
  67504. }
  67505. declare module BABYLON {
  67506. interface Scene {
  67507. /** @hidden */
  67508. _outlineRenderer: OutlineRenderer;
  67509. /**
  67510. * Gets the outline renderer associated with the scene
  67511. * @returns a OutlineRenderer
  67512. */
  67513. getOutlineRenderer(): OutlineRenderer;
  67514. }
  67515. interface AbstractMesh {
  67516. /** @hidden (Backing field) */
  67517. _renderOutline: boolean;
  67518. /**
  67519. * Gets or sets a boolean indicating if the outline must be rendered as well
  67520. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67521. */
  67522. renderOutline: boolean;
  67523. /** @hidden (Backing field) */
  67524. _renderOverlay: boolean;
  67525. /**
  67526. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67527. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67528. */
  67529. renderOverlay: boolean;
  67530. }
  67531. /**
  67532. * This class is responsible to draw bothe outline/overlay of meshes.
  67533. * It should not be used directly but through the available method on mesh.
  67534. */
  67535. export class OutlineRenderer implements ISceneComponent {
  67536. /**
  67537. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67538. */
  67539. private static _StencilReference;
  67540. /**
  67541. * The name of the component. Each component must have a unique name.
  67542. */
  67543. name: string;
  67544. /**
  67545. * The scene the component belongs to.
  67546. */
  67547. scene: Scene;
  67548. /**
  67549. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67550. */
  67551. zOffset: number;
  67552. private _engine;
  67553. private _effect;
  67554. private _cachedDefines;
  67555. private _savedDepthWrite;
  67556. /**
  67557. * Instantiates a new outline renderer. (There could be only one per scene).
  67558. * @param scene Defines the scene it belongs to
  67559. */
  67560. constructor(scene: Scene);
  67561. /**
  67562. * Register the component to one instance of a scene.
  67563. */
  67564. register(): void;
  67565. /**
  67566. * Rebuilds the elements related to this component in case of
  67567. * context lost for instance.
  67568. */
  67569. rebuild(): void;
  67570. /**
  67571. * Disposes the component and the associated ressources.
  67572. */
  67573. dispose(): void;
  67574. /**
  67575. * Renders the outline in the canvas.
  67576. * @param subMesh Defines the sumesh to render
  67577. * @param batch Defines the batch of meshes in case of instances
  67578. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67579. */
  67580. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67581. /**
  67582. * Returns whether or not the outline renderer is ready for a given submesh.
  67583. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67584. * @param subMesh Defines the submesh to check readyness for
  67585. * @param useInstances Defines wheter wee are trying to render instances or not
  67586. * @returns true if ready otherwise false
  67587. */
  67588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67589. private _beforeRenderingMesh;
  67590. private _afterRenderingMesh;
  67591. }
  67592. }
  67593. declare module BABYLON {
  67594. /**
  67595. * Defines the basic options interface of a Sprite Frame Source Size.
  67596. */
  67597. export interface ISpriteJSONSpriteSourceSize {
  67598. /**
  67599. * number of the original width of the Frame
  67600. */
  67601. w: number;
  67602. /**
  67603. * number of the original height of the Frame
  67604. */
  67605. h: number;
  67606. }
  67607. /**
  67608. * Defines the basic options interface of a Sprite Frame Data.
  67609. */
  67610. export interface ISpriteJSONSpriteFrameData {
  67611. /**
  67612. * number of the x offset of the Frame
  67613. */
  67614. x: number;
  67615. /**
  67616. * number of the y offset of the Frame
  67617. */
  67618. y: number;
  67619. /**
  67620. * number of the width of the Frame
  67621. */
  67622. w: number;
  67623. /**
  67624. * number of the height of the Frame
  67625. */
  67626. h: number;
  67627. }
  67628. /**
  67629. * Defines the basic options interface of a JSON Sprite.
  67630. */
  67631. export interface ISpriteJSONSprite {
  67632. /**
  67633. * string name of the Frame
  67634. */
  67635. filename: string;
  67636. /**
  67637. * ISpriteJSONSpriteFrame basic object of the frame data
  67638. */
  67639. frame: ISpriteJSONSpriteFrameData;
  67640. /**
  67641. * boolean to flag is the frame was rotated.
  67642. */
  67643. rotated: boolean;
  67644. /**
  67645. * boolean to flag is the frame was trimmed.
  67646. */
  67647. trimmed: boolean;
  67648. /**
  67649. * ISpriteJSONSpriteFrame basic object of the source data
  67650. */
  67651. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67652. /**
  67653. * ISpriteJSONSpriteFrame basic object of the source data
  67654. */
  67655. sourceSize: ISpriteJSONSpriteSourceSize;
  67656. }
  67657. /**
  67658. * Defines the basic options interface of a JSON atlas.
  67659. */
  67660. export interface ISpriteJSONAtlas {
  67661. /**
  67662. * Array of objects that contain the frame data.
  67663. */
  67664. frames: Array<ISpriteJSONSprite>;
  67665. /**
  67666. * object basic object containing the sprite meta data.
  67667. */
  67668. meta?: object;
  67669. }
  67670. }
  67671. declare module BABYLON {
  67672. /** @hidden */
  67673. export var spriteMapPixelShader: {
  67674. name: string;
  67675. shader: string;
  67676. };
  67677. }
  67678. declare module BABYLON {
  67679. /** @hidden */
  67680. export var spriteMapVertexShader: {
  67681. name: string;
  67682. shader: string;
  67683. };
  67684. }
  67685. declare module BABYLON {
  67686. /**
  67687. * Defines the basic options interface of a SpriteMap
  67688. */
  67689. export interface ISpriteMapOptions {
  67690. /**
  67691. * Vector2 of the number of cells in the grid.
  67692. */
  67693. stageSize?: Vector2;
  67694. /**
  67695. * Vector2 of the size of the output plane in World Units.
  67696. */
  67697. outputSize?: Vector2;
  67698. /**
  67699. * Vector3 of the position of the output plane in World Units.
  67700. */
  67701. outputPosition?: Vector3;
  67702. /**
  67703. * Vector3 of the rotation of the output plane.
  67704. */
  67705. outputRotation?: Vector3;
  67706. /**
  67707. * number of layers that the system will reserve in resources.
  67708. */
  67709. layerCount?: number;
  67710. /**
  67711. * number of max animation frames a single cell will reserve in resources.
  67712. */
  67713. maxAnimationFrames?: number;
  67714. /**
  67715. * number cell index of the base tile when the system compiles.
  67716. */
  67717. baseTile?: number;
  67718. /**
  67719. * boolean flip the sprite after its been repositioned by the framing data.
  67720. */
  67721. flipU?: boolean;
  67722. /**
  67723. * Vector3 scalar of the global RGB values of the SpriteMap.
  67724. */
  67725. colorMultiply?: Vector3;
  67726. }
  67727. /**
  67728. * Defines the IDisposable interface in order to be cleanable from resources.
  67729. */
  67730. export interface ISpriteMap extends IDisposable {
  67731. /**
  67732. * String name of the SpriteMap.
  67733. */
  67734. name: string;
  67735. /**
  67736. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67737. */
  67738. atlasJSON: ISpriteJSONAtlas;
  67739. /**
  67740. * Texture of the SpriteMap.
  67741. */
  67742. spriteSheet: Texture;
  67743. /**
  67744. * The parameters to initialize the SpriteMap with.
  67745. */
  67746. options: ISpriteMapOptions;
  67747. }
  67748. /**
  67749. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67750. */
  67751. export class SpriteMap implements ISpriteMap {
  67752. /** The Name of the spriteMap */
  67753. name: string;
  67754. /** The JSON file with the frame and meta data */
  67755. atlasJSON: ISpriteJSONAtlas;
  67756. /** The systems Sprite Sheet Texture */
  67757. spriteSheet: Texture;
  67758. /** Arguments passed with the Constructor */
  67759. options: ISpriteMapOptions;
  67760. /** Public Sprite Storage array, parsed from atlasJSON */
  67761. sprites: Array<ISpriteJSONSprite>;
  67762. /** Returns the Number of Sprites in the System */
  67763. get spriteCount(): number;
  67764. /** Returns the Position of Output Plane*/
  67765. get position(): Vector3;
  67766. /** Returns the Position of Output Plane*/
  67767. set position(v: Vector3);
  67768. /** Returns the Rotation of Output Plane*/
  67769. get rotation(): Vector3;
  67770. /** Returns the Rotation of Output Plane*/
  67771. set rotation(v: Vector3);
  67772. /** Sets the AnimationMap*/
  67773. get animationMap(): RawTexture;
  67774. /** Sets the AnimationMap*/
  67775. set animationMap(v: RawTexture);
  67776. /** Scene that the SpriteMap was created in */
  67777. private _scene;
  67778. /** Texture Buffer of Float32 that holds tile frame data*/
  67779. private _frameMap;
  67780. /** Texture Buffers of Float32 that holds tileMap data*/
  67781. private _tileMaps;
  67782. /** Texture Buffer of Float32 that holds Animation Data*/
  67783. private _animationMap;
  67784. /** Custom ShaderMaterial Central to the System*/
  67785. private _material;
  67786. /** Custom ShaderMaterial Central to the System*/
  67787. private _output;
  67788. /** Systems Time Ticker*/
  67789. private _time;
  67790. /**
  67791. * Creates a new SpriteMap
  67792. * @param name defines the SpriteMaps Name
  67793. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67794. * @param spriteSheet is the Texture that the Sprites are on.
  67795. * @param options a basic deployment configuration
  67796. * @param scene The Scene that the map is deployed on
  67797. */
  67798. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67799. /**
  67800. * Returns tileID location
  67801. * @returns Vector2 the cell position ID
  67802. */
  67803. getTileID(): Vector2;
  67804. /**
  67805. * Gets the UV location of the mouse over the SpriteMap.
  67806. * @returns Vector2 the UV position of the mouse interaction
  67807. */
  67808. getMousePosition(): Vector2;
  67809. /**
  67810. * Creates the "frame" texture Buffer
  67811. * -------------------------------------
  67812. * Structure of frames
  67813. * "filename": "Falling-Water-2.png",
  67814. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67815. * "rotated": true,
  67816. * "trimmed": true,
  67817. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67818. * "sourceSize": {"w":32,"h":32}
  67819. * @returns RawTexture of the frameMap
  67820. */
  67821. private _createFrameBuffer;
  67822. /**
  67823. * Creates the tileMap texture Buffer
  67824. * @param buffer normally and array of numbers, or a false to generate from scratch
  67825. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67826. * @returns RawTexture of the tileMap
  67827. */
  67828. private _createTileBuffer;
  67829. /**
  67830. * Modifies the data of the tileMaps
  67831. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67832. * @param pos is the iVector2 Coordinates of the Tile
  67833. * @param tile The SpriteIndex of the new Tile
  67834. */
  67835. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67836. /**
  67837. * Creates the animationMap texture Buffer
  67838. * @param buffer normally and array of numbers, or a false to generate from scratch
  67839. * @returns RawTexture of the animationMap
  67840. */
  67841. private _createTileAnimationBuffer;
  67842. /**
  67843. * Modifies the data of the animationMap
  67844. * @param cellID is the Index of the Sprite
  67845. * @param _frame is the target Animation frame
  67846. * @param toCell is the Target Index of the next frame of the animation
  67847. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67848. * @param speed is a global scalar of the time variable on the map.
  67849. */
  67850. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67851. /**
  67852. * Exports the .tilemaps file
  67853. */
  67854. saveTileMaps(): void;
  67855. /**
  67856. * Imports the .tilemaps file
  67857. * @param url of the .tilemaps file
  67858. */
  67859. loadTileMaps(url: string): void;
  67860. /**
  67861. * Release associated resources
  67862. */
  67863. dispose(): void;
  67864. }
  67865. }
  67866. declare module BABYLON {
  67867. /**
  67868. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67869. * @see http://doc.babylonjs.com/babylon101/sprites
  67870. */
  67871. export class SpritePackedManager extends SpriteManager {
  67872. /** defines the packed manager's name */
  67873. name: string;
  67874. /**
  67875. * Creates a new sprite manager from a packed sprite sheet
  67876. * @param name defines the manager's name
  67877. * @param imgUrl defines the sprite sheet url
  67878. * @param capacity defines the maximum allowed number of sprites
  67879. * @param scene defines the hosting scene
  67880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67881. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67882. * @param samplingMode defines the smapling mode to use with spritesheet
  67883. * @param fromPacked set to true; do not alter
  67884. */
  67885. constructor(
  67886. /** defines the packed manager's name */
  67887. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67888. }
  67889. }
  67890. declare module BABYLON {
  67891. /**
  67892. * Defines the list of states available for a task inside a AssetsManager
  67893. */
  67894. export enum AssetTaskState {
  67895. /**
  67896. * Initialization
  67897. */
  67898. INIT = 0,
  67899. /**
  67900. * Running
  67901. */
  67902. RUNNING = 1,
  67903. /**
  67904. * Done
  67905. */
  67906. DONE = 2,
  67907. /**
  67908. * Error
  67909. */
  67910. ERROR = 3
  67911. }
  67912. /**
  67913. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67914. */
  67915. export abstract class AbstractAssetTask {
  67916. /**
  67917. * Task name
  67918. */ name: string;
  67919. /**
  67920. * Callback called when the task is successful
  67921. */
  67922. onSuccess: (task: any) => void;
  67923. /**
  67924. * Callback called when the task is not successful
  67925. */
  67926. onError: (task: any, message?: string, exception?: any) => void;
  67927. /**
  67928. * Creates a new AssetsManager
  67929. * @param name defines the name of the task
  67930. */
  67931. constructor(
  67932. /**
  67933. * Task name
  67934. */ name: string);
  67935. private _isCompleted;
  67936. private _taskState;
  67937. private _errorObject;
  67938. /**
  67939. * Get if the task is completed
  67940. */
  67941. get isCompleted(): boolean;
  67942. /**
  67943. * Gets the current state of the task
  67944. */
  67945. get taskState(): AssetTaskState;
  67946. /**
  67947. * Gets the current error object (if task is in error)
  67948. */
  67949. get errorObject(): {
  67950. message?: string;
  67951. exception?: any;
  67952. };
  67953. /**
  67954. * Internal only
  67955. * @hidden
  67956. */
  67957. _setErrorObject(message?: string, exception?: any): void;
  67958. /**
  67959. * Execute the current task
  67960. * @param scene defines the scene where you want your assets to be loaded
  67961. * @param onSuccess is a callback called when the task is successfully executed
  67962. * @param onError is a callback called if an error occurs
  67963. */
  67964. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67965. /**
  67966. * Execute the current task
  67967. * @param scene defines the scene where you want your assets to be loaded
  67968. * @param onSuccess is a callback called when the task is successfully executed
  67969. * @param onError is a callback called if an error occurs
  67970. */
  67971. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67972. /**
  67973. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67974. * This can be used with failed tasks that have the reason for failure fixed.
  67975. */
  67976. reset(): void;
  67977. private onErrorCallback;
  67978. private onDoneCallback;
  67979. }
  67980. /**
  67981. * Define the interface used by progress events raised during assets loading
  67982. */
  67983. export interface IAssetsProgressEvent {
  67984. /**
  67985. * Defines the number of remaining tasks to process
  67986. */
  67987. remainingCount: number;
  67988. /**
  67989. * Defines the total number of tasks
  67990. */
  67991. totalCount: number;
  67992. /**
  67993. * Defines the task that was just processed
  67994. */
  67995. task: AbstractAssetTask;
  67996. }
  67997. /**
  67998. * Class used to share progress information about assets loading
  67999. */
  68000. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68001. /**
  68002. * Defines the number of remaining tasks to process
  68003. */
  68004. remainingCount: number;
  68005. /**
  68006. * Defines the total number of tasks
  68007. */
  68008. totalCount: number;
  68009. /**
  68010. * Defines the task that was just processed
  68011. */
  68012. task: AbstractAssetTask;
  68013. /**
  68014. * Creates a AssetsProgressEvent
  68015. * @param remainingCount defines the number of remaining tasks to process
  68016. * @param totalCount defines the total number of tasks
  68017. * @param task defines the task that was just processed
  68018. */
  68019. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68020. }
  68021. /**
  68022. * Define a task used by AssetsManager to load meshes
  68023. */
  68024. export class MeshAssetTask extends AbstractAssetTask {
  68025. /**
  68026. * Defines the name of the task
  68027. */
  68028. name: string;
  68029. /**
  68030. * Defines the list of mesh's names you want to load
  68031. */
  68032. meshesNames: any;
  68033. /**
  68034. * Defines the root url to use as a base to load your meshes and associated resources
  68035. */
  68036. rootUrl: string;
  68037. /**
  68038. * Defines the filename of the scene to load from
  68039. */
  68040. sceneFilename: string;
  68041. /**
  68042. * Gets the list of loaded meshes
  68043. */
  68044. loadedMeshes: Array<AbstractMesh>;
  68045. /**
  68046. * Gets the list of loaded particle systems
  68047. */
  68048. loadedParticleSystems: Array<IParticleSystem>;
  68049. /**
  68050. * Gets the list of loaded skeletons
  68051. */
  68052. loadedSkeletons: Array<Skeleton>;
  68053. /**
  68054. * Gets the list of loaded animation groups
  68055. */
  68056. loadedAnimationGroups: Array<AnimationGroup>;
  68057. /**
  68058. * Callback called when the task is successful
  68059. */
  68060. onSuccess: (task: MeshAssetTask) => void;
  68061. /**
  68062. * Callback called when the task is successful
  68063. */
  68064. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68065. /**
  68066. * Creates a new MeshAssetTask
  68067. * @param name defines the name of the task
  68068. * @param meshesNames defines the list of mesh's names you want to load
  68069. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68070. * @param sceneFilename defines the filename of the scene to load from
  68071. */
  68072. constructor(
  68073. /**
  68074. * Defines the name of the task
  68075. */
  68076. name: string,
  68077. /**
  68078. * Defines the list of mesh's names you want to load
  68079. */
  68080. meshesNames: any,
  68081. /**
  68082. * Defines the root url to use as a base to load your meshes and associated resources
  68083. */
  68084. rootUrl: string,
  68085. /**
  68086. * Defines the filename of the scene to load from
  68087. */
  68088. sceneFilename: string);
  68089. /**
  68090. * Execute the current task
  68091. * @param scene defines the scene where you want your assets to be loaded
  68092. * @param onSuccess is a callback called when the task is successfully executed
  68093. * @param onError is a callback called if an error occurs
  68094. */
  68095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68096. }
  68097. /**
  68098. * Define a task used by AssetsManager to load text content
  68099. */
  68100. export class TextFileAssetTask extends AbstractAssetTask {
  68101. /**
  68102. * Defines the name of the task
  68103. */
  68104. name: string;
  68105. /**
  68106. * Defines the location of the file to load
  68107. */
  68108. url: string;
  68109. /**
  68110. * Gets the loaded text string
  68111. */
  68112. text: string;
  68113. /**
  68114. * Callback called when the task is successful
  68115. */
  68116. onSuccess: (task: TextFileAssetTask) => void;
  68117. /**
  68118. * Callback called when the task is successful
  68119. */
  68120. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  68121. /**
  68122. * Creates a new TextFileAssetTask object
  68123. * @param name defines the name of the task
  68124. * @param url defines the location of the file to load
  68125. */
  68126. constructor(
  68127. /**
  68128. * Defines the name of the task
  68129. */
  68130. name: string,
  68131. /**
  68132. * Defines the location of the file to load
  68133. */
  68134. url: string);
  68135. /**
  68136. * Execute the current task
  68137. * @param scene defines the scene where you want your assets to be loaded
  68138. * @param onSuccess is a callback called when the task is successfully executed
  68139. * @param onError is a callback called if an error occurs
  68140. */
  68141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68142. }
  68143. /**
  68144. * Define a task used by AssetsManager to load binary data
  68145. */
  68146. export class BinaryFileAssetTask extends AbstractAssetTask {
  68147. /**
  68148. * Defines the name of the task
  68149. */
  68150. name: string;
  68151. /**
  68152. * Defines the location of the file to load
  68153. */
  68154. url: string;
  68155. /**
  68156. * Gets the lodaded data (as an array buffer)
  68157. */
  68158. data: ArrayBuffer;
  68159. /**
  68160. * Callback called when the task is successful
  68161. */
  68162. onSuccess: (task: BinaryFileAssetTask) => void;
  68163. /**
  68164. * Callback called when the task is successful
  68165. */
  68166. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68167. /**
  68168. * Creates a new BinaryFileAssetTask object
  68169. * @param name defines the name of the new task
  68170. * @param url defines the location of the file to load
  68171. */
  68172. constructor(
  68173. /**
  68174. * Defines the name of the task
  68175. */
  68176. name: string,
  68177. /**
  68178. * Defines the location of the file to load
  68179. */
  68180. url: string);
  68181. /**
  68182. * Execute the current task
  68183. * @param scene defines the scene where you want your assets to be loaded
  68184. * @param onSuccess is a callback called when the task is successfully executed
  68185. * @param onError is a callback called if an error occurs
  68186. */
  68187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68188. }
  68189. /**
  68190. * Define a task used by AssetsManager to load images
  68191. */
  68192. export class ImageAssetTask extends AbstractAssetTask {
  68193. /**
  68194. * Defines the name of the task
  68195. */
  68196. name: string;
  68197. /**
  68198. * Defines the location of the image to load
  68199. */
  68200. url: string;
  68201. /**
  68202. * Gets the loaded images
  68203. */
  68204. image: HTMLImageElement;
  68205. /**
  68206. * Callback called when the task is successful
  68207. */
  68208. onSuccess: (task: ImageAssetTask) => void;
  68209. /**
  68210. * Callback called when the task is successful
  68211. */
  68212. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68213. /**
  68214. * Creates a new ImageAssetTask
  68215. * @param name defines the name of the task
  68216. * @param url defines the location of the image to load
  68217. */
  68218. constructor(
  68219. /**
  68220. * Defines the name of the task
  68221. */
  68222. name: string,
  68223. /**
  68224. * Defines the location of the image to load
  68225. */
  68226. url: string);
  68227. /**
  68228. * Execute the current task
  68229. * @param scene defines the scene where you want your assets to be loaded
  68230. * @param onSuccess is a callback called when the task is successfully executed
  68231. * @param onError is a callback called if an error occurs
  68232. */
  68233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68234. }
  68235. /**
  68236. * Defines the interface used by texture loading tasks
  68237. */
  68238. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68239. /**
  68240. * Gets the loaded texture
  68241. */
  68242. texture: TEX;
  68243. }
  68244. /**
  68245. * Define a task used by AssetsManager to load 2D textures
  68246. */
  68247. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68248. /**
  68249. * Defines the name of the task
  68250. */
  68251. name: string;
  68252. /**
  68253. * Defines the location of the file to load
  68254. */
  68255. url: string;
  68256. /**
  68257. * Defines if mipmap should not be generated (default is false)
  68258. */
  68259. noMipmap?: boolean | undefined;
  68260. /**
  68261. * Defines if texture must be inverted on Y axis (default is true)
  68262. */
  68263. invertY: boolean;
  68264. /**
  68265. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68266. */
  68267. samplingMode: number;
  68268. /**
  68269. * Gets the loaded texture
  68270. */
  68271. texture: Texture;
  68272. /**
  68273. * Callback called when the task is successful
  68274. */
  68275. onSuccess: (task: TextureAssetTask) => void;
  68276. /**
  68277. * Callback called when the task is successful
  68278. */
  68279. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68280. /**
  68281. * Creates a new TextureAssetTask object
  68282. * @param name defines the name of the task
  68283. * @param url defines the location of the file to load
  68284. * @param noMipmap defines if mipmap should not be generated (default is false)
  68285. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68286. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68287. */
  68288. constructor(
  68289. /**
  68290. * Defines the name of the task
  68291. */
  68292. name: string,
  68293. /**
  68294. * Defines the location of the file to load
  68295. */
  68296. url: string,
  68297. /**
  68298. * Defines if mipmap should not be generated (default is false)
  68299. */
  68300. noMipmap?: boolean | undefined,
  68301. /**
  68302. * Defines if texture must be inverted on Y axis (default is true)
  68303. */
  68304. invertY?: boolean,
  68305. /**
  68306. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68307. */
  68308. samplingMode?: number);
  68309. /**
  68310. * Execute the current task
  68311. * @param scene defines the scene where you want your assets to be loaded
  68312. * @param onSuccess is a callback called when the task is successfully executed
  68313. * @param onError is a callback called if an error occurs
  68314. */
  68315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68316. }
  68317. /**
  68318. * Define a task used by AssetsManager to load cube textures
  68319. */
  68320. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68321. /**
  68322. * Defines the name of the task
  68323. */
  68324. name: string;
  68325. /**
  68326. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68327. */
  68328. url: string;
  68329. /**
  68330. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68331. */
  68332. extensions?: string[] | undefined;
  68333. /**
  68334. * Defines if mipmaps should not be generated (default is false)
  68335. */
  68336. noMipmap?: boolean | undefined;
  68337. /**
  68338. * Defines the explicit list of files (undefined by default)
  68339. */
  68340. files?: string[] | undefined;
  68341. /**
  68342. * Gets the loaded texture
  68343. */
  68344. texture: CubeTexture;
  68345. /**
  68346. * Callback called when the task is successful
  68347. */
  68348. onSuccess: (task: CubeTextureAssetTask) => void;
  68349. /**
  68350. * Callback called when the task is successful
  68351. */
  68352. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68353. /**
  68354. * Creates a new CubeTextureAssetTask
  68355. * @param name defines the name of the task
  68356. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68357. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68358. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68359. * @param files defines the explicit list of files (undefined by default)
  68360. */
  68361. constructor(
  68362. /**
  68363. * Defines the name of the task
  68364. */
  68365. name: string,
  68366. /**
  68367. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68368. */
  68369. url: string,
  68370. /**
  68371. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68372. */
  68373. extensions?: string[] | undefined,
  68374. /**
  68375. * Defines if mipmaps should not be generated (default is false)
  68376. */
  68377. noMipmap?: boolean | undefined,
  68378. /**
  68379. * Defines the explicit list of files (undefined by default)
  68380. */
  68381. files?: string[] | undefined);
  68382. /**
  68383. * Execute the current task
  68384. * @param scene defines the scene where you want your assets to be loaded
  68385. * @param onSuccess is a callback called when the task is successfully executed
  68386. * @param onError is a callback called if an error occurs
  68387. */
  68388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68389. }
  68390. /**
  68391. * Define a task used by AssetsManager to load HDR cube textures
  68392. */
  68393. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68394. /**
  68395. * Defines the name of the task
  68396. */
  68397. name: string;
  68398. /**
  68399. * Defines the location of the file to load
  68400. */
  68401. url: string;
  68402. /**
  68403. * Defines the desired size (the more it increases the longer the generation will be)
  68404. */
  68405. size: number;
  68406. /**
  68407. * Defines if mipmaps should not be generated (default is false)
  68408. */
  68409. noMipmap: boolean;
  68410. /**
  68411. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68412. */
  68413. generateHarmonics: boolean;
  68414. /**
  68415. * 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)
  68416. */
  68417. gammaSpace: boolean;
  68418. /**
  68419. * Internal Use Only
  68420. */
  68421. reserved: boolean;
  68422. /**
  68423. * Gets the loaded texture
  68424. */
  68425. texture: HDRCubeTexture;
  68426. /**
  68427. * Callback called when the task is successful
  68428. */
  68429. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68430. /**
  68431. * Callback called when the task is successful
  68432. */
  68433. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68434. /**
  68435. * Creates a new HDRCubeTextureAssetTask object
  68436. * @param name defines the name of the task
  68437. * @param url defines the location of the file to load
  68438. * @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.
  68439. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68440. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68441. * @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)
  68442. * @param reserved Internal use only
  68443. */
  68444. constructor(
  68445. /**
  68446. * Defines the name of the task
  68447. */
  68448. name: string,
  68449. /**
  68450. * Defines the location of the file to load
  68451. */
  68452. url: string,
  68453. /**
  68454. * Defines the desired size (the more it increases the longer the generation will be)
  68455. */
  68456. size: number,
  68457. /**
  68458. * Defines if mipmaps should not be generated (default is false)
  68459. */
  68460. noMipmap?: boolean,
  68461. /**
  68462. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68463. */
  68464. generateHarmonics?: boolean,
  68465. /**
  68466. * 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)
  68467. */
  68468. gammaSpace?: boolean,
  68469. /**
  68470. * Internal Use Only
  68471. */
  68472. reserved?: boolean);
  68473. /**
  68474. * Execute the current task
  68475. * @param scene defines the scene where you want your assets to be loaded
  68476. * @param onSuccess is a callback called when the task is successfully executed
  68477. * @param onError is a callback called if an error occurs
  68478. */
  68479. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68480. }
  68481. /**
  68482. * Define a task used by AssetsManager to load Equirectangular cube textures
  68483. */
  68484. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68485. /**
  68486. * Defines the name of the task
  68487. */
  68488. name: string;
  68489. /**
  68490. * Defines the location of the file to load
  68491. */
  68492. url: string;
  68493. /**
  68494. * Defines the desired size (the more it increases the longer the generation will be)
  68495. */
  68496. size: number;
  68497. /**
  68498. * Defines if mipmaps should not be generated (default is false)
  68499. */
  68500. noMipmap: boolean;
  68501. /**
  68502. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68503. * but the standard material would require them in Gamma space) (default is true)
  68504. */
  68505. gammaSpace: boolean;
  68506. /**
  68507. * Gets the loaded texture
  68508. */
  68509. texture: EquiRectangularCubeTexture;
  68510. /**
  68511. * Callback called when the task is successful
  68512. */
  68513. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68514. /**
  68515. * Callback called when the task is successful
  68516. */
  68517. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68518. /**
  68519. * Creates a new EquiRectangularCubeTextureAssetTask object
  68520. * @param name defines the name of the task
  68521. * @param url defines the location of the file to load
  68522. * @param size defines the desired size (the more it increases the longer the generation will be)
  68523. * If the size is omitted this implies you are using a preprocessed cubemap.
  68524. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68525. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68526. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68527. * (default is true)
  68528. */
  68529. constructor(
  68530. /**
  68531. * Defines the name of the task
  68532. */
  68533. name: string,
  68534. /**
  68535. * Defines the location of the file to load
  68536. */
  68537. url: string,
  68538. /**
  68539. * Defines the desired size (the more it increases the longer the generation will be)
  68540. */
  68541. size: number,
  68542. /**
  68543. * Defines if mipmaps should not be generated (default is false)
  68544. */
  68545. noMipmap?: boolean,
  68546. /**
  68547. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68548. * but the standard material would require them in Gamma space) (default is true)
  68549. */
  68550. gammaSpace?: boolean);
  68551. /**
  68552. * Execute the current task
  68553. * @param scene defines the scene where you want your assets to be loaded
  68554. * @param onSuccess is a callback called when the task is successfully executed
  68555. * @param onError is a callback called if an error occurs
  68556. */
  68557. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68558. }
  68559. /**
  68560. * This class can be used to easily import assets into a scene
  68561. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68562. */
  68563. export class AssetsManager {
  68564. private _scene;
  68565. private _isLoading;
  68566. protected _tasks: AbstractAssetTask[];
  68567. protected _waitingTasksCount: number;
  68568. protected _totalTasksCount: number;
  68569. /**
  68570. * Callback called when all tasks are processed
  68571. */
  68572. onFinish: (tasks: AbstractAssetTask[]) => void;
  68573. /**
  68574. * Callback called when a task is successful
  68575. */
  68576. onTaskSuccess: (task: AbstractAssetTask) => void;
  68577. /**
  68578. * Callback called when a task had an error
  68579. */
  68580. onTaskError: (task: AbstractAssetTask) => void;
  68581. /**
  68582. * Callback called when a task is done (whatever the result is)
  68583. */
  68584. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68585. /**
  68586. * Observable called when all tasks are processed
  68587. */
  68588. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68589. /**
  68590. * Observable called when a task had an error
  68591. */
  68592. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68593. /**
  68594. * Observable called when all tasks were executed
  68595. */
  68596. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68597. /**
  68598. * Observable called when a task is done (whatever the result is)
  68599. */
  68600. onProgressObservable: Observable<IAssetsProgressEvent>;
  68601. /**
  68602. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68603. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68604. */
  68605. useDefaultLoadingScreen: boolean;
  68606. /**
  68607. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68608. * when all assets have been downloaded.
  68609. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68610. */
  68611. autoHideLoadingUI: boolean;
  68612. /**
  68613. * Creates a new AssetsManager
  68614. * @param scene defines the scene to work on
  68615. */
  68616. constructor(scene: Scene);
  68617. /**
  68618. * Add a MeshAssetTask to the list of active tasks
  68619. * @param taskName defines the name of the new task
  68620. * @param meshesNames defines the name of meshes to load
  68621. * @param rootUrl defines the root url to use to locate files
  68622. * @param sceneFilename defines the filename of the scene file
  68623. * @returns a new MeshAssetTask object
  68624. */
  68625. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68626. /**
  68627. * Add a TextFileAssetTask to the list of active tasks
  68628. * @param taskName defines the name of the new task
  68629. * @param url defines the url of the file to load
  68630. * @returns a new TextFileAssetTask object
  68631. */
  68632. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68633. /**
  68634. * Add a BinaryFileAssetTask to the list of active tasks
  68635. * @param taskName defines the name of the new task
  68636. * @param url defines the url of the file to load
  68637. * @returns a new BinaryFileAssetTask object
  68638. */
  68639. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68640. /**
  68641. * Add a ImageAssetTask to the list of active tasks
  68642. * @param taskName defines the name of the new task
  68643. * @param url defines the url of the file to load
  68644. * @returns a new ImageAssetTask object
  68645. */
  68646. addImageTask(taskName: string, url: string): ImageAssetTask;
  68647. /**
  68648. * Add a TextureAssetTask to the list of active tasks
  68649. * @param taskName defines the name of the new task
  68650. * @param url defines the url of the file to load
  68651. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68652. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68653. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68654. * @returns a new TextureAssetTask object
  68655. */
  68656. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68657. /**
  68658. * Add a CubeTextureAssetTask to the list of active tasks
  68659. * @param taskName defines the name of the new task
  68660. * @param url defines the url of the file to load
  68661. * @param extensions defines the extension to use to load the cube map (can be null)
  68662. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68663. * @param files defines the list of files to load (can be null)
  68664. * @returns a new CubeTextureAssetTask object
  68665. */
  68666. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68667. /**
  68668. *
  68669. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68670. * @param taskName defines the name of the new task
  68671. * @param url defines the url of the file to load
  68672. * @param size defines the size you want for the cubemap (can be null)
  68673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68674. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68675. * @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)
  68676. * @param reserved Internal use only
  68677. * @returns a new HDRCubeTextureAssetTask object
  68678. */
  68679. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68680. /**
  68681. *
  68682. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68683. * @param taskName defines the name of the new task
  68684. * @param url defines the url of the file to load
  68685. * @param size defines the size you want for the cubemap (can be null)
  68686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68687. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68688. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68689. * @returns a new EquiRectangularCubeTextureAssetTask object
  68690. */
  68691. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68692. /**
  68693. * Remove a task from the assets manager.
  68694. * @param task the task to remove
  68695. */
  68696. removeTask(task: AbstractAssetTask): void;
  68697. private _decreaseWaitingTasksCount;
  68698. private _runTask;
  68699. /**
  68700. * Reset the AssetsManager and remove all tasks
  68701. * @return the current instance of the AssetsManager
  68702. */
  68703. reset(): AssetsManager;
  68704. /**
  68705. * Start the loading process
  68706. * @return the current instance of the AssetsManager
  68707. */
  68708. load(): AssetsManager;
  68709. /**
  68710. * Start the loading process as an async operation
  68711. * @return a promise returning the list of failed tasks
  68712. */
  68713. loadAsync(): Promise<void>;
  68714. }
  68715. }
  68716. declare module BABYLON {
  68717. /**
  68718. * Wrapper class for promise with external resolve and reject.
  68719. */
  68720. export class Deferred<T> {
  68721. /**
  68722. * The promise associated with this deferred object.
  68723. */
  68724. readonly promise: Promise<T>;
  68725. private _resolve;
  68726. private _reject;
  68727. /**
  68728. * The resolve method of the promise associated with this deferred object.
  68729. */
  68730. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68731. /**
  68732. * The reject method of the promise associated with this deferred object.
  68733. */
  68734. get reject(): (reason?: any) => void;
  68735. /**
  68736. * Constructor for this deferred object.
  68737. */
  68738. constructor();
  68739. }
  68740. }
  68741. declare module BABYLON {
  68742. /**
  68743. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68744. */
  68745. export class MeshExploder {
  68746. private _centerMesh;
  68747. private _meshes;
  68748. private _meshesOrigins;
  68749. private _toCenterVectors;
  68750. private _scaledDirection;
  68751. private _newPosition;
  68752. private _centerPosition;
  68753. /**
  68754. * Explodes meshes from a center mesh.
  68755. * @param meshes The meshes to explode.
  68756. * @param centerMesh The mesh to be center of explosion.
  68757. */
  68758. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68759. private _setCenterMesh;
  68760. /**
  68761. * Get class name
  68762. * @returns "MeshExploder"
  68763. */
  68764. getClassName(): string;
  68765. /**
  68766. * "Exploded meshes"
  68767. * @returns Array of meshes with the centerMesh at index 0.
  68768. */
  68769. getMeshes(): Array<Mesh>;
  68770. /**
  68771. * Explodes meshes giving a specific direction
  68772. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68773. */
  68774. explode(direction?: number): void;
  68775. }
  68776. }
  68777. declare module BABYLON {
  68778. /**
  68779. * Class used to help managing file picking and drag'n'drop
  68780. */
  68781. export class FilesInput {
  68782. /**
  68783. * List of files ready to be loaded
  68784. */
  68785. static get FilesToLoad(): {
  68786. [key: string]: File;
  68787. };
  68788. /**
  68789. * Callback called when a file is processed
  68790. */
  68791. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68792. private _engine;
  68793. private _currentScene;
  68794. private _sceneLoadedCallback;
  68795. private _progressCallback;
  68796. private _additionalRenderLoopLogicCallback;
  68797. private _textureLoadingCallback;
  68798. private _startingProcessingFilesCallback;
  68799. private _onReloadCallback;
  68800. private _errorCallback;
  68801. private _elementToMonitor;
  68802. private _sceneFileToLoad;
  68803. private _filesToLoad;
  68804. /**
  68805. * Creates a new FilesInput
  68806. * @param engine defines the rendering engine
  68807. * @param scene defines the hosting scene
  68808. * @param sceneLoadedCallback callback called when scene is loaded
  68809. * @param progressCallback callback called to track progress
  68810. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68811. * @param textureLoadingCallback callback called when a texture is loading
  68812. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68813. * @param onReloadCallback callback called when a reload is requested
  68814. * @param errorCallback callback call if an error occurs
  68815. */
  68816. 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);
  68817. private _dragEnterHandler;
  68818. private _dragOverHandler;
  68819. private _dropHandler;
  68820. /**
  68821. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68822. * @param elementToMonitor defines the DOM element to track
  68823. */
  68824. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68825. /**
  68826. * Release all associated resources
  68827. */
  68828. dispose(): void;
  68829. private renderFunction;
  68830. private drag;
  68831. private drop;
  68832. private _traverseFolder;
  68833. private _processFiles;
  68834. /**
  68835. * Load files from a drop event
  68836. * @param event defines the drop event to use as source
  68837. */
  68838. loadFiles(event: any): void;
  68839. private _processReload;
  68840. /**
  68841. * Reload the current scene from the loaded files
  68842. */
  68843. reload(): void;
  68844. }
  68845. }
  68846. declare module BABYLON {
  68847. /**
  68848. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68850. */
  68851. export class SceneOptimization {
  68852. /**
  68853. * Defines the priority of this optimization (0 by default which means first in the list)
  68854. */
  68855. priority: number;
  68856. /**
  68857. * Gets a string describing the action executed by the current optimization
  68858. * @returns description string
  68859. */
  68860. getDescription(): string;
  68861. /**
  68862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68863. * @param scene defines the current scene where to apply this optimization
  68864. * @param optimizer defines the current optimizer
  68865. * @returns true if everything that can be done was applied
  68866. */
  68867. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68868. /**
  68869. * Creates the SceneOptimization object
  68870. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68871. * @param desc defines the description associated with the optimization
  68872. */
  68873. constructor(
  68874. /**
  68875. * Defines the priority of this optimization (0 by default which means first in the list)
  68876. */
  68877. priority?: number);
  68878. }
  68879. /**
  68880. * Defines an optimization used to reduce the size of render target textures
  68881. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68882. */
  68883. export class TextureOptimization extends SceneOptimization {
  68884. /**
  68885. * Defines the priority of this optimization (0 by default which means first in the list)
  68886. */
  68887. priority: number;
  68888. /**
  68889. * 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
  68890. */
  68891. maximumSize: number;
  68892. /**
  68893. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68894. */
  68895. step: number;
  68896. /**
  68897. * Gets a string describing the action executed by the current optimization
  68898. * @returns description string
  68899. */
  68900. getDescription(): string;
  68901. /**
  68902. * Creates the TextureOptimization object
  68903. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68904. * @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
  68905. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68906. */
  68907. constructor(
  68908. /**
  68909. * Defines the priority of this optimization (0 by default which means first in the list)
  68910. */
  68911. priority?: number,
  68912. /**
  68913. * 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
  68914. */
  68915. maximumSize?: number,
  68916. /**
  68917. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68918. */
  68919. step?: number);
  68920. /**
  68921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68922. * @param scene defines the current scene where to apply this optimization
  68923. * @param optimizer defines the current optimizer
  68924. * @returns true if everything that can be done was applied
  68925. */
  68926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68927. }
  68928. /**
  68929. * Defines an optimization used to increase or decrease the rendering resolution
  68930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68931. */
  68932. export class HardwareScalingOptimization extends SceneOptimization {
  68933. /**
  68934. * Defines the priority of this optimization (0 by default which means first in the list)
  68935. */
  68936. priority: number;
  68937. /**
  68938. * Defines the maximum scale to use (2 by default)
  68939. */
  68940. maximumScale: number;
  68941. /**
  68942. * Defines the step to use between two passes (0.5 by default)
  68943. */
  68944. step: number;
  68945. private _currentScale;
  68946. private _directionOffset;
  68947. /**
  68948. * Gets a string describing the action executed by the current optimization
  68949. * @return description string
  68950. */
  68951. getDescription(): string;
  68952. /**
  68953. * Creates the HardwareScalingOptimization object
  68954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68955. * @param maximumScale defines the maximum scale to use (2 by default)
  68956. * @param step defines the step to use between two passes (0.5 by default)
  68957. */
  68958. constructor(
  68959. /**
  68960. * Defines the priority of this optimization (0 by default which means first in the list)
  68961. */
  68962. priority?: number,
  68963. /**
  68964. * Defines the maximum scale to use (2 by default)
  68965. */
  68966. maximumScale?: number,
  68967. /**
  68968. * Defines the step to use between two passes (0.5 by default)
  68969. */
  68970. step?: number);
  68971. /**
  68972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68973. * @param scene defines the current scene where to apply this optimization
  68974. * @param optimizer defines the current optimizer
  68975. * @returns true if everything that can be done was applied
  68976. */
  68977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68978. }
  68979. /**
  68980. * Defines an optimization used to remove shadows
  68981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68982. */
  68983. export class ShadowsOptimization extends SceneOptimization {
  68984. /**
  68985. * Gets a string describing the action executed by the current optimization
  68986. * @return description string
  68987. */
  68988. getDescription(): string;
  68989. /**
  68990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68991. * @param scene defines the current scene where to apply this optimization
  68992. * @param optimizer defines the current optimizer
  68993. * @returns true if everything that can be done was applied
  68994. */
  68995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68996. }
  68997. /**
  68998. * Defines an optimization used to turn post-processes off
  68999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69000. */
  69001. export class PostProcessesOptimization extends SceneOptimization {
  69002. /**
  69003. * Gets a string describing the action executed by the current optimization
  69004. * @return description string
  69005. */
  69006. getDescription(): string;
  69007. /**
  69008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69009. * @param scene defines the current scene where to apply this optimization
  69010. * @param optimizer defines the current optimizer
  69011. * @returns true if everything that can be done was applied
  69012. */
  69013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69014. }
  69015. /**
  69016. * Defines an optimization used to turn lens flares off
  69017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69018. */
  69019. export class LensFlaresOptimization extends SceneOptimization {
  69020. /**
  69021. * Gets a string describing the action executed by the current optimization
  69022. * @return description string
  69023. */
  69024. getDescription(): string;
  69025. /**
  69026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69027. * @param scene defines the current scene where to apply this optimization
  69028. * @param optimizer defines the current optimizer
  69029. * @returns true if everything that can be done was applied
  69030. */
  69031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69032. }
  69033. /**
  69034. * Defines an optimization based on user defined callback.
  69035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69036. */
  69037. export class CustomOptimization extends SceneOptimization {
  69038. /**
  69039. * Callback called to apply the custom optimization.
  69040. */
  69041. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69042. /**
  69043. * Callback called to get custom description
  69044. */
  69045. onGetDescription: () => string;
  69046. /**
  69047. * Gets a string describing the action executed by the current optimization
  69048. * @returns description string
  69049. */
  69050. getDescription(): string;
  69051. /**
  69052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69053. * @param scene defines the current scene where to apply this optimization
  69054. * @param optimizer defines the current optimizer
  69055. * @returns true if everything that can be done was applied
  69056. */
  69057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69058. }
  69059. /**
  69060. * Defines an optimization used to turn particles off
  69061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69062. */
  69063. export class ParticlesOptimization extends SceneOptimization {
  69064. /**
  69065. * Gets a string describing the action executed by the current optimization
  69066. * @return description string
  69067. */
  69068. getDescription(): string;
  69069. /**
  69070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69071. * @param scene defines the current scene where to apply this optimization
  69072. * @param optimizer defines the current optimizer
  69073. * @returns true if everything that can be done was applied
  69074. */
  69075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69076. }
  69077. /**
  69078. * Defines an optimization used to turn render targets off
  69079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69080. */
  69081. export class RenderTargetsOptimization extends SceneOptimization {
  69082. /**
  69083. * Gets a string describing the action executed by the current optimization
  69084. * @return description string
  69085. */
  69086. getDescription(): string;
  69087. /**
  69088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69089. * @param scene defines the current scene where to apply this optimization
  69090. * @param optimizer defines the current optimizer
  69091. * @returns true if everything that can be done was applied
  69092. */
  69093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69094. }
  69095. /**
  69096. * Defines an optimization used to merge meshes with compatible materials
  69097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69098. */
  69099. export class MergeMeshesOptimization extends SceneOptimization {
  69100. private static _UpdateSelectionTree;
  69101. /**
  69102. * Gets or sets a boolean which defines if optimization octree has to be updated
  69103. */
  69104. static get UpdateSelectionTree(): boolean;
  69105. /**
  69106. * Gets or sets a boolean which defines if optimization octree has to be updated
  69107. */
  69108. static set UpdateSelectionTree(value: boolean);
  69109. /**
  69110. * Gets a string describing the action executed by the current optimization
  69111. * @return description string
  69112. */
  69113. getDescription(): string;
  69114. private _canBeMerged;
  69115. /**
  69116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69117. * @param scene defines the current scene where to apply this optimization
  69118. * @param optimizer defines the current optimizer
  69119. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  69120. * @returns true if everything that can be done was applied
  69121. */
  69122. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69123. }
  69124. /**
  69125. * Defines a list of options used by SceneOptimizer
  69126. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69127. */
  69128. export class SceneOptimizerOptions {
  69129. /**
  69130. * Defines the target frame rate to reach (60 by default)
  69131. */
  69132. targetFrameRate: number;
  69133. /**
  69134. * Defines the interval between two checkes (2000ms by default)
  69135. */
  69136. trackerDuration: number;
  69137. /**
  69138. * Gets the list of optimizations to apply
  69139. */
  69140. optimizations: SceneOptimization[];
  69141. /**
  69142. * Creates a new list of options used by SceneOptimizer
  69143. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69144. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69145. */
  69146. constructor(
  69147. /**
  69148. * Defines the target frame rate to reach (60 by default)
  69149. */
  69150. targetFrameRate?: number,
  69151. /**
  69152. * Defines the interval between two checkes (2000ms by default)
  69153. */
  69154. trackerDuration?: number);
  69155. /**
  69156. * Add a new optimization
  69157. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69158. * @returns the current SceneOptimizerOptions
  69159. */
  69160. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69161. /**
  69162. * Add a new custom optimization
  69163. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69164. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69165. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69166. * @returns the current SceneOptimizerOptions
  69167. */
  69168. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69169. /**
  69170. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69171. * @param targetFrameRate defines the target frame rate (60 by default)
  69172. * @returns a SceneOptimizerOptions object
  69173. */
  69174. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69175. /**
  69176. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69177. * @param targetFrameRate defines the target frame rate (60 by default)
  69178. * @returns a SceneOptimizerOptions object
  69179. */
  69180. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69181. /**
  69182. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69183. * @param targetFrameRate defines the target frame rate (60 by default)
  69184. * @returns a SceneOptimizerOptions object
  69185. */
  69186. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69187. }
  69188. /**
  69189. * Class used to run optimizations in order to reach a target frame rate
  69190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69191. */
  69192. export class SceneOptimizer implements IDisposable {
  69193. private _isRunning;
  69194. private _options;
  69195. private _scene;
  69196. private _currentPriorityLevel;
  69197. private _targetFrameRate;
  69198. private _trackerDuration;
  69199. private _currentFrameRate;
  69200. private _sceneDisposeObserver;
  69201. private _improvementMode;
  69202. /**
  69203. * Defines an observable called when the optimizer reaches the target frame rate
  69204. */
  69205. onSuccessObservable: Observable<SceneOptimizer>;
  69206. /**
  69207. * Defines an observable called when the optimizer enables an optimization
  69208. */
  69209. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69210. /**
  69211. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69212. */
  69213. onFailureObservable: Observable<SceneOptimizer>;
  69214. /**
  69215. * Gets a boolean indicating if the optimizer is in improvement mode
  69216. */
  69217. get isInImprovementMode(): boolean;
  69218. /**
  69219. * Gets the current priority level (0 at start)
  69220. */
  69221. get currentPriorityLevel(): number;
  69222. /**
  69223. * Gets the current frame rate checked by the SceneOptimizer
  69224. */
  69225. get currentFrameRate(): number;
  69226. /**
  69227. * Gets or sets the current target frame rate (60 by default)
  69228. */
  69229. get targetFrameRate(): number;
  69230. /**
  69231. * Gets or sets the current target frame rate (60 by default)
  69232. */
  69233. set targetFrameRate(value: number);
  69234. /**
  69235. * Gets or sets the current interval between two checks (every 2000ms by default)
  69236. */
  69237. get trackerDuration(): number;
  69238. /**
  69239. * Gets or sets the current interval between two checks (every 2000ms by default)
  69240. */
  69241. set trackerDuration(value: number);
  69242. /**
  69243. * Gets the list of active optimizations
  69244. */
  69245. get optimizations(): SceneOptimization[];
  69246. /**
  69247. * Creates a new SceneOptimizer
  69248. * @param scene defines the scene to work on
  69249. * @param options defines the options to use with the SceneOptimizer
  69250. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69251. * @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)
  69252. */
  69253. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69254. /**
  69255. * Stops the current optimizer
  69256. */
  69257. stop(): void;
  69258. /**
  69259. * Reset the optimizer to initial step (current priority level = 0)
  69260. */
  69261. reset(): void;
  69262. /**
  69263. * Start the optimizer. By default it will try to reach a specific framerate
  69264. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69265. */
  69266. start(): void;
  69267. private _checkCurrentState;
  69268. /**
  69269. * Release all resources
  69270. */
  69271. dispose(): void;
  69272. /**
  69273. * Helper function to create a SceneOptimizer with one single line of code
  69274. * @param scene defines the scene to work on
  69275. * @param options defines the options to use with the SceneOptimizer
  69276. * @param onSuccess defines a callback to call on success
  69277. * @param onFailure defines a callback to call on failure
  69278. * @returns the new SceneOptimizer object
  69279. */
  69280. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69281. }
  69282. }
  69283. declare module BABYLON {
  69284. /**
  69285. * Class used to serialize a scene into a string
  69286. */
  69287. export class SceneSerializer {
  69288. /**
  69289. * Clear cache used by a previous serialization
  69290. */
  69291. static ClearCache(): void;
  69292. /**
  69293. * Serialize a scene into a JSON compatible object
  69294. * @param scene defines the scene to serialize
  69295. * @returns a JSON compatible object
  69296. */
  69297. static Serialize(scene: Scene): any;
  69298. /**
  69299. * Serialize a mesh into a JSON compatible object
  69300. * @param toSerialize defines the mesh to serialize
  69301. * @param withParents defines if parents must be serialized as well
  69302. * @param withChildren defines if children must be serialized as well
  69303. * @returns a JSON compatible object
  69304. */
  69305. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69306. }
  69307. }
  69308. declare module BABYLON {
  69309. /**
  69310. * Class used to host texture specific utilities
  69311. */
  69312. export class TextureTools {
  69313. /**
  69314. * Uses the GPU to create a copy texture rescaled at a given size
  69315. * @param texture Texture to copy from
  69316. * @param width defines the desired width
  69317. * @param height defines the desired height
  69318. * @param useBilinearMode defines if bilinear mode has to be used
  69319. * @return the generated texture
  69320. */
  69321. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69322. }
  69323. }
  69324. declare module BABYLON {
  69325. /**
  69326. * This represents the different options available for the video capture.
  69327. */
  69328. export interface VideoRecorderOptions {
  69329. /** Defines the mime type of the video. */
  69330. mimeType: string;
  69331. /** Defines the FPS the video should be recorded at. */
  69332. fps: number;
  69333. /** Defines the chunk size for the recording data. */
  69334. recordChunckSize: number;
  69335. /** The audio tracks to attach to the recording. */
  69336. audioTracks?: MediaStreamTrack[];
  69337. }
  69338. /**
  69339. * This can help with recording videos from BabylonJS.
  69340. * This is based on the available WebRTC functionalities of the browser.
  69341. *
  69342. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69343. */
  69344. export class VideoRecorder {
  69345. private static readonly _defaultOptions;
  69346. /**
  69347. * Returns whether or not the VideoRecorder is available in your browser.
  69348. * @param engine Defines the Babylon Engine.
  69349. * @returns true if supported otherwise false.
  69350. */
  69351. static IsSupported(engine: Engine): boolean;
  69352. private readonly _options;
  69353. private _canvas;
  69354. private _mediaRecorder;
  69355. private _recordedChunks;
  69356. private _fileName;
  69357. private _resolve;
  69358. private _reject;
  69359. /**
  69360. * True when a recording is already in progress.
  69361. */
  69362. get isRecording(): boolean;
  69363. /**
  69364. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69365. * @param engine Defines the BabylonJS Engine you wish to record.
  69366. * @param options Defines options that can be used to customize the capture.
  69367. */
  69368. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69369. /**
  69370. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69371. */
  69372. stopRecording(): void;
  69373. /**
  69374. * Starts recording the canvas for a max duration specified in parameters.
  69375. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69376. * If null no automatic download will start and you can rely on the promise to get the data back.
  69377. * @param maxDuration Defines the maximum recording time in seconds.
  69378. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69379. * @return A promise callback at the end of the recording with the video data in Blob.
  69380. */
  69381. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69382. /**
  69383. * Releases internal resources used during the recording.
  69384. */
  69385. dispose(): void;
  69386. private _handleDataAvailable;
  69387. private _handleError;
  69388. private _handleStop;
  69389. }
  69390. }
  69391. declare module BABYLON {
  69392. /**
  69393. * Class containing a set of static utilities functions for screenshots
  69394. */
  69395. export class ScreenshotTools {
  69396. /**
  69397. * Captures a screenshot of the current rendering
  69398. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69399. * @param engine defines the rendering engine
  69400. * @param camera defines the source camera
  69401. * @param size This parameter can be set to a single number or to an object with the
  69402. * following (optional) properties: precision, width, height. If a single number is passed,
  69403. * it will be used for both width and height. If an object is passed, the screenshot size
  69404. * will be derived from the parameters. The precision property is a multiplier allowing
  69405. * rendering at a higher or lower resolution
  69406. * @param successCallback defines the callback receives a single parameter which contains the
  69407. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69408. * src parameter of an <img> to display it
  69409. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69410. * Check your browser for supported MIME types
  69411. */
  69412. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69413. /**
  69414. * Captures a screenshot of the current rendering
  69415. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69416. * @param engine defines the rendering engine
  69417. * @param camera defines the source camera
  69418. * @param size This parameter can be set to a single number or to an object with the
  69419. * following (optional) properties: precision, width, height. If a single number is passed,
  69420. * it will be used for both width and height. If an object is passed, the screenshot size
  69421. * will be derived from the parameters. The precision property is a multiplier allowing
  69422. * rendering at a higher or lower resolution
  69423. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69424. * Check your browser for supported MIME types
  69425. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69426. * to the src parameter of an <img> to display it
  69427. */
  69428. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69429. /**
  69430. * Generates an image screenshot from the specified camera.
  69431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69432. * @param engine The engine to use for rendering
  69433. * @param camera The camera to use for rendering
  69434. * @param size This parameter can be set to a single number or to an object with the
  69435. * following (optional) properties: precision, width, height. If a single number is passed,
  69436. * it will be used for both width and height. If an object is passed, the screenshot size
  69437. * will be derived from the parameters. The precision property is a multiplier allowing
  69438. * rendering at a higher or lower resolution
  69439. * @param successCallback The callback receives a single parameter which contains the
  69440. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69441. * src parameter of an <img> to display it
  69442. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69443. * Check your browser for supported MIME types
  69444. * @param samples Texture samples (default: 1)
  69445. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69446. * @param fileName A name for for the downloaded file.
  69447. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69448. */
  69449. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69450. /**
  69451. * Generates an image screenshot from the specified camera.
  69452. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69453. * @param engine The engine to use for rendering
  69454. * @param camera The camera to use for rendering
  69455. * @param size This parameter can be set to a single number or to an object with the
  69456. * following (optional) properties: precision, width, height. If a single number is passed,
  69457. * it will be used for both width and height. If an object is passed, the screenshot size
  69458. * will be derived from the parameters. The precision property is a multiplier allowing
  69459. * rendering at a higher or lower resolution
  69460. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69461. * Check your browser for supported MIME types
  69462. * @param samples Texture samples (default: 1)
  69463. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69464. * @param fileName A name for for the downloaded file.
  69465. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69466. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69467. * to the src parameter of an <img> to display it
  69468. */
  69469. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69470. /**
  69471. * Gets height and width for screenshot size
  69472. * @private
  69473. */
  69474. private static _getScreenshotSize;
  69475. }
  69476. }
  69477. declare module BABYLON {
  69478. /**
  69479. * Interface for a data buffer
  69480. */
  69481. export interface IDataBuffer {
  69482. /**
  69483. * Reads bytes from the data buffer.
  69484. * @param byteOffset The byte offset to read
  69485. * @param byteLength The byte length to read
  69486. * @returns A promise that resolves when the bytes are read
  69487. */
  69488. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69489. /**
  69490. * The byte length of the buffer.
  69491. */
  69492. readonly byteLength: number;
  69493. }
  69494. /**
  69495. * Utility class for reading from a data buffer
  69496. */
  69497. export class DataReader {
  69498. /**
  69499. * The data buffer associated with this data reader.
  69500. */
  69501. readonly buffer: IDataBuffer;
  69502. /**
  69503. * The current byte offset from the beginning of the data buffer.
  69504. */
  69505. byteOffset: number;
  69506. private _dataView;
  69507. private _dataByteOffset;
  69508. /**
  69509. * Constructor
  69510. * @param buffer The buffer to read
  69511. */
  69512. constructor(buffer: IDataBuffer);
  69513. /**
  69514. * Loads the given byte length.
  69515. * @param byteLength The byte length to load
  69516. * @returns A promise that resolves when the load is complete
  69517. */
  69518. loadAsync(byteLength: number): Promise<void>;
  69519. /**
  69520. * Read a unsigned 32-bit integer from the currently loaded data range.
  69521. * @returns The 32-bit integer read
  69522. */
  69523. readUint32(): number;
  69524. /**
  69525. * Read a byte array from the currently loaded data range.
  69526. * @param byteLength The byte length to read
  69527. * @returns The byte array read
  69528. */
  69529. readUint8Array(byteLength: number): Uint8Array;
  69530. /**
  69531. * Read a string from the currently loaded data range.
  69532. * @param byteLength The byte length to read
  69533. * @returns The string read
  69534. */
  69535. readString(byteLength: number): string;
  69536. /**
  69537. * Skips the given byte length the currently loaded data range.
  69538. * @param byteLength The byte length to skip
  69539. */
  69540. skipBytes(byteLength: number): void;
  69541. }
  69542. }
  69543. declare module BABYLON {
  69544. /**
  69545. * Class for storing data to local storage if available or in-memory storage otherwise
  69546. */
  69547. export class DataStorage {
  69548. private static _Storage;
  69549. private static _GetStorage;
  69550. /**
  69551. * Reads a string from the data storage
  69552. * @param key The key to read
  69553. * @param defaultValue The value if the key doesn't exist
  69554. * @returns The string value
  69555. */
  69556. static ReadString(key: string, defaultValue: string): string;
  69557. /**
  69558. * Writes a string to the data storage
  69559. * @param key The key to write
  69560. * @param value The value to write
  69561. */
  69562. static WriteString(key: string, value: string): void;
  69563. /**
  69564. * Reads a boolean from the data storage
  69565. * @param key The key to read
  69566. * @param defaultValue The value if the key doesn't exist
  69567. * @returns The boolean value
  69568. */
  69569. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69570. /**
  69571. * Writes a boolean to the data storage
  69572. * @param key The key to write
  69573. * @param value The value to write
  69574. */
  69575. static WriteBoolean(key: string, value: boolean): void;
  69576. /**
  69577. * Reads a number from the data storage
  69578. * @param key The key to read
  69579. * @param defaultValue The value if the key doesn't exist
  69580. * @returns The number value
  69581. */
  69582. static ReadNumber(key: string, defaultValue: number): number;
  69583. /**
  69584. * Writes a number to the data storage
  69585. * @param key The key to write
  69586. * @param value The value to write
  69587. */
  69588. static WriteNumber(key: string, value: number): void;
  69589. }
  69590. }
  69591. declare module BABYLON {
  69592. /**
  69593. * Options used for hit testing
  69594. */
  69595. export interface IWebXRLegacyHitTestOptions {
  69596. /**
  69597. * Only test when user interacted with the scene. Default - hit test every frame
  69598. */
  69599. testOnPointerDownOnly?: boolean;
  69600. /**
  69601. * The node to use to transform the local results to world coordinates
  69602. */
  69603. worldParentNode?: TransformNode;
  69604. }
  69605. /**
  69606. * Interface defining the babylon result of raycasting/hit-test
  69607. */
  69608. export interface IWebXRLegacyHitResult {
  69609. /**
  69610. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69611. */
  69612. transformationMatrix: Matrix;
  69613. /**
  69614. * The native hit test result
  69615. */
  69616. xrHitResult: XRHitResult | XRHitTestResult;
  69617. }
  69618. /**
  69619. * The currently-working hit-test module.
  69620. * Hit test (or Ray-casting) is used to interact with the real world.
  69621. * For further information read here - https://github.com/immersive-web/hit-test
  69622. */
  69623. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69624. /**
  69625. * options to use when constructing this feature
  69626. */
  69627. readonly options: IWebXRLegacyHitTestOptions;
  69628. private _direction;
  69629. private _mat;
  69630. private _onSelectEnabled;
  69631. private _origin;
  69632. /**
  69633. * The module's name
  69634. */
  69635. static readonly Name: string;
  69636. /**
  69637. * The (Babylon) version of this module.
  69638. * This is an integer representing the implementation version.
  69639. * This number does not correspond to the WebXR specs version
  69640. */
  69641. static readonly Version: number;
  69642. /**
  69643. * Populated with the last native XR Hit Results
  69644. */
  69645. lastNativeXRHitResults: XRHitResult[];
  69646. /**
  69647. * Triggered when new babylon (transformed) hit test results are available
  69648. */
  69649. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69650. /**
  69651. * Creates a new instance of the (legacy version) hit test feature
  69652. * @param _xrSessionManager an instance of WebXRSessionManager
  69653. * @param options options to use when constructing this feature
  69654. */
  69655. constructor(_xrSessionManager: WebXRSessionManager,
  69656. /**
  69657. * options to use when constructing this feature
  69658. */
  69659. options?: IWebXRLegacyHitTestOptions);
  69660. /**
  69661. * execute a hit test with an XR Ray
  69662. *
  69663. * @param xrSession a native xrSession that will execute this hit test
  69664. * @param xrRay the ray (position and direction) to use for ray-casting
  69665. * @param referenceSpace native XR reference space to use for the hit-test
  69666. * @param filter filter function that will filter the results
  69667. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69668. */
  69669. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69670. /**
  69671. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69672. * @param event the (select) event to use to select with
  69673. * @param referenceSpace the reference space to use for this hit test
  69674. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69675. */
  69676. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69677. /**
  69678. * attach this feature
  69679. * Will usually be called by the features manager
  69680. *
  69681. * @returns true if successful.
  69682. */
  69683. attach(): boolean;
  69684. /**
  69685. * detach this feature.
  69686. * Will usually be called by the features manager
  69687. *
  69688. * @returns true if successful.
  69689. */
  69690. detach(): boolean;
  69691. /**
  69692. * Dispose this feature and all of the resources attached
  69693. */
  69694. dispose(): void;
  69695. protected _onXRFrame(frame: XRFrame): void;
  69696. private _onHitTestResults;
  69697. private _onSelect;
  69698. }
  69699. }
  69700. declare module BABYLON {
  69701. /**
  69702. * Options used in the plane detector module
  69703. */
  69704. export interface IWebXRPlaneDetectorOptions {
  69705. /**
  69706. * The node to use to transform the local results to world coordinates
  69707. */
  69708. worldParentNode?: TransformNode;
  69709. }
  69710. /**
  69711. * A babylon interface for a WebXR plane.
  69712. * A Plane is actually a polygon, built from N points in space
  69713. *
  69714. * Supported in chrome 79, not supported in canary 81 ATM
  69715. */
  69716. export interface IWebXRPlane {
  69717. /**
  69718. * a babylon-assigned ID for this polygon
  69719. */
  69720. id: number;
  69721. /**
  69722. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69723. */
  69724. polygonDefinition: Array<Vector3>;
  69725. /**
  69726. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69727. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69728. */
  69729. transformationMatrix: Matrix;
  69730. /**
  69731. * the native xr-plane object
  69732. */
  69733. xrPlane: XRPlane;
  69734. }
  69735. /**
  69736. * The plane detector is used to detect planes in the real world when in AR
  69737. * For more information see https://github.com/immersive-web/real-world-geometry/
  69738. */
  69739. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69740. private _options;
  69741. private _detectedPlanes;
  69742. private _enabled;
  69743. private _lastFrameDetected;
  69744. /**
  69745. * The module's name
  69746. */
  69747. static readonly Name: string;
  69748. /**
  69749. * The (Babylon) version of this module.
  69750. * This is an integer representing the implementation version.
  69751. * This number does not correspond to the WebXR specs version
  69752. */
  69753. static readonly Version: number;
  69754. /**
  69755. * Observers registered here will be executed when a new plane was added to the session
  69756. */
  69757. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69758. /**
  69759. * Observers registered here will be executed when a plane is no longer detected in the session
  69760. */
  69761. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69762. /**
  69763. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69764. * This can execute N times every frame
  69765. */
  69766. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69767. /**
  69768. * construct a new Plane Detector
  69769. * @param _xrSessionManager an instance of xr Session manager
  69770. * @param _options configuration to use when constructing this feature
  69771. */
  69772. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69773. /**
  69774. * Dispose this feature and all of the resources attached
  69775. */
  69776. dispose(): void;
  69777. protected _onXRFrame(frame: XRFrame): void;
  69778. private _init;
  69779. private _updatePlaneWithXRPlane;
  69780. /**
  69781. * avoiding using Array.find for global support.
  69782. * @param xrPlane the plane to find in the array
  69783. */
  69784. private findIndexInPlaneArray;
  69785. }
  69786. }
  69787. declare module BABYLON {
  69788. /**
  69789. * Configuration options of the anchor system
  69790. */
  69791. export interface IWebXRAnchorSystemOptions {
  69792. /**
  69793. * Should a new anchor be added every time a select event is triggered
  69794. */
  69795. addAnchorOnSelect?: boolean;
  69796. /**
  69797. * should the anchor system use plane detection.
  69798. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69799. */
  69800. usePlaneDetection?: boolean;
  69801. /**
  69802. * a node that will be used to convert local to world coordinates
  69803. */
  69804. worldParentNode?: TransformNode;
  69805. }
  69806. /**
  69807. * A babylon container for an XR Anchor
  69808. */
  69809. export interface IWebXRAnchor {
  69810. /**
  69811. * A babylon-assigned ID for this anchor
  69812. */
  69813. id: number;
  69814. /**
  69815. * Transformation matrix to apply to an object attached to this anchor
  69816. */
  69817. transformationMatrix: Matrix;
  69818. /**
  69819. * The native anchor object
  69820. */
  69821. xrAnchor: XRAnchor;
  69822. }
  69823. /**
  69824. * An implementation of the anchor system of WebXR.
  69825. * Note that the current documented implementation is not available in any browser. Future implementations
  69826. * will use the frame to create an anchor and not the session or a detected plane
  69827. * For further information see https://github.com/immersive-web/anchors/
  69828. */
  69829. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69830. private _options;
  69831. private _enabled;
  69832. private _hitTestModule;
  69833. private _lastFrameDetected;
  69834. private _onSelect;
  69835. private _planeDetector;
  69836. private _trackedAnchors;
  69837. /**
  69838. * The module's name
  69839. */
  69840. static readonly Name: string;
  69841. /**
  69842. * The (Babylon) version of this module.
  69843. * This is an integer representing the implementation version.
  69844. * This number does not correspond to the WebXR specs version
  69845. */
  69846. static readonly Version: number;
  69847. /**
  69848. * Observers registered here will be executed when a new anchor was added to the session
  69849. */
  69850. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69851. /**
  69852. * Observers registered here will be executed when an anchor was removed from the session
  69853. */
  69854. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69855. /**
  69856. * Observers registered here will be executed when an existing anchor updates
  69857. * This can execute N times every frame
  69858. */
  69859. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69860. /**
  69861. * constructs a new anchor system
  69862. * @param _xrSessionManager an instance of WebXRSessionManager
  69863. * @param _options configuration object for this feature
  69864. */
  69865. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69866. /**
  69867. * Add anchor at a specific XR point.
  69868. *
  69869. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69870. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69871. * @returns a promise the fulfills when the anchor was created
  69872. */
  69873. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69874. /**
  69875. * attach this feature
  69876. * Will usually be called by the features manager
  69877. *
  69878. * @returns true if successful.
  69879. */
  69880. attach(): boolean;
  69881. /**
  69882. * detach this feature.
  69883. * Will usually be called by the features manager
  69884. *
  69885. * @returns true if successful.
  69886. */
  69887. detach(): boolean;
  69888. /**
  69889. * Dispose this feature and all of the resources attached
  69890. */
  69891. dispose(): void;
  69892. /**
  69893. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69894. * @param hitTestModule the hit-test module to use.
  69895. */
  69896. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69897. /**
  69898. * set the plane detector to use in order to create anchors from frames
  69899. * @param planeDetector the plane-detector module to use
  69900. * @param enable enable plane-anchors. default is true
  69901. */
  69902. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69903. protected _onXRFrame(frame: XRFrame): void;
  69904. /**
  69905. * avoiding using Array.find for global support.
  69906. * @param xrAnchor the plane to find in the array
  69907. */
  69908. private _findIndexInAnchorArray;
  69909. private _updateAnchorWithXRFrame;
  69910. }
  69911. }
  69912. declare module BABYLON {
  69913. /**
  69914. * Options interface for the background remover plugin
  69915. */
  69916. export interface IWebXRBackgroundRemoverOptions {
  69917. /**
  69918. * Further background meshes to disable when entering AR
  69919. */
  69920. backgroundMeshes?: AbstractMesh[];
  69921. /**
  69922. * flags to configure the removal of the environment helper.
  69923. * If not set, the entire background will be removed. If set, flags should be set as well.
  69924. */
  69925. environmentHelperRemovalFlags?: {
  69926. /**
  69927. * Should the skybox be removed (default false)
  69928. */
  69929. skyBox?: boolean;
  69930. /**
  69931. * Should the ground be removed (default false)
  69932. */
  69933. ground?: boolean;
  69934. };
  69935. /**
  69936. * don't disable the environment helper
  69937. */
  69938. ignoreEnvironmentHelper?: boolean;
  69939. }
  69940. /**
  69941. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69942. */
  69943. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69944. /**
  69945. * read-only options to be used in this module
  69946. */
  69947. readonly options: IWebXRBackgroundRemoverOptions;
  69948. /**
  69949. * The module's name
  69950. */
  69951. static readonly Name: string;
  69952. /**
  69953. * The (Babylon) version of this module.
  69954. * This is an integer representing the implementation version.
  69955. * This number does not correspond to the WebXR specs version
  69956. */
  69957. static readonly Version: number;
  69958. /**
  69959. * registered observers will be triggered when the background state changes
  69960. */
  69961. onBackgroundStateChangedObservable: Observable<boolean>;
  69962. /**
  69963. * constructs a new background remover module
  69964. * @param _xrSessionManager the session manager for this module
  69965. * @param options read-only options to be used in this module
  69966. */
  69967. constructor(_xrSessionManager: WebXRSessionManager,
  69968. /**
  69969. * read-only options to be used in this module
  69970. */
  69971. options?: IWebXRBackgroundRemoverOptions);
  69972. /**
  69973. * attach this feature
  69974. * Will usually be called by the features manager
  69975. *
  69976. * @returns true if successful.
  69977. */
  69978. attach(): boolean;
  69979. /**
  69980. * detach this feature.
  69981. * Will usually be called by the features manager
  69982. *
  69983. * @returns true if successful.
  69984. */
  69985. detach(): boolean;
  69986. /**
  69987. * Dispose this feature and all of the resources attached
  69988. */
  69989. dispose(): void;
  69990. protected _onXRFrame(_xrFrame: XRFrame): void;
  69991. private _setBackgroundState;
  69992. }
  69993. }
  69994. declare module BABYLON {
  69995. /**
  69996. * Options for the controller physics feature
  69997. */
  69998. export class IWebXRControllerPhysicsOptions {
  69999. /**
  70000. * Should the headset get its own impostor
  70001. */
  70002. enableHeadsetImpostor?: boolean;
  70003. /**
  70004. * Optional parameters for the headset impostor
  70005. */
  70006. headsetImpostorParams?: {
  70007. /**
  70008. * The type of impostor to create. Default is sphere
  70009. */
  70010. impostorType: number;
  70011. /**
  70012. * the size of the impostor. Defaults to 10cm
  70013. */
  70014. impostorSize?: number | {
  70015. width: number;
  70016. height: number;
  70017. depth: number;
  70018. };
  70019. /**
  70020. * Friction definitions
  70021. */
  70022. friction?: number;
  70023. /**
  70024. * Restitution
  70025. */
  70026. restitution?: number;
  70027. };
  70028. /**
  70029. * The physics properties of the future impostors
  70030. */
  70031. physicsProperties?: {
  70032. /**
  70033. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  70034. * Note that this requires a physics engine that supports mesh impostors!
  70035. */
  70036. useControllerMesh?: boolean;
  70037. /**
  70038. * The type of impostor to create. Default is sphere
  70039. */
  70040. impostorType?: number;
  70041. /**
  70042. * the size of the impostor. Defaults to 10cm
  70043. */
  70044. impostorSize?: number | {
  70045. width: number;
  70046. height: number;
  70047. depth: number;
  70048. };
  70049. /**
  70050. * Friction definitions
  70051. */
  70052. friction?: number;
  70053. /**
  70054. * Restitution
  70055. */
  70056. restitution?: number;
  70057. };
  70058. /**
  70059. * the xr input to use with this pointer selection
  70060. */
  70061. xrInput: WebXRInput;
  70062. }
  70063. /**
  70064. * Add physics impostor to your webxr controllers,
  70065. * including naive calculation of their linear and angular velocity
  70066. */
  70067. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  70068. private readonly _options;
  70069. private _attachController;
  70070. private _controllers;
  70071. private _debugMode;
  70072. private _delta;
  70073. private _headsetImpostor?;
  70074. private _headsetMesh?;
  70075. private _lastTimestamp;
  70076. private _tmpQuaternion;
  70077. private _tmpVector;
  70078. /**
  70079. * The module's name
  70080. */
  70081. static readonly Name: string;
  70082. /**
  70083. * The (Babylon) version of this module.
  70084. * This is an integer representing the implementation version.
  70085. * This number does not correspond to the webxr specs version
  70086. */
  70087. static readonly Version: number;
  70088. /**
  70089. * Construct a new Controller Physics Feature
  70090. * @param _xrSessionManager the corresponding xr session manager
  70091. * @param _options options to create this feature with
  70092. */
  70093. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  70094. /**
  70095. * @hidden
  70096. * enable debugging - will show console outputs and the impostor mesh
  70097. */
  70098. _enablePhysicsDebug(): void;
  70099. /**
  70100. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  70101. * @param xrController the controller to add
  70102. */
  70103. addController(xrController: WebXRInputSource): void;
  70104. /**
  70105. * attach this feature
  70106. * Will usually be called by the features manager
  70107. *
  70108. * @returns true if successful.
  70109. */
  70110. attach(): boolean;
  70111. /**
  70112. * detach this feature.
  70113. * Will usually be called by the features manager
  70114. *
  70115. * @returns true if successful.
  70116. */
  70117. detach(): boolean;
  70118. /**
  70119. * Get the headset impostor, if enabled
  70120. * @returns the impostor
  70121. */
  70122. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70123. /**
  70124. * Get the physics impostor of a specific controller.
  70125. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70126. * @param controller the controller or the controller id of which to get the impostor
  70127. * @returns the impostor or null
  70128. */
  70129. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70130. /**
  70131. * Update the physics properties provided in the constructor
  70132. * @param newProperties the new properties object
  70133. */
  70134. setPhysicsProperties(newProperties: {
  70135. impostorType?: number;
  70136. impostorSize?: number | {
  70137. width: number;
  70138. height: number;
  70139. depth: number;
  70140. };
  70141. friction?: number;
  70142. restitution?: number;
  70143. }): void;
  70144. protected _onXRFrame(_xrFrame: any): void;
  70145. private _detachController;
  70146. }
  70147. }
  70148. declare module BABYLON {
  70149. /**
  70150. * Options used for hit testing (version 2)
  70151. */
  70152. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70153. /**
  70154. * Do not create a permanent hit test. Will usually be used when only
  70155. * transient inputs are needed.
  70156. */
  70157. disablePermanentHitTest?: boolean;
  70158. /**
  70159. * Enable transient (for example touch-based) hit test inspections
  70160. */
  70161. enableTransientHitTest?: boolean;
  70162. /**
  70163. * Offset ray for the permanent hit test
  70164. */
  70165. offsetRay?: Vector3;
  70166. /**
  70167. * Offset ray for the transient hit test
  70168. */
  70169. transientOffsetRay?: Vector3;
  70170. /**
  70171. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70172. */
  70173. useReferenceSpace?: boolean;
  70174. }
  70175. /**
  70176. * Interface defining the babylon result of hit-test
  70177. */
  70178. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70179. /**
  70180. * The input source that generated this hit test (if transient)
  70181. */
  70182. inputSource?: XRInputSource;
  70183. /**
  70184. * Is this a transient hit test
  70185. */
  70186. isTransient?: boolean;
  70187. /**
  70188. * Position of the hit test result
  70189. */
  70190. position: Vector3;
  70191. /**
  70192. * Rotation of the hit test result
  70193. */
  70194. rotationQuaternion: Quaternion;
  70195. }
  70196. /**
  70197. * The currently-working hit-test module.
  70198. * Hit test (or Ray-casting) is used to interact with the real world.
  70199. * For further information read here - https://github.com/immersive-web/hit-test
  70200. *
  70201. * Tested on chrome (mobile) 80.
  70202. */
  70203. export class WebXRHitTest extends WebXRAbstractFeature {
  70204. /**
  70205. * options to use when constructing this feature
  70206. */
  70207. readonly options: IWebXRHitTestOptions;
  70208. private _tmpMat;
  70209. private _tmpPos;
  70210. private _tmpQuat;
  70211. private _transientXrHitTestSource;
  70212. private _xrHitTestSource;
  70213. private initHitTestSource;
  70214. /**
  70215. * The module's name
  70216. */
  70217. static readonly Name: string;
  70218. /**
  70219. * The (Babylon) version of this module.
  70220. * This is an integer representing the implementation version.
  70221. * This number does not correspond to the WebXR specs version
  70222. */
  70223. static readonly Version: number;
  70224. /**
  70225. * When set to true, each hit test will have its own position/rotation objects
  70226. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70227. * the developers will clone them or copy them as they see fit.
  70228. */
  70229. autoCloneTransformation: boolean;
  70230. /**
  70231. * Populated with the last native XR Hit Results
  70232. */
  70233. lastNativeXRHitResults: XRHitResult[];
  70234. /**
  70235. * Triggered when new babylon (transformed) hit test results are available
  70236. */
  70237. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70238. /**
  70239. * Use this to temporarily pause hit test checks.
  70240. */
  70241. paused: boolean;
  70242. /**
  70243. * Creates a new instance of the hit test feature
  70244. * @param _xrSessionManager an instance of WebXRSessionManager
  70245. * @param options options to use when constructing this feature
  70246. */
  70247. constructor(_xrSessionManager: WebXRSessionManager,
  70248. /**
  70249. * options to use when constructing this feature
  70250. */
  70251. options?: IWebXRHitTestOptions);
  70252. /**
  70253. * attach this feature
  70254. * Will usually be called by the features manager
  70255. *
  70256. * @returns true if successful.
  70257. */
  70258. attach(): boolean;
  70259. /**
  70260. * detach this feature.
  70261. * Will usually be called by the features manager
  70262. *
  70263. * @returns true if successful.
  70264. */
  70265. detach(): boolean;
  70266. /**
  70267. * Dispose this feature and all of the resources attached
  70268. */
  70269. dispose(): void;
  70270. protected _onXRFrame(frame: XRFrame): void;
  70271. private _processWebXRHitTestResult;
  70272. }
  70273. }
  70274. declare module BABYLON {
  70275. /**
  70276. * The motion controller class for all microsoft mixed reality controllers
  70277. */
  70278. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70279. protected readonly _mapping: {
  70280. defaultButton: {
  70281. valueNodeName: string;
  70282. unpressedNodeName: string;
  70283. pressedNodeName: string;
  70284. };
  70285. defaultAxis: {
  70286. valueNodeName: string;
  70287. minNodeName: string;
  70288. maxNodeName: string;
  70289. };
  70290. buttons: {
  70291. "xr-standard-trigger": {
  70292. rootNodeName: string;
  70293. componentProperty: string;
  70294. states: string[];
  70295. };
  70296. "xr-standard-squeeze": {
  70297. rootNodeName: string;
  70298. componentProperty: string;
  70299. states: string[];
  70300. };
  70301. "xr-standard-touchpad": {
  70302. rootNodeName: string;
  70303. labelAnchorNodeName: string;
  70304. touchPointNodeName: string;
  70305. };
  70306. "xr-standard-thumbstick": {
  70307. rootNodeName: string;
  70308. componentProperty: string;
  70309. states: string[];
  70310. };
  70311. };
  70312. axes: {
  70313. "xr-standard-touchpad": {
  70314. "x-axis": {
  70315. rootNodeName: string;
  70316. };
  70317. "y-axis": {
  70318. rootNodeName: string;
  70319. };
  70320. };
  70321. "xr-standard-thumbstick": {
  70322. "x-axis": {
  70323. rootNodeName: string;
  70324. };
  70325. "y-axis": {
  70326. rootNodeName: string;
  70327. };
  70328. };
  70329. };
  70330. };
  70331. /**
  70332. * The base url used to load the left and right controller models
  70333. */
  70334. static MODEL_BASE_URL: string;
  70335. /**
  70336. * The name of the left controller model file
  70337. */
  70338. static MODEL_LEFT_FILENAME: string;
  70339. /**
  70340. * The name of the right controller model file
  70341. */
  70342. static MODEL_RIGHT_FILENAME: string;
  70343. profileId: string;
  70344. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70345. protected _getFilenameAndPath(): {
  70346. filename: string;
  70347. path: string;
  70348. };
  70349. protected _getModelLoadingConstraints(): boolean;
  70350. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70351. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70352. protected _updateModel(): void;
  70353. }
  70354. }
  70355. declare module BABYLON {
  70356. /**
  70357. * The motion controller class for oculus touch (quest, rift).
  70358. * This class supports legacy mapping as well the standard xr mapping
  70359. */
  70360. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70361. private _forceLegacyControllers;
  70362. private _modelRootNode;
  70363. /**
  70364. * The base url used to load the left and right controller models
  70365. */
  70366. static MODEL_BASE_URL: string;
  70367. /**
  70368. * The name of the left controller model file
  70369. */
  70370. static MODEL_LEFT_FILENAME: string;
  70371. /**
  70372. * The name of the right controller model file
  70373. */
  70374. static MODEL_RIGHT_FILENAME: string;
  70375. /**
  70376. * Base Url for the Quest controller model.
  70377. */
  70378. static QUEST_MODEL_BASE_URL: string;
  70379. profileId: string;
  70380. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70381. protected _getFilenameAndPath(): {
  70382. filename: string;
  70383. path: string;
  70384. };
  70385. protected _getModelLoadingConstraints(): boolean;
  70386. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70387. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70388. protected _updateModel(): void;
  70389. /**
  70390. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70391. * between the touch and touch 2.
  70392. */
  70393. private _isQuest;
  70394. }
  70395. }
  70396. declare module BABYLON {
  70397. /**
  70398. * The motion controller class for the standard HTC-Vive controllers
  70399. */
  70400. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70401. private _modelRootNode;
  70402. /**
  70403. * The base url used to load the left and right controller models
  70404. */
  70405. static MODEL_BASE_URL: string;
  70406. /**
  70407. * File name for the controller model.
  70408. */
  70409. static MODEL_FILENAME: string;
  70410. profileId: string;
  70411. /**
  70412. * Create a new Vive motion controller object
  70413. * @param scene the scene to use to create this controller
  70414. * @param gamepadObject the corresponding gamepad object
  70415. * @param handness the handness of the controller
  70416. */
  70417. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70418. protected _getFilenameAndPath(): {
  70419. filename: string;
  70420. path: string;
  70421. };
  70422. protected _getModelLoadingConstraints(): boolean;
  70423. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70424. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70425. protected _updateModel(): void;
  70426. }
  70427. }
  70428. declare module BABYLON {
  70429. /**
  70430. * A cursor which tracks a point on a path
  70431. */
  70432. export class PathCursor {
  70433. private path;
  70434. /**
  70435. * Stores path cursor callbacks for when an onchange event is triggered
  70436. */
  70437. private _onchange;
  70438. /**
  70439. * The value of the path cursor
  70440. */
  70441. value: number;
  70442. /**
  70443. * The animation array of the path cursor
  70444. */
  70445. animations: Animation[];
  70446. /**
  70447. * Initializes the path cursor
  70448. * @param path The path to track
  70449. */
  70450. constructor(path: Path2);
  70451. /**
  70452. * Gets the cursor point on the path
  70453. * @returns A point on the path cursor at the cursor location
  70454. */
  70455. getPoint(): Vector3;
  70456. /**
  70457. * Moves the cursor ahead by the step amount
  70458. * @param step The amount to move the cursor forward
  70459. * @returns This path cursor
  70460. */
  70461. moveAhead(step?: number): PathCursor;
  70462. /**
  70463. * Moves the cursor behind by the step amount
  70464. * @param step The amount to move the cursor back
  70465. * @returns This path cursor
  70466. */
  70467. moveBack(step?: number): PathCursor;
  70468. /**
  70469. * Moves the cursor by the step amount
  70470. * If the step amount is greater than one, an exception is thrown
  70471. * @param step The amount to move the cursor
  70472. * @returns This path cursor
  70473. */
  70474. move(step: number): PathCursor;
  70475. /**
  70476. * Ensures that the value is limited between zero and one
  70477. * @returns This path cursor
  70478. */
  70479. private ensureLimits;
  70480. /**
  70481. * Runs onchange callbacks on change (used by the animation engine)
  70482. * @returns This path cursor
  70483. */
  70484. private raiseOnChange;
  70485. /**
  70486. * Executes a function on change
  70487. * @param f A path cursor onchange callback
  70488. * @returns This path cursor
  70489. */
  70490. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70491. }
  70492. }
  70493. declare module BABYLON {
  70494. /** @hidden */
  70495. export var blurPixelShader: {
  70496. name: string;
  70497. shader: string;
  70498. };
  70499. }
  70500. declare module BABYLON {
  70501. /** @hidden */
  70502. export var pointCloudVertexDeclaration: {
  70503. name: string;
  70504. shader: string;
  70505. };
  70506. }
  70507. // Mixins
  70508. interface Window {
  70509. mozIndexedDB: IDBFactory;
  70510. webkitIndexedDB: IDBFactory;
  70511. msIndexedDB: IDBFactory;
  70512. webkitURL: typeof URL;
  70513. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70514. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70515. WebGLRenderingContext: WebGLRenderingContext;
  70516. MSGesture: MSGesture;
  70517. CANNON: any;
  70518. AudioContext: AudioContext;
  70519. webkitAudioContext: AudioContext;
  70520. PointerEvent: any;
  70521. Math: Math;
  70522. Uint8Array: Uint8ArrayConstructor;
  70523. Float32Array: Float32ArrayConstructor;
  70524. mozURL: typeof URL;
  70525. msURL: typeof URL;
  70526. VRFrameData: any; // WebVR, from specs 1.1
  70527. DracoDecoderModule: any;
  70528. setImmediate(handler: (...args: any[]) => void): number;
  70529. }
  70530. interface HTMLCanvasElement {
  70531. requestPointerLock(): void;
  70532. msRequestPointerLock?(): void;
  70533. mozRequestPointerLock?(): void;
  70534. webkitRequestPointerLock?(): void;
  70535. /** Track wether a record is in progress */
  70536. isRecording: boolean;
  70537. /** Capture Stream method defined by some browsers */
  70538. captureStream(fps?: number): MediaStream;
  70539. }
  70540. interface CanvasRenderingContext2D {
  70541. msImageSmoothingEnabled: boolean;
  70542. }
  70543. interface MouseEvent {
  70544. mozMovementX: number;
  70545. mozMovementY: number;
  70546. webkitMovementX: number;
  70547. webkitMovementY: number;
  70548. msMovementX: number;
  70549. msMovementY: number;
  70550. }
  70551. interface Navigator {
  70552. mozGetVRDevices: (any: any) => any;
  70553. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70554. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70555. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70556. webkitGetGamepads(): Gamepad[];
  70557. msGetGamepads(): Gamepad[];
  70558. webkitGamepads(): Gamepad[];
  70559. }
  70560. interface HTMLVideoElement {
  70561. mozSrcObject: any;
  70562. }
  70563. interface Math {
  70564. fround(x: number): number;
  70565. imul(a: number, b: number): number;
  70566. }
  70567. interface WebGLRenderingContext {
  70568. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70569. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70570. vertexAttribDivisor(index: number, divisor: number): void;
  70571. createVertexArray(): any;
  70572. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70573. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70574. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70575. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70576. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70577. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70578. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70579. // Queries
  70580. createQuery(): WebGLQuery;
  70581. deleteQuery(query: WebGLQuery): void;
  70582. beginQuery(target: number, query: WebGLQuery): void;
  70583. endQuery(target: number): void;
  70584. getQueryParameter(query: WebGLQuery, pname: number): any;
  70585. getQuery(target: number, pname: number): any;
  70586. MAX_SAMPLES: number;
  70587. RGBA8: number;
  70588. READ_FRAMEBUFFER: number;
  70589. DRAW_FRAMEBUFFER: number;
  70590. UNIFORM_BUFFER: number;
  70591. HALF_FLOAT_OES: number;
  70592. RGBA16F: number;
  70593. RGBA32F: number;
  70594. R32F: number;
  70595. RG32F: number;
  70596. RGB32F: number;
  70597. R16F: number;
  70598. RG16F: number;
  70599. RGB16F: number;
  70600. RED: number;
  70601. RG: number;
  70602. R8: number;
  70603. RG8: number;
  70604. UNSIGNED_INT_24_8: number;
  70605. DEPTH24_STENCIL8: number;
  70606. MIN: number;
  70607. MAX: number;
  70608. /* Multiple Render Targets */
  70609. drawBuffers(buffers: number[]): void;
  70610. readBuffer(src: number): void;
  70611. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70612. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70613. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70614. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70615. // Occlusion Query
  70616. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70617. ANY_SAMPLES_PASSED: number;
  70618. QUERY_RESULT_AVAILABLE: number;
  70619. QUERY_RESULT: number;
  70620. }
  70621. interface WebGLProgram {
  70622. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70623. }
  70624. interface EXT_disjoint_timer_query {
  70625. QUERY_COUNTER_BITS_EXT: number;
  70626. TIME_ELAPSED_EXT: number;
  70627. TIMESTAMP_EXT: number;
  70628. GPU_DISJOINT_EXT: number;
  70629. QUERY_RESULT_EXT: number;
  70630. QUERY_RESULT_AVAILABLE_EXT: number;
  70631. queryCounterEXT(query: WebGLQuery, target: number): void;
  70632. createQueryEXT(): WebGLQuery;
  70633. beginQueryEXT(target: number, query: WebGLQuery): void;
  70634. endQueryEXT(target: number): void;
  70635. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70636. deleteQueryEXT(query: WebGLQuery): void;
  70637. }
  70638. interface WebGLUniformLocation {
  70639. _currentState: any;
  70640. }
  70641. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70642. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70643. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70644. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70645. interface WebGLRenderingContext {
  70646. readonly RASTERIZER_DISCARD: number;
  70647. readonly DEPTH_COMPONENT24: number;
  70648. readonly TEXTURE_3D: number;
  70649. readonly TEXTURE_2D_ARRAY: number;
  70650. readonly TEXTURE_COMPARE_FUNC: number;
  70651. readonly TEXTURE_COMPARE_MODE: number;
  70652. readonly COMPARE_REF_TO_TEXTURE: number;
  70653. readonly TEXTURE_WRAP_R: number;
  70654. readonly HALF_FLOAT: number;
  70655. readonly RGB8: number;
  70656. readonly RED_INTEGER: number;
  70657. readonly RG_INTEGER: number;
  70658. readonly RGB_INTEGER: number;
  70659. readonly RGBA_INTEGER: number;
  70660. readonly R8_SNORM: number;
  70661. readonly RG8_SNORM: number;
  70662. readonly RGB8_SNORM: number;
  70663. readonly RGBA8_SNORM: number;
  70664. readonly R8I: number;
  70665. readonly RG8I: number;
  70666. readonly RGB8I: number;
  70667. readonly RGBA8I: number;
  70668. readonly R8UI: number;
  70669. readonly RG8UI: number;
  70670. readonly RGB8UI: number;
  70671. readonly RGBA8UI: number;
  70672. readonly R16I: number;
  70673. readonly RG16I: number;
  70674. readonly RGB16I: number;
  70675. readonly RGBA16I: number;
  70676. readonly R16UI: number;
  70677. readonly RG16UI: number;
  70678. readonly RGB16UI: number;
  70679. readonly RGBA16UI: number;
  70680. readonly R32I: number;
  70681. readonly RG32I: number;
  70682. readonly RGB32I: number;
  70683. readonly RGBA32I: number;
  70684. readonly R32UI: number;
  70685. readonly RG32UI: number;
  70686. readonly RGB32UI: number;
  70687. readonly RGBA32UI: number;
  70688. readonly RGB10_A2UI: number;
  70689. readonly R11F_G11F_B10F: number;
  70690. readonly RGB9_E5: number;
  70691. readonly RGB10_A2: number;
  70692. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70693. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70694. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70695. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70696. readonly DEPTH_COMPONENT32F: number;
  70697. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70698. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70699. 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;
  70700. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70701. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70702. readonly TRANSFORM_FEEDBACK: number;
  70703. readonly INTERLEAVED_ATTRIBS: number;
  70704. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70705. createTransformFeedback(): WebGLTransformFeedback;
  70706. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70707. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70708. beginTransformFeedback(primitiveMode: number): void;
  70709. endTransformFeedback(): void;
  70710. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70711. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70712. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70713. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70714. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70715. }
  70716. interface ImageBitmap {
  70717. readonly width: number;
  70718. readonly height: number;
  70719. close(): void;
  70720. }
  70721. interface WebGLQuery extends WebGLObject {
  70722. }
  70723. declare var WebGLQuery: {
  70724. prototype: WebGLQuery;
  70725. new(): WebGLQuery;
  70726. };
  70727. interface WebGLSampler extends WebGLObject {
  70728. }
  70729. declare var WebGLSampler: {
  70730. prototype: WebGLSampler;
  70731. new(): WebGLSampler;
  70732. };
  70733. interface WebGLSync extends WebGLObject {
  70734. }
  70735. declare var WebGLSync: {
  70736. prototype: WebGLSync;
  70737. new(): WebGLSync;
  70738. };
  70739. interface WebGLTransformFeedback extends WebGLObject {
  70740. }
  70741. declare var WebGLTransformFeedback: {
  70742. prototype: WebGLTransformFeedback;
  70743. new(): WebGLTransformFeedback;
  70744. };
  70745. interface WebGLVertexArrayObject extends WebGLObject {
  70746. }
  70747. declare var WebGLVertexArrayObject: {
  70748. prototype: WebGLVertexArrayObject;
  70749. new(): WebGLVertexArrayObject;
  70750. };
  70751. // Type definitions for WebVR API
  70752. // Project: https://w3c.github.io/webvr/
  70753. // Definitions by: six a <https://github.com/lostfictions>
  70754. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70755. interface VRDisplay extends EventTarget {
  70756. /**
  70757. * Dictionary of capabilities describing the VRDisplay.
  70758. */
  70759. readonly capabilities: VRDisplayCapabilities;
  70760. /**
  70761. * z-depth defining the far plane of the eye view frustum
  70762. * enables mapping of values in the render target depth
  70763. * attachment to scene coordinates. Initially set to 10000.0.
  70764. */
  70765. depthFar: number;
  70766. /**
  70767. * z-depth defining the near plane of the eye view frustum
  70768. * enables mapping of values in the render target depth
  70769. * attachment to scene coordinates. Initially set to 0.01.
  70770. */
  70771. depthNear: number;
  70772. /**
  70773. * An identifier for this distinct VRDisplay. Used as an
  70774. * association point in the Gamepad API.
  70775. */
  70776. readonly displayId: number;
  70777. /**
  70778. * A display name, a user-readable name identifying it.
  70779. */
  70780. readonly displayName: string;
  70781. readonly isConnected: boolean;
  70782. readonly isPresenting: boolean;
  70783. /**
  70784. * If this VRDisplay supports room-scale experiences, the optional
  70785. * stage attribute contains details on the room-scale parameters.
  70786. */
  70787. readonly stageParameters: VRStageParameters | null;
  70788. /**
  70789. * Passing the value returned by `requestAnimationFrame` to
  70790. * `cancelAnimationFrame` will unregister the callback.
  70791. * @param handle Define the hanle of the request to cancel
  70792. */
  70793. cancelAnimationFrame(handle: number): void;
  70794. /**
  70795. * Stops presenting to the VRDisplay.
  70796. * @returns a promise to know when it stopped
  70797. */
  70798. exitPresent(): Promise<void>;
  70799. /**
  70800. * Return the current VREyeParameters for the given eye.
  70801. * @param whichEye Define the eye we want the parameter for
  70802. * @returns the eye parameters
  70803. */
  70804. getEyeParameters(whichEye: string): VREyeParameters;
  70805. /**
  70806. * Populates the passed VRFrameData with the information required to render
  70807. * the current frame.
  70808. * @param frameData Define the data structure to populate
  70809. * @returns true if ok otherwise false
  70810. */
  70811. getFrameData(frameData: VRFrameData): boolean;
  70812. /**
  70813. * Get the layers currently being presented.
  70814. * @returns the list of VR layers
  70815. */
  70816. getLayers(): VRLayer[];
  70817. /**
  70818. * Return a VRPose containing the future predicted pose of the VRDisplay
  70819. * when the current frame will be presented. The value returned will not
  70820. * change until JavaScript has returned control to the browser.
  70821. *
  70822. * The VRPose will contain the position, orientation, velocity,
  70823. * and acceleration of each of these properties.
  70824. * @returns the pose object
  70825. */
  70826. getPose(): VRPose;
  70827. /**
  70828. * Return the current instantaneous pose of the VRDisplay, with no
  70829. * prediction applied.
  70830. * @returns the current instantaneous pose
  70831. */
  70832. getImmediatePose(): VRPose;
  70833. /**
  70834. * The callback passed to `requestAnimationFrame` will be called
  70835. * any time a new frame should be rendered. When the VRDisplay is
  70836. * presenting the callback will be called at the native refresh
  70837. * rate of the HMD. When not presenting this function acts
  70838. * identically to how window.requestAnimationFrame acts. Content should
  70839. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70840. * asynchronously from other displays and at differing refresh rates.
  70841. * @param callback Define the eaction to run next frame
  70842. * @returns the request handle it
  70843. */
  70844. requestAnimationFrame(callback: FrameRequestCallback): number;
  70845. /**
  70846. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70847. * Repeat calls while already presenting will update the VRLayers being displayed.
  70848. * @param layers Define the list of layer to present
  70849. * @returns a promise to know when the request has been fulfilled
  70850. */
  70851. requestPresent(layers: VRLayer[]): Promise<void>;
  70852. /**
  70853. * Reset the pose for this display, treating its current position and
  70854. * orientation as the "origin/zero" values. VRPose.position,
  70855. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70856. * updated when calling resetPose(). This should be called in only
  70857. * sitting-space experiences.
  70858. */
  70859. resetPose(): void;
  70860. /**
  70861. * The VRLayer provided to the VRDisplay will be captured and presented
  70862. * in the HMD. Calling this function has the same effect on the source
  70863. * canvas as any other operation that uses its source image, and canvases
  70864. * created without preserveDrawingBuffer set to true will be cleared.
  70865. * @param pose Define the pose to submit
  70866. */
  70867. submitFrame(pose?: VRPose): void;
  70868. }
  70869. declare var VRDisplay: {
  70870. prototype: VRDisplay;
  70871. new(): VRDisplay;
  70872. };
  70873. interface VRLayer {
  70874. leftBounds?: number[] | Float32Array | null;
  70875. rightBounds?: number[] | Float32Array | null;
  70876. source?: HTMLCanvasElement | null;
  70877. }
  70878. interface VRDisplayCapabilities {
  70879. readonly canPresent: boolean;
  70880. readonly hasExternalDisplay: boolean;
  70881. readonly hasOrientation: boolean;
  70882. readonly hasPosition: boolean;
  70883. readonly maxLayers: number;
  70884. }
  70885. interface VREyeParameters {
  70886. /** @deprecated */
  70887. readonly fieldOfView: VRFieldOfView;
  70888. readonly offset: Float32Array;
  70889. readonly renderHeight: number;
  70890. readonly renderWidth: number;
  70891. }
  70892. interface VRFieldOfView {
  70893. readonly downDegrees: number;
  70894. readonly leftDegrees: number;
  70895. readonly rightDegrees: number;
  70896. readonly upDegrees: number;
  70897. }
  70898. interface VRFrameData {
  70899. readonly leftProjectionMatrix: Float32Array;
  70900. readonly leftViewMatrix: Float32Array;
  70901. readonly pose: VRPose;
  70902. readonly rightProjectionMatrix: Float32Array;
  70903. readonly rightViewMatrix: Float32Array;
  70904. readonly timestamp: number;
  70905. }
  70906. interface VRPose {
  70907. readonly angularAcceleration: Float32Array | null;
  70908. readonly angularVelocity: Float32Array | null;
  70909. readonly linearAcceleration: Float32Array | null;
  70910. readonly linearVelocity: Float32Array | null;
  70911. readonly orientation: Float32Array | null;
  70912. readonly position: Float32Array | null;
  70913. readonly timestamp: number;
  70914. }
  70915. interface VRStageParameters {
  70916. sittingToStandingTransform?: Float32Array;
  70917. sizeX?: number;
  70918. sizeY?: number;
  70919. }
  70920. interface Navigator {
  70921. getVRDisplays(): Promise<VRDisplay[]>;
  70922. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70923. }
  70924. interface Window {
  70925. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70926. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70927. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70928. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70929. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70930. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70931. }
  70932. interface Gamepad {
  70933. readonly displayId: number;
  70934. }
  70935. type XRSessionMode =
  70936. | "inline"
  70937. | "immersive-vr"
  70938. | "immersive-ar";
  70939. type XRReferenceSpaceType =
  70940. | "viewer"
  70941. | "local"
  70942. | "local-floor"
  70943. | "bounded-floor"
  70944. | "unbounded";
  70945. type XREnvironmentBlendMode =
  70946. | "opaque"
  70947. | "additive"
  70948. | "alpha-blend";
  70949. type XRVisibilityState =
  70950. | "visible"
  70951. | "visible-blurred"
  70952. | "hidden";
  70953. type XRHandedness =
  70954. | "none"
  70955. | "left"
  70956. | "right";
  70957. type XRTargetRayMode =
  70958. | "gaze"
  70959. | "tracked-pointer"
  70960. | "screen";
  70961. type XREye =
  70962. | "none"
  70963. | "left"
  70964. | "right";
  70965. interface XRSpace extends EventTarget {
  70966. }
  70967. interface XRRenderState {
  70968. depthNear?: number;
  70969. depthFar?: number;
  70970. inlineVerticalFieldOfView?: number;
  70971. baseLayer?: XRWebGLLayer;
  70972. }
  70973. interface XRInputSource {
  70974. handedness: XRHandedness;
  70975. targetRayMode: XRTargetRayMode;
  70976. targetRaySpace: XRSpace;
  70977. gripSpace: XRSpace | undefined;
  70978. gamepad: Gamepad | undefined;
  70979. profiles: Array<string>;
  70980. }
  70981. interface XRSessionInit {
  70982. optionalFeatures?: XRReferenceSpaceType[];
  70983. requiredFeatures?: XRReferenceSpaceType[];
  70984. }
  70985. interface XRSession extends XRAnchorCreator {
  70986. addEventListener: Function;
  70987. removeEventListener: Function;
  70988. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70989. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70990. requestAnimationFrame: Function;
  70991. end(): Promise<void>;
  70992. renderState: XRRenderState;
  70993. inputSources: Array<XRInputSource>;
  70994. // hit test
  70995. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70996. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70997. // legacy AR hit test
  70998. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70999. // legacy plane detection
  71000. updateWorldTrackingState(options: {
  71001. planeDetectionState?: { enabled: boolean; }
  71002. }): void;
  71003. }
  71004. interface XRReferenceSpace extends XRSpace {
  71005. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  71006. onreset: any;
  71007. }
  71008. type XRPlaneSet = Set<XRPlane>;
  71009. type XRAnchorSet = Set<XRAnchor>;
  71010. interface XRFrame {
  71011. session: XRSession;
  71012. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  71013. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  71014. // AR
  71015. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  71016. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  71017. // Anchors
  71018. trackedAnchors?: XRAnchorSet;
  71019. // Planes
  71020. worldInformation: {
  71021. detectedPlanes?: XRPlaneSet;
  71022. };
  71023. }
  71024. interface XRViewerPose extends XRPose {
  71025. views: Array<XRView>;
  71026. }
  71027. interface XRPose {
  71028. transform: XRRigidTransform;
  71029. emulatedPosition: boolean;
  71030. }
  71031. interface XRWebGLLayerOptions {
  71032. antialias?: boolean;
  71033. depth?: boolean;
  71034. stencil?: boolean;
  71035. alpha?: boolean;
  71036. multiview?: boolean;
  71037. framebufferScaleFactor?: number;
  71038. }
  71039. declare var XRWebGLLayer: {
  71040. prototype: XRWebGLLayer;
  71041. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  71042. };
  71043. interface XRWebGLLayer {
  71044. framebuffer: WebGLFramebuffer;
  71045. framebufferWidth: number;
  71046. framebufferHeight: number;
  71047. getViewport: Function;
  71048. }
  71049. declare class XRRigidTransform {
  71050. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  71051. position: DOMPointReadOnly;
  71052. orientation: DOMPointReadOnly;
  71053. matrix: Float32Array;
  71054. inverse: XRRigidTransform;
  71055. }
  71056. interface XRView {
  71057. eye: XREye;
  71058. projectionMatrix: Float32Array;
  71059. transform: XRRigidTransform;
  71060. }
  71061. interface XRInputSourceChangeEvent {
  71062. session: XRSession;
  71063. removed: Array<XRInputSource>;
  71064. added: Array<XRInputSource>;
  71065. }
  71066. interface XRInputSourceEvent extends Event {
  71067. readonly frame: XRFrame;
  71068. readonly inputSource: XRInputSource;
  71069. }
  71070. // Experimental(er) features
  71071. declare class XRRay {
  71072. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  71073. origin: DOMPointReadOnly;
  71074. direction: DOMPointReadOnly;
  71075. matrix: Float32Array;
  71076. }
  71077. declare enum XRHitTestTrackableType {
  71078. "point",
  71079. "plane"
  71080. }
  71081. interface XRHitResult {
  71082. hitMatrix: Float32Array;
  71083. }
  71084. interface XRTransientInputHitTestResult {
  71085. readonly inputSource: XRInputSource;
  71086. readonly results: Array<XRHitTestResult>;
  71087. }
  71088. interface XRHitTestResult {
  71089. getPose(baseSpace: XRSpace): XRPose | undefined;
  71090. }
  71091. interface XRHitTestSource {
  71092. cancel(): void;
  71093. }
  71094. interface XRTransientInputHitTestSource {
  71095. cancel(): void;
  71096. }
  71097. interface XRHitTestOptionsInit {
  71098. space: XRSpace;
  71099. entityTypes?: Array<XRHitTestTrackableType>;
  71100. offsetRay?: XRRay;
  71101. }
  71102. interface XRTransientInputHitTestOptionsInit {
  71103. profile: string;
  71104. entityTypes?: Array<XRHitTestTrackableType>;
  71105. offsetRay?: XRRay;
  71106. }
  71107. interface XRAnchor {
  71108. // remove?
  71109. id?: string;
  71110. anchorSpace: XRSpace;
  71111. lastChangedTime: number;
  71112. detach(): void;
  71113. }
  71114. interface XRPlane extends XRAnchorCreator {
  71115. orientation: "Horizontal" | "Vertical";
  71116. planeSpace: XRSpace;
  71117. polygon: Array<DOMPointReadOnly>;
  71118. lastChangedTime: number;
  71119. }
  71120. interface XRAnchorCreator {
  71121. // AR Anchors
  71122. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71123. }
  71124. /**
  71125. * @ignore
  71126. */
  71127. declare module BABYLON.GLTF2.Exporter {
  71128. }
  71129. /**
  71130. * @ignore
  71131. */
  71132. declare module BABYLON.GLTF1 {
  71133. }
  71134. declare module BABYLON.GUI {
  71135. /**
  71136. * Class used to specific a value and its associated unit
  71137. */
  71138. export class ValueAndUnit {
  71139. /** defines the unit to store */
  71140. unit: number;
  71141. /** defines a boolean indicating if the value can be negative */
  71142. negativeValueAllowed: boolean;
  71143. private _value;
  71144. private _originalUnit;
  71145. /**
  71146. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71147. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71148. */
  71149. ignoreAdaptiveScaling: boolean;
  71150. /**
  71151. * Creates a new ValueAndUnit
  71152. * @param value defines the value to store
  71153. * @param unit defines the unit to store
  71154. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71155. */
  71156. constructor(value: number,
  71157. /** defines the unit to store */
  71158. unit?: number,
  71159. /** defines a boolean indicating if the value can be negative */
  71160. negativeValueAllowed?: boolean);
  71161. /** Gets a boolean indicating if the value is a percentage */
  71162. get isPercentage(): boolean;
  71163. /** Gets a boolean indicating if the value is store as pixel */
  71164. get isPixel(): boolean;
  71165. /** Gets direct internal value */
  71166. get internalValue(): number;
  71167. /**
  71168. * Gets value as pixel
  71169. * @param host defines the root host
  71170. * @param refValue defines the reference value for percentages
  71171. * @returns the value as pixel
  71172. */
  71173. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71174. /**
  71175. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71176. * @param value defines the value to store
  71177. * @param unit defines the unit to store
  71178. * @returns the current ValueAndUnit
  71179. */
  71180. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71181. /**
  71182. * Gets the value accordingly to its unit
  71183. * @param host defines the root host
  71184. * @returns the value
  71185. */
  71186. getValue(host: AdvancedDynamicTexture): number;
  71187. /**
  71188. * Gets a string representation of the value
  71189. * @param host defines the root host
  71190. * @param decimals defines an optional number of decimals to display
  71191. * @returns a string
  71192. */
  71193. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71194. /**
  71195. * Store a value parsed from a string
  71196. * @param source defines the source string
  71197. * @returns true if the value was successfully parsed
  71198. */
  71199. fromString(source: string | number): boolean;
  71200. private static _Regex;
  71201. private static _UNITMODE_PERCENTAGE;
  71202. private static _UNITMODE_PIXEL;
  71203. /** UNITMODE_PERCENTAGE */
  71204. static get UNITMODE_PERCENTAGE(): number;
  71205. /** UNITMODE_PIXEL */
  71206. static get UNITMODE_PIXEL(): number;
  71207. }
  71208. }
  71209. declare module BABYLON.GUI {
  71210. /**
  71211. * Define a style used by control to automatically setup properties based on a template.
  71212. * Only support font related properties so far
  71213. */
  71214. export class Style implements BABYLON.IDisposable {
  71215. private _fontFamily;
  71216. private _fontStyle;
  71217. private _fontWeight;
  71218. /** @hidden */
  71219. _host: AdvancedDynamicTexture;
  71220. /** @hidden */
  71221. _fontSize: ValueAndUnit;
  71222. /**
  71223. * BABYLON.Observable raised when the style values are changed
  71224. */
  71225. onChangedObservable: BABYLON.Observable<Style>;
  71226. /**
  71227. * Creates a new style object
  71228. * @param host defines the AdvancedDynamicTexture which hosts this style
  71229. */
  71230. constructor(host: AdvancedDynamicTexture);
  71231. /**
  71232. * Gets or sets the font size
  71233. */
  71234. get fontSize(): string | number;
  71235. set fontSize(value: string | number);
  71236. /**
  71237. * Gets or sets the font family
  71238. */
  71239. get fontFamily(): string;
  71240. set fontFamily(value: string);
  71241. /**
  71242. * Gets or sets the font style
  71243. */
  71244. get fontStyle(): string;
  71245. set fontStyle(value: string);
  71246. /** Gets or sets font weight */
  71247. get fontWeight(): string;
  71248. set fontWeight(value: string);
  71249. /** Dispose all associated resources */
  71250. dispose(): void;
  71251. }
  71252. }
  71253. declare module BABYLON.GUI {
  71254. /**
  71255. * Class used to transport BABYLON.Vector2 information for pointer events
  71256. */
  71257. export class Vector2WithInfo extends BABYLON.Vector2 {
  71258. /** defines the current mouse button index */
  71259. buttonIndex: number;
  71260. /**
  71261. * Creates a new Vector2WithInfo
  71262. * @param source defines the vector2 data to transport
  71263. * @param buttonIndex defines the current mouse button index
  71264. */
  71265. constructor(source: BABYLON.Vector2,
  71266. /** defines the current mouse button index */
  71267. buttonIndex?: number);
  71268. }
  71269. /** Class used to provide 2D matrix features */
  71270. export class Matrix2D {
  71271. /** Gets the internal array of 6 floats used to store matrix data */
  71272. m: Float32Array;
  71273. /**
  71274. * Creates a new matrix
  71275. * @param m00 defines value for (0, 0)
  71276. * @param m01 defines value for (0, 1)
  71277. * @param m10 defines value for (1, 0)
  71278. * @param m11 defines value for (1, 1)
  71279. * @param m20 defines value for (2, 0)
  71280. * @param m21 defines value for (2, 1)
  71281. */
  71282. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71283. /**
  71284. * Fills the matrix from direct values
  71285. * @param m00 defines value for (0, 0)
  71286. * @param m01 defines value for (0, 1)
  71287. * @param m10 defines value for (1, 0)
  71288. * @param m11 defines value for (1, 1)
  71289. * @param m20 defines value for (2, 0)
  71290. * @param m21 defines value for (2, 1)
  71291. * @returns the current modified matrix
  71292. */
  71293. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71294. /**
  71295. * Gets matrix determinant
  71296. * @returns the determinant
  71297. */
  71298. determinant(): number;
  71299. /**
  71300. * Inverses the matrix and stores it in a target matrix
  71301. * @param result defines the target matrix
  71302. * @returns the current matrix
  71303. */
  71304. invertToRef(result: Matrix2D): Matrix2D;
  71305. /**
  71306. * Multiplies the current matrix with another one
  71307. * @param other defines the second operand
  71308. * @param result defines the target matrix
  71309. * @returns the current matrix
  71310. */
  71311. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71312. /**
  71313. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71314. * @param x defines the x coordinate to transform
  71315. * @param y defines the x coordinate to transform
  71316. * @param result defines the target vector2
  71317. * @returns the current matrix
  71318. */
  71319. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71320. /**
  71321. * Creates an identity matrix
  71322. * @returns a new matrix
  71323. */
  71324. static Identity(): Matrix2D;
  71325. /**
  71326. * Creates a translation matrix and stores it in a target matrix
  71327. * @param x defines the x coordinate of the translation
  71328. * @param y defines the y coordinate of the translation
  71329. * @param result defines the target matrix
  71330. */
  71331. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71332. /**
  71333. * Creates a scaling matrix and stores it in a target matrix
  71334. * @param x defines the x coordinate of the scaling
  71335. * @param y defines the y coordinate of the scaling
  71336. * @param result defines the target matrix
  71337. */
  71338. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71339. /**
  71340. * Creates a rotation matrix and stores it in a target matrix
  71341. * @param angle defines the rotation angle
  71342. * @param result defines the target matrix
  71343. */
  71344. static RotationToRef(angle: number, result: Matrix2D): void;
  71345. private static _TempPreTranslationMatrix;
  71346. private static _TempPostTranslationMatrix;
  71347. private static _TempRotationMatrix;
  71348. private static _TempScalingMatrix;
  71349. private static _TempCompose0;
  71350. private static _TempCompose1;
  71351. private static _TempCompose2;
  71352. /**
  71353. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71354. * @param tx defines the x coordinate of the translation
  71355. * @param ty defines the y coordinate of the translation
  71356. * @param angle defines the rotation angle
  71357. * @param scaleX defines the x coordinate of the scaling
  71358. * @param scaleY defines the y coordinate of the scaling
  71359. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71360. * @param result defines the target matrix
  71361. */
  71362. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71363. }
  71364. }
  71365. declare module BABYLON.GUI {
  71366. /**
  71367. * Class used to store 2D control sizes
  71368. */
  71369. export class Measure {
  71370. /** defines left coordinate */
  71371. left: number;
  71372. /** defines top coordinate */
  71373. top: number;
  71374. /** defines width dimension */
  71375. width: number;
  71376. /** defines height dimension */
  71377. height: number;
  71378. /**
  71379. * Creates a new measure
  71380. * @param left defines left coordinate
  71381. * @param top defines top coordinate
  71382. * @param width defines width dimension
  71383. * @param height defines height dimension
  71384. */
  71385. constructor(
  71386. /** defines left coordinate */
  71387. left: number,
  71388. /** defines top coordinate */
  71389. top: number,
  71390. /** defines width dimension */
  71391. width: number,
  71392. /** defines height dimension */
  71393. height: number);
  71394. /**
  71395. * Copy from another measure
  71396. * @param other defines the other measure to copy from
  71397. */
  71398. copyFrom(other: Measure): void;
  71399. /**
  71400. * Copy from a group of 4 floats
  71401. * @param left defines left coordinate
  71402. * @param top defines top coordinate
  71403. * @param width defines width dimension
  71404. * @param height defines height dimension
  71405. */
  71406. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71407. /**
  71408. * Computes the axis aligned bounding box measure for two given measures
  71409. * @param a Input measure
  71410. * @param b Input measure
  71411. * @param result the resulting bounding measure
  71412. */
  71413. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71414. /**
  71415. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71416. * @param transform the matrix to transform the measure before computing the AABB
  71417. * @param result the resulting AABB
  71418. */
  71419. transformToRef(transform: Matrix2D, result: Measure): void;
  71420. /**
  71421. * Check equality between this measure and another one
  71422. * @param other defines the other measures
  71423. * @returns true if both measures are equals
  71424. */
  71425. isEqualsTo(other: Measure): boolean;
  71426. /**
  71427. * Creates an empty measure
  71428. * @returns a new measure
  71429. */
  71430. static Empty(): Measure;
  71431. }
  71432. }
  71433. declare module BABYLON.GUI {
  71434. /**
  71435. * Interface used to define a control that can receive focus
  71436. */
  71437. export interface IFocusableControl {
  71438. /**
  71439. * Function called when the control receives the focus
  71440. */
  71441. onFocus(): void;
  71442. /**
  71443. * Function called when the control loses the focus
  71444. */
  71445. onBlur(): void;
  71446. /**
  71447. * Function called to let the control handle keyboard events
  71448. * @param evt defines the current keyboard event
  71449. */
  71450. processKeyboard(evt: KeyboardEvent): void;
  71451. /**
  71452. * Function called to get the list of controls that should not steal the focus from this control
  71453. * @returns an array of controls
  71454. */
  71455. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71456. }
  71457. /**
  71458. * Class used to create texture to support 2D GUI elements
  71459. * @see http://doc.babylonjs.com/how_to/gui
  71460. */
  71461. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71462. private _isDirty;
  71463. private _renderObserver;
  71464. private _resizeObserver;
  71465. private _preKeyboardObserver;
  71466. private _pointerMoveObserver;
  71467. private _pointerObserver;
  71468. private _canvasPointerOutObserver;
  71469. private _background;
  71470. /** @hidden */
  71471. _rootContainer: Container;
  71472. /** @hidden */
  71473. _lastPickedControl: Control;
  71474. /** @hidden */
  71475. _lastControlOver: {
  71476. [pointerId: number]: Control;
  71477. };
  71478. /** @hidden */
  71479. _lastControlDown: {
  71480. [pointerId: number]: Control;
  71481. };
  71482. /** @hidden */
  71483. _capturingControl: {
  71484. [pointerId: number]: Control;
  71485. };
  71486. /** @hidden */
  71487. _shouldBlockPointer: boolean;
  71488. /** @hidden */
  71489. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71490. /** @hidden */
  71491. _linkedControls: Control[];
  71492. private _isFullscreen;
  71493. private _fullscreenViewport;
  71494. private _idealWidth;
  71495. private _idealHeight;
  71496. private _useSmallestIdeal;
  71497. private _renderAtIdealSize;
  71498. private _focusedControl;
  71499. private _blockNextFocusCheck;
  71500. private _renderScale;
  71501. private _rootElement;
  71502. private _cursorChanged;
  71503. private _defaultMousePointerId;
  71504. /** @hidden */
  71505. _numLayoutCalls: number;
  71506. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71507. get numLayoutCalls(): number;
  71508. /** @hidden */
  71509. _numRenderCalls: number;
  71510. /** Gets the number of render calls made the last time the ADT has been rendered */
  71511. get numRenderCalls(): number;
  71512. /**
  71513. * Define type to string to ensure compatibility across browsers
  71514. * Safari doesn't support DataTransfer constructor
  71515. */
  71516. private _clipboardData;
  71517. /**
  71518. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71519. */
  71520. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71521. /**
  71522. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71523. */
  71524. onControlPickedObservable: BABYLON.Observable<Control>;
  71525. /**
  71526. * BABYLON.Observable event triggered before layout is evaluated
  71527. */
  71528. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71529. /**
  71530. * BABYLON.Observable event triggered after the layout was evaluated
  71531. */
  71532. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71533. /**
  71534. * BABYLON.Observable event triggered before the texture is rendered
  71535. */
  71536. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71537. /**
  71538. * BABYLON.Observable event triggered after the texture was rendered
  71539. */
  71540. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71541. /**
  71542. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71543. */
  71544. premulAlpha: boolean;
  71545. /**
  71546. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71547. * Useful when you want more antialiasing
  71548. */
  71549. get renderScale(): number;
  71550. set renderScale(value: number);
  71551. /** Gets or sets the background color */
  71552. get background(): string;
  71553. set background(value: string);
  71554. /**
  71555. * Gets or sets the ideal width used to design controls.
  71556. * The GUI will then rescale everything accordingly
  71557. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71558. */
  71559. get idealWidth(): number;
  71560. set idealWidth(value: number);
  71561. /**
  71562. * Gets or sets the ideal height used to design controls.
  71563. * The GUI will then rescale everything accordingly
  71564. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71565. */
  71566. get idealHeight(): number;
  71567. set idealHeight(value: number);
  71568. /**
  71569. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71570. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71571. */
  71572. get useSmallestIdeal(): boolean;
  71573. set useSmallestIdeal(value: boolean);
  71574. /**
  71575. * Gets or sets a boolean indicating if adaptive scaling must be used
  71576. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71577. */
  71578. get renderAtIdealSize(): boolean;
  71579. set renderAtIdealSize(value: boolean);
  71580. /**
  71581. * Gets the ratio used when in "ideal mode"
  71582. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71583. * */
  71584. get idealRatio(): number;
  71585. /**
  71586. * Gets the underlying layer used to render the texture when in fullscreen mode
  71587. */
  71588. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71589. /**
  71590. * Gets the root container control
  71591. */
  71592. get rootContainer(): Container;
  71593. /**
  71594. * Returns an array containing the root container.
  71595. * This is mostly used to let the Inspector introspects the ADT
  71596. * @returns an array containing the rootContainer
  71597. */
  71598. getChildren(): Array<Container>;
  71599. /**
  71600. * Will return all controls that are inside this texture
  71601. * @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
  71602. * @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
  71603. * @return all child controls
  71604. */
  71605. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71606. /**
  71607. * Gets or sets the current focused control
  71608. */
  71609. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71610. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71611. /**
  71612. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71613. */
  71614. get isForeground(): boolean;
  71615. set isForeground(value: boolean);
  71616. /**
  71617. * Gets or set information about clipboardData
  71618. */
  71619. get clipboardData(): string;
  71620. set clipboardData(value: string);
  71621. /**
  71622. * Creates a new AdvancedDynamicTexture
  71623. * @param name defines the name of the texture
  71624. * @param width defines the width of the texture
  71625. * @param height defines the height of the texture
  71626. * @param scene defines the hosting scene
  71627. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71628. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71629. */
  71630. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71631. /**
  71632. * Get the current class name of the texture useful for serialization or dynamic coding.
  71633. * @returns "AdvancedDynamicTexture"
  71634. */
  71635. getClassName(): string;
  71636. /**
  71637. * Function used to execute a function on all controls
  71638. * @param func defines the function to execute
  71639. * @param container defines the container where controls belong. If null the root container will be used
  71640. */
  71641. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71642. private _useInvalidateRectOptimization;
  71643. /**
  71644. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71645. */
  71646. get useInvalidateRectOptimization(): boolean;
  71647. set useInvalidateRectOptimization(value: boolean);
  71648. private _invalidatedRectangle;
  71649. /**
  71650. * Invalidates a rectangle area on the gui texture
  71651. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71652. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71653. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71654. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71655. */
  71656. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71657. /**
  71658. * Marks the texture as dirty forcing a complete update
  71659. */
  71660. markAsDirty(): void;
  71661. /**
  71662. * Helper function used to create a new style
  71663. * @returns a new style
  71664. * @see http://doc.babylonjs.com/how_to/gui#styles
  71665. */
  71666. createStyle(): Style;
  71667. /**
  71668. * Adds a new control to the root container
  71669. * @param control defines the control to add
  71670. * @returns the current texture
  71671. */
  71672. addControl(control: Control): AdvancedDynamicTexture;
  71673. /**
  71674. * Removes a control from the root container
  71675. * @param control defines the control to remove
  71676. * @returns the current texture
  71677. */
  71678. removeControl(control: Control): AdvancedDynamicTexture;
  71679. /**
  71680. * Release all resources
  71681. */
  71682. dispose(): void;
  71683. private _onResize;
  71684. /** @hidden */
  71685. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71686. /**
  71687. * Get screen coordinates for a vector3
  71688. * @param position defines the position to project
  71689. * @param worldMatrix defines the world matrix to use
  71690. * @returns the projected position
  71691. */
  71692. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71693. private _checkUpdate;
  71694. private _clearMeasure;
  71695. private _render;
  71696. /** @hidden */
  71697. _changeCursor(cursor: string): void;
  71698. /** @hidden */
  71699. _registerLastControlDown(control: Control, pointerId: number): void;
  71700. private _doPicking;
  71701. /** @hidden */
  71702. _cleanControlAfterRemovalFromList(list: {
  71703. [pointerId: number]: Control;
  71704. }, control: Control): void;
  71705. /** @hidden */
  71706. _cleanControlAfterRemoval(control: Control): void;
  71707. /** Attach to all scene events required to support pointer events */
  71708. attach(): void;
  71709. /** @hidden */
  71710. private onClipboardCopy;
  71711. /** @hidden */
  71712. private onClipboardCut;
  71713. /** @hidden */
  71714. private onClipboardPaste;
  71715. /**
  71716. * Register the clipboard Events onto the canvas
  71717. */
  71718. registerClipboardEvents(): void;
  71719. /**
  71720. * Unregister the clipboard Events from the canvas
  71721. */
  71722. unRegisterClipboardEvents(): void;
  71723. /**
  71724. * Connect the texture to a hosting mesh to enable interactions
  71725. * @param mesh defines the mesh to attach to
  71726. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71727. */
  71728. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71729. /**
  71730. * Move the focus to a specific control
  71731. * @param control defines the control which will receive the focus
  71732. */
  71733. moveFocusToControl(control: IFocusableControl): void;
  71734. private _manageFocus;
  71735. private _attachToOnPointerOut;
  71736. /**
  71737. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71738. * @param mesh defines the mesh which will receive the texture
  71739. * @param width defines the texture width (1024 by default)
  71740. * @param height defines the texture height (1024 by default)
  71741. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71742. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71743. * @returns a new AdvancedDynamicTexture
  71744. */
  71745. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71746. /**
  71747. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71748. * In this mode the texture will rely on a layer for its rendering.
  71749. * This allows it to be treated like any other layer.
  71750. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71751. * LayerMask is set through advancedTexture.layer.layerMask
  71752. * @param name defines name for the texture
  71753. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71754. * @param scene defines the hsoting scene
  71755. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71756. * @returns a new AdvancedDynamicTexture
  71757. */
  71758. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71759. }
  71760. }
  71761. declare module BABYLON.GUI {
  71762. /**
  71763. * Root class used for all 2D controls
  71764. * @see http://doc.babylonjs.com/how_to/gui#controls
  71765. */
  71766. export class Control {
  71767. /** defines the name of the control */
  71768. name?: string | undefined;
  71769. /**
  71770. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71771. */
  71772. static AllowAlphaInheritance: boolean;
  71773. private _alpha;
  71774. private _alphaSet;
  71775. private _zIndex;
  71776. /** @hidden */
  71777. _host: AdvancedDynamicTexture;
  71778. /** Gets or sets the control parent */
  71779. parent: BABYLON.Nullable<Container>;
  71780. /** @hidden */
  71781. _currentMeasure: Measure;
  71782. private _fontFamily;
  71783. private _fontStyle;
  71784. private _fontWeight;
  71785. private _fontSize;
  71786. private _font;
  71787. /** @hidden */
  71788. _width: ValueAndUnit;
  71789. /** @hidden */
  71790. _height: ValueAndUnit;
  71791. /** @hidden */
  71792. protected _fontOffset: {
  71793. ascent: number;
  71794. height: number;
  71795. descent: number;
  71796. };
  71797. private _color;
  71798. private _style;
  71799. private _styleObserver;
  71800. /** @hidden */
  71801. protected _horizontalAlignment: number;
  71802. /** @hidden */
  71803. protected _verticalAlignment: number;
  71804. /** @hidden */
  71805. protected _isDirty: boolean;
  71806. /** @hidden */
  71807. protected _wasDirty: boolean;
  71808. /** @hidden */
  71809. _tempParentMeasure: Measure;
  71810. /** @hidden */
  71811. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71812. /** @hidden */
  71813. protected _cachedParentMeasure: Measure;
  71814. private _paddingLeft;
  71815. private _paddingRight;
  71816. private _paddingTop;
  71817. private _paddingBottom;
  71818. /** @hidden */
  71819. _left: ValueAndUnit;
  71820. /** @hidden */
  71821. _top: ValueAndUnit;
  71822. private _scaleX;
  71823. private _scaleY;
  71824. private _rotation;
  71825. private _transformCenterX;
  71826. private _transformCenterY;
  71827. /** @hidden */
  71828. _transformMatrix: Matrix2D;
  71829. /** @hidden */
  71830. protected _invertTransformMatrix: Matrix2D;
  71831. /** @hidden */
  71832. protected _transformedPosition: BABYLON.Vector2;
  71833. private _isMatrixDirty;
  71834. private _cachedOffsetX;
  71835. private _cachedOffsetY;
  71836. private _isVisible;
  71837. private _isHighlighted;
  71838. /** @hidden */
  71839. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71840. private _fontSet;
  71841. private _dummyVector2;
  71842. private _downCount;
  71843. private _enterCount;
  71844. private _doNotRender;
  71845. private _downPointerIds;
  71846. protected _isEnabled: boolean;
  71847. protected _disabledColor: string;
  71848. protected _disabledColorItem: string;
  71849. /** @hidden */
  71850. protected _rebuildLayout: boolean;
  71851. /** @hidden */
  71852. _customData: any;
  71853. /** @hidden */
  71854. _isClipped: boolean;
  71855. /** @hidden */
  71856. _automaticSize: boolean;
  71857. /** @hidden */
  71858. _tag: any;
  71859. /**
  71860. * 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
  71861. */
  71862. uniqueId: number;
  71863. /**
  71864. * Gets or sets an object used to store user defined information for the node
  71865. */
  71866. metadata: any;
  71867. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71868. isHitTestVisible: boolean;
  71869. /** Gets or sets a boolean indicating if the control can block pointer events */
  71870. isPointerBlocker: boolean;
  71871. /** Gets or sets a boolean indicating if the control can be focusable */
  71872. isFocusInvisible: boolean;
  71873. /**
  71874. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71875. * 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
  71876. */
  71877. clipChildren: boolean;
  71878. /**
  71879. * Gets or sets a boolean indicating that control content must be clipped
  71880. * 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
  71881. */
  71882. clipContent: boolean;
  71883. /**
  71884. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71885. */
  71886. useBitmapCache: boolean;
  71887. private _cacheData;
  71888. private _shadowOffsetX;
  71889. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71890. get shadowOffsetX(): number;
  71891. set shadowOffsetX(value: number);
  71892. private _shadowOffsetY;
  71893. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71894. get shadowOffsetY(): number;
  71895. set shadowOffsetY(value: number);
  71896. private _shadowBlur;
  71897. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71898. get shadowBlur(): number;
  71899. set shadowBlur(value: number);
  71900. private _shadowColor;
  71901. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71902. get shadowColor(): string;
  71903. set shadowColor(value: string);
  71904. /** Gets or sets the cursor to use when the control is hovered */
  71905. hoverCursor: string;
  71906. /** @hidden */
  71907. protected _linkOffsetX: ValueAndUnit;
  71908. /** @hidden */
  71909. protected _linkOffsetY: ValueAndUnit;
  71910. /** Gets the control type name */
  71911. get typeName(): string;
  71912. /**
  71913. * Get the current class name of the control.
  71914. * @returns current class name
  71915. */
  71916. getClassName(): string;
  71917. /**
  71918. * An event triggered when pointer wheel is scrolled
  71919. */
  71920. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71921. /**
  71922. * An event triggered when the pointer move over the control.
  71923. */
  71924. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71925. /**
  71926. * An event triggered when the pointer move out of the control.
  71927. */
  71928. onPointerOutObservable: BABYLON.Observable<Control>;
  71929. /**
  71930. * An event triggered when the pointer taps the control
  71931. */
  71932. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71933. /**
  71934. * An event triggered when pointer up
  71935. */
  71936. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71937. /**
  71938. * An event triggered when a control is clicked on
  71939. */
  71940. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71941. /**
  71942. * An event triggered when pointer enters the control
  71943. */
  71944. onPointerEnterObservable: BABYLON.Observable<Control>;
  71945. /**
  71946. * An event triggered when the control is marked as dirty
  71947. */
  71948. onDirtyObservable: BABYLON.Observable<Control>;
  71949. /**
  71950. * An event triggered before drawing the control
  71951. */
  71952. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71953. /**
  71954. * An event triggered after the control was drawn
  71955. */
  71956. onAfterDrawObservable: BABYLON.Observable<Control>;
  71957. /**
  71958. * Get the hosting AdvancedDynamicTexture
  71959. */
  71960. get host(): AdvancedDynamicTexture;
  71961. /** Gets or set information about font offsets (used to render and align text) */
  71962. get fontOffset(): {
  71963. ascent: number;
  71964. height: number;
  71965. descent: number;
  71966. };
  71967. set fontOffset(offset: {
  71968. ascent: number;
  71969. height: number;
  71970. descent: number;
  71971. });
  71972. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71973. get alpha(): number;
  71974. set alpha(value: number);
  71975. /**
  71976. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71977. */
  71978. get isHighlighted(): boolean;
  71979. set isHighlighted(value: boolean);
  71980. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71981. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71982. */
  71983. get scaleX(): number;
  71984. set scaleX(value: number);
  71985. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71986. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71987. */
  71988. get scaleY(): number;
  71989. set scaleY(value: number);
  71990. /** Gets or sets the rotation angle (0 by default)
  71991. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71992. */
  71993. get rotation(): number;
  71994. set rotation(value: number);
  71995. /** Gets or sets the transformation center on Y axis (0 by default)
  71996. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71997. */
  71998. get transformCenterY(): number;
  71999. set transformCenterY(value: number);
  72000. /** Gets or sets the transformation center on X axis (0 by default)
  72001. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  72002. */
  72003. get transformCenterX(): number;
  72004. set transformCenterX(value: number);
  72005. /**
  72006. * Gets or sets the horizontal alignment
  72007. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72008. */
  72009. get horizontalAlignment(): number;
  72010. set horizontalAlignment(value: number);
  72011. /**
  72012. * Gets or sets the vertical alignment
  72013. * @see http://doc.babylonjs.com/how_to/gui#alignments
  72014. */
  72015. get verticalAlignment(): number;
  72016. set verticalAlignment(value: number);
  72017. /**
  72018. * Gets or sets control width
  72019. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72020. */
  72021. get width(): string | number;
  72022. set width(value: string | number);
  72023. /**
  72024. * Gets or sets the control width in pixel
  72025. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72026. */
  72027. get widthInPixels(): number;
  72028. set widthInPixels(value: number);
  72029. /**
  72030. * Gets or sets control height
  72031. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72032. */
  72033. get height(): string | number;
  72034. set height(value: string | number);
  72035. /**
  72036. * Gets or sets control height in pixel
  72037. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72038. */
  72039. get heightInPixels(): number;
  72040. set heightInPixels(value: number);
  72041. /** Gets or set font family */
  72042. get fontFamily(): string;
  72043. set fontFamily(value: string);
  72044. /** Gets or sets font style */
  72045. get fontStyle(): string;
  72046. set fontStyle(value: string);
  72047. /** Gets or sets font weight */
  72048. get fontWeight(): string;
  72049. set fontWeight(value: string);
  72050. /**
  72051. * Gets or sets style
  72052. * @see http://doc.babylonjs.com/how_to/gui#styles
  72053. */
  72054. get style(): BABYLON.Nullable<Style>;
  72055. set style(value: BABYLON.Nullable<Style>);
  72056. /** @hidden */
  72057. get _isFontSizeInPercentage(): boolean;
  72058. /** Gets or sets font size in pixels */
  72059. get fontSizeInPixels(): number;
  72060. set fontSizeInPixels(value: number);
  72061. /** Gets or sets font size */
  72062. get fontSize(): string | number;
  72063. set fontSize(value: string | number);
  72064. /** Gets or sets foreground color */
  72065. get color(): string;
  72066. set color(value: string);
  72067. /** Gets or sets z index which is used to reorder controls on the z axis */
  72068. get zIndex(): number;
  72069. set zIndex(value: number);
  72070. /** Gets or sets a boolean indicating if the control can be rendered */
  72071. get notRenderable(): boolean;
  72072. set notRenderable(value: boolean);
  72073. /** Gets or sets a boolean indicating if the control is visible */
  72074. get isVisible(): boolean;
  72075. set isVisible(value: boolean);
  72076. /** Gets a boolean indicating that the control needs to update its rendering */
  72077. get isDirty(): boolean;
  72078. /**
  72079. * Gets the current linked mesh (or null if none)
  72080. */
  72081. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72082. /**
  72083. * Gets or sets a value indicating the padding to use on the left of the control
  72084. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72085. */
  72086. get paddingLeft(): string | number;
  72087. set paddingLeft(value: string | number);
  72088. /**
  72089. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  72090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72091. */
  72092. get paddingLeftInPixels(): number;
  72093. set paddingLeftInPixels(value: number);
  72094. /**
  72095. * Gets or sets a value indicating the padding to use on the right of the control
  72096. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72097. */
  72098. get paddingRight(): string | number;
  72099. set paddingRight(value: string | number);
  72100. /**
  72101. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  72102. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72103. */
  72104. get paddingRightInPixels(): number;
  72105. set paddingRightInPixels(value: number);
  72106. /**
  72107. * Gets or sets a value indicating the padding to use on the top of the control
  72108. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72109. */
  72110. get paddingTop(): string | number;
  72111. set paddingTop(value: string | number);
  72112. /**
  72113. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  72114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72115. */
  72116. get paddingTopInPixels(): number;
  72117. set paddingTopInPixels(value: number);
  72118. /**
  72119. * Gets or sets a value indicating the padding to use on the bottom of the control
  72120. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72121. */
  72122. get paddingBottom(): string | number;
  72123. set paddingBottom(value: string | number);
  72124. /**
  72125. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72127. */
  72128. get paddingBottomInPixels(): number;
  72129. set paddingBottomInPixels(value: number);
  72130. /**
  72131. * Gets or sets a value indicating the left coordinate of the control
  72132. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72133. */
  72134. get left(): string | number;
  72135. set left(value: string | number);
  72136. /**
  72137. * Gets or sets a value indicating the left coordinate in pixels of the control
  72138. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72139. */
  72140. get leftInPixels(): number;
  72141. set leftInPixels(value: number);
  72142. /**
  72143. * Gets or sets a value indicating the top coordinate of the control
  72144. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72145. */
  72146. get top(): string | number;
  72147. set top(value: string | number);
  72148. /**
  72149. * Gets or sets a value indicating the top coordinate in pixels of the control
  72150. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72151. */
  72152. get topInPixels(): number;
  72153. set topInPixels(value: number);
  72154. /**
  72155. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72156. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72157. */
  72158. get linkOffsetX(): string | number;
  72159. set linkOffsetX(value: string | number);
  72160. /**
  72161. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72162. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72163. */
  72164. get linkOffsetXInPixels(): number;
  72165. set linkOffsetXInPixels(value: number);
  72166. /**
  72167. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72168. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72169. */
  72170. get linkOffsetY(): string | number;
  72171. set linkOffsetY(value: string | number);
  72172. /**
  72173. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72174. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72175. */
  72176. get linkOffsetYInPixels(): number;
  72177. set linkOffsetYInPixels(value: number);
  72178. /** Gets the center coordinate on X axis */
  72179. get centerX(): number;
  72180. /** Gets the center coordinate on Y axis */
  72181. get centerY(): number;
  72182. /** Gets or sets if control is Enabled*/
  72183. get isEnabled(): boolean;
  72184. set isEnabled(value: boolean);
  72185. /** Gets or sets background color of control if it's disabled*/
  72186. get disabledColor(): string;
  72187. set disabledColor(value: string);
  72188. /** Gets or sets front color of control if it's disabled*/
  72189. get disabledColorItem(): string;
  72190. set disabledColorItem(value: string);
  72191. /**
  72192. * Creates a new control
  72193. * @param name defines the name of the control
  72194. */
  72195. constructor(
  72196. /** defines the name of the control */
  72197. name?: string | undefined);
  72198. /** @hidden */
  72199. protected _getTypeName(): string;
  72200. /**
  72201. * Gets the first ascendant in the hierarchy of the given type
  72202. * @param className defines the required type
  72203. * @returns the ascendant or null if not found
  72204. */
  72205. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72206. /** @hidden */
  72207. _resetFontCache(): void;
  72208. /**
  72209. * Determines if a container is an ascendant of the current control
  72210. * @param container defines the container to look for
  72211. * @returns true if the container is one of the ascendant of the control
  72212. */
  72213. isAscendant(container: Control): boolean;
  72214. /**
  72215. * Gets coordinates in local control space
  72216. * @param globalCoordinates defines the coordinates to transform
  72217. * @returns the new coordinates in local space
  72218. */
  72219. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72220. /**
  72221. * Gets coordinates in local control space
  72222. * @param globalCoordinates defines the coordinates to transform
  72223. * @param result defines the target vector2 where to store the result
  72224. * @returns the current control
  72225. */
  72226. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72227. /**
  72228. * Gets coordinates in parent local control space
  72229. * @param globalCoordinates defines the coordinates to transform
  72230. * @returns the new coordinates in parent local space
  72231. */
  72232. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72233. /**
  72234. * Move the current control to a vector3 position projected onto the screen.
  72235. * @param position defines the target position
  72236. * @param scene defines the hosting scene
  72237. */
  72238. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72239. /**
  72240. * Will store all controls that have this control as ascendant in a given array
  72241. * @param results defines the array where to store the descendants
  72242. * @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
  72243. * @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
  72244. */
  72245. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72246. /**
  72247. * Will return all controls that have this control as ascendant
  72248. * @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
  72249. * @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
  72250. * @return all child controls
  72251. */
  72252. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72253. /**
  72254. * Link current control with a target mesh
  72255. * @param mesh defines the mesh to link with
  72256. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72257. */
  72258. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72259. /** @hidden */
  72260. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72261. /** @hidden */
  72262. _offsetLeft(offset: number): void;
  72263. /** @hidden */
  72264. _offsetTop(offset: number): void;
  72265. /** @hidden */
  72266. _markMatrixAsDirty(): void;
  72267. /** @hidden */
  72268. _flagDescendantsAsMatrixDirty(): void;
  72269. /** @hidden */
  72270. _intersectsRect(rect: Measure): boolean;
  72271. /** @hidden */
  72272. protected invalidateRect(): void;
  72273. /** @hidden */
  72274. _markAsDirty(force?: boolean): void;
  72275. /** @hidden */
  72276. _markAllAsDirty(): void;
  72277. /** @hidden */
  72278. _link(host: AdvancedDynamicTexture): void;
  72279. /** @hidden */
  72280. protected _transform(context?: CanvasRenderingContext2D): void;
  72281. /** @hidden */
  72282. _renderHighlight(context: CanvasRenderingContext2D): void;
  72283. /** @hidden */
  72284. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72285. /** @hidden */
  72286. protected _applyStates(context: CanvasRenderingContext2D): void;
  72287. /** @hidden */
  72288. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72289. /** @hidden */
  72290. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72291. protected _evaluateClippingState(parentMeasure: Measure): void;
  72292. /** @hidden */
  72293. _measure(): void;
  72294. /** @hidden */
  72295. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72296. /** @hidden */
  72297. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72298. /** @hidden */
  72299. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72300. /** @hidden */
  72301. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72302. private static _ClipMeasure;
  72303. private _tmpMeasureA;
  72304. private _clip;
  72305. /** @hidden */
  72306. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72307. /** @hidden */
  72308. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72309. /**
  72310. * Tests if a given coordinates belong to the current control
  72311. * @param x defines x coordinate to test
  72312. * @param y defines y coordinate to test
  72313. * @returns true if the coordinates are inside the control
  72314. */
  72315. contains(x: number, y: number): boolean;
  72316. /** @hidden */
  72317. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72318. /** @hidden */
  72319. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72320. /** @hidden */
  72321. _onPointerEnter(target: Control): boolean;
  72322. /** @hidden */
  72323. _onPointerOut(target: Control, force?: boolean): void;
  72324. /** @hidden */
  72325. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72326. /** @hidden */
  72327. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72328. /** @hidden */
  72329. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72330. /** @hidden */
  72331. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72332. /** @hidden */
  72333. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72334. private _prepareFont;
  72335. /** Releases associated resources */
  72336. dispose(): void;
  72337. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72338. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72339. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72340. private static _VERTICAL_ALIGNMENT_TOP;
  72341. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72342. private static _VERTICAL_ALIGNMENT_CENTER;
  72343. /** HORIZONTAL_ALIGNMENT_LEFT */
  72344. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72345. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72346. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72347. /** HORIZONTAL_ALIGNMENT_CENTER */
  72348. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72349. /** VERTICAL_ALIGNMENT_TOP */
  72350. static get VERTICAL_ALIGNMENT_TOP(): number;
  72351. /** VERTICAL_ALIGNMENT_BOTTOM */
  72352. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72353. /** VERTICAL_ALIGNMENT_CENTER */
  72354. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72355. private static _FontHeightSizes;
  72356. /** @hidden */
  72357. static _GetFontOffset(font: string): {
  72358. ascent: number;
  72359. height: number;
  72360. descent: number;
  72361. };
  72362. /**
  72363. * Creates a stack panel that can be used to render headers
  72364. * @param control defines the control to associate with the header
  72365. * @param text defines the text of the header
  72366. * @param size defines the size of the header
  72367. * @param options defines options used to configure the header
  72368. * @returns a new StackPanel
  72369. * @ignore
  72370. * @hidden
  72371. */
  72372. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72373. isHorizontal: boolean;
  72374. controlFirst: boolean;
  72375. }) => any;
  72376. /** @hidden */
  72377. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72378. }
  72379. }
  72380. declare module BABYLON.GUI {
  72381. /**
  72382. * Root class for 2D containers
  72383. * @see http://doc.babylonjs.com/how_to/gui#containers
  72384. */
  72385. export class Container extends Control {
  72386. name?: string | undefined;
  72387. /** @hidden */
  72388. _children: Control[];
  72389. /** @hidden */
  72390. protected _measureForChildren: Measure;
  72391. /** @hidden */
  72392. protected _background: string;
  72393. /** @hidden */
  72394. protected _adaptWidthToChildren: boolean;
  72395. /** @hidden */
  72396. protected _adaptHeightToChildren: boolean;
  72397. /**
  72398. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72399. */
  72400. logLayoutCycleErrors: boolean;
  72401. /**
  72402. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72403. */
  72404. maxLayoutCycle: number;
  72405. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72406. get adaptHeightToChildren(): boolean;
  72407. set adaptHeightToChildren(value: boolean);
  72408. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72409. get adaptWidthToChildren(): boolean;
  72410. set adaptWidthToChildren(value: boolean);
  72411. /** Gets or sets background color */
  72412. get background(): string;
  72413. set background(value: string);
  72414. /** Gets the list of children */
  72415. get children(): Control[];
  72416. /**
  72417. * Creates a new Container
  72418. * @param name defines the name of the container
  72419. */
  72420. constructor(name?: string | undefined);
  72421. protected _getTypeName(): string;
  72422. _flagDescendantsAsMatrixDirty(): void;
  72423. /**
  72424. * Gets a child using its name
  72425. * @param name defines the child name to look for
  72426. * @returns the child control if found
  72427. */
  72428. getChildByName(name: string): BABYLON.Nullable<Control>;
  72429. /**
  72430. * Gets a child using its type and its name
  72431. * @param name defines the child name to look for
  72432. * @param type defines the child type to look for
  72433. * @returns the child control if found
  72434. */
  72435. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72436. /**
  72437. * Search for a specific control in children
  72438. * @param control defines the control to look for
  72439. * @returns true if the control is in child list
  72440. */
  72441. containsControl(control: Control): boolean;
  72442. /**
  72443. * Adds a new control to the current container
  72444. * @param control defines the control to add
  72445. * @returns the current container
  72446. */
  72447. addControl(control: BABYLON.Nullable<Control>): Container;
  72448. /**
  72449. * Removes all controls from the current container
  72450. * @returns the current container
  72451. */
  72452. clearControls(): Container;
  72453. /**
  72454. * Removes a control from the current container
  72455. * @param control defines the control to remove
  72456. * @returns the current container
  72457. */
  72458. removeControl(control: Control): Container;
  72459. /** @hidden */
  72460. _reOrderControl(control: Control): void;
  72461. /** @hidden */
  72462. _offsetLeft(offset: number): void;
  72463. /** @hidden */
  72464. _offsetTop(offset: number): void;
  72465. /** @hidden */
  72466. _markAllAsDirty(): void;
  72467. /** @hidden */
  72468. protected _localDraw(context: CanvasRenderingContext2D): void;
  72469. /** @hidden */
  72470. _link(host: AdvancedDynamicTexture): void;
  72471. /** @hidden */
  72472. protected _beforeLayout(): void;
  72473. /** @hidden */
  72474. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72475. /** @hidden */
  72476. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72477. protected _postMeasure(): void;
  72478. /** @hidden */
  72479. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72480. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72481. /** @hidden */
  72482. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72483. /** @hidden */
  72484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72485. /** Releases associated resources */
  72486. dispose(): void;
  72487. }
  72488. }
  72489. declare module BABYLON.GUI {
  72490. /** Class used to create rectangle container */
  72491. export class Rectangle extends Container {
  72492. name?: string | undefined;
  72493. private _thickness;
  72494. private _cornerRadius;
  72495. /** Gets or sets border thickness */
  72496. get thickness(): number;
  72497. set thickness(value: number);
  72498. /** Gets or sets the corner radius angle */
  72499. get cornerRadius(): number;
  72500. set cornerRadius(value: number);
  72501. /**
  72502. * Creates a new Rectangle
  72503. * @param name defines the control name
  72504. */
  72505. constructor(name?: string | undefined);
  72506. protected _getTypeName(): string;
  72507. protected _localDraw(context: CanvasRenderingContext2D): void;
  72508. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72509. private _drawRoundedRect;
  72510. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72511. }
  72512. }
  72513. declare module BABYLON.GUI {
  72514. /**
  72515. * Enum that determines the text-wrapping mode to use.
  72516. */
  72517. export enum TextWrapping {
  72518. /**
  72519. * Clip the text when it's larger than Control.width; this is the default mode.
  72520. */
  72521. Clip = 0,
  72522. /**
  72523. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72524. */
  72525. WordWrap = 1,
  72526. /**
  72527. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72528. */
  72529. Ellipsis = 2
  72530. }
  72531. /**
  72532. * Class used to create text block control
  72533. */
  72534. export class TextBlock extends Control {
  72535. /**
  72536. * Defines the name of the control
  72537. */
  72538. name?: string | undefined;
  72539. private _text;
  72540. private _textWrapping;
  72541. private _textHorizontalAlignment;
  72542. private _textVerticalAlignment;
  72543. private _lines;
  72544. private _resizeToFit;
  72545. private _lineSpacing;
  72546. private _outlineWidth;
  72547. private _outlineColor;
  72548. /**
  72549. * An event triggered after the text is changed
  72550. */
  72551. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72552. /**
  72553. * An event triggered after the text was broken up into lines
  72554. */
  72555. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72556. /**
  72557. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72558. */
  72559. get lines(): any[];
  72560. /**
  72561. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72562. */
  72563. get resizeToFit(): boolean;
  72564. /**
  72565. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72566. */
  72567. set resizeToFit(value: boolean);
  72568. /**
  72569. * Gets or sets a boolean indicating if text must be wrapped
  72570. */
  72571. get textWrapping(): TextWrapping | boolean;
  72572. /**
  72573. * Gets or sets a boolean indicating if text must be wrapped
  72574. */
  72575. set textWrapping(value: TextWrapping | boolean);
  72576. /**
  72577. * Gets or sets text to display
  72578. */
  72579. get text(): string;
  72580. /**
  72581. * Gets or sets text to display
  72582. */
  72583. set text(value: string);
  72584. /**
  72585. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72586. */
  72587. get textHorizontalAlignment(): number;
  72588. /**
  72589. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72590. */
  72591. set textHorizontalAlignment(value: number);
  72592. /**
  72593. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72594. */
  72595. get textVerticalAlignment(): number;
  72596. /**
  72597. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72598. */
  72599. set textVerticalAlignment(value: number);
  72600. /**
  72601. * Gets or sets line spacing value
  72602. */
  72603. set lineSpacing(value: string | number);
  72604. /**
  72605. * Gets or sets line spacing value
  72606. */
  72607. get lineSpacing(): string | number;
  72608. /**
  72609. * Gets or sets outlineWidth of the text to display
  72610. */
  72611. get outlineWidth(): number;
  72612. /**
  72613. * Gets or sets outlineWidth of the text to display
  72614. */
  72615. set outlineWidth(value: number);
  72616. /**
  72617. * Gets or sets outlineColor of the text to display
  72618. */
  72619. get outlineColor(): string;
  72620. /**
  72621. * Gets or sets outlineColor of the text to display
  72622. */
  72623. set outlineColor(value: string);
  72624. /**
  72625. * Creates a new TextBlock object
  72626. * @param name defines the name of the control
  72627. * @param text defines the text to display (emptry string by default)
  72628. */
  72629. constructor(
  72630. /**
  72631. * Defines the name of the control
  72632. */
  72633. name?: string | undefined, text?: string);
  72634. protected _getTypeName(): string;
  72635. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72636. private _drawText;
  72637. /** @hidden */
  72638. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72639. protected _applyStates(context: CanvasRenderingContext2D): void;
  72640. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72641. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72642. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72643. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72644. protected _renderLines(context: CanvasRenderingContext2D): void;
  72645. /**
  72646. * Given a width constraint applied on the text block, find the expected height
  72647. * @returns expected height
  72648. */
  72649. computeExpectedHeight(): number;
  72650. dispose(): void;
  72651. }
  72652. }
  72653. declare module BABYLON.GUI {
  72654. /**
  72655. * Class used to create 2D images
  72656. */
  72657. export class Image extends Control {
  72658. name?: string | undefined;
  72659. private _workingCanvas;
  72660. private _domImage;
  72661. private _imageWidth;
  72662. private _imageHeight;
  72663. private _loaded;
  72664. private _stretch;
  72665. private _source;
  72666. private _autoScale;
  72667. private _sourceLeft;
  72668. private _sourceTop;
  72669. private _sourceWidth;
  72670. private _sourceHeight;
  72671. private _svgAttributesComputationCompleted;
  72672. private _isSVG;
  72673. private _cellWidth;
  72674. private _cellHeight;
  72675. private _cellId;
  72676. private _populateNinePatchSlicesFromImage;
  72677. private _sliceLeft;
  72678. private _sliceRight;
  72679. private _sliceTop;
  72680. private _sliceBottom;
  72681. private _detectPointerOnOpaqueOnly;
  72682. /**
  72683. * BABYLON.Observable notified when the content is loaded
  72684. */
  72685. onImageLoadedObservable: BABYLON.Observable<Image>;
  72686. /**
  72687. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72688. */
  72689. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72690. /**
  72691. * Gets a boolean indicating that the content is loaded
  72692. */
  72693. get isLoaded(): boolean;
  72694. /**
  72695. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72696. */
  72697. get populateNinePatchSlicesFromImage(): boolean;
  72698. set populateNinePatchSlicesFromImage(value: boolean);
  72699. /**
  72700. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72701. * Beware using this as this will comsume more memory as the image has to be stored twice
  72702. */
  72703. get detectPointerOnOpaqueOnly(): boolean;
  72704. set detectPointerOnOpaqueOnly(value: boolean);
  72705. /**
  72706. * Gets or sets the left value for slicing (9-patch)
  72707. */
  72708. get sliceLeft(): number;
  72709. set sliceLeft(value: number);
  72710. /**
  72711. * Gets or sets the right value for slicing (9-patch)
  72712. */
  72713. get sliceRight(): number;
  72714. set sliceRight(value: number);
  72715. /**
  72716. * Gets or sets the top value for slicing (9-patch)
  72717. */
  72718. get sliceTop(): number;
  72719. set sliceTop(value: number);
  72720. /**
  72721. * Gets or sets the bottom value for slicing (9-patch)
  72722. */
  72723. get sliceBottom(): number;
  72724. set sliceBottom(value: number);
  72725. /**
  72726. * Gets or sets the left coordinate in the source image
  72727. */
  72728. get sourceLeft(): number;
  72729. set sourceLeft(value: number);
  72730. /**
  72731. * Gets or sets the top coordinate in the source image
  72732. */
  72733. get sourceTop(): number;
  72734. set sourceTop(value: number);
  72735. /**
  72736. * Gets or sets the width to capture in the source image
  72737. */
  72738. get sourceWidth(): number;
  72739. set sourceWidth(value: number);
  72740. /**
  72741. * Gets or sets the height to capture in the source image
  72742. */
  72743. get sourceHeight(): number;
  72744. set sourceHeight(value: number);
  72745. /** Indicates if the format of the image is SVG */
  72746. get isSVG(): boolean;
  72747. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72748. get svgAttributesComputationCompleted(): boolean;
  72749. /**
  72750. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72751. * @see http://doc.babylonjs.com/how_to/gui#image
  72752. */
  72753. get autoScale(): boolean;
  72754. set autoScale(value: boolean);
  72755. /** Gets or sets the streching mode used by the image */
  72756. get stretch(): number;
  72757. set stretch(value: number);
  72758. /** @hidden */
  72759. _rotate90(n: number, preserveProperties?: boolean): Image;
  72760. private _handleRotationForSVGImage;
  72761. private _rotate90SourceProperties;
  72762. /**
  72763. * Gets or sets the internal DOM image used to render the control
  72764. */
  72765. set domImage(value: HTMLImageElement);
  72766. get domImage(): HTMLImageElement;
  72767. private _onImageLoaded;
  72768. private _extractNinePatchSliceDataFromImage;
  72769. /**
  72770. * Gets or sets image source url
  72771. */
  72772. set source(value: BABYLON.Nullable<string>);
  72773. /**
  72774. * Checks for svg document with icon id present
  72775. */
  72776. private _svgCheck;
  72777. /**
  72778. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72779. * given external svg file and icon id
  72780. */
  72781. private _getSVGAttribs;
  72782. /**
  72783. * Gets or sets the cell width to use when animation sheet is enabled
  72784. * @see http://doc.babylonjs.com/how_to/gui#image
  72785. */
  72786. get cellWidth(): number;
  72787. set cellWidth(value: number);
  72788. /**
  72789. * Gets or sets the cell height to use when animation sheet is enabled
  72790. * @see http://doc.babylonjs.com/how_to/gui#image
  72791. */
  72792. get cellHeight(): number;
  72793. set cellHeight(value: number);
  72794. /**
  72795. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72796. * @see http://doc.babylonjs.com/how_to/gui#image
  72797. */
  72798. get cellId(): number;
  72799. set cellId(value: number);
  72800. /**
  72801. * Creates a new Image
  72802. * @param name defines the control name
  72803. * @param url defines the image url
  72804. */
  72805. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72806. /**
  72807. * Tests if a given coordinates belong to the current control
  72808. * @param x defines x coordinate to test
  72809. * @param y defines y coordinate to test
  72810. * @returns true if the coordinates are inside the control
  72811. */
  72812. contains(x: number, y: number): boolean;
  72813. protected _getTypeName(): string;
  72814. /** Force the control to synchronize with its content */
  72815. synchronizeSizeWithContent(): void;
  72816. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72817. private _prepareWorkingCanvasForOpaqueDetection;
  72818. private _drawImage;
  72819. _draw(context: CanvasRenderingContext2D): void;
  72820. private _renderCornerPatch;
  72821. private _renderNinePatch;
  72822. dispose(): void;
  72823. /** STRETCH_NONE */
  72824. static readonly STRETCH_NONE: number;
  72825. /** STRETCH_FILL */
  72826. static readonly STRETCH_FILL: number;
  72827. /** STRETCH_UNIFORM */
  72828. static readonly STRETCH_UNIFORM: number;
  72829. /** STRETCH_EXTEND */
  72830. static readonly STRETCH_EXTEND: number;
  72831. /** NINE_PATCH */
  72832. static readonly STRETCH_NINE_PATCH: number;
  72833. }
  72834. }
  72835. declare module BABYLON.GUI {
  72836. /**
  72837. * Class used to create 2D buttons
  72838. */
  72839. export class Button extends Rectangle {
  72840. name?: string | undefined;
  72841. /**
  72842. * Function called to generate a pointer enter animation
  72843. */
  72844. pointerEnterAnimation: () => void;
  72845. /**
  72846. * Function called to generate a pointer out animation
  72847. */
  72848. pointerOutAnimation: () => void;
  72849. /**
  72850. * Function called to generate a pointer down animation
  72851. */
  72852. pointerDownAnimation: () => void;
  72853. /**
  72854. * Function called to generate a pointer up animation
  72855. */
  72856. pointerUpAnimation: () => void;
  72857. /**
  72858. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72859. */
  72860. delegatePickingToChildren: boolean;
  72861. private _image;
  72862. /**
  72863. * Returns the image part of the button (if any)
  72864. */
  72865. get image(): BABYLON.Nullable<Image>;
  72866. private _textBlock;
  72867. /**
  72868. * Returns the image part of the button (if any)
  72869. */
  72870. get textBlock(): BABYLON.Nullable<TextBlock>;
  72871. /**
  72872. * Creates a new Button
  72873. * @param name defines the name of the button
  72874. */
  72875. constructor(name?: string | undefined);
  72876. protected _getTypeName(): string;
  72877. /** @hidden */
  72878. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72879. /** @hidden */
  72880. _onPointerEnter(target: Control): boolean;
  72881. /** @hidden */
  72882. _onPointerOut(target: Control, force?: boolean): void;
  72883. /** @hidden */
  72884. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72885. /** @hidden */
  72886. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72887. /**
  72888. * Creates a new button made with an image and a text
  72889. * @param name defines the name of the button
  72890. * @param text defines the text of the button
  72891. * @param imageUrl defines the url of the image
  72892. * @returns a new Button
  72893. */
  72894. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72895. /**
  72896. * Creates a new button made with an image
  72897. * @param name defines the name of the button
  72898. * @param imageUrl defines the url of the image
  72899. * @returns a new Button
  72900. */
  72901. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72902. /**
  72903. * Creates a new button made with a text
  72904. * @param name defines the name of the button
  72905. * @param text defines the text of the button
  72906. * @returns a new Button
  72907. */
  72908. static CreateSimpleButton(name: string, text: string): Button;
  72909. /**
  72910. * Creates a new button made with an image and a centered text
  72911. * @param name defines the name of the button
  72912. * @param text defines the text of the button
  72913. * @param imageUrl defines the url of the image
  72914. * @returns a new Button
  72915. */
  72916. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72917. }
  72918. }
  72919. declare module BABYLON.GUI {
  72920. /**
  72921. * Class used to create a 2D stack panel container
  72922. */
  72923. export class StackPanel extends Container {
  72924. name?: string | undefined;
  72925. private _isVertical;
  72926. private _manualWidth;
  72927. private _manualHeight;
  72928. private _doNotTrackManualChanges;
  72929. /**
  72930. * Gets or sets a boolean indicating that layou warnings should be ignored
  72931. */
  72932. ignoreLayoutWarnings: boolean;
  72933. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72934. get isVertical(): boolean;
  72935. set isVertical(value: boolean);
  72936. /**
  72937. * Gets or sets panel width.
  72938. * This value should not be set when in horizontal mode as it will be computed automatically
  72939. */
  72940. set width(value: string | number);
  72941. get width(): string | number;
  72942. /**
  72943. * Gets or sets panel height.
  72944. * This value should not be set when in vertical mode as it will be computed automatically
  72945. */
  72946. set height(value: string | number);
  72947. get height(): string | number;
  72948. /**
  72949. * Creates a new StackPanel
  72950. * @param name defines control name
  72951. */
  72952. constructor(name?: string | undefined);
  72953. protected _getTypeName(): string;
  72954. /** @hidden */
  72955. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72956. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72957. protected _postMeasure(): void;
  72958. }
  72959. }
  72960. declare module BABYLON.GUI {
  72961. /**
  72962. * Class used to represent a 2D checkbox
  72963. */
  72964. export class Checkbox extends Control {
  72965. name?: string | undefined;
  72966. private _isChecked;
  72967. private _background;
  72968. private _checkSizeRatio;
  72969. private _thickness;
  72970. /** Gets or sets border thickness */
  72971. get thickness(): number;
  72972. set thickness(value: number);
  72973. /**
  72974. * BABYLON.Observable raised when isChecked property changes
  72975. */
  72976. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72977. /** Gets or sets a value indicating the ratio between overall size and check size */
  72978. get checkSizeRatio(): number;
  72979. set checkSizeRatio(value: number);
  72980. /** Gets or sets background color */
  72981. get background(): string;
  72982. set background(value: string);
  72983. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72984. get isChecked(): boolean;
  72985. set isChecked(value: boolean);
  72986. /**
  72987. * Creates a new CheckBox
  72988. * @param name defines the control name
  72989. */
  72990. constructor(name?: string | undefined);
  72991. protected _getTypeName(): string;
  72992. /** @hidden */
  72993. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72994. /** @hidden */
  72995. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72996. /**
  72997. * Utility function to easily create a checkbox with a header
  72998. * @param title defines the label to use for the header
  72999. * @param onValueChanged defines the callback to call when value changes
  73000. * @returns a StackPanel containing the checkbox and a textBlock
  73001. */
  73002. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  73003. }
  73004. }
  73005. declare module BABYLON.GUI {
  73006. /**
  73007. * Class used to store key control properties
  73008. */
  73009. export class KeyPropertySet {
  73010. /** Width */
  73011. width?: string;
  73012. /** Height */
  73013. height?: string;
  73014. /** Left padding */
  73015. paddingLeft?: string;
  73016. /** Right padding */
  73017. paddingRight?: string;
  73018. /** Top padding */
  73019. paddingTop?: string;
  73020. /** Bottom padding */
  73021. paddingBottom?: string;
  73022. /** Foreground color */
  73023. color?: string;
  73024. /** Background color */
  73025. background?: string;
  73026. }
  73027. /**
  73028. * Class used to create virtual keyboard
  73029. */
  73030. export class VirtualKeyboard extends StackPanel {
  73031. /** BABYLON.Observable raised when a key is pressed */
  73032. onKeyPressObservable: BABYLON.Observable<string>;
  73033. /** Gets or sets default key button width */
  73034. defaultButtonWidth: string;
  73035. /** Gets or sets default key button height */
  73036. defaultButtonHeight: string;
  73037. /** Gets or sets default key button left padding */
  73038. defaultButtonPaddingLeft: string;
  73039. /** Gets or sets default key button right padding */
  73040. defaultButtonPaddingRight: string;
  73041. /** Gets or sets default key button top padding */
  73042. defaultButtonPaddingTop: string;
  73043. /** Gets or sets default key button bottom padding */
  73044. defaultButtonPaddingBottom: string;
  73045. /** Gets or sets default key button foreground color */
  73046. defaultButtonColor: string;
  73047. /** Gets or sets default key button background color */
  73048. defaultButtonBackground: string;
  73049. /** Gets or sets shift button foreground color */
  73050. shiftButtonColor: string;
  73051. /** Gets or sets shift button thickness*/
  73052. selectedShiftThickness: number;
  73053. /** Gets shift key state */
  73054. shiftState: number;
  73055. protected _getTypeName(): string;
  73056. private _createKey;
  73057. /**
  73058. * Adds a new row of keys
  73059. * @param keys defines the list of keys to add
  73060. * @param propertySets defines the associated property sets
  73061. */
  73062. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  73063. /**
  73064. * Set the shift key to a specific state
  73065. * @param shiftState defines the new shift state
  73066. */
  73067. applyShiftState(shiftState: number): void;
  73068. private _currentlyConnectedInputText;
  73069. private _connectedInputTexts;
  73070. private _onKeyPressObserver;
  73071. /** Gets the input text control currently attached to the keyboard */
  73072. get connectedInputText(): BABYLON.Nullable<InputText>;
  73073. /**
  73074. * Connects the keyboard with an input text control
  73075. *
  73076. * @param input defines the target control
  73077. */
  73078. connect(input: InputText): void;
  73079. /**
  73080. * Disconnects the keyboard from connected InputText controls
  73081. *
  73082. * @param input optionally defines a target control, otherwise all are disconnected
  73083. */
  73084. disconnect(input?: InputText): void;
  73085. private _removeConnectedInputObservables;
  73086. /**
  73087. * Release all resources
  73088. */
  73089. dispose(): void;
  73090. /**
  73091. * Creates a new keyboard using a default layout
  73092. *
  73093. * @param name defines control name
  73094. * @returns a new VirtualKeyboard
  73095. */
  73096. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  73097. }
  73098. }
  73099. declare module BABYLON.GUI {
  73100. /**
  73101. * Class used to create input text control
  73102. */
  73103. export class InputText extends Control implements IFocusableControl {
  73104. name?: string | undefined;
  73105. private _text;
  73106. private _placeholderText;
  73107. private _background;
  73108. private _focusedBackground;
  73109. private _focusedColor;
  73110. private _placeholderColor;
  73111. private _thickness;
  73112. private _margin;
  73113. private _autoStretchWidth;
  73114. private _maxWidth;
  73115. private _isFocused;
  73116. private _blinkTimeout;
  73117. private _blinkIsEven;
  73118. private _cursorOffset;
  73119. private _scrollLeft;
  73120. private _textWidth;
  73121. private _clickedCoordinate;
  73122. private _deadKey;
  73123. private _addKey;
  73124. private _currentKey;
  73125. private _isTextHighlightOn;
  73126. private _textHighlightColor;
  73127. private _highligherOpacity;
  73128. private _highlightedText;
  73129. private _startHighlightIndex;
  73130. private _endHighlightIndex;
  73131. private _cursorIndex;
  73132. private _onFocusSelectAll;
  73133. private _isPointerDown;
  73134. private _onClipboardObserver;
  73135. private _onPointerDblTapObserver;
  73136. /** @hidden */
  73137. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73138. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73139. promptMessage: string;
  73140. /** Force disable prompt on mobile device */
  73141. disableMobilePrompt: boolean;
  73142. /** BABYLON.Observable raised when the text changes */
  73143. onTextChangedObservable: BABYLON.Observable<InputText>;
  73144. /** BABYLON.Observable raised just before an entered character is to be added */
  73145. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73146. /** BABYLON.Observable raised when the control gets the focus */
  73147. onFocusObservable: BABYLON.Observable<InputText>;
  73148. /** BABYLON.Observable raised when the control loses the focus */
  73149. onBlurObservable: BABYLON.Observable<InputText>;
  73150. /**Observable raised when the text is highlighted */
  73151. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73152. /**Observable raised when copy event is triggered */
  73153. onTextCopyObservable: BABYLON.Observable<InputText>;
  73154. /** BABYLON.Observable raised when cut event is triggered */
  73155. onTextCutObservable: BABYLON.Observable<InputText>;
  73156. /** BABYLON.Observable raised when paste event is triggered */
  73157. onTextPasteObservable: BABYLON.Observable<InputText>;
  73158. /** BABYLON.Observable raised when a key event was processed */
  73159. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73160. /** Gets or sets the maximum width allowed by the control */
  73161. get maxWidth(): string | number;
  73162. /** Gets the maximum width allowed by the control in pixels */
  73163. get maxWidthInPixels(): number;
  73164. set maxWidth(value: string | number);
  73165. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73166. get highligherOpacity(): number;
  73167. set highligherOpacity(value: number);
  73168. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73169. get onFocusSelectAll(): boolean;
  73170. set onFocusSelectAll(value: boolean);
  73171. /** Gets or sets the text hightlight color */
  73172. get textHighlightColor(): string;
  73173. set textHighlightColor(value: string);
  73174. /** Gets or sets control margin */
  73175. get margin(): string;
  73176. /** Gets control margin in pixels */
  73177. get marginInPixels(): number;
  73178. set margin(value: string);
  73179. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73180. get autoStretchWidth(): boolean;
  73181. set autoStretchWidth(value: boolean);
  73182. /** Gets or sets border thickness */
  73183. get thickness(): number;
  73184. set thickness(value: number);
  73185. /** Gets or sets the background color when focused */
  73186. get focusedBackground(): string;
  73187. set focusedBackground(value: string);
  73188. /** Gets or sets the background color when focused */
  73189. get focusedColor(): string;
  73190. set focusedColor(value: string);
  73191. /** Gets or sets the background color */
  73192. get background(): string;
  73193. set background(value: string);
  73194. /** Gets or sets the placeholder color */
  73195. get placeholderColor(): string;
  73196. set placeholderColor(value: string);
  73197. /** Gets or sets the text displayed when the control is empty */
  73198. get placeholderText(): string;
  73199. set placeholderText(value: string);
  73200. /** Gets or sets the dead key flag */
  73201. get deadKey(): boolean;
  73202. set deadKey(flag: boolean);
  73203. /** Gets or sets the highlight text */
  73204. get highlightedText(): string;
  73205. set highlightedText(text: string);
  73206. /** Gets or sets if the current key should be added */
  73207. get addKey(): boolean;
  73208. set addKey(flag: boolean);
  73209. /** Gets or sets the value of the current key being entered */
  73210. get currentKey(): string;
  73211. set currentKey(key: string);
  73212. /** Gets or sets the text displayed in the control */
  73213. get text(): string;
  73214. set text(value: string);
  73215. /** Gets or sets control width */
  73216. get width(): string | number;
  73217. set width(value: string | number);
  73218. /**
  73219. * Creates a new InputText
  73220. * @param name defines the control name
  73221. * @param text defines the text of the control
  73222. */
  73223. constructor(name?: string | undefined, text?: string);
  73224. /** @hidden */
  73225. onBlur(): void;
  73226. /** @hidden */
  73227. onFocus(): void;
  73228. protected _getTypeName(): string;
  73229. /**
  73230. * Function called to get the list of controls that should not steal the focus from this control
  73231. * @returns an array of controls
  73232. */
  73233. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73234. /** @hidden */
  73235. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73236. /** @hidden */
  73237. private _updateValueFromCursorIndex;
  73238. /** @hidden */
  73239. private _processDblClick;
  73240. /** @hidden */
  73241. private _selectAllText;
  73242. /**
  73243. * Handles the keyboard event
  73244. * @param evt Defines the KeyboardEvent
  73245. */
  73246. processKeyboard(evt: KeyboardEvent): void;
  73247. /** @hidden */
  73248. private _onCopyText;
  73249. /** @hidden */
  73250. private _onCutText;
  73251. /** @hidden */
  73252. private _onPasteText;
  73253. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73254. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73255. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73256. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73257. protected _beforeRenderText(text: string): string;
  73258. dispose(): void;
  73259. }
  73260. }
  73261. declare module BABYLON.GUI {
  73262. /**
  73263. * Class used to create a 2D grid container
  73264. */
  73265. export class Grid extends Container {
  73266. name?: string | undefined;
  73267. private _rowDefinitions;
  73268. private _columnDefinitions;
  73269. private _cells;
  73270. private _childControls;
  73271. /**
  73272. * Gets the number of columns
  73273. */
  73274. get columnCount(): number;
  73275. /**
  73276. * Gets the number of rows
  73277. */
  73278. get rowCount(): number;
  73279. /** Gets the list of children */
  73280. get children(): Control[];
  73281. /** Gets the list of cells (e.g. the containers) */
  73282. get cells(): {
  73283. [key: string]: Container;
  73284. };
  73285. /**
  73286. * Gets the definition of a specific row
  73287. * @param index defines the index of the row
  73288. * @returns the row definition
  73289. */
  73290. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73291. /**
  73292. * Gets the definition of a specific column
  73293. * @param index defines the index of the column
  73294. * @returns the column definition
  73295. */
  73296. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73297. /**
  73298. * Adds a new row to the grid
  73299. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73300. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73301. * @returns the current grid
  73302. */
  73303. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73304. /**
  73305. * Adds a new column to the grid
  73306. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73307. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73308. * @returns the current grid
  73309. */
  73310. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73311. /**
  73312. * Update a row definition
  73313. * @param index defines the index of the row to update
  73314. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73315. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73316. * @returns the current grid
  73317. */
  73318. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73319. /**
  73320. * Update a column definition
  73321. * @param index defines the index of the column to update
  73322. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73323. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73324. * @returns the current grid
  73325. */
  73326. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73327. /**
  73328. * Gets the list of children stored in a specific cell
  73329. * @param row defines the row to check
  73330. * @param column defines the column to check
  73331. * @returns the list of controls
  73332. */
  73333. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73334. /**
  73335. * Gets a string representing the child cell info (row x column)
  73336. * @param child defines the control to get info from
  73337. * @returns a string containing the child cell info (row x column)
  73338. */
  73339. getChildCellInfo(child: Control): string;
  73340. private _removeCell;
  73341. private _offsetCell;
  73342. /**
  73343. * Remove a column definition at specified index
  73344. * @param index defines the index of the column to remove
  73345. * @returns the current grid
  73346. */
  73347. removeColumnDefinition(index: number): Grid;
  73348. /**
  73349. * Remove a row definition at specified index
  73350. * @param index defines the index of the row to remove
  73351. * @returns the current grid
  73352. */
  73353. removeRowDefinition(index: number): Grid;
  73354. /**
  73355. * Adds a new control to the current grid
  73356. * @param control defines the control to add
  73357. * @param row defines the row where to add the control (0 by default)
  73358. * @param column defines the column where to add the control (0 by default)
  73359. * @returns the current grid
  73360. */
  73361. addControl(control: Control, row?: number, column?: number): Grid;
  73362. /**
  73363. * Removes a control from the current container
  73364. * @param control defines the control to remove
  73365. * @returns the current container
  73366. */
  73367. removeControl(control: Control): Container;
  73368. /**
  73369. * Creates a new Grid
  73370. * @param name defines control name
  73371. */
  73372. constructor(name?: string | undefined);
  73373. protected _getTypeName(): string;
  73374. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73375. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73376. _flagDescendantsAsMatrixDirty(): void;
  73377. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73378. /** Releases associated resources */
  73379. dispose(): void;
  73380. }
  73381. }
  73382. declare module BABYLON.GUI {
  73383. /** Class used to create color pickers */
  73384. export class ColorPicker extends Control {
  73385. name?: string | undefined;
  73386. private static _Epsilon;
  73387. private _colorWheelCanvas;
  73388. private _value;
  73389. private _tmpColor;
  73390. private _pointerStartedOnSquare;
  73391. private _pointerStartedOnWheel;
  73392. private _squareLeft;
  73393. private _squareTop;
  73394. private _squareSize;
  73395. private _h;
  73396. private _s;
  73397. private _v;
  73398. private _lastPointerDownID;
  73399. /**
  73400. * BABYLON.Observable raised when the value changes
  73401. */
  73402. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73403. /** Gets or sets the color of the color picker */
  73404. get value(): BABYLON.Color3;
  73405. set value(value: BABYLON.Color3);
  73406. /**
  73407. * Gets or sets control width
  73408. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73409. */
  73410. get width(): string | number;
  73411. set width(value: string | number);
  73412. /**
  73413. * Gets or sets control height
  73414. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73415. */
  73416. get height(): string | number;
  73417. /** Gets or sets control height */
  73418. set height(value: string | number);
  73419. /** Gets or sets control size */
  73420. get size(): string | number;
  73421. set size(value: string | number);
  73422. /**
  73423. * Creates a new ColorPicker
  73424. * @param name defines the control name
  73425. */
  73426. constructor(name?: string | undefined);
  73427. protected _getTypeName(): string;
  73428. /** @hidden */
  73429. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73430. private _updateSquareProps;
  73431. private _drawGradientSquare;
  73432. private _drawCircle;
  73433. private _createColorWheelCanvas;
  73434. /** @hidden */
  73435. _draw(context: CanvasRenderingContext2D): void;
  73436. private _pointerIsDown;
  73437. private _updateValueFromPointer;
  73438. private _isPointOnSquare;
  73439. private _isPointOnWheel;
  73440. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73441. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73442. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73443. /**
  73444. * This function expands the color picker by creating a color picker dialog with manual
  73445. * color value input and the ability to save colors into an array to be used later in
  73446. * subsequent launches of the dialogue.
  73447. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73448. * @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.
  73449. * @returns picked color as a hex string and the saved colors array as hex strings.
  73450. */
  73451. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73452. pickerWidth?: string;
  73453. pickerHeight?: string;
  73454. headerHeight?: string;
  73455. lastColor?: string;
  73456. swatchLimit?: number;
  73457. numSwatchesPerLine?: number;
  73458. savedColors?: Array<string>;
  73459. }): Promise<{
  73460. savedColors?: string[];
  73461. pickedColor: string;
  73462. }>;
  73463. }
  73464. }
  73465. declare module BABYLON.GUI {
  73466. /** Class used to create 2D ellipse containers */
  73467. export class Ellipse extends Container {
  73468. name?: string | undefined;
  73469. private _thickness;
  73470. /** Gets or sets border thickness */
  73471. get thickness(): number;
  73472. set thickness(value: number);
  73473. /**
  73474. * Creates a new Ellipse
  73475. * @param name defines the control name
  73476. */
  73477. constructor(name?: string | undefined);
  73478. protected _getTypeName(): string;
  73479. protected _localDraw(context: CanvasRenderingContext2D): void;
  73480. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73481. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73482. }
  73483. }
  73484. declare module BABYLON.GUI {
  73485. /**
  73486. * Class used to create a password control
  73487. */
  73488. export class InputPassword extends InputText {
  73489. protected _beforeRenderText(text: string): string;
  73490. }
  73491. }
  73492. declare module BABYLON.GUI {
  73493. /** Class used to render 2D lines */
  73494. export class Line extends Control {
  73495. name?: string | undefined;
  73496. private _lineWidth;
  73497. private _x1;
  73498. private _y1;
  73499. private _x2;
  73500. private _y2;
  73501. private _dash;
  73502. private _connectedControl;
  73503. private _connectedControlDirtyObserver;
  73504. /** Gets or sets the dash pattern */
  73505. get dash(): Array<number>;
  73506. set dash(value: Array<number>);
  73507. /** Gets or sets the control connected with the line end */
  73508. get connectedControl(): Control;
  73509. set connectedControl(value: Control);
  73510. /** Gets or sets start coordinates on X axis */
  73511. get x1(): string | number;
  73512. set x1(value: string | number);
  73513. /** Gets or sets start coordinates on Y axis */
  73514. get y1(): string | number;
  73515. set y1(value: string | number);
  73516. /** Gets or sets end coordinates on X axis */
  73517. get x2(): string | number;
  73518. set x2(value: string | number);
  73519. /** Gets or sets end coordinates on Y axis */
  73520. get y2(): string | number;
  73521. set y2(value: string | number);
  73522. /** Gets or sets line width */
  73523. get lineWidth(): number;
  73524. set lineWidth(value: number);
  73525. /** Gets or sets horizontal alignment */
  73526. set horizontalAlignment(value: number);
  73527. /** Gets or sets vertical alignment */
  73528. set verticalAlignment(value: number);
  73529. private get _effectiveX2();
  73530. private get _effectiveY2();
  73531. /**
  73532. * Creates a new Line
  73533. * @param name defines the control name
  73534. */
  73535. constructor(name?: string | undefined);
  73536. protected _getTypeName(): string;
  73537. _draw(context: CanvasRenderingContext2D): void;
  73538. _measure(): void;
  73539. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73540. /**
  73541. * Move one end of the line given 3D cartesian coordinates.
  73542. * @param position Targeted world position
  73543. * @param scene BABYLON.Scene
  73544. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73545. */
  73546. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73547. /**
  73548. * Move one end of the line to a position in screen absolute space.
  73549. * @param projectedPosition Position in screen absolute space (X, Y)
  73550. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73551. */
  73552. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73553. }
  73554. }
  73555. declare module BABYLON.GUI {
  73556. /**
  73557. * Class used to store a point for a MultiLine object.
  73558. * The point can be pure 2D coordinates, a mesh or a control
  73559. */
  73560. export class MultiLinePoint {
  73561. private _multiLine;
  73562. private _x;
  73563. private _y;
  73564. private _control;
  73565. private _mesh;
  73566. private _controlObserver;
  73567. private _meshObserver;
  73568. /** @hidden */
  73569. _point: BABYLON.Vector2;
  73570. /**
  73571. * Creates a new MultiLinePoint
  73572. * @param multiLine defines the source MultiLine object
  73573. */
  73574. constructor(multiLine: MultiLine);
  73575. /** Gets or sets x coordinate */
  73576. get x(): string | number;
  73577. set x(value: string | number);
  73578. /** Gets or sets y coordinate */
  73579. get y(): string | number;
  73580. set y(value: string | number);
  73581. /** Gets or sets the control associated with this point */
  73582. get control(): BABYLON.Nullable<Control>;
  73583. set control(value: BABYLON.Nullable<Control>);
  73584. /** Gets or sets the mesh associated with this point */
  73585. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73586. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73587. /** Resets links */
  73588. resetLinks(): void;
  73589. /**
  73590. * Gets a translation vector
  73591. * @returns the translation vector
  73592. */
  73593. translate(): BABYLON.Vector2;
  73594. private _translatePoint;
  73595. /** Release associated resources */
  73596. dispose(): void;
  73597. }
  73598. }
  73599. declare module BABYLON.GUI {
  73600. /**
  73601. * Class used to create multi line control
  73602. */
  73603. export class MultiLine extends Control {
  73604. name?: string | undefined;
  73605. private _lineWidth;
  73606. private _dash;
  73607. private _points;
  73608. private _minX;
  73609. private _minY;
  73610. private _maxX;
  73611. private _maxY;
  73612. /**
  73613. * Creates a new MultiLine
  73614. * @param name defines the control name
  73615. */
  73616. constructor(name?: string | undefined);
  73617. /** Gets or sets dash pattern */
  73618. get dash(): Array<number>;
  73619. set dash(value: Array<number>);
  73620. /**
  73621. * Gets point stored at specified index
  73622. * @param index defines the index to look for
  73623. * @returns the requested point if found
  73624. */
  73625. getAt(index: number): MultiLinePoint;
  73626. /** Function called when a point is updated */
  73627. onPointUpdate: () => void;
  73628. /**
  73629. * Adds new points to the point collection
  73630. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73631. * @returns the list of created MultiLinePoint
  73632. */
  73633. add(...items: (AbstractMesh | Control | {
  73634. x: string | number;
  73635. y: string | number;
  73636. })[]): MultiLinePoint[];
  73637. /**
  73638. * Adds a new point to the point collection
  73639. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73640. * @returns the created MultiLinePoint
  73641. */
  73642. push(item?: (AbstractMesh | Control | {
  73643. x: string | number;
  73644. y: string | number;
  73645. })): MultiLinePoint;
  73646. /**
  73647. * Remove a specific value or point from the active point collection
  73648. * @param value defines the value or point to remove
  73649. */
  73650. remove(value: number | MultiLinePoint): void;
  73651. /**
  73652. * Resets this object to initial state (no point)
  73653. */
  73654. reset(): void;
  73655. /**
  73656. * Resets all links
  73657. */
  73658. resetLinks(): void;
  73659. /** Gets or sets line width */
  73660. get lineWidth(): number;
  73661. set lineWidth(value: number);
  73662. set horizontalAlignment(value: number);
  73663. set verticalAlignment(value: number);
  73664. protected _getTypeName(): string;
  73665. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73666. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73667. _measure(): void;
  73668. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73669. dispose(): void;
  73670. }
  73671. }
  73672. declare module BABYLON.GUI {
  73673. /**
  73674. * Class used to create radio button controls
  73675. */
  73676. export class RadioButton extends Control {
  73677. name?: string | undefined;
  73678. private _isChecked;
  73679. private _background;
  73680. private _checkSizeRatio;
  73681. private _thickness;
  73682. /** Gets or sets border thickness */
  73683. get thickness(): number;
  73684. set thickness(value: number);
  73685. /** Gets or sets group name */
  73686. group: string;
  73687. /** BABYLON.Observable raised when isChecked is changed */
  73688. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73689. /** Gets or sets a value indicating the ratio between overall size and check size */
  73690. get checkSizeRatio(): number;
  73691. set checkSizeRatio(value: number);
  73692. /** Gets or sets background color */
  73693. get background(): string;
  73694. set background(value: string);
  73695. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73696. get isChecked(): boolean;
  73697. set isChecked(value: boolean);
  73698. /**
  73699. * Creates a new RadioButton
  73700. * @param name defines the control name
  73701. */
  73702. constructor(name?: string | undefined);
  73703. protected _getTypeName(): string;
  73704. _draw(context: CanvasRenderingContext2D): void;
  73705. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73706. /**
  73707. * Utility function to easily create a radio button with a header
  73708. * @param title defines the label to use for the header
  73709. * @param group defines the group to use for the radio button
  73710. * @param isChecked defines the initial state of the radio button
  73711. * @param onValueChanged defines the callback to call when value changes
  73712. * @returns a StackPanel containing the radio button and a textBlock
  73713. */
  73714. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73715. }
  73716. }
  73717. declare module BABYLON.GUI {
  73718. /**
  73719. * Class used to create slider controls
  73720. */
  73721. export class BaseSlider extends Control {
  73722. name?: string | undefined;
  73723. protected _thumbWidth: ValueAndUnit;
  73724. private _minimum;
  73725. private _maximum;
  73726. private _value;
  73727. private _isVertical;
  73728. protected _barOffset: ValueAndUnit;
  73729. private _isThumbClamped;
  73730. protected _displayThumb: boolean;
  73731. private _step;
  73732. private _lastPointerDownID;
  73733. protected _effectiveBarOffset: number;
  73734. protected _renderLeft: number;
  73735. protected _renderTop: number;
  73736. protected _renderWidth: number;
  73737. protected _renderHeight: number;
  73738. protected _backgroundBoxLength: number;
  73739. protected _backgroundBoxThickness: number;
  73740. protected _effectiveThumbThickness: number;
  73741. /** BABYLON.Observable raised when the sldier value changes */
  73742. onValueChangedObservable: BABYLON.Observable<number>;
  73743. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73744. get displayThumb(): boolean;
  73745. set displayThumb(value: boolean);
  73746. /** Gets or sets a step to apply to values (0 by default) */
  73747. get step(): number;
  73748. set step(value: number);
  73749. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73750. get barOffset(): string | number;
  73751. /** Gets main bar offset in pixels*/
  73752. get barOffsetInPixels(): number;
  73753. set barOffset(value: string | number);
  73754. /** Gets or sets thumb width */
  73755. get thumbWidth(): string | number;
  73756. /** Gets thumb width in pixels */
  73757. get thumbWidthInPixels(): number;
  73758. set thumbWidth(value: string | number);
  73759. /** Gets or sets minimum value */
  73760. get minimum(): number;
  73761. set minimum(value: number);
  73762. /** Gets or sets maximum value */
  73763. get maximum(): number;
  73764. set maximum(value: number);
  73765. /** Gets or sets current value */
  73766. get value(): number;
  73767. set value(value: number);
  73768. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73769. get isVertical(): boolean;
  73770. set isVertical(value: boolean);
  73771. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73772. get isThumbClamped(): boolean;
  73773. set isThumbClamped(value: boolean);
  73774. /**
  73775. * Creates a new BaseSlider
  73776. * @param name defines the control name
  73777. */
  73778. constructor(name?: string | undefined);
  73779. protected _getTypeName(): string;
  73780. protected _getThumbPosition(): number;
  73781. protected _getThumbThickness(type: string): number;
  73782. protected _prepareRenderingData(type: string): void;
  73783. private _pointerIsDown;
  73784. /** @hidden */
  73785. protected _updateValueFromPointer(x: number, y: number): void;
  73786. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73787. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73788. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73789. }
  73790. }
  73791. declare module BABYLON.GUI {
  73792. /**
  73793. * Class used to create slider controls
  73794. */
  73795. export class Slider extends BaseSlider {
  73796. name?: string | undefined;
  73797. private _background;
  73798. private _borderColor;
  73799. private _isThumbCircle;
  73800. protected _displayValueBar: boolean;
  73801. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73802. get displayValueBar(): boolean;
  73803. set displayValueBar(value: boolean);
  73804. /** Gets or sets border color */
  73805. get borderColor(): string;
  73806. set borderColor(value: string);
  73807. /** Gets or sets background color */
  73808. get background(): string;
  73809. set background(value: string);
  73810. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73811. get isThumbCircle(): boolean;
  73812. set isThumbCircle(value: boolean);
  73813. /**
  73814. * Creates a new Slider
  73815. * @param name defines the control name
  73816. */
  73817. constructor(name?: string | undefined);
  73818. protected _getTypeName(): string;
  73819. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73820. }
  73821. }
  73822. declare module BABYLON.GUI {
  73823. /** Class used to create a RadioGroup
  73824. * which contains groups of radio buttons
  73825. */
  73826. export class SelectorGroup {
  73827. /** name of SelectorGroup */
  73828. name: string;
  73829. private _groupPanel;
  73830. private _selectors;
  73831. private _groupHeader;
  73832. /**
  73833. * Creates a new SelectorGroup
  73834. * @param name of group, used as a group heading
  73835. */
  73836. constructor(
  73837. /** name of SelectorGroup */
  73838. name: string);
  73839. /** Gets the groupPanel of the SelectorGroup */
  73840. get groupPanel(): StackPanel;
  73841. /** Gets the selectors array */
  73842. get selectors(): StackPanel[];
  73843. /** Gets and sets the group header */
  73844. get header(): string;
  73845. set header(label: string);
  73846. /** @hidden */
  73847. private _addGroupHeader;
  73848. /** @hidden*/
  73849. _getSelector(selectorNb: number): StackPanel | undefined;
  73850. /** Removes the selector at the given position
  73851. * @param selectorNb the position of the selector within the group
  73852. */
  73853. removeSelector(selectorNb: number): void;
  73854. }
  73855. /** Class used to create a CheckboxGroup
  73856. * which contains groups of checkbox buttons
  73857. */
  73858. export class CheckboxGroup extends SelectorGroup {
  73859. /** Adds a checkbox as a control
  73860. * @param text is the label for the selector
  73861. * @param func is the function called when the Selector is checked
  73862. * @param checked is true when Selector is checked
  73863. */
  73864. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73865. /** @hidden */
  73866. _setSelectorLabel(selectorNb: number, label: string): void;
  73867. /** @hidden */
  73868. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73869. /** @hidden */
  73870. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73871. /** @hidden */
  73872. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73873. }
  73874. /** Class used to create a RadioGroup
  73875. * which contains groups of radio buttons
  73876. */
  73877. export class RadioGroup extends SelectorGroup {
  73878. private _selectNb;
  73879. /** Adds a radio button as a control
  73880. * @param label is the label for the selector
  73881. * @param func is the function called when the Selector is checked
  73882. * @param checked is true when Selector is checked
  73883. */
  73884. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73885. /** @hidden */
  73886. _setSelectorLabel(selectorNb: number, label: string): void;
  73887. /** @hidden */
  73888. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73889. /** @hidden */
  73890. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73891. /** @hidden */
  73892. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73893. }
  73894. /** Class used to create a SliderGroup
  73895. * which contains groups of slider buttons
  73896. */
  73897. export class SliderGroup extends SelectorGroup {
  73898. /**
  73899. * Adds a slider to the SelectorGroup
  73900. * @param label is the label for the SliderBar
  73901. * @param func is the function called when the Slider moves
  73902. * @param unit is a string describing the units used, eg degrees or metres
  73903. * @param min is the minimum value for the Slider
  73904. * @param max is the maximum value for the Slider
  73905. * @param value is the start value for the Slider between min and max
  73906. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73907. */
  73908. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73909. /** @hidden */
  73910. _setSelectorLabel(selectorNb: number, label: string): void;
  73911. /** @hidden */
  73912. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73913. /** @hidden */
  73914. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73915. /** @hidden */
  73916. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73917. }
  73918. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73919. * @see http://doc.babylonjs.com/how_to/selector
  73920. */
  73921. export class SelectionPanel extends Rectangle {
  73922. /** name of SelectionPanel */
  73923. name: string;
  73924. /** an array of SelectionGroups */
  73925. groups: SelectorGroup[];
  73926. private _panel;
  73927. private _buttonColor;
  73928. private _buttonBackground;
  73929. private _headerColor;
  73930. private _barColor;
  73931. private _barHeight;
  73932. private _spacerHeight;
  73933. private _labelColor;
  73934. private _groups;
  73935. private _bars;
  73936. /**
  73937. * Creates a new SelectionPanel
  73938. * @param name of SelectionPanel
  73939. * @param groups is an array of SelectionGroups
  73940. */
  73941. constructor(
  73942. /** name of SelectionPanel */
  73943. name: string,
  73944. /** an array of SelectionGroups */
  73945. groups?: SelectorGroup[]);
  73946. protected _getTypeName(): string;
  73947. /** Gets or sets the headerColor */
  73948. get headerColor(): string;
  73949. set headerColor(color: string);
  73950. private _setHeaderColor;
  73951. /** Gets or sets the button color */
  73952. get buttonColor(): string;
  73953. set buttonColor(color: string);
  73954. private _setbuttonColor;
  73955. /** Gets or sets the label color */
  73956. get labelColor(): string;
  73957. set labelColor(color: string);
  73958. private _setLabelColor;
  73959. /** Gets or sets the button background */
  73960. get buttonBackground(): string;
  73961. set buttonBackground(color: string);
  73962. private _setButtonBackground;
  73963. /** Gets or sets the color of separator bar */
  73964. get barColor(): string;
  73965. set barColor(color: string);
  73966. private _setBarColor;
  73967. /** Gets or sets the height of separator bar */
  73968. get barHeight(): string;
  73969. set barHeight(value: string);
  73970. private _setBarHeight;
  73971. /** Gets or sets the height of spacers*/
  73972. get spacerHeight(): string;
  73973. set spacerHeight(value: string);
  73974. private _setSpacerHeight;
  73975. /** Adds a bar between groups */
  73976. private _addSpacer;
  73977. /** Add a group to the selection panel
  73978. * @param group is the selector group to add
  73979. */
  73980. addGroup(group: SelectorGroup): void;
  73981. /** Remove the group from the given position
  73982. * @param groupNb is the position of the group in the list
  73983. */
  73984. removeGroup(groupNb: number): void;
  73985. /** Change a group header label
  73986. * @param label is the new group header label
  73987. * @param groupNb is the number of the group to relabel
  73988. * */
  73989. setHeaderName(label: string, groupNb: number): void;
  73990. /** Change selector label to the one given
  73991. * @param label is the new selector label
  73992. * @param groupNb is the number of the groupcontaining the selector
  73993. * @param selectorNb is the number of the selector within a group to relabel
  73994. * */
  73995. relabel(label: string, groupNb: number, selectorNb: number): void;
  73996. /** For a given group position remove the selector at the given position
  73997. * @param groupNb is the number of the group to remove the selector from
  73998. * @param selectorNb is the number of the selector within the group
  73999. */
  74000. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  74001. /** For a given group position of correct type add a checkbox button
  74002. * @param groupNb is the number of the group to remove the selector from
  74003. * @param label is the label for the selector
  74004. * @param func is the function called when the Selector is checked
  74005. * @param checked is true when Selector is checked
  74006. */
  74007. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74008. /** For a given group position of correct type add a radio button
  74009. * @param groupNb is the number of the group to remove the selector from
  74010. * @param label is the label for the selector
  74011. * @param func is the function called when the Selector is checked
  74012. * @param checked is true when Selector is checked
  74013. */
  74014. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  74015. /**
  74016. * For a given slider group add a slider
  74017. * @param groupNb is the number of the group to add the slider to
  74018. * @param label is the label for the Slider
  74019. * @param func is the function called when the Slider moves
  74020. * @param unit is a string describing the units used, eg degrees or metres
  74021. * @param min is the minimum value for the Slider
  74022. * @param max is the maximum value for the Slider
  74023. * @param value is the start value for the Slider between min and max
  74024. * @param onVal is the function used to format the value displayed, eg radians to degrees
  74025. */
  74026. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  74027. }
  74028. }
  74029. declare module BABYLON.GUI {
  74030. /**
  74031. * Class used to hold a the container for ScrollViewer
  74032. * @hidden
  74033. */
  74034. export class _ScrollViewerWindow extends Container {
  74035. parentClientWidth: number;
  74036. parentClientHeight: number;
  74037. private _freezeControls;
  74038. private _parentMeasure;
  74039. private _oldLeft;
  74040. private _oldTop;
  74041. get freezeControls(): boolean;
  74042. set freezeControls(value: boolean);
  74043. private _bucketWidth;
  74044. private _bucketHeight;
  74045. private _buckets;
  74046. private _bucketLen;
  74047. get bucketWidth(): number;
  74048. get bucketHeight(): number;
  74049. setBucketSizes(width: number, height: number): void;
  74050. private _useBuckets;
  74051. private _makeBuckets;
  74052. private _dispatchInBuckets;
  74053. private _updateMeasures;
  74054. private _updateChildrenMeasures;
  74055. private _restoreMeasures;
  74056. /**
  74057. * Creates a new ScrollViewerWindow
  74058. * @param name of ScrollViewerWindow
  74059. */
  74060. constructor(name?: string);
  74061. protected _getTypeName(): string;
  74062. /** @hidden */
  74063. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74064. /** @hidden */
  74065. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74066. private _scrollChildren;
  74067. private _scrollChildrenWithBuckets;
  74068. /** @hidden */
  74069. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  74070. protected _postMeasure(): void;
  74071. }
  74072. }
  74073. declare module BABYLON.GUI {
  74074. /**
  74075. * Class used to create slider controls
  74076. */
  74077. export class ScrollBar extends BaseSlider {
  74078. name?: string | undefined;
  74079. private _background;
  74080. private _borderColor;
  74081. private _tempMeasure;
  74082. /** Gets or sets border color */
  74083. get borderColor(): string;
  74084. set borderColor(value: string);
  74085. /** Gets or sets background color */
  74086. get background(): string;
  74087. set background(value: string);
  74088. /**
  74089. * Creates a new Slider
  74090. * @param name defines the control name
  74091. */
  74092. constructor(name?: string | undefined);
  74093. protected _getTypeName(): string;
  74094. protected _getThumbThickness(): number;
  74095. _draw(context: CanvasRenderingContext2D): void;
  74096. private _first;
  74097. private _originX;
  74098. private _originY;
  74099. /** @hidden */
  74100. protected _updateValueFromPointer(x: number, y: number): void;
  74101. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74102. }
  74103. }
  74104. declare module BABYLON.GUI {
  74105. /**
  74106. * Class used to create slider controls
  74107. */
  74108. export class ImageScrollBar extends BaseSlider {
  74109. name?: string | undefined;
  74110. private _backgroundBaseImage;
  74111. private _backgroundImage;
  74112. private _thumbImage;
  74113. private _thumbBaseImage;
  74114. private _thumbLength;
  74115. private _thumbHeight;
  74116. private _barImageHeight;
  74117. private _tempMeasure;
  74118. /** Number of 90° rotation to apply on the images when in vertical mode */
  74119. num90RotationInVerticalMode: number;
  74120. /**
  74121. * Gets or sets the image used to render the background for horizontal bar
  74122. */
  74123. get backgroundImage(): Image;
  74124. set backgroundImage(value: Image);
  74125. /**
  74126. * Gets or sets the image used to render the thumb
  74127. */
  74128. get thumbImage(): Image;
  74129. set thumbImage(value: Image);
  74130. /**
  74131. * Gets or sets the length of the thumb
  74132. */
  74133. get thumbLength(): number;
  74134. set thumbLength(value: number);
  74135. /**
  74136. * Gets or sets the height of the thumb
  74137. */
  74138. get thumbHeight(): number;
  74139. set thumbHeight(value: number);
  74140. /**
  74141. * Gets or sets the height of the bar image
  74142. */
  74143. get barImageHeight(): number;
  74144. set barImageHeight(value: number);
  74145. /**
  74146. * Creates a new ImageScrollBar
  74147. * @param name defines the control name
  74148. */
  74149. constructor(name?: string | undefined);
  74150. protected _getTypeName(): string;
  74151. protected _getThumbThickness(): number;
  74152. _draw(context: CanvasRenderingContext2D): void;
  74153. private _first;
  74154. private _originX;
  74155. private _originY;
  74156. /** @hidden */
  74157. protected _updateValueFromPointer(x: number, y: number): void;
  74158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74159. }
  74160. }
  74161. declare module BABYLON.GUI {
  74162. /**
  74163. * Class used to hold a viewer window and sliders in a grid
  74164. */
  74165. export class ScrollViewer extends Rectangle {
  74166. private _grid;
  74167. private _horizontalBarSpace;
  74168. private _verticalBarSpace;
  74169. private _dragSpace;
  74170. private _horizontalBar;
  74171. private _verticalBar;
  74172. private _barColor;
  74173. private _barBackground;
  74174. private _barImage;
  74175. private _horizontalBarImage;
  74176. private _verticalBarImage;
  74177. private _barBackgroundImage;
  74178. private _horizontalBarBackgroundImage;
  74179. private _verticalBarBackgroundImage;
  74180. private _barSize;
  74181. private _window;
  74182. private _pointerIsOver;
  74183. private _wheelPrecision;
  74184. private _onWheelObserver;
  74185. private _clientWidth;
  74186. private _clientHeight;
  74187. private _useImageBar;
  74188. private _thumbLength;
  74189. private _thumbHeight;
  74190. private _barImageHeight;
  74191. private _horizontalBarImageHeight;
  74192. private _verticalBarImageHeight;
  74193. private _oldWindowContentsWidth;
  74194. private _oldWindowContentsHeight;
  74195. /**
  74196. * Gets the horizontal scrollbar
  74197. */
  74198. get horizontalBar(): ScrollBar | ImageScrollBar;
  74199. /**
  74200. * Gets the vertical scrollbar
  74201. */
  74202. get verticalBar(): ScrollBar | ImageScrollBar;
  74203. /**
  74204. * Adds a new control to the current container
  74205. * @param control defines the control to add
  74206. * @returns the current container
  74207. */
  74208. addControl(control: BABYLON.Nullable<Control>): Container;
  74209. /**
  74210. * Removes a control from the current container
  74211. * @param control defines the control to remove
  74212. * @returns the current container
  74213. */
  74214. removeControl(control: Control): Container;
  74215. /** Gets the list of children */
  74216. get children(): Control[];
  74217. _flagDescendantsAsMatrixDirty(): void;
  74218. /**
  74219. * Freezes or unfreezes the controls in the window.
  74220. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74221. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74222. */
  74223. get freezeControls(): boolean;
  74224. set freezeControls(value: boolean);
  74225. /** Gets the bucket width */
  74226. get bucketWidth(): number;
  74227. /** Gets the bucket height */
  74228. get bucketHeight(): number;
  74229. /**
  74230. * Sets the bucket sizes.
  74231. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74232. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74233. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74234. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74235. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74236. * used), that's why it is not enabled by default.
  74237. * @param width width of the bucket
  74238. * @param height height of the bucket
  74239. */
  74240. setBucketSizes(width: number, height: number): void;
  74241. private _forceHorizontalBar;
  74242. private _forceVerticalBar;
  74243. /**
  74244. * Forces the horizontal scroll bar to be displayed
  74245. */
  74246. get forceHorizontalBar(): boolean;
  74247. set forceHorizontalBar(value: boolean);
  74248. /**
  74249. * Forces the vertical scroll bar to be displayed
  74250. */
  74251. get forceVerticalBar(): boolean;
  74252. set forceVerticalBar(value: boolean);
  74253. /**
  74254. * Creates a new ScrollViewer
  74255. * @param name of ScrollViewer
  74256. */
  74257. constructor(name?: string, isImageBased?: boolean);
  74258. /** Reset the scroll viewer window to initial size */
  74259. resetWindow(): void;
  74260. protected _getTypeName(): string;
  74261. private _buildClientSizes;
  74262. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74263. protected _postMeasure(): void;
  74264. /**
  74265. * Gets or sets the mouse wheel precision
  74266. * from 0 to 1 with a default value of 0.05
  74267. * */
  74268. get wheelPrecision(): number;
  74269. set wheelPrecision(value: number);
  74270. /** Gets or sets the scroll bar container background color */
  74271. get scrollBackground(): string;
  74272. set scrollBackground(color: string);
  74273. /** Gets or sets the bar color */
  74274. get barColor(): string;
  74275. set barColor(color: string);
  74276. /** Gets or sets the bar image */
  74277. get thumbImage(): Image;
  74278. set thumbImage(value: Image);
  74279. /** Gets or sets the horizontal bar image */
  74280. get horizontalThumbImage(): Image;
  74281. set horizontalThumbImage(value: Image);
  74282. /** Gets or sets the vertical bar image */
  74283. get verticalThumbImage(): Image;
  74284. set verticalThumbImage(value: Image);
  74285. /** Gets or sets the size of the bar */
  74286. get barSize(): number;
  74287. set barSize(value: number);
  74288. /** Gets or sets the length of the thumb */
  74289. get thumbLength(): number;
  74290. set thumbLength(value: number);
  74291. /** Gets or sets the height of the thumb */
  74292. get thumbHeight(): number;
  74293. set thumbHeight(value: number);
  74294. /** Gets or sets the height of the bar image */
  74295. get barImageHeight(): number;
  74296. set barImageHeight(value: number);
  74297. /** Gets or sets the height of the horizontal bar image */
  74298. get horizontalBarImageHeight(): number;
  74299. set horizontalBarImageHeight(value: number);
  74300. /** Gets or sets the height of the vertical bar image */
  74301. get verticalBarImageHeight(): number;
  74302. set verticalBarImageHeight(value: number);
  74303. /** Gets or sets the bar background */
  74304. get barBackground(): string;
  74305. set barBackground(color: string);
  74306. /** Gets or sets the bar background image */
  74307. get barImage(): Image;
  74308. set barImage(value: Image);
  74309. /** Gets or sets the horizontal bar background image */
  74310. get horizontalBarImage(): Image;
  74311. set horizontalBarImage(value: Image);
  74312. /** Gets or sets the vertical bar background image */
  74313. get verticalBarImage(): Image;
  74314. set verticalBarImage(value: Image);
  74315. private _setWindowPosition;
  74316. /** @hidden */
  74317. private _updateScroller;
  74318. _link(host: AdvancedDynamicTexture): void;
  74319. /** @hidden */
  74320. private _addBar;
  74321. /** @hidden */
  74322. private _attachWheel;
  74323. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74324. /** Releases associated resources */
  74325. dispose(): void;
  74326. }
  74327. }
  74328. declare module BABYLON.GUI {
  74329. /** Class used to render a grid */
  74330. export class DisplayGrid extends Control {
  74331. name?: string | undefined;
  74332. private _cellWidth;
  74333. private _cellHeight;
  74334. private _minorLineTickness;
  74335. private _minorLineColor;
  74336. private _majorLineTickness;
  74337. private _majorLineColor;
  74338. private _majorLineFrequency;
  74339. private _background;
  74340. private _displayMajorLines;
  74341. private _displayMinorLines;
  74342. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74343. get displayMinorLines(): boolean;
  74344. set displayMinorLines(value: boolean);
  74345. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74346. get displayMajorLines(): boolean;
  74347. set displayMajorLines(value: boolean);
  74348. /** Gets or sets background color (Black by default) */
  74349. get background(): string;
  74350. set background(value: string);
  74351. /** Gets or sets the width of each cell (20 by default) */
  74352. get cellWidth(): number;
  74353. set cellWidth(value: number);
  74354. /** Gets or sets the height of each cell (20 by default) */
  74355. get cellHeight(): number;
  74356. set cellHeight(value: number);
  74357. /** Gets or sets the tickness of minor lines (1 by default) */
  74358. get minorLineTickness(): number;
  74359. set minorLineTickness(value: number);
  74360. /** Gets or sets the color of minor lines (DarkGray by default) */
  74361. get minorLineColor(): string;
  74362. set minorLineColor(value: string);
  74363. /** Gets or sets the tickness of major lines (2 by default) */
  74364. get majorLineTickness(): number;
  74365. set majorLineTickness(value: number);
  74366. /** Gets or sets the color of major lines (White by default) */
  74367. get majorLineColor(): string;
  74368. set majorLineColor(value: string);
  74369. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74370. get majorLineFrequency(): number;
  74371. set majorLineFrequency(value: number);
  74372. /**
  74373. * Creates a new GridDisplayRectangle
  74374. * @param name defines the control name
  74375. */
  74376. constructor(name?: string | undefined);
  74377. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74378. protected _getTypeName(): string;
  74379. }
  74380. }
  74381. declare module BABYLON.GUI {
  74382. /**
  74383. * Class used to create slider controls based on images
  74384. */
  74385. export class ImageBasedSlider extends BaseSlider {
  74386. name?: string | undefined;
  74387. private _backgroundImage;
  74388. private _thumbImage;
  74389. private _valueBarImage;
  74390. private _tempMeasure;
  74391. get displayThumb(): boolean;
  74392. set displayThumb(value: boolean);
  74393. /**
  74394. * Gets or sets the image used to render the background
  74395. */
  74396. get backgroundImage(): Image;
  74397. set backgroundImage(value: Image);
  74398. /**
  74399. * Gets or sets the image used to render the value bar
  74400. */
  74401. get valueBarImage(): Image;
  74402. set valueBarImage(value: Image);
  74403. /**
  74404. * Gets or sets the image used to render the thumb
  74405. */
  74406. get thumbImage(): Image;
  74407. set thumbImage(value: Image);
  74408. /**
  74409. * Creates a new ImageBasedSlider
  74410. * @param name defines the control name
  74411. */
  74412. constructor(name?: string | undefined);
  74413. protected _getTypeName(): string;
  74414. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74415. }
  74416. }
  74417. declare module BABYLON.GUI {
  74418. /**
  74419. * Forcing an export so that this code will execute
  74420. * @hidden
  74421. */
  74422. const name = "Statics";
  74423. }
  74424. declare module BABYLON.GUI {
  74425. /**
  74426. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74427. */
  74428. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74429. /**
  74430. * Define the instrumented AdvancedDynamicTexture.
  74431. */
  74432. texture: AdvancedDynamicTexture;
  74433. private _captureRenderTime;
  74434. private _renderTime;
  74435. private _captureLayoutTime;
  74436. private _layoutTime;
  74437. private _onBeginRenderObserver;
  74438. private _onEndRenderObserver;
  74439. private _onBeginLayoutObserver;
  74440. private _onEndLayoutObserver;
  74441. /**
  74442. * Gets the perf counter used to capture render time
  74443. */
  74444. get renderTimeCounter(): BABYLON.PerfCounter;
  74445. /**
  74446. * Gets the perf counter used to capture layout time
  74447. */
  74448. get layoutTimeCounter(): BABYLON.PerfCounter;
  74449. /**
  74450. * Enable or disable the render time capture
  74451. */
  74452. get captureRenderTime(): boolean;
  74453. set captureRenderTime(value: boolean);
  74454. /**
  74455. * Enable or disable the layout time capture
  74456. */
  74457. get captureLayoutTime(): boolean;
  74458. set captureLayoutTime(value: boolean);
  74459. /**
  74460. * Instantiates a new advanced dynamic texture instrumentation.
  74461. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74462. * @param texture Defines the AdvancedDynamicTexture to instrument
  74463. */
  74464. constructor(
  74465. /**
  74466. * Define the instrumented AdvancedDynamicTexture.
  74467. */
  74468. texture: AdvancedDynamicTexture);
  74469. /**
  74470. * Dispose and release associated resources.
  74471. */
  74472. dispose(): void;
  74473. }
  74474. }
  74475. declare module BABYLON.GUI {
  74476. /**
  74477. * Class used to load GUI via XML.
  74478. */
  74479. export class XmlLoader {
  74480. private _nodes;
  74481. private _nodeTypes;
  74482. private _isLoaded;
  74483. private _objectAttributes;
  74484. private _parentClass;
  74485. /**
  74486. * Create a new xml loader
  74487. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74488. */
  74489. constructor(parentClass?: null);
  74490. private _getChainElement;
  74491. private _getClassAttribute;
  74492. private _createGuiElement;
  74493. private _parseGrid;
  74494. private _parseElement;
  74495. private _prepareSourceElement;
  74496. private _parseElementsFromSource;
  74497. private _parseXml;
  74498. /**
  74499. * Gets if the loading has finished.
  74500. * @returns whether the loading has finished or not
  74501. */
  74502. isLoaded(): boolean;
  74503. /**
  74504. * Gets a loaded node / control by id.
  74505. * @param id the Controls id set in the xml
  74506. * @returns element of type Control
  74507. */
  74508. getNodeById(id: string): any;
  74509. /**
  74510. * Gets all loaded nodes / controls
  74511. * @returns Array of controls
  74512. */
  74513. getNodes(): any;
  74514. /**
  74515. * Initiates the xml layout loading
  74516. * @param xmlFile defines the xml layout to load
  74517. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74518. * @param callback defines the callback called on layout load.
  74519. */
  74520. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74521. }
  74522. }
  74523. declare module BABYLON.GUI {
  74524. /**
  74525. * Class used to create containers for controls
  74526. */
  74527. export class Container3D extends Control3D {
  74528. private _blockLayout;
  74529. /**
  74530. * Gets the list of child controls
  74531. */
  74532. protected _children: Control3D[];
  74533. /**
  74534. * Gets the list of child controls
  74535. */
  74536. get children(): Array<Control3D>;
  74537. /**
  74538. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74539. * This is helpful to optimize layout operation when adding multiple children in a row
  74540. */
  74541. get blockLayout(): boolean;
  74542. set blockLayout(value: boolean);
  74543. /**
  74544. * Creates a new container
  74545. * @param name defines the container name
  74546. */
  74547. constructor(name?: string);
  74548. /**
  74549. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74550. * @returns the current container
  74551. */
  74552. updateLayout(): Container3D;
  74553. /**
  74554. * Gets a boolean indicating if the given control is in the children of this control
  74555. * @param control defines the control to check
  74556. * @returns true if the control is in the child list
  74557. */
  74558. containsControl(control: Control3D): boolean;
  74559. /**
  74560. * Adds a control to the children of this control
  74561. * @param control defines the control to add
  74562. * @returns the current container
  74563. */
  74564. addControl(control: Control3D): Container3D;
  74565. /**
  74566. * This function will be called everytime a new control is added
  74567. */
  74568. protected _arrangeChildren(): void;
  74569. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74570. /**
  74571. * Removes a control from the children of this control
  74572. * @param control defines the control to remove
  74573. * @returns the current container
  74574. */
  74575. removeControl(control: Control3D): Container3D;
  74576. protected _getTypeName(): string;
  74577. /**
  74578. * Releases all associated resources
  74579. */
  74580. dispose(): void;
  74581. /** Control rotation will remain unchanged */
  74582. static readonly UNSET_ORIENTATION: number;
  74583. /** Control will rotate to make it look at sphere central axis */
  74584. static readonly FACEORIGIN_ORIENTATION: number;
  74585. /** Control will rotate to make it look back at sphere central axis */
  74586. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74587. /** Control will rotate to look at z axis (0, 0, 1) */
  74588. static readonly FACEFORWARD_ORIENTATION: number;
  74589. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74590. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74591. }
  74592. }
  74593. declare module BABYLON.GUI {
  74594. /**
  74595. * Class used to manage 3D user interface
  74596. * @see http://doc.babylonjs.com/how_to/gui3d
  74597. */
  74598. export class GUI3DManager implements BABYLON.IDisposable {
  74599. private _scene;
  74600. private _sceneDisposeObserver;
  74601. private _utilityLayer;
  74602. private _rootContainer;
  74603. private _pointerObserver;
  74604. private _pointerOutObserver;
  74605. /** @hidden */
  74606. _lastPickedControl: Control3D;
  74607. /** @hidden */
  74608. _lastControlOver: {
  74609. [pointerId: number]: Control3D;
  74610. };
  74611. /** @hidden */
  74612. _lastControlDown: {
  74613. [pointerId: number]: Control3D;
  74614. };
  74615. /**
  74616. * BABYLON.Observable raised when the point picked by the pointer events changed
  74617. */
  74618. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74619. /** @hidden */
  74620. _sharedMaterials: {
  74621. [key: string]: BABYLON.Material;
  74622. };
  74623. /** Gets the hosting scene */
  74624. get scene(): BABYLON.Scene;
  74625. /** Gets associated utility layer */
  74626. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74627. /**
  74628. * Creates a new GUI3DManager
  74629. * @param scene
  74630. */
  74631. constructor(scene?: BABYLON.Scene);
  74632. private _handlePointerOut;
  74633. private _doPicking;
  74634. /**
  74635. * Gets the root container
  74636. */
  74637. get rootContainer(): Container3D;
  74638. /**
  74639. * Gets a boolean indicating if the given control is in the root child list
  74640. * @param control defines the control to check
  74641. * @returns true if the control is in the root child list
  74642. */
  74643. containsControl(control: Control3D): boolean;
  74644. /**
  74645. * Adds a control to the root child list
  74646. * @param control defines the control to add
  74647. * @returns the current manager
  74648. */
  74649. addControl(control: Control3D): GUI3DManager;
  74650. /**
  74651. * Removes a control from the root child list
  74652. * @param control defines the control to remove
  74653. * @returns the current container
  74654. */
  74655. removeControl(control: Control3D): GUI3DManager;
  74656. /**
  74657. * Releases all associated resources
  74658. */
  74659. dispose(): void;
  74660. }
  74661. }
  74662. declare module BABYLON.GUI {
  74663. /**
  74664. * Class used to transport BABYLON.Vector3 information for pointer events
  74665. */
  74666. export class Vector3WithInfo extends BABYLON.Vector3 {
  74667. /** defines the current mouse button index */
  74668. buttonIndex: number;
  74669. /**
  74670. * Creates a new Vector3WithInfo
  74671. * @param source defines the vector3 data to transport
  74672. * @param buttonIndex defines the current mouse button index
  74673. */
  74674. constructor(source: BABYLON.Vector3,
  74675. /** defines the current mouse button index */
  74676. buttonIndex?: number);
  74677. }
  74678. }
  74679. declare module BABYLON.GUI {
  74680. /**
  74681. * Class used as base class for controls
  74682. */
  74683. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74684. /** Defines the control name */
  74685. name?: string | undefined;
  74686. /** @hidden */
  74687. _host: GUI3DManager;
  74688. private _node;
  74689. private _downCount;
  74690. private _enterCount;
  74691. private _downPointerIds;
  74692. private _isVisible;
  74693. /** Gets or sets the control position in world space */
  74694. get position(): BABYLON.Vector3;
  74695. set position(value: BABYLON.Vector3);
  74696. /** Gets or sets the control scaling in world space */
  74697. get scaling(): BABYLON.Vector3;
  74698. set scaling(value: BABYLON.Vector3);
  74699. /** Callback used to start pointer enter animation */
  74700. pointerEnterAnimation: () => void;
  74701. /** Callback used to start pointer out animation */
  74702. pointerOutAnimation: () => void;
  74703. /** Callback used to start pointer down animation */
  74704. pointerDownAnimation: () => void;
  74705. /** Callback used to start pointer up animation */
  74706. pointerUpAnimation: () => void;
  74707. /**
  74708. * An event triggered when the pointer move over the control
  74709. */
  74710. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74711. /**
  74712. * An event triggered when the pointer move out of the control
  74713. */
  74714. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74715. /**
  74716. * An event triggered when the pointer taps the control
  74717. */
  74718. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74719. /**
  74720. * An event triggered when pointer is up
  74721. */
  74722. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74723. /**
  74724. * An event triggered when a control is clicked on (with a mouse)
  74725. */
  74726. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74727. /**
  74728. * An event triggered when pointer enters the control
  74729. */
  74730. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74731. /**
  74732. * Gets or sets the parent container
  74733. */
  74734. parent: BABYLON.Nullable<Container3D>;
  74735. private _behaviors;
  74736. /**
  74737. * Gets the list of attached behaviors
  74738. * @see http://doc.babylonjs.com/features/behaviour
  74739. */
  74740. get behaviors(): BABYLON.Behavior<Control3D>[];
  74741. /**
  74742. * Attach a behavior to the control
  74743. * @see http://doc.babylonjs.com/features/behaviour
  74744. * @param behavior defines the behavior to attach
  74745. * @returns the current control
  74746. */
  74747. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74748. /**
  74749. * Remove an attached behavior
  74750. * @see http://doc.babylonjs.com/features/behaviour
  74751. * @param behavior defines the behavior to attach
  74752. * @returns the current control
  74753. */
  74754. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74755. /**
  74756. * Gets an attached behavior by name
  74757. * @param name defines the name of the behavior to look for
  74758. * @see http://doc.babylonjs.com/features/behaviour
  74759. * @returns null if behavior was not found else the requested behavior
  74760. */
  74761. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74762. /** Gets or sets a boolean indicating if the control is visible */
  74763. get isVisible(): boolean;
  74764. set isVisible(value: boolean);
  74765. /**
  74766. * Creates a new control
  74767. * @param name defines the control name
  74768. */
  74769. constructor(
  74770. /** Defines the control name */
  74771. name?: string | undefined);
  74772. /**
  74773. * Gets a string representing the class name
  74774. */
  74775. get typeName(): string;
  74776. /**
  74777. * Get the current class name of the control.
  74778. * @returns current class name
  74779. */
  74780. getClassName(): string;
  74781. protected _getTypeName(): string;
  74782. /**
  74783. * Gets the transform node used by this control
  74784. */
  74785. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74786. /**
  74787. * Gets the mesh used to render this control
  74788. */
  74789. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74790. /**
  74791. * Link the control as child of the given node
  74792. * @param node defines the node to link to. Use null to unlink the control
  74793. * @returns the current control
  74794. */
  74795. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74796. /** @hidden **/
  74797. _prepareNode(scene: BABYLON.Scene): void;
  74798. /**
  74799. * Node creation.
  74800. * Can be overriden by children
  74801. * @param scene defines the scene where the node must be attached
  74802. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74803. */
  74804. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74805. /**
  74806. * Affect a material to the given mesh
  74807. * @param mesh defines the mesh which will represent the control
  74808. */
  74809. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74810. /** @hidden */
  74811. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74812. /** @hidden */
  74813. _onPointerEnter(target: Control3D): boolean;
  74814. /** @hidden */
  74815. _onPointerOut(target: Control3D): void;
  74816. /** @hidden */
  74817. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74818. /** @hidden */
  74819. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74820. /** @hidden */
  74821. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74822. /** @hidden */
  74823. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74824. /** @hidden */
  74825. _disposeNode(): void;
  74826. /**
  74827. * Releases all associated resources
  74828. */
  74829. dispose(): void;
  74830. }
  74831. }
  74832. declare module BABYLON.GUI {
  74833. /**
  74834. * Class used as a root to all buttons
  74835. */
  74836. export class AbstractButton3D extends Control3D {
  74837. /**
  74838. * Creates a new button
  74839. * @param name defines the control name
  74840. */
  74841. constructor(name?: string);
  74842. protected _getTypeName(): string;
  74843. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74844. }
  74845. }
  74846. declare module BABYLON.GUI {
  74847. /**
  74848. * Class used to create a button in 3D
  74849. */
  74850. export class Button3D extends AbstractButton3D {
  74851. /** @hidden */
  74852. protected _currentMaterial: BABYLON.Material;
  74853. private _facadeTexture;
  74854. private _content;
  74855. private _contentResolution;
  74856. private _contentScaleRatio;
  74857. /**
  74858. * Gets or sets the texture resolution used to render content (512 by default)
  74859. */
  74860. get contentResolution(): BABYLON.int;
  74861. set contentResolution(value: BABYLON.int);
  74862. /**
  74863. * Gets or sets the texture scale ratio used to render content (2 by default)
  74864. */
  74865. get contentScaleRatio(): number;
  74866. set contentScaleRatio(value: number);
  74867. protected _disposeFacadeTexture(): void;
  74868. protected _resetContent(): void;
  74869. /**
  74870. * Creates a new button
  74871. * @param name defines the control name
  74872. */
  74873. constructor(name?: string);
  74874. /**
  74875. * Gets or sets the GUI 2D content used to display the button's facade
  74876. */
  74877. get content(): Control;
  74878. set content(value: Control);
  74879. /**
  74880. * Apply the facade texture (created from the content property).
  74881. * This function can be overloaded by child classes
  74882. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74883. */
  74884. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74885. protected _getTypeName(): string;
  74886. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74887. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74888. /**
  74889. * Releases all associated resources
  74890. */
  74891. dispose(): void;
  74892. }
  74893. }
  74894. declare module BABYLON.GUI {
  74895. /**
  74896. * Abstract class used to create a container panel deployed on the surface of a volume
  74897. */
  74898. export abstract class VolumeBasedPanel extends Container3D {
  74899. private _columns;
  74900. private _rows;
  74901. private _rowThenColum;
  74902. private _orientation;
  74903. protected _cellWidth: number;
  74904. protected _cellHeight: number;
  74905. /**
  74906. * Gets or sets the distance between elements
  74907. */
  74908. margin: number;
  74909. /**
  74910. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74911. * | Value | Type | Description |
  74912. * | ----- | ----------------------------------- | ----------- |
  74913. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74914. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74915. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74916. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74917. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74918. */
  74919. get orientation(): number;
  74920. set orientation(value: number);
  74921. /**
  74922. * Gets or sets the number of columns requested (10 by default).
  74923. * The panel will automatically compute the number of rows based on number of child controls.
  74924. */
  74925. get columns(): BABYLON.int;
  74926. set columns(value: BABYLON.int);
  74927. /**
  74928. * Gets or sets a the number of rows requested.
  74929. * The panel will automatically compute the number of columns based on number of child controls.
  74930. */
  74931. get rows(): BABYLON.int;
  74932. set rows(value: BABYLON.int);
  74933. /**
  74934. * Creates new VolumeBasedPanel
  74935. */
  74936. constructor();
  74937. protected _arrangeChildren(): void;
  74938. /** Child classes must implement this function to provide correct control positioning */
  74939. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74940. /** Child classes can implement this function to provide additional processing */
  74941. protected _finalProcessing(): void;
  74942. }
  74943. }
  74944. declare module BABYLON.GUI {
  74945. /**
  74946. * Class used to create a container panel deployed on the surface of a cylinder
  74947. */
  74948. export class CylinderPanel extends VolumeBasedPanel {
  74949. private _radius;
  74950. /**
  74951. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74952. */
  74953. get radius(): BABYLON.float;
  74954. set radius(value: BABYLON.float);
  74955. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74956. private _cylindricalMapping;
  74957. }
  74958. }
  74959. declare module BABYLON.GUI {
  74960. /** @hidden */
  74961. export var fluentVertexShader: {
  74962. name: string;
  74963. shader: string;
  74964. };
  74965. }
  74966. declare module BABYLON.GUI {
  74967. /** @hidden */
  74968. export var fluentPixelShader: {
  74969. name: string;
  74970. shader: string;
  74971. };
  74972. }
  74973. declare module BABYLON.GUI {
  74974. /** @hidden */
  74975. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74976. INNERGLOW: boolean;
  74977. BORDER: boolean;
  74978. HOVERLIGHT: boolean;
  74979. TEXTURE: boolean;
  74980. constructor();
  74981. }
  74982. /**
  74983. * Class used to render controls with fluent desgin
  74984. */
  74985. export class FluentMaterial extends BABYLON.PushMaterial {
  74986. /**
  74987. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74988. */
  74989. innerGlowColorIntensity: number;
  74990. /**
  74991. * Gets or sets the inner glow color (white by default)
  74992. */
  74993. innerGlowColor: BABYLON.Color3;
  74994. /**
  74995. * Gets or sets alpha value (default is 1.0)
  74996. */
  74997. alpha: number;
  74998. /**
  74999. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  75000. */
  75001. albedoColor: BABYLON.Color3;
  75002. /**
  75003. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  75004. */
  75005. renderBorders: boolean;
  75006. /**
  75007. * Gets or sets border width (default is 0.5)
  75008. */
  75009. borderWidth: number;
  75010. /**
  75011. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  75012. */
  75013. edgeSmoothingValue: number;
  75014. /**
  75015. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  75016. */
  75017. borderMinValue: number;
  75018. /**
  75019. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  75020. */
  75021. renderHoverLight: boolean;
  75022. /**
  75023. * Gets or sets the radius used to render the hover light (default is 1.0)
  75024. */
  75025. hoverRadius: number;
  75026. /**
  75027. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  75028. */
  75029. hoverColor: BABYLON.Color4;
  75030. /**
  75031. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  75032. */
  75033. hoverPosition: BABYLON.Vector3;
  75034. private _albedoTexture;
  75035. /** Gets or sets the texture to use for albedo color */
  75036. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  75037. /**
  75038. * Creates a new Fluent material
  75039. * @param name defines the name of the material
  75040. * @param scene defines the hosting scene
  75041. */
  75042. constructor(name: string, scene: BABYLON.Scene);
  75043. needAlphaBlending(): boolean;
  75044. needAlphaTesting(): boolean;
  75045. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  75046. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  75047. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  75048. getActiveTextures(): BABYLON.BaseTexture[];
  75049. hasTexture(texture: BABYLON.BaseTexture): boolean;
  75050. dispose(forceDisposeEffect?: boolean): void;
  75051. clone(name: string): FluentMaterial;
  75052. serialize(): any;
  75053. getClassName(): string;
  75054. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  75055. }
  75056. }
  75057. declare module BABYLON.GUI {
  75058. /**
  75059. * Class used to create a holographic button in 3D
  75060. */
  75061. export class HolographicButton extends Button3D {
  75062. private _backPlate;
  75063. private _textPlate;
  75064. private _frontPlate;
  75065. private _text;
  75066. private _imageUrl;
  75067. private _shareMaterials;
  75068. private _frontMaterial;
  75069. private _backMaterial;
  75070. private _plateMaterial;
  75071. private _pickedPointObserver;
  75072. private _tooltipFade;
  75073. private _tooltipTextBlock;
  75074. private _tooltipTexture;
  75075. private _tooltipMesh;
  75076. private _tooltipHoverObserver;
  75077. private _tooltipOutObserver;
  75078. private _disposeTooltip;
  75079. /**
  75080. * Rendering ground id of all the mesh in the button
  75081. */
  75082. set renderingGroupId(id: number);
  75083. get renderingGroupId(): number;
  75084. /**
  75085. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  75086. */
  75087. set tooltipText(text: BABYLON.Nullable<string>);
  75088. get tooltipText(): BABYLON.Nullable<string>;
  75089. /**
  75090. * Gets or sets text for the button
  75091. */
  75092. get text(): string;
  75093. set text(value: string);
  75094. /**
  75095. * Gets or sets the image url for the button
  75096. */
  75097. get imageUrl(): string;
  75098. set imageUrl(value: string);
  75099. /**
  75100. * Gets the back material used by this button
  75101. */
  75102. get backMaterial(): FluentMaterial;
  75103. /**
  75104. * Gets the front material used by this button
  75105. */
  75106. get frontMaterial(): FluentMaterial;
  75107. /**
  75108. * Gets the plate material used by this button
  75109. */
  75110. get plateMaterial(): BABYLON.StandardMaterial;
  75111. /**
  75112. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  75113. */
  75114. get shareMaterials(): boolean;
  75115. /**
  75116. * Creates a new button
  75117. * @param name defines the control name
  75118. */
  75119. constructor(name?: string, shareMaterials?: boolean);
  75120. protected _getTypeName(): string;
  75121. private _rebuildContent;
  75122. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75123. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  75124. private _createBackMaterial;
  75125. private _createFrontMaterial;
  75126. private _createPlateMaterial;
  75127. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75128. /**
  75129. * Releases all associated resources
  75130. */
  75131. dispose(): void;
  75132. }
  75133. }
  75134. declare module BABYLON.GUI {
  75135. /**
  75136. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75137. */
  75138. export class MeshButton3D extends Button3D {
  75139. /** @hidden */
  75140. protected _currentMesh: BABYLON.Mesh;
  75141. /**
  75142. * Creates a new 3D button based on a mesh
  75143. * @param mesh mesh to become a 3D button
  75144. * @param name defines the control name
  75145. */
  75146. constructor(mesh: BABYLON.Mesh, name?: string);
  75147. protected _getTypeName(): string;
  75148. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75149. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75150. }
  75151. }
  75152. declare module BABYLON.GUI {
  75153. /**
  75154. * Class used to create a container panel deployed on the surface of a plane
  75155. */
  75156. export class PlanePanel extends VolumeBasedPanel {
  75157. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75158. }
  75159. }
  75160. declare module BABYLON.GUI {
  75161. /**
  75162. * Class used to create a container panel where items get randomized planar mapping
  75163. */
  75164. export class ScatterPanel extends VolumeBasedPanel {
  75165. private _iteration;
  75166. /**
  75167. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75168. */
  75169. get iteration(): BABYLON.float;
  75170. set iteration(value: BABYLON.float);
  75171. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75172. private _scatterMapping;
  75173. protected _finalProcessing(): void;
  75174. }
  75175. }
  75176. declare module BABYLON.GUI {
  75177. /**
  75178. * Class used to create a container panel deployed on the surface of a sphere
  75179. */
  75180. export class SpherePanel extends VolumeBasedPanel {
  75181. private _radius;
  75182. /**
  75183. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75184. */
  75185. get radius(): BABYLON.float;
  75186. set radius(value: BABYLON.float);
  75187. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75188. private _sphericalMapping;
  75189. }
  75190. }
  75191. declare module BABYLON.GUI {
  75192. /**
  75193. * Class used to create a stack panel in 3D on XY plane
  75194. */
  75195. export class StackPanel3D extends Container3D {
  75196. private _isVertical;
  75197. /**
  75198. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75199. */
  75200. get isVertical(): boolean;
  75201. set isVertical(value: boolean);
  75202. /**
  75203. * Gets or sets the distance between elements
  75204. */
  75205. margin: number;
  75206. /**
  75207. * Creates new StackPanel
  75208. * @param isVertical
  75209. */
  75210. constructor(isVertical?: boolean);
  75211. protected _arrangeChildren(): void;
  75212. }
  75213. }
  75214. declare module BABYLON {
  75215. /**
  75216. * Configuration for glTF validation
  75217. */
  75218. export interface IGLTFValidationConfiguration {
  75219. /**
  75220. * The url of the glTF validator.
  75221. */
  75222. url: string;
  75223. }
  75224. /**
  75225. * glTF validation
  75226. */
  75227. export class GLTFValidation {
  75228. /**
  75229. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75230. */
  75231. static Configuration: IGLTFValidationConfiguration;
  75232. private static _LoadScriptPromise;
  75233. /**
  75234. * Validate a glTF asset using the glTF-Validator.
  75235. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75236. * @param rootUrl The root url for the glTF
  75237. * @param fileName The file name for the glTF
  75238. * @param getExternalResource The callback to get external resources for the glTF validator
  75239. * @returns A promise that resolves with the glTF validation results once complete
  75240. */
  75241. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75242. }
  75243. }
  75244. declare module BABYLON {
  75245. /**
  75246. * Mode that determines the coordinate system to use.
  75247. */
  75248. export enum GLTFLoaderCoordinateSystemMode {
  75249. /**
  75250. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75251. */
  75252. AUTO = 0,
  75253. /**
  75254. * Sets the useRightHandedSystem flag on the scene.
  75255. */
  75256. FORCE_RIGHT_HANDED = 1
  75257. }
  75258. /**
  75259. * Mode that determines what animations will start.
  75260. */
  75261. export enum GLTFLoaderAnimationStartMode {
  75262. /**
  75263. * No animation will start.
  75264. */
  75265. NONE = 0,
  75266. /**
  75267. * The first animation will start.
  75268. */
  75269. FIRST = 1,
  75270. /**
  75271. * All animations will start.
  75272. */
  75273. ALL = 2
  75274. }
  75275. /**
  75276. * Interface that contains the data for the glTF asset.
  75277. */
  75278. export interface IGLTFLoaderData {
  75279. /**
  75280. * The object that represents the glTF JSON.
  75281. */
  75282. json: Object;
  75283. /**
  75284. * The BIN chunk of a binary glTF.
  75285. */
  75286. bin: Nullable<IDataBuffer>;
  75287. }
  75288. /**
  75289. * Interface for extending the loader.
  75290. */
  75291. export interface IGLTFLoaderExtension {
  75292. /**
  75293. * The name of this extension.
  75294. */
  75295. readonly name: string;
  75296. /**
  75297. * Defines whether this extension is enabled.
  75298. */
  75299. enabled: boolean;
  75300. /**
  75301. * Defines the order of this extension.
  75302. * The loader sorts the extensions using these values when loading.
  75303. */
  75304. order?: number;
  75305. }
  75306. /**
  75307. * Loader state.
  75308. */
  75309. export enum GLTFLoaderState {
  75310. /**
  75311. * The asset is loading.
  75312. */
  75313. LOADING = 0,
  75314. /**
  75315. * The asset is ready for rendering.
  75316. */
  75317. READY = 1,
  75318. /**
  75319. * The asset is completely loaded.
  75320. */
  75321. COMPLETE = 2
  75322. }
  75323. /** @hidden */
  75324. export interface IImportMeshAsyncOutput {
  75325. meshes: AbstractMesh[];
  75326. particleSystems: IParticleSystem[];
  75327. skeletons: Skeleton[];
  75328. animationGroups: AnimationGroup[];
  75329. lights: Light[];
  75330. transformNodes: TransformNode[];
  75331. }
  75332. /** @hidden */
  75333. export interface IGLTFLoader extends IDisposable {
  75334. readonly state: Nullable<GLTFLoaderState>;
  75335. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75336. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75337. }
  75338. /**
  75339. * File loader for loading glTF files into a scene.
  75340. */
  75341. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75342. /** @hidden */
  75343. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75344. /** @hidden */
  75345. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75346. /**
  75347. * Raised when the asset has been parsed
  75348. */
  75349. onParsedObservable: Observable<IGLTFLoaderData>;
  75350. private _onParsedObserver;
  75351. /**
  75352. * Raised when the asset has been parsed
  75353. */
  75354. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75355. /**
  75356. * 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.
  75357. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75358. * Defaults to true.
  75359. * @hidden
  75360. */
  75361. static IncrementalLoading: boolean;
  75362. /**
  75363. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75364. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75365. * @hidden
  75366. */
  75367. static HomogeneousCoordinates: boolean;
  75368. /**
  75369. * The coordinate system mode. Defaults to AUTO.
  75370. */
  75371. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75372. /**
  75373. * The animation start mode. Defaults to FIRST.
  75374. */
  75375. animationStartMode: GLTFLoaderAnimationStartMode;
  75376. /**
  75377. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75378. */
  75379. compileMaterials: boolean;
  75380. /**
  75381. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75382. */
  75383. useClipPlane: boolean;
  75384. /**
  75385. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75386. */
  75387. compileShadowGenerators: boolean;
  75388. /**
  75389. * Defines if the Alpha blended materials are only applied as coverage.
  75390. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75391. * If true, no extra effects are applied to transparent pixels.
  75392. */
  75393. transparencyAsCoverage: boolean;
  75394. /**
  75395. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75396. * Enabling will disable offline support and glTF validator.
  75397. * Defaults to false.
  75398. */
  75399. useRangeRequests: boolean;
  75400. /**
  75401. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75402. */
  75403. createInstances: boolean;
  75404. /**
  75405. * Function called before loading a url referenced by the asset.
  75406. */
  75407. preprocessUrlAsync: (url: string) => Promise<string>;
  75408. /**
  75409. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75410. */
  75411. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75412. private _onMeshLoadedObserver;
  75413. /**
  75414. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75415. */
  75416. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75417. /**
  75418. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75419. */
  75420. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75421. private _onTextureLoadedObserver;
  75422. /**
  75423. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75424. */
  75425. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75426. /**
  75427. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75428. */
  75429. readonly onMaterialLoadedObservable: Observable<Material>;
  75430. private _onMaterialLoadedObserver;
  75431. /**
  75432. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75433. */
  75434. set onMaterialLoaded(callback: (material: Material) => void);
  75435. /**
  75436. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75437. */
  75438. readonly onCameraLoadedObservable: Observable<Camera>;
  75439. private _onCameraLoadedObserver;
  75440. /**
  75441. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75442. */
  75443. set onCameraLoaded(callback: (camera: Camera) => void);
  75444. /**
  75445. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75446. * For assets with LODs, raised when all of the LODs are complete.
  75447. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75448. */
  75449. readonly onCompleteObservable: Observable<void>;
  75450. private _onCompleteObserver;
  75451. /**
  75452. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75453. * For assets with LODs, raised when all of the LODs are complete.
  75454. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75455. */
  75456. set onComplete(callback: () => void);
  75457. /**
  75458. * Observable raised when an error occurs.
  75459. */
  75460. readonly onErrorObservable: Observable<any>;
  75461. private _onErrorObserver;
  75462. /**
  75463. * Callback raised when an error occurs.
  75464. */
  75465. set onError(callback: (reason: any) => void);
  75466. /**
  75467. * Observable raised after the loader is disposed.
  75468. */
  75469. readonly onDisposeObservable: Observable<void>;
  75470. private _onDisposeObserver;
  75471. /**
  75472. * Callback raised after the loader is disposed.
  75473. */
  75474. set onDispose(callback: () => void);
  75475. /**
  75476. * Observable raised after a loader extension is created.
  75477. * Set additional options for a loader extension in this event.
  75478. */
  75479. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75480. private _onExtensionLoadedObserver;
  75481. /**
  75482. * Callback raised after a loader extension is created.
  75483. */
  75484. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75485. /**
  75486. * Defines if the loader logging is enabled.
  75487. */
  75488. get loggingEnabled(): boolean;
  75489. set loggingEnabled(value: boolean);
  75490. /**
  75491. * Defines if the loader should capture performance counters.
  75492. */
  75493. get capturePerformanceCounters(): boolean;
  75494. set capturePerformanceCounters(value: boolean);
  75495. /**
  75496. * Defines if the loader should validate the asset.
  75497. */
  75498. validate: boolean;
  75499. /**
  75500. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75501. */
  75502. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75503. private _onValidatedObserver;
  75504. /**
  75505. * Callback raised after a loader extension is created.
  75506. */
  75507. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75508. private _loader;
  75509. /**
  75510. * Name of the loader ("gltf")
  75511. */
  75512. name: string;
  75513. /** @hidden */
  75514. extensions: ISceneLoaderPluginExtensions;
  75515. /**
  75516. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75517. */
  75518. dispose(): void;
  75519. /** @hidden */
  75520. _clear(): void;
  75521. /** @hidden */
  75522. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75523. /** @hidden */
  75524. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75525. /** @hidden */
  75526. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75527. meshes: AbstractMesh[];
  75528. particleSystems: IParticleSystem[];
  75529. skeletons: Skeleton[];
  75530. animationGroups: AnimationGroup[];
  75531. }>;
  75532. /** @hidden */
  75533. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75534. /** @hidden */
  75535. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75536. /** @hidden */
  75537. canDirectLoad(data: string): boolean;
  75538. /** @hidden */
  75539. directLoad(scene: Scene, data: string): any;
  75540. /**
  75541. * The callback that allows custom handling of the root url based on the response url.
  75542. * @param rootUrl the original root url
  75543. * @param responseURL the response url if available
  75544. * @returns the new root url
  75545. */
  75546. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75547. /** @hidden */
  75548. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75549. /**
  75550. * The loader state or null if the loader is not active.
  75551. */
  75552. get loaderState(): Nullable<GLTFLoaderState>;
  75553. /**
  75554. * Returns a promise that resolves when the asset is completely loaded.
  75555. * @returns a promise that resolves when the asset is completely loaded.
  75556. */
  75557. whenCompleteAsync(): Promise<void>;
  75558. private _validate;
  75559. private _getLoader;
  75560. private _parseJson;
  75561. private _unpackBinaryAsync;
  75562. private _unpackBinaryV1Async;
  75563. private _unpackBinaryV2Async;
  75564. private static _parseVersion;
  75565. private static _compareVersion;
  75566. private static readonly _logSpaces;
  75567. private _logIndentLevel;
  75568. private _loggingEnabled;
  75569. /** @hidden */
  75570. _log: (message: string) => void;
  75571. /** @hidden */
  75572. _logOpen(message: string): void;
  75573. /** @hidden */
  75574. _logClose(): void;
  75575. private _logEnabled;
  75576. private _logDisabled;
  75577. private _capturePerformanceCounters;
  75578. /** @hidden */
  75579. _startPerformanceCounter: (counterName: string) => void;
  75580. /** @hidden */
  75581. _endPerformanceCounter: (counterName: string) => void;
  75582. private _startPerformanceCounterEnabled;
  75583. private _startPerformanceCounterDisabled;
  75584. private _endPerformanceCounterEnabled;
  75585. private _endPerformanceCounterDisabled;
  75586. }
  75587. }
  75588. declare module BABYLON.GLTF1 {
  75589. /**
  75590. * Enums
  75591. * @hidden
  75592. */
  75593. export enum EComponentType {
  75594. BYTE = 5120,
  75595. UNSIGNED_BYTE = 5121,
  75596. SHORT = 5122,
  75597. UNSIGNED_SHORT = 5123,
  75598. FLOAT = 5126
  75599. }
  75600. /** @hidden */
  75601. export enum EShaderType {
  75602. FRAGMENT = 35632,
  75603. VERTEX = 35633
  75604. }
  75605. /** @hidden */
  75606. export enum EParameterType {
  75607. BYTE = 5120,
  75608. UNSIGNED_BYTE = 5121,
  75609. SHORT = 5122,
  75610. UNSIGNED_SHORT = 5123,
  75611. INT = 5124,
  75612. UNSIGNED_INT = 5125,
  75613. FLOAT = 5126,
  75614. FLOAT_VEC2 = 35664,
  75615. FLOAT_VEC3 = 35665,
  75616. FLOAT_VEC4 = 35666,
  75617. INT_VEC2 = 35667,
  75618. INT_VEC3 = 35668,
  75619. INT_VEC4 = 35669,
  75620. BOOL = 35670,
  75621. BOOL_VEC2 = 35671,
  75622. BOOL_VEC3 = 35672,
  75623. BOOL_VEC4 = 35673,
  75624. FLOAT_MAT2 = 35674,
  75625. FLOAT_MAT3 = 35675,
  75626. FLOAT_MAT4 = 35676,
  75627. SAMPLER_2D = 35678
  75628. }
  75629. /** @hidden */
  75630. export enum ETextureWrapMode {
  75631. CLAMP_TO_EDGE = 33071,
  75632. MIRRORED_REPEAT = 33648,
  75633. REPEAT = 10497
  75634. }
  75635. /** @hidden */
  75636. export enum ETextureFilterType {
  75637. NEAREST = 9728,
  75638. LINEAR = 9728,
  75639. NEAREST_MIPMAP_NEAREST = 9984,
  75640. LINEAR_MIPMAP_NEAREST = 9985,
  75641. NEAREST_MIPMAP_LINEAR = 9986,
  75642. LINEAR_MIPMAP_LINEAR = 9987
  75643. }
  75644. /** @hidden */
  75645. export enum ETextureFormat {
  75646. ALPHA = 6406,
  75647. RGB = 6407,
  75648. RGBA = 6408,
  75649. LUMINANCE = 6409,
  75650. LUMINANCE_ALPHA = 6410
  75651. }
  75652. /** @hidden */
  75653. export enum ECullingType {
  75654. FRONT = 1028,
  75655. BACK = 1029,
  75656. FRONT_AND_BACK = 1032
  75657. }
  75658. /** @hidden */
  75659. export enum EBlendingFunction {
  75660. ZERO = 0,
  75661. ONE = 1,
  75662. SRC_COLOR = 768,
  75663. ONE_MINUS_SRC_COLOR = 769,
  75664. DST_COLOR = 774,
  75665. ONE_MINUS_DST_COLOR = 775,
  75666. SRC_ALPHA = 770,
  75667. ONE_MINUS_SRC_ALPHA = 771,
  75668. DST_ALPHA = 772,
  75669. ONE_MINUS_DST_ALPHA = 773,
  75670. CONSTANT_COLOR = 32769,
  75671. ONE_MINUS_CONSTANT_COLOR = 32770,
  75672. CONSTANT_ALPHA = 32771,
  75673. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75674. SRC_ALPHA_SATURATE = 776
  75675. }
  75676. /** @hidden */
  75677. export interface IGLTFProperty {
  75678. extensions?: {
  75679. [key: string]: any;
  75680. };
  75681. extras?: Object;
  75682. }
  75683. /** @hidden */
  75684. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75685. name?: string;
  75686. }
  75687. /** @hidden */
  75688. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75689. bufferView: string;
  75690. byteOffset: number;
  75691. byteStride: number;
  75692. count: number;
  75693. type: string;
  75694. componentType: EComponentType;
  75695. max?: number[];
  75696. min?: number[];
  75697. name?: string;
  75698. }
  75699. /** @hidden */
  75700. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75701. buffer: string;
  75702. byteOffset: number;
  75703. byteLength: number;
  75704. byteStride: number;
  75705. target?: number;
  75706. }
  75707. /** @hidden */
  75708. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75709. uri: string;
  75710. byteLength?: number;
  75711. type?: string;
  75712. }
  75713. /** @hidden */
  75714. export interface IGLTFShader extends IGLTFChildRootProperty {
  75715. uri: string;
  75716. type: EShaderType;
  75717. }
  75718. /** @hidden */
  75719. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75720. attributes: string[];
  75721. fragmentShader: string;
  75722. vertexShader: string;
  75723. }
  75724. /** @hidden */
  75725. export interface IGLTFTechniqueParameter {
  75726. type: number;
  75727. count?: number;
  75728. semantic?: string;
  75729. node?: string;
  75730. value?: number | boolean | string | Array<any>;
  75731. source?: string;
  75732. babylonValue?: any;
  75733. }
  75734. /** @hidden */
  75735. export interface IGLTFTechniqueCommonProfile {
  75736. lightingModel: string;
  75737. texcoordBindings: Object;
  75738. parameters?: Array<any>;
  75739. }
  75740. /** @hidden */
  75741. export interface IGLTFTechniqueStatesFunctions {
  75742. blendColor?: number[];
  75743. blendEquationSeparate?: number[];
  75744. blendFuncSeparate?: number[];
  75745. colorMask: boolean[];
  75746. cullFace: number[];
  75747. }
  75748. /** @hidden */
  75749. export interface IGLTFTechniqueStates {
  75750. enable: number[];
  75751. functions: IGLTFTechniqueStatesFunctions;
  75752. }
  75753. /** @hidden */
  75754. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75755. parameters: {
  75756. [key: string]: IGLTFTechniqueParameter;
  75757. };
  75758. program: string;
  75759. attributes: {
  75760. [key: string]: string;
  75761. };
  75762. uniforms: {
  75763. [key: string]: string;
  75764. };
  75765. states: IGLTFTechniqueStates;
  75766. }
  75767. /** @hidden */
  75768. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75769. technique?: string;
  75770. values: string[];
  75771. }
  75772. /** @hidden */
  75773. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75774. attributes: {
  75775. [key: string]: string;
  75776. };
  75777. indices: string;
  75778. material: string;
  75779. mode?: number;
  75780. }
  75781. /** @hidden */
  75782. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75783. primitives: IGLTFMeshPrimitive[];
  75784. }
  75785. /** @hidden */
  75786. export interface IGLTFImage extends IGLTFChildRootProperty {
  75787. uri: string;
  75788. }
  75789. /** @hidden */
  75790. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75791. magFilter?: number;
  75792. minFilter?: number;
  75793. wrapS?: number;
  75794. wrapT?: number;
  75795. }
  75796. /** @hidden */
  75797. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75798. sampler: string;
  75799. source: string;
  75800. format?: ETextureFormat;
  75801. internalFormat?: ETextureFormat;
  75802. target?: number;
  75803. type?: number;
  75804. babylonTexture?: Texture;
  75805. }
  75806. /** @hidden */
  75807. export interface IGLTFAmbienLight {
  75808. color?: number[];
  75809. }
  75810. /** @hidden */
  75811. export interface IGLTFDirectionalLight {
  75812. color?: number[];
  75813. }
  75814. /** @hidden */
  75815. export interface IGLTFPointLight {
  75816. color?: number[];
  75817. constantAttenuation?: number;
  75818. linearAttenuation?: number;
  75819. quadraticAttenuation?: number;
  75820. }
  75821. /** @hidden */
  75822. export interface IGLTFSpotLight {
  75823. color?: number[];
  75824. constantAttenuation?: number;
  75825. fallOfAngle?: number;
  75826. fallOffExponent?: number;
  75827. linearAttenuation?: number;
  75828. quadraticAttenuation?: number;
  75829. }
  75830. /** @hidden */
  75831. export interface IGLTFLight extends IGLTFChildRootProperty {
  75832. type: string;
  75833. }
  75834. /** @hidden */
  75835. export interface IGLTFCameraOrthographic {
  75836. xmag: number;
  75837. ymag: number;
  75838. zfar: number;
  75839. znear: number;
  75840. }
  75841. /** @hidden */
  75842. export interface IGLTFCameraPerspective {
  75843. aspectRatio: number;
  75844. yfov: number;
  75845. zfar: number;
  75846. znear: number;
  75847. }
  75848. /** @hidden */
  75849. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75850. type: string;
  75851. }
  75852. /** @hidden */
  75853. export interface IGLTFAnimationChannelTarget {
  75854. id: string;
  75855. path: string;
  75856. }
  75857. /** @hidden */
  75858. export interface IGLTFAnimationChannel {
  75859. sampler: string;
  75860. target: IGLTFAnimationChannelTarget;
  75861. }
  75862. /** @hidden */
  75863. export interface IGLTFAnimationSampler {
  75864. input: string;
  75865. output: string;
  75866. interpolation?: string;
  75867. }
  75868. /** @hidden */
  75869. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75870. channels?: IGLTFAnimationChannel[];
  75871. parameters?: {
  75872. [key: string]: string;
  75873. };
  75874. samplers?: {
  75875. [key: string]: IGLTFAnimationSampler;
  75876. };
  75877. }
  75878. /** @hidden */
  75879. export interface IGLTFNodeInstanceSkin {
  75880. skeletons: string[];
  75881. skin: string;
  75882. meshes: string[];
  75883. }
  75884. /** @hidden */
  75885. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75886. bindShapeMatrix: number[];
  75887. inverseBindMatrices: string;
  75888. jointNames: string[];
  75889. babylonSkeleton?: Skeleton;
  75890. }
  75891. /** @hidden */
  75892. export interface IGLTFNode extends IGLTFChildRootProperty {
  75893. camera?: string;
  75894. children: string[];
  75895. skin?: string;
  75896. jointName?: string;
  75897. light?: string;
  75898. matrix: number[];
  75899. mesh?: string;
  75900. meshes?: string[];
  75901. rotation?: number[];
  75902. scale?: number[];
  75903. translation?: number[];
  75904. babylonNode?: Node;
  75905. }
  75906. /** @hidden */
  75907. export interface IGLTFScene extends IGLTFChildRootProperty {
  75908. nodes: string[];
  75909. }
  75910. /** @hidden */
  75911. export interface IGLTFRuntime {
  75912. extensions: {
  75913. [key: string]: any;
  75914. };
  75915. accessors: {
  75916. [key: string]: IGLTFAccessor;
  75917. };
  75918. buffers: {
  75919. [key: string]: IGLTFBuffer;
  75920. };
  75921. bufferViews: {
  75922. [key: string]: IGLTFBufferView;
  75923. };
  75924. meshes: {
  75925. [key: string]: IGLTFMesh;
  75926. };
  75927. lights: {
  75928. [key: string]: IGLTFLight;
  75929. };
  75930. cameras: {
  75931. [key: string]: IGLTFCamera;
  75932. };
  75933. nodes: {
  75934. [key: string]: IGLTFNode;
  75935. };
  75936. images: {
  75937. [key: string]: IGLTFImage;
  75938. };
  75939. textures: {
  75940. [key: string]: IGLTFTexture;
  75941. };
  75942. shaders: {
  75943. [key: string]: IGLTFShader;
  75944. };
  75945. programs: {
  75946. [key: string]: IGLTFProgram;
  75947. };
  75948. samplers: {
  75949. [key: string]: IGLTFSampler;
  75950. };
  75951. techniques: {
  75952. [key: string]: IGLTFTechnique;
  75953. };
  75954. materials: {
  75955. [key: string]: IGLTFMaterial;
  75956. };
  75957. animations: {
  75958. [key: string]: IGLTFAnimation;
  75959. };
  75960. skins: {
  75961. [key: string]: IGLTFSkins;
  75962. };
  75963. currentScene?: Object;
  75964. scenes: {
  75965. [key: string]: IGLTFScene;
  75966. };
  75967. extensionsUsed: string[];
  75968. extensionsRequired?: string[];
  75969. buffersCount: number;
  75970. shaderscount: number;
  75971. scene: Scene;
  75972. rootUrl: string;
  75973. loadedBufferCount: number;
  75974. loadedBufferViews: {
  75975. [name: string]: ArrayBufferView;
  75976. };
  75977. loadedShaderCount: number;
  75978. importOnlyMeshes: boolean;
  75979. importMeshesNames?: string[];
  75980. dummyNodes: Node[];
  75981. forAssetContainer: boolean;
  75982. }
  75983. /** @hidden */
  75984. export interface INodeToRoot {
  75985. bone: Bone;
  75986. node: IGLTFNode;
  75987. id: string;
  75988. }
  75989. /** @hidden */
  75990. export interface IJointNode {
  75991. node: IGLTFNode;
  75992. id: string;
  75993. }
  75994. }
  75995. declare module BABYLON.GLTF1 {
  75996. /**
  75997. * Utils functions for GLTF
  75998. * @hidden
  75999. */
  76000. export class GLTFUtils {
  76001. /**
  76002. * Sets the given "parameter" matrix
  76003. * @param scene: the Scene object
  76004. * @param source: the source node where to pick the matrix
  76005. * @param parameter: the GLTF technique parameter
  76006. * @param uniformName: the name of the shader's uniform
  76007. * @param shaderMaterial: the shader material
  76008. */
  76009. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  76010. /**
  76011. * Sets the given "parameter" matrix
  76012. * @param shaderMaterial: the shader material
  76013. * @param uniform: the name of the shader's uniform
  76014. * @param value: the value of the uniform
  76015. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  76016. */
  76017. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  76018. /**
  76019. * Returns the wrap mode of the texture
  76020. * @param mode: the mode value
  76021. */
  76022. static GetWrapMode(mode: number): number;
  76023. /**
  76024. * Returns the byte stride giving an accessor
  76025. * @param accessor: the GLTF accessor objet
  76026. */
  76027. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  76028. /**
  76029. * Returns the texture filter mode giving a mode value
  76030. * @param mode: the filter mode value
  76031. */
  76032. static GetTextureFilterMode(mode: number): ETextureFilterType;
  76033. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  76034. /**
  76035. * Returns a buffer from its accessor
  76036. * @param gltfRuntime: the GLTF runtime
  76037. * @param accessor: the GLTF accessor
  76038. */
  76039. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  76040. /**
  76041. * Decodes a buffer view into a string
  76042. * @param view: the buffer view
  76043. */
  76044. static DecodeBufferToText(view: ArrayBufferView): string;
  76045. /**
  76046. * Returns the default material of gltf. Related to
  76047. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  76048. * @param scene: the Babylon.js scene
  76049. */
  76050. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  76051. private static _DefaultMaterial;
  76052. }
  76053. }
  76054. declare module BABYLON.GLTF1 {
  76055. /**
  76056. * Implementation of the base glTF spec
  76057. * @hidden
  76058. */
  76059. export class GLTFLoaderBase {
  76060. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  76061. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76062. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  76063. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76064. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  76065. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76066. }
  76067. /**
  76068. * glTF V1 Loader
  76069. * @hidden
  76070. */
  76071. export class GLTFLoader implements IGLTFLoader {
  76072. static Extensions: {
  76073. [name: string]: GLTFLoaderExtension;
  76074. };
  76075. static RegisterExtension(extension: GLTFLoaderExtension): void;
  76076. state: Nullable<GLTFLoaderState>;
  76077. dispose(): void;
  76078. private _importMeshAsync;
  76079. /**
  76080. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  76081. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76082. * @param scene the scene the meshes should be added to
  76083. * @param forAssetContainer defines if the entities must be stored in the scene
  76084. * @param data gltf data containing information of the meshes in a loaded file
  76085. * @param rootUrl root url to load from
  76086. * @param onProgress event that fires when loading progress has occured
  76087. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76088. */
  76089. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  76090. private _loadAsync;
  76091. /**
  76092. * Imports all objects from a loaded gltf file and adds them to the scene
  76093. * @param scene the scene the objects should be added to
  76094. * @param data gltf data containing information of the meshes in a loaded file
  76095. * @param rootUrl root url to load from
  76096. * @param onProgress event that fires when loading progress has occured
  76097. * @returns a promise which completes when objects have been loaded to the scene
  76098. */
  76099. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  76100. private _loadShadersAsync;
  76101. private _loadBuffersAsync;
  76102. private _createNodes;
  76103. }
  76104. /** @hidden */
  76105. export abstract class GLTFLoaderExtension {
  76106. private _name;
  76107. constructor(name: string);
  76108. get name(): string;
  76109. /**
  76110. * Defines an override for loading the runtime
  76111. * Return true to stop further extensions from loading the runtime
  76112. */
  76113. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  76114. /**
  76115. * Defines an onverride for creating gltf runtime
  76116. * Return true to stop further extensions from creating the runtime
  76117. */
  76118. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  76119. /**
  76120. * Defines an override for loading buffers
  76121. * Return true to stop further extensions from loading this buffer
  76122. */
  76123. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  76124. /**
  76125. * Defines an override for loading texture buffers
  76126. * Return true to stop further extensions from loading this texture data
  76127. */
  76128. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76129. /**
  76130. * Defines an override for creating textures
  76131. * Return true to stop further extensions from loading this texture
  76132. */
  76133. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76134. /**
  76135. * Defines an override for loading shader strings
  76136. * Return true to stop further extensions from loading this shader data
  76137. */
  76138. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76139. /**
  76140. * Defines an override for loading materials
  76141. * Return true to stop further extensions from loading this material
  76142. */
  76143. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76144. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76145. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76146. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76147. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76148. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76149. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76150. private static LoadTextureBufferAsync;
  76151. private static CreateTextureAsync;
  76152. private static ApplyExtensions;
  76153. }
  76154. }
  76155. declare module BABYLON.GLTF1 {
  76156. /** @hidden */
  76157. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76158. private _bin;
  76159. constructor();
  76160. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76161. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76162. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76163. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76164. }
  76165. }
  76166. declare module BABYLON.GLTF1 {
  76167. /** @hidden */
  76168. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76169. constructor();
  76170. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76171. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76172. private _loadTexture;
  76173. }
  76174. }
  76175. declare module BABYLON.GLTF2.Loader {
  76176. /**
  76177. * Loader interface with an index field.
  76178. */
  76179. export interface IArrayItem {
  76180. /**
  76181. * The index of this item in the array.
  76182. */
  76183. index: number;
  76184. }
  76185. /**
  76186. * Loader interface with additional members.
  76187. */
  76188. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76189. /** @hidden */
  76190. _data?: Promise<ArrayBufferView>;
  76191. /** @hidden */
  76192. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76193. }
  76194. /**
  76195. * Loader interface with additional members.
  76196. */
  76197. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76198. }
  76199. /** @hidden */
  76200. export interface _IAnimationSamplerData {
  76201. input: Float32Array;
  76202. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76203. output: Float32Array;
  76204. }
  76205. /**
  76206. * Loader interface with additional members.
  76207. */
  76208. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76209. /** @hidden */
  76210. _data?: Promise<_IAnimationSamplerData>;
  76211. }
  76212. /**
  76213. * Loader interface with additional members.
  76214. */
  76215. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76216. channels: IAnimationChannel[];
  76217. samplers: IAnimationSampler[];
  76218. /** @hidden */
  76219. _babylonAnimationGroup?: AnimationGroup;
  76220. }
  76221. /**
  76222. * Loader interface with additional members.
  76223. */
  76224. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76225. /** @hidden */
  76226. _data?: Promise<ArrayBufferView>;
  76227. }
  76228. /**
  76229. * Loader interface with additional members.
  76230. */
  76231. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76232. /** @hidden */
  76233. _data?: Promise<ArrayBufferView>;
  76234. /** @hidden */
  76235. _babylonBuffer?: Promise<Buffer>;
  76236. }
  76237. /**
  76238. * Loader interface with additional members.
  76239. */
  76240. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76241. }
  76242. /**
  76243. * Loader interface with additional members.
  76244. */
  76245. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76246. /** @hidden */
  76247. _data?: Promise<ArrayBufferView>;
  76248. }
  76249. /**
  76250. * Loader interface with additional members.
  76251. */
  76252. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76253. }
  76254. /**
  76255. * Loader interface with additional members.
  76256. */
  76257. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76258. }
  76259. /**
  76260. * Loader interface with additional members.
  76261. */
  76262. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76263. baseColorTexture?: ITextureInfo;
  76264. metallicRoughnessTexture?: ITextureInfo;
  76265. }
  76266. /**
  76267. * Loader interface with additional members.
  76268. */
  76269. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76270. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76271. normalTexture?: IMaterialNormalTextureInfo;
  76272. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76273. emissiveTexture?: ITextureInfo;
  76274. /** @hidden */
  76275. _data?: {
  76276. [babylonDrawMode: number]: {
  76277. babylonMaterial: Material;
  76278. babylonMeshes: AbstractMesh[];
  76279. promise: Promise<void>;
  76280. };
  76281. };
  76282. }
  76283. /**
  76284. * Loader interface with additional members.
  76285. */
  76286. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76287. primitives: IMeshPrimitive[];
  76288. }
  76289. /**
  76290. * Loader interface with additional members.
  76291. */
  76292. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76293. /** @hidden */
  76294. _instanceData?: {
  76295. babylonSourceMesh: Mesh;
  76296. promise: Promise<any>;
  76297. };
  76298. }
  76299. /**
  76300. * Loader interface with additional members.
  76301. */
  76302. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76303. /**
  76304. * The parent glTF node.
  76305. */
  76306. parent?: INode;
  76307. /** @hidden */
  76308. _babylonTransformNode?: TransformNode;
  76309. /** @hidden */
  76310. _primitiveBabylonMeshes?: AbstractMesh[];
  76311. /** @hidden */
  76312. _babylonBones?: Bone[];
  76313. /** @hidden */
  76314. _numMorphTargets?: number;
  76315. }
  76316. /** @hidden */
  76317. export interface _ISamplerData {
  76318. noMipMaps: boolean;
  76319. samplingMode: number;
  76320. wrapU: number;
  76321. wrapV: number;
  76322. }
  76323. /**
  76324. * Loader interface with additional members.
  76325. */
  76326. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76327. /** @hidden */
  76328. _data?: _ISamplerData;
  76329. }
  76330. /**
  76331. * Loader interface with additional members.
  76332. */
  76333. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76334. }
  76335. /**
  76336. * Loader interface with additional members.
  76337. */
  76338. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76339. /** @hidden */
  76340. _data?: {
  76341. babylonSkeleton: Skeleton;
  76342. promise: Promise<void>;
  76343. };
  76344. }
  76345. /**
  76346. * Loader interface with additional members.
  76347. */
  76348. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76349. }
  76350. /**
  76351. * Loader interface with additional members.
  76352. */
  76353. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76354. }
  76355. /**
  76356. * Loader interface with additional members.
  76357. */
  76358. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76359. accessors?: IAccessor[];
  76360. animations?: IAnimation[];
  76361. buffers?: IBuffer[];
  76362. bufferViews?: IBufferView[];
  76363. cameras?: ICamera[];
  76364. images?: IImage[];
  76365. materials?: IMaterial[];
  76366. meshes?: IMesh[];
  76367. nodes?: INode[];
  76368. samplers?: ISampler[];
  76369. scenes?: IScene[];
  76370. skins?: ISkin[];
  76371. textures?: ITexture[];
  76372. }
  76373. }
  76374. declare module BABYLON.GLTF2 {
  76375. /**
  76376. * Interface for a glTF loader extension.
  76377. */
  76378. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76379. /**
  76380. * Called after the loader state changes to LOADING.
  76381. */
  76382. onLoading?(): void;
  76383. /**
  76384. * Called after the loader state changes to READY.
  76385. */
  76386. onReady?(): void;
  76387. /**
  76388. * Define this method to modify the default behavior when loading scenes.
  76389. * @param context The context when loading the asset
  76390. * @param scene The glTF scene property
  76391. * @returns A promise that resolves when the load is complete or null if not handled
  76392. */
  76393. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76394. /**
  76395. * Define this method to modify the default behavior when loading nodes.
  76396. * @param context The context when loading the asset
  76397. * @param node The glTF node property
  76398. * @param assign A function called synchronously after parsing the glTF properties
  76399. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76400. */
  76401. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76402. /**
  76403. * Define this method to modify the default behavior when loading cameras.
  76404. * @param context The context when loading the asset
  76405. * @param camera The glTF camera property
  76406. * @param assign A function called synchronously after parsing the glTF properties
  76407. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76408. */
  76409. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76410. /**
  76411. * @hidden
  76412. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76413. * @param context The context when loading the asset
  76414. * @param primitive The glTF mesh primitive property
  76415. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76416. */
  76417. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76418. /**
  76419. * @hidden
  76420. * Define this method to modify the default behavior when loading data for mesh primitives.
  76421. * @param context The context when loading the asset
  76422. * @param name The mesh name when loading the asset
  76423. * @param node The glTF node when loading the asset
  76424. * @param mesh The glTF mesh when loading the asset
  76425. * @param primitive The glTF mesh primitive property
  76426. * @param assign A function called synchronously after parsing the glTF properties
  76427. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76428. */
  76429. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76430. /**
  76431. * @hidden
  76432. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76433. * @param context The context when loading the asset
  76434. * @param material The glTF material property
  76435. * @param assign A function called synchronously after parsing the glTF properties
  76436. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76437. */
  76438. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76439. /**
  76440. * Define this method to modify the default behavior when creating materials.
  76441. * @param context The context when loading the asset
  76442. * @param material The glTF material property
  76443. * @param babylonDrawMode The draw mode for the Babylon material
  76444. * @returns The Babylon material or null if not handled
  76445. */
  76446. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76447. /**
  76448. * Define this method to modify the default behavior when loading material properties.
  76449. * @param context The context when loading the asset
  76450. * @param material The glTF material property
  76451. * @param babylonMaterial The Babylon material
  76452. * @returns A promise that resolves when the load is complete or null if not handled
  76453. */
  76454. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76455. /**
  76456. * Define this method to modify the default behavior when loading texture infos.
  76457. * @param context The context when loading the asset
  76458. * @param textureInfo The glTF texture info property
  76459. * @param assign A function called synchronously after parsing the glTF properties
  76460. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76461. */
  76462. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76463. /**
  76464. * @hidden
  76465. * Define this method to modify the default behavior when loading textures.
  76466. * @param context The context when loading the asset
  76467. * @param texture The glTF texture property
  76468. * @param assign A function called synchronously after parsing the glTF properties
  76469. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76470. */
  76471. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76472. /**
  76473. * Define this method to modify the default behavior when loading animations.
  76474. * @param context The context when loading the asset
  76475. * @param animation The glTF animation property
  76476. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76477. */
  76478. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76479. /**
  76480. * @hidden
  76481. * Define this method to modify the default behavior when loading skins.
  76482. * @param context The context when loading the asset
  76483. * @param node The glTF node property
  76484. * @param skin The glTF skin property
  76485. * @returns A promise that resolves when the load is complete or null if not handled
  76486. */
  76487. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76488. /**
  76489. * @hidden
  76490. * Define this method to modify the default behavior when loading uris.
  76491. * @param context The context when loading the asset
  76492. * @param property The glTF property associated with the uri
  76493. * @param uri The uri to load
  76494. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76495. */
  76496. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76497. /**
  76498. * Define this method to modify the default behavior when loading buffer views.
  76499. * @param context The context when loading the asset
  76500. * @param bufferView The glTF buffer view property
  76501. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76502. */
  76503. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76504. /**
  76505. * Define this method to modify the default behavior when loading buffers.
  76506. * @param context The context when loading the asset
  76507. * @param buffer The glTF buffer property
  76508. * @param byteOffset The byte offset to load
  76509. * @param byteLength The byte length to load
  76510. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76511. */
  76512. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76513. }
  76514. }
  76515. declare module BABYLON.GLTF2 {
  76516. /**
  76517. * Helper class for working with arrays when loading the glTF asset
  76518. */
  76519. export class ArrayItem {
  76520. /**
  76521. * Gets an item from the given array.
  76522. * @param context The context when loading the asset
  76523. * @param array The array to get the item from
  76524. * @param index The index to the array
  76525. * @returns The array item
  76526. */
  76527. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76528. /**
  76529. * Assign an `index` field to each item of the given array.
  76530. * @param array The array of items
  76531. */
  76532. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76533. }
  76534. /**
  76535. * The glTF 2.0 loader
  76536. */
  76537. export class GLTFLoader implements IGLTFLoader {
  76538. /** @hidden */
  76539. _completePromises: Promise<any>[];
  76540. /** @hidden */
  76541. _forAssetContainer: boolean;
  76542. /** Storage */
  76543. _babylonLights: Light[];
  76544. private _disposed;
  76545. private _parent;
  76546. private _state;
  76547. private _extensions;
  76548. private _rootUrl;
  76549. private _fileName;
  76550. private _uniqueRootUrl;
  76551. private _gltf;
  76552. private _bin;
  76553. private _babylonScene;
  76554. private _rootBabylonMesh;
  76555. private _defaultBabylonMaterialData;
  76556. private _progressCallback?;
  76557. private _requests;
  76558. private static _RegisteredExtensions;
  76559. /**
  76560. * The default glTF sampler.
  76561. */
  76562. static readonly DefaultSampler: ISampler;
  76563. /**
  76564. * Registers a loader extension.
  76565. * @param name The name of the loader extension.
  76566. * @param factory The factory function that creates the loader extension.
  76567. */
  76568. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76569. /**
  76570. * Unregisters a loader extension.
  76571. * @param name The name of the loader extension.
  76572. * @returns A boolean indicating whether the extension has been unregistered
  76573. */
  76574. static UnregisterExtension(name: string): boolean;
  76575. /**
  76576. * The loader state.
  76577. */
  76578. get state(): Nullable<GLTFLoaderState>;
  76579. /**
  76580. * The object that represents the glTF JSON.
  76581. */
  76582. get gltf(): IGLTF;
  76583. /**
  76584. * The BIN chunk of a binary glTF.
  76585. */
  76586. get bin(): Nullable<IDataBuffer>;
  76587. /**
  76588. * The parent file loader.
  76589. */
  76590. get parent(): GLTFFileLoader;
  76591. /**
  76592. * The Babylon scene when loading the asset.
  76593. */
  76594. get babylonScene(): Scene;
  76595. /**
  76596. * The root Babylon mesh when loading the asset.
  76597. */
  76598. get rootBabylonMesh(): Mesh;
  76599. /** @hidden */
  76600. constructor(parent: GLTFFileLoader);
  76601. /** @hidden */
  76602. dispose(): void;
  76603. /** @hidden */
  76604. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76605. /** @hidden */
  76606. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76607. private _loadAsync;
  76608. private _loadData;
  76609. private _setupData;
  76610. private _loadExtensions;
  76611. private _checkExtensions;
  76612. private _setState;
  76613. private _createRootNode;
  76614. /**
  76615. * Loads a glTF scene.
  76616. * @param context The context when loading the asset
  76617. * @param scene The glTF scene property
  76618. * @returns A promise that resolves when the load is complete
  76619. */
  76620. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76621. private _forEachPrimitive;
  76622. private _getMeshes;
  76623. private _getTransformNodes;
  76624. private _getSkeletons;
  76625. private _getAnimationGroups;
  76626. private _startAnimations;
  76627. /**
  76628. * Loads a glTF node.
  76629. * @param context The context when loading the asset
  76630. * @param node The glTF node property
  76631. * @param assign A function called synchronously after parsing the glTF properties
  76632. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76633. */
  76634. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76635. private _loadMeshAsync;
  76636. /**
  76637. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76638. * @param context The context when loading the asset
  76639. * @param name The mesh name when loading the asset
  76640. * @param node The glTF node when loading the asset
  76641. * @param mesh The glTF mesh when loading the asset
  76642. * @param primitive The glTF mesh primitive property
  76643. * @param assign A function called synchronously after parsing the glTF properties
  76644. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76645. */
  76646. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76647. private _loadVertexDataAsync;
  76648. private _createMorphTargets;
  76649. private _loadMorphTargetsAsync;
  76650. private _loadMorphTargetVertexDataAsync;
  76651. private static _LoadTransform;
  76652. private _loadSkinAsync;
  76653. private _loadBones;
  76654. private _loadBone;
  76655. private _loadSkinInverseBindMatricesDataAsync;
  76656. private _updateBoneMatrices;
  76657. private _getNodeMatrix;
  76658. /**
  76659. * Loads a glTF camera.
  76660. * @param context The context when loading the asset
  76661. * @param camera The glTF camera property
  76662. * @param assign A function called synchronously after parsing the glTF properties
  76663. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76664. */
  76665. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76666. private _loadAnimationsAsync;
  76667. /**
  76668. * Loads a glTF animation.
  76669. * @param context The context when loading the asset
  76670. * @param animation The glTF animation property
  76671. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76672. */
  76673. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76674. /**
  76675. * @hidden Loads a glTF animation channel.
  76676. * @param context The context when loading the asset
  76677. * @param animationContext The context of the animation when loading the asset
  76678. * @param animation The glTF animation property
  76679. * @param channel The glTF animation channel property
  76680. * @param babylonAnimationGroup The babylon animation group property
  76681. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76682. * @returns A void promise when the channel load is complete
  76683. */
  76684. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76685. private _loadAnimationSamplerAsync;
  76686. private _loadBufferAsync;
  76687. /**
  76688. * Loads a glTF buffer view.
  76689. * @param context The context when loading the asset
  76690. * @param bufferView The glTF buffer view property
  76691. * @returns A promise that resolves with the loaded data when the load is complete
  76692. */
  76693. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76694. private _loadAccessorAsync;
  76695. /** @hidden */
  76696. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76697. private _loadIndicesAccessorAsync;
  76698. private _loadVertexBufferViewAsync;
  76699. private _loadVertexAccessorAsync;
  76700. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76701. /** @hidden */
  76702. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76703. private _createDefaultMaterial;
  76704. /**
  76705. * Creates a Babylon material from a glTF material.
  76706. * @param context The context when loading the asset
  76707. * @param material The glTF material property
  76708. * @param babylonDrawMode The draw mode for the Babylon material
  76709. * @returns The Babylon material
  76710. */
  76711. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76712. /**
  76713. * Loads properties from a glTF material into a Babylon material.
  76714. * @param context The context when loading the asset
  76715. * @param material The glTF material property
  76716. * @param babylonMaterial The Babylon material
  76717. * @returns A promise that resolves when the load is complete
  76718. */
  76719. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76720. /**
  76721. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76722. * @param context The context when loading the asset
  76723. * @param material The glTF material property
  76724. * @param babylonMaterial The Babylon material
  76725. * @returns A promise that resolves when the load is complete
  76726. */
  76727. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76728. /**
  76729. * Loads the alpha properties from a glTF material into a Babylon material.
  76730. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76731. * @param context The context when loading the asset
  76732. * @param material The glTF material property
  76733. * @param babylonMaterial The Babylon material
  76734. */
  76735. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76736. /**
  76737. * Loads a glTF texture info.
  76738. * @param context The context when loading the asset
  76739. * @param textureInfo The glTF texture info property
  76740. * @param assign A function called synchronously after parsing the glTF properties
  76741. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76742. */
  76743. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76744. /** @hidden */
  76745. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76746. /** @hidden */
  76747. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76748. private _loadSampler;
  76749. /**
  76750. * Loads a glTF image.
  76751. * @param context The context when loading the asset
  76752. * @param image The glTF image property
  76753. * @returns A promise that resolves with the loaded data when the load is complete
  76754. */
  76755. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76756. /**
  76757. * Loads a glTF uri.
  76758. * @param context The context when loading the asset
  76759. * @param property The glTF property associated with the uri
  76760. * @param uri The base64 or relative uri
  76761. * @returns A promise that resolves with the loaded data when the load is complete
  76762. */
  76763. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76764. private _onProgress;
  76765. /**
  76766. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76767. * @param babylonObject the Babylon object with metadata
  76768. * @param pointer the JSON pointer
  76769. */
  76770. static AddPointerMetadata(babylonObject: {
  76771. metadata: any;
  76772. }, pointer: string): void;
  76773. private static _GetTextureWrapMode;
  76774. private static _GetTextureSamplingMode;
  76775. private static _GetTypedArrayConstructor;
  76776. private static _GetTypedArray;
  76777. private static _GetNumComponents;
  76778. private static _ValidateUri;
  76779. private static _GetDrawMode;
  76780. private _compileMaterialsAsync;
  76781. private _compileShadowGeneratorsAsync;
  76782. private _forEachExtensions;
  76783. private _applyExtensions;
  76784. private _extensionsOnLoading;
  76785. private _extensionsOnReady;
  76786. private _extensionsLoadSceneAsync;
  76787. private _extensionsLoadNodeAsync;
  76788. private _extensionsLoadCameraAsync;
  76789. private _extensionsLoadVertexDataAsync;
  76790. private _extensionsLoadMeshPrimitiveAsync;
  76791. private _extensionsLoadMaterialAsync;
  76792. private _extensionsCreateMaterial;
  76793. private _extensionsLoadMaterialPropertiesAsync;
  76794. private _extensionsLoadTextureInfoAsync;
  76795. private _extensionsLoadTextureAsync;
  76796. private _extensionsLoadAnimationAsync;
  76797. private _extensionsLoadSkinAsync;
  76798. private _extensionsLoadUriAsync;
  76799. private _extensionsLoadBufferViewAsync;
  76800. private _extensionsLoadBufferAsync;
  76801. /**
  76802. * Helper method called by a loader extension to load an glTF extension.
  76803. * @param context The context when loading the asset
  76804. * @param property The glTF property to load the extension from
  76805. * @param extensionName The name of the extension to load
  76806. * @param actionAsync The action to run
  76807. * @returns The promise returned by actionAsync or null if the extension does not exist
  76808. */
  76809. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76810. /**
  76811. * Helper method called by a loader extension to load a glTF extra.
  76812. * @param context The context when loading the asset
  76813. * @param property The glTF property to load the extra from
  76814. * @param extensionName The name of the extension to load
  76815. * @param actionAsync The action to run
  76816. * @returns The promise returned by actionAsync or null if the extra does not exist
  76817. */
  76818. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76819. /**
  76820. * Checks for presence of an extension.
  76821. * @param name The name of the extension to check
  76822. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76823. */
  76824. isExtensionUsed(name: string): boolean;
  76825. /**
  76826. * Increments the indentation level and logs a message.
  76827. * @param message The message to log
  76828. */
  76829. logOpen(message: string): void;
  76830. /**
  76831. * Decrements the indentation level.
  76832. */
  76833. logClose(): void;
  76834. /**
  76835. * Logs a message
  76836. * @param message The message to log
  76837. */
  76838. log(message: string): void;
  76839. /**
  76840. * Starts a performance counter.
  76841. * @param counterName The name of the performance counter
  76842. */
  76843. startPerformanceCounter(counterName: string): void;
  76844. /**
  76845. * Ends a performance counter.
  76846. * @param counterName The name of the performance counter
  76847. */
  76848. endPerformanceCounter(counterName: string): void;
  76849. }
  76850. }
  76851. declare module BABYLON.GLTF2.Loader.Extensions {
  76852. /**
  76853. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76854. */
  76855. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76856. /**
  76857. * The name of this extension.
  76858. */
  76859. readonly name: string;
  76860. /**
  76861. * Defines whether this extension is enabled.
  76862. */
  76863. enabled: boolean;
  76864. private _loader;
  76865. private _lights?;
  76866. /** @hidden */
  76867. constructor(loader: GLTFLoader);
  76868. /** @hidden */
  76869. dispose(): void;
  76870. /** @hidden */
  76871. onLoading(): void;
  76872. /** @hidden */
  76873. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76874. private _loadLightAsync;
  76875. }
  76876. }
  76877. declare module BABYLON.GLTF2.Loader.Extensions {
  76878. /**
  76879. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76880. */
  76881. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76882. /**
  76883. * The name of this extension.
  76884. */
  76885. readonly name: string;
  76886. /**
  76887. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76888. */
  76889. dracoCompression?: DracoCompression;
  76890. /**
  76891. * Defines whether this extension is enabled.
  76892. */
  76893. enabled: boolean;
  76894. private _loader;
  76895. /** @hidden */
  76896. constructor(loader: GLTFLoader);
  76897. /** @hidden */
  76898. dispose(): void;
  76899. /** @hidden */
  76900. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76901. }
  76902. }
  76903. declare module BABYLON.GLTF2.Loader.Extensions {
  76904. /**
  76905. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76906. */
  76907. export class KHR_lights implements IGLTFLoaderExtension {
  76908. /**
  76909. * The name of this extension.
  76910. */
  76911. readonly name: string;
  76912. /**
  76913. * Defines whether this extension is enabled.
  76914. */
  76915. enabled: boolean;
  76916. private _loader;
  76917. private _lights?;
  76918. /** @hidden */
  76919. constructor(loader: GLTFLoader);
  76920. /** @hidden */
  76921. dispose(): void;
  76922. /** @hidden */
  76923. onLoading(): void;
  76924. /** @hidden */
  76925. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76926. }
  76927. }
  76928. declare module BABYLON.GLTF2.Loader.Extensions {
  76929. /**
  76930. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76931. */
  76932. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76933. /**
  76934. * The name of this extension.
  76935. */
  76936. readonly name: string;
  76937. /**
  76938. * Defines whether this extension is enabled.
  76939. */
  76940. enabled: boolean;
  76941. /**
  76942. * Defines a number that determines the order the extensions are applied.
  76943. */
  76944. order: number;
  76945. private _loader;
  76946. /** @hidden */
  76947. constructor(loader: GLTFLoader);
  76948. /** @hidden */
  76949. dispose(): void;
  76950. /** @hidden */
  76951. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76952. private _loadSpecularGlossinessPropertiesAsync;
  76953. }
  76954. }
  76955. declare module BABYLON.GLTF2.Loader.Extensions {
  76956. /**
  76957. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76958. */
  76959. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76960. /**
  76961. * The name of this extension.
  76962. */
  76963. readonly name: string;
  76964. /**
  76965. * Defines whether this extension is enabled.
  76966. */
  76967. enabled: boolean;
  76968. /**
  76969. * Defines a number that determines the order the extensions are applied.
  76970. */
  76971. order: number;
  76972. private _loader;
  76973. /** @hidden */
  76974. constructor(loader: GLTFLoader);
  76975. /** @hidden */
  76976. dispose(): void;
  76977. /** @hidden */
  76978. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76979. private _loadUnlitPropertiesAsync;
  76980. }
  76981. }
  76982. declare module BABYLON.GLTF2.Loader.Extensions {
  76983. /**
  76984. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76985. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76986. * !!! Experimental Extension Subject to Changes !!!
  76987. */
  76988. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76989. /**
  76990. * The name of this extension.
  76991. */
  76992. readonly name: string;
  76993. /**
  76994. * Defines whether this extension is enabled.
  76995. */
  76996. enabled: boolean;
  76997. /**
  76998. * Defines a number that determines the order the extensions are applied.
  76999. */
  77000. order: number;
  77001. private _loader;
  77002. /** @hidden */
  77003. constructor(loader: GLTFLoader);
  77004. /** @hidden */
  77005. dispose(): void;
  77006. /** @hidden */
  77007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77008. private _loadClearCoatPropertiesAsync;
  77009. }
  77010. }
  77011. declare module BABYLON.GLTF2.Loader.Extensions {
  77012. /**
  77013. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  77014. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77015. * !!! Experimental Extension Subject to Changes !!!
  77016. */
  77017. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  77018. /**
  77019. * The name of this extension.
  77020. */
  77021. readonly name: string;
  77022. /**
  77023. * Defines whether this extension is enabled.
  77024. */
  77025. enabled: boolean;
  77026. /**
  77027. * Defines a number that determines the order the extensions are applied.
  77028. */
  77029. order: number;
  77030. private _loader;
  77031. /** @hidden */
  77032. constructor(loader: GLTFLoader);
  77033. /** @hidden */
  77034. dispose(): void;
  77035. /** @hidden */
  77036. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77037. private _loadSheenPropertiesAsync;
  77038. }
  77039. }
  77040. declare module BABYLON.GLTF2.Loader.Extensions {
  77041. /**
  77042. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  77043. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  77044. * !!! Experimental Extension Subject to Changes !!!
  77045. */
  77046. export class KHR_materials_specular implements IGLTFLoaderExtension {
  77047. /**
  77048. * The name of this extension.
  77049. */
  77050. readonly name: string;
  77051. /**
  77052. * Defines whether this extension is enabled.
  77053. */
  77054. enabled: boolean;
  77055. /**
  77056. * Defines a number that determines the order the extensions are applied.
  77057. */
  77058. order: number;
  77059. private _loader;
  77060. /** @hidden */
  77061. constructor(loader: GLTFLoader);
  77062. /** @hidden */
  77063. dispose(): void;
  77064. /** @hidden */
  77065. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77066. private _loadSpecularPropertiesAsync;
  77067. }
  77068. }
  77069. declare module BABYLON.GLTF2.Loader.Extensions {
  77070. /**
  77071. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  77072. * [Playground Sample](//TODO)
  77073. * !!! Experimental Extension Subject to Changes !!!
  77074. */
  77075. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  77076. /**
  77077. * The name of this extension.
  77078. */
  77079. readonly name: string;
  77080. /**
  77081. * Defines whether this extension is enabled.
  77082. */
  77083. enabled: boolean;
  77084. private _loader;
  77085. /** @hidden */
  77086. constructor(loader: GLTFLoader);
  77087. /** @hidden */
  77088. dispose(): void;
  77089. /** @hidden */
  77090. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77091. }
  77092. }
  77093. declare module BABYLON.GLTF2.Loader.Extensions {
  77094. /**
  77095. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  77096. */
  77097. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  77098. /**
  77099. * The name of this extension.
  77100. */
  77101. readonly name: string;
  77102. /**
  77103. * Defines whether this extension is enabled.
  77104. */
  77105. enabled: boolean;
  77106. /** @hidden */
  77107. constructor(loader: GLTFLoader);
  77108. /** @hidden */
  77109. dispose(): void;
  77110. }
  77111. }
  77112. declare module BABYLON.GLTF2.Loader.Extensions {
  77113. /**
  77114. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  77115. * !!! Experimental Extension Subject to Changes !!!
  77116. */
  77117. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  77118. /** The name of this extension. */
  77119. readonly name: string;
  77120. /** Defines whether this extension is enabled. */
  77121. enabled: boolean;
  77122. private _loader;
  77123. /** @hidden */
  77124. constructor(loader: GLTFLoader);
  77125. /** @hidden */
  77126. dispose(): void;
  77127. /** @hidden */
  77128. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77129. }
  77130. }
  77131. declare module BABYLON.GLTF2.Loader.Extensions {
  77132. /**
  77133. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77134. */
  77135. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77136. /**
  77137. * The name of this extension.
  77138. */
  77139. readonly name: string;
  77140. /**
  77141. * Defines whether this extension is enabled.
  77142. */
  77143. enabled: boolean;
  77144. private _loader;
  77145. /** @hidden */
  77146. constructor(loader: GLTFLoader);
  77147. /** @hidden */
  77148. dispose(): void;
  77149. /** @hidden */
  77150. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77151. }
  77152. }
  77153. declare module BABYLON.GLTF2.Loader.Extensions {
  77154. /**
  77155. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77156. */
  77157. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77158. /**
  77159. * The name of this extension.
  77160. */
  77161. readonly name: string;
  77162. /**
  77163. * Defines whether this extension is enabled.
  77164. */
  77165. enabled: boolean;
  77166. private _loader;
  77167. private _clips;
  77168. private _emitters;
  77169. /** @hidden */
  77170. constructor(loader: GLTFLoader);
  77171. /** @hidden */
  77172. dispose(): void;
  77173. /** @hidden */
  77174. onLoading(): void;
  77175. /** @hidden */
  77176. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77177. /** @hidden */
  77178. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77179. /** @hidden */
  77180. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77181. private _loadClipAsync;
  77182. private _loadEmitterAsync;
  77183. private _getEventAction;
  77184. private _loadAnimationEventAsync;
  77185. }
  77186. }
  77187. declare module BABYLON.GLTF2.Loader.Extensions {
  77188. /**
  77189. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77190. */
  77191. export class MSFT_lod implements IGLTFLoaderExtension {
  77192. /**
  77193. * The name of this extension.
  77194. */
  77195. readonly name: string;
  77196. /**
  77197. * Defines whether this extension is enabled.
  77198. */
  77199. enabled: boolean;
  77200. /**
  77201. * Defines a number that determines the order the extensions are applied.
  77202. */
  77203. order: number;
  77204. /**
  77205. * Maximum number of LODs to load, starting from the lowest LOD.
  77206. */
  77207. maxLODsToLoad: number;
  77208. /**
  77209. * Observable raised when all node LODs of one level are loaded.
  77210. * The event data is the index of the loaded LOD starting from zero.
  77211. * Dispose the loader to cancel the loading of the next level of LODs.
  77212. */
  77213. onNodeLODsLoadedObservable: Observable<number>;
  77214. /**
  77215. * Observable raised when all material LODs of one level are loaded.
  77216. * The event data is the index of the loaded LOD starting from zero.
  77217. * Dispose the loader to cancel the loading of the next level of LODs.
  77218. */
  77219. onMaterialLODsLoadedObservable: Observable<number>;
  77220. private _loader;
  77221. private _nodeIndexLOD;
  77222. private _nodeSignalLODs;
  77223. private _nodePromiseLODs;
  77224. private _materialIndexLOD;
  77225. private _materialSignalLODs;
  77226. private _materialPromiseLODs;
  77227. private _indexLOD;
  77228. private _bufferLODs;
  77229. /** @hidden */
  77230. constructor(loader: GLTFLoader);
  77231. /** @hidden */
  77232. dispose(): void;
  77233. /** @hidden */
  77234. onReady(): void;
  77235. /** @hidden */
  77236. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77237. /** @hidden */
  77238. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77239. /** @hidden */
  77240. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77241. /** @hidden */
  77242. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77243. /** @hidden */
  77244. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77245. private _loadBufferLOD;
  77246. /**
  77247. * Gets an array of LOD properties from lowest to highest.
  77248. */
  77249. private _getLODs;
  77250. private _disposeTransformNode;
  77251. private _disposeMaterials;
  77252. }
  77253. }
  77254. declare module BABYLON.GLTF2.Loader.Extensions {
  77255. /** @hidden */
  77256. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77257. readonly name: string;
  77258. enabled: boolean;
  77259. private _loader;
  77260. constructor(loader: GLTFLoader);
  77261. dispose(): void;
  77262. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77263. }
  77264. }
  77265. declare module BABYLON.GLTF2.Loader.Extensions {
  77266. /** @hidden */
  77267. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77268. readonly name: string;
  77269. enabled: boolean;
  77270. private _loader;
  77271. constructor(loader: GLTFLoader);
  77272. dispose(): void;
  77273. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77274. }
  77275. }
  77276. declare module BABYLON.GLTF2.Loader.Extensions {
  77277. /**
  77278. * Store glTF extras (if present) in BJS objects' metadata
  77279. */
  77280. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77281. /**
  77282. * The name of this extension.
  77283. */
  77284. readonly name: string;
  77285. /**
  77286. * Defines whether this extension is enabled.
  77287. */
  77288. enabled: boolean;
  77289. private _loader;
  77290. private _assignExtras;
  77291. /** @hidden */
  77292. constructor(loader: GLTFLoader);
  77293. /** @hidden */
  77294. dispose(): void;
  77295. /** @hidden */
  77296. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77297. /** @hidden */
  77298. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77299. /** @hidden */
  77300. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77301. }
  77302. }
  77303. declare module BABYLON {
  77304. /**
  77305. * Class reading and parsing the MTL file bundled with the obj file.
  77306. */
  77307. export class MTLFileLoader {
  77308. /**
  77309. * Invert Y-Axis of referenced textures on load
  77310. */
  77311. static INVERT_TEXTURE_Y: boolean;
  77312. /**
  77313. * All material loaded from the mtl will be set here
  77314. */
  77315. materials: StandardMaterial[];
  77316. /**
  77317. * This function will read the mtl file and create each material described inside
  77318. * This function could be improve by adding :
  77319. * -some component missing (Ni, Tf...)
  77320. * -including the specific options available
  77321. *
  77322. * @param scene defines the scene the material will be created in
  77323. * @param data defines the mtl data to parse
  77324. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77325. * @param forAssetContainer defines if the material should be registered in the scene
  77326. */
  77327. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77328. /**
  77329. * Gets the texture for the material.
  77330. *
  77331. * If the material is imported from input file,
  77332. * We sanitize the url to ensure it takes the textre from aside the material.
  77333. *
  77334. * @param rootUrl The root url to load from
  77335. * @param value The value stored in the mtl
  77336. * @return The Texture
  77337. */
  77338. private static _getTexture;
  77339. }
  77340. }
  77341. declare module BABYLON {
  77342. /**
  77343. * Options for loading OBJ/MTL files
  77344. */
  77345. type MeshLoadOptions = {
  77346. /**
  77347. * Defines if UVs are optimized by default during load.
  77348. */
  77349. OptimizeWithUV: boolean;
  77350. /**
  77351. * Defines custom scaling of UV coordinates of loaded meshes.
  77352. */
  77353. UVScaling: Vector2;
  77354. /**
  77355. * Invert model on y-axis (does a model scaling inversion)
  77356. */
  77357. InvertY: boolean;
  77358. /**
  77359. * Invert Y-Axis of referenced textures on load
  77360. */
  77361. InvertTextureY: boolean;
  77362. /**
  77363. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77364. */
  77365. ImportVertexColors: boolean;
  77366. /**
  77367. * Compute the normals for the model, even if normals are present in the file.
  77368. */
  77369. ComputeNormals: boolean;
  77370. /**
  77371. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77372. */
  77373. SkipMaterials: boolean;
  77374. /**
  77375. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77376. */
  77377. MaterialLoadingFailsSilently: boolean;
  77378. };
  77379. /**
  77380. * OBJ file type loader.
  77381. * This is a babylon scene loader plugin.
  77382. */
  77383. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77384. /**
  77385. * Defines if UVs are optimized by default during load.
  77386. */
  77387. static OPTIMIZE_WITH_UV: boolean;
  77388. /**
  77389. * Invert model on y-axis (does a model scaling inversion)
  77390. */
  77391. static INVERT_Y: boolean;
  77392. /**
  77393. * Invert Y-Axis of referenced textures on load
  77394. */
  77395. static get INVERT_TEXTURE_Y(): boolean;
  77396. static set INVERT_TEXTURE_Y(value: boolean);
  77397. /**
  77398. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77399. */
  77400. static IMPORT_VERTEX_COLORS: boolean;
  77401. /**
  77402. * Compute the normals for the model, even if normals are present in the file.
  77403. */
  77404. static COMPUTE_NORMALS: boolean;
  77405. /**
  77406. * Defines custom scaling of UV coordinates of loaded meshes.
  77407. */
  77408. static UV_SCALING: Vector2;
  77409. /**
  77410. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77411. */
  77412. static SKIP_MATERIALS: boolean;
  77413. /**
  77414. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77415. *
  77416. * Defaults to true for backwards compatibility.
  77417. */
  77418. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77419. /**
  77420. * Defines the name of the plugin.
  77421. */
  77422. name: string;
  77423. /**
  77424. * Defines the extension the plugin is able to load.
  77425. */
  77426. extensions: string;
  77427. /** @hidden */
  77428. obj: RegExp;
  77429. /** @hidden */
  77430. group: RegExp;
  77431. /** @hidden */
  77432. mtllib: RegExp;
  77433. /** @hidden */
  77434. usemtl: RegExp;
  77435. /** @hidden */
  77436. smooth: RegExp;
  77437. /** @hidden */
  77438. vertexPattern: RegExp;
  77439. /** @hidden */
  77440. normalPattern: RegExp;
  77441. /** @hidden */
  77442. uvPattern: RegExp;
  77443. /** @hidden */
  77444. facePattern1: RegExp;
  77445. /** @hidden */
  77446. facePattern2: RegExp;
  77447. /** @hidden */
  77448. facePattern3: RegExp;
  77449. /** @hidden */
  77450. facePattern4: RegExp;
  77451. /** @hidden */
  77452. facePattern5: RegExp;
  77453. private _forAssetContainer;
  77454. private _meshLoadOptions;
  77455. /**
  77456. * Creates loader for .OBJ files
  77457. *
  77458. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77459. */
  77460. constructor(meshLoadOptions?: MeshLoadOptions);
  77461. private static get currentMeshLoadOptions();
  77462. /**
  77463. * Calls synchronously the MTL file attached to this obj.
  77464. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77465. * Without this function materials are not displayed in the first frame (but displayed after).
  77466. * In consequence it is impossible to get material information in your HTML file
  77467. *
  77468. * @param url The URL of the MTL file
  77469. * @param rootUrl
  77470. * @param onSuccess Callback function to be called when the MTL file is loaded
  77471. * @private
  77472. */
  77473. private _loadMTL;
  77474. /**
  77475. * Instantiates a OBJ file loader plugin.
  77476. * @returns the created plugin
  77477. */
  77478. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77479. /**
  77480. * If the data string can be loaded directly.
  77481. *
  77482. * @param data string containing the file data
  77483. * @returns if the data can be loaded directly
  77484. */
  77485. canDirectLoad(data: string): boolean;
  77486. /**
  77487. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77488. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77489. * @param scene the scene the meshes should be added to
  77490. * @param data the OBJ data to load
  77491. * @param rootUrl root url to load from
  77492. * @param onProgress event that fires when loading progress has occured
  77493. * @param fileName Defines the name of the file to load
  77494. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77495. */
  77496. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77497. meshes: AbstractMesh[];
  77498. particleSystems: IParticleSystem[];
  77499. skeletons: Skeleton[];
  77500. animationGroups: AnimationGroup[];
  77501. }>;
  77502. /**
  77503. * Imports all objects from the loaded OBJ data and adds them to the scene
  77504. * @param scene the scene the objects should be added to
  77505. * @param data the OBJ data to load
  77506. * @param rootUrl root url to load from
  77507. * @param onProgress event that fires when loading progress has occured
  77508. * @param fileName Defines the name of the file to load
  77509. * @returns a promise which completes when objects have been loaded to the scene
  77510. */
  77511. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77512. /**
  77513. * Load into an asset container.
  77514. * @param scene The scene to load into
  77515. * @param data The data to import
  77516. * @param rootUrl The root url for scene and resources
  77517. * @param onProgress The callback when the load progresses
  77518. * @param fileName Defines the name of the file to load
  77519. * @returns The loaded asset container
  77520. */
  77521. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77522. /**
  77523. * Read the OBJ file and create an Array of meshes.
  77524. * Each mesh contains all information given by the OBJ and the MTL file.
  77525. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77526. *
  77527. * @param meshesNames
  77528. * @param scene Scene The scene where are displayed the data
  77529. * @param data String The content of the obj file
  77530. * @param rootUrl String The path to the folder
  77531. * @returns Array<AbstractMesh>
  77532. * @private
  77533. */
  77534. private _parseSolid;
  77535. }
  77536. }
  77537. declare module BABYLON {
  77538. /**
  77539. * STL file type loader.
  77540. * This is a babylon scene loader plugin.
  77541. */
  77542. export class STLFileLoader implements ISceneLoaderPlugin {
  77543. /** @hidden */
  77544. solidPattern: RegExp;
  77545. /** @hidden */
  77546. facetsPattern: RegExp;
  77547. /** @hidden */
  77548. normalPattern: RegExp;
  77549. /** @hidden */
  77550. vertexPattern: RegExp;
  77551. /**
  77552. * Defines the name of the plugin.
  77553. */
  77554. name: string;
  77555. /**
  77556. * Defines the extensions the stl loader is able to load.
  77557. * force data to come in as an ArrayBuffer
  77558. * we'll convert to string if it looks like it's an ASCII .stl
  77559. */
  77560. extensions: ISceneLoaderPluginExtensions;
  77561. /**
  77562. * Import meshes into a scene.
  77563. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77564. * @param scene The scene to import into
  77565. * @param data The data to import
  77566. * @param rootUrl The root url for scene and resources
  77567. * @param meshes The meshes array to import into
  77568. * @param particleSystems The particle systems array to import into
  77569. * @param skeletons The skeletons array to import into
  77570. * @param onError The callback when import fails
  77571. * @returns True if successful or false otherwise
  77572. */
  77573. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77574. /**
  77575. * Load into a scene.
  77576. * @param scene The scene to load into
  77577. * @param data The data to import
  77578. * @param rootUrl The root url for scene and resources
  77579. * @param onError The callback when import fails
  77580. * @returns true if successful or false otherwise
  77581. */
  77582. load(scene: Scene, data: any, rootUrl: string): boolean;
  77583. /**
  77584. * Load into an asset container.
  77585. * @param scene The scene to load into
  77586. * @param data The data to import
  77587. * @param rootUrl The root url for scene and resources
  77588. * @param onError The callback when import fails
  77589. * @returns The loaded asset container
  77590. */
  77591. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77592. private _isBinary;
  77593. private _parseBinary;
  77594. private _parseASCII;
  77595. }
  77596. }
  77597. declare module BABYLON {
  77598. /**
  77599. * Class for generating OBJ data from a Babylon scene.
  77600. */
  77601. export class OBJExport {
  77602. /**
  77603. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77604. * @param mesh defines the list of meshes to serialize
  77605. * @param materials defines if materials should be exported
  77606. * @param matlibname defines the name of the associated mtl file
  77607. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77608. * @returns the OBJ content
  77609. */
  77610. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77611. /**
  77612. * Exports the material(s) of a mesh in .MTL file format (text)
  77613. * @param mesh defines the mesh to extract the material from
  77614. * @returns the mtl content
  77615. */
  77616. static MTL(mesh: Mesh): string;
  77617. }
  77618. }
  77619. declare module BABYLON {
  77620. /** @hidden */
  77621. export var __IGLTFExporterExtension: number;
  77622. /**
  77623. * Interface for extending the exporter
  77624. * @hidden
  77625. */
  77626. export interface IGLTFExporterExtension {
  77627. /**
  77628. * The name of this extension
  77629. */
  77630. readonly name: string;
  77631. /**
  77632. * Defines whether this extension is enabled
  77633. */
  77634. enabled: boolean;
  77635. /**
  77636. * Defines whether this extension is required
  77637. */
  77638. required: boolean;
  77639. }
  77640. }
  77641. declare module BABYLON.GLTF2.Exporter {
  77642. /** @hidden */
  77643. export var __IGLTFExporterExtensionV2: number;
  77644. /**
  77645. * Interface for a glTF exporter extension
  77646. * @hidden
  77647. */
  77648. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77649. /**
  77650. * Define this method to modify the default behavior before exporting a texture
  77651. * @param context The context when loading the asset
  77652. * @param babylonTexture The Babylon.js texture
  77653. * @param mimeType The mime-type of the generated image
  77654. * @returns A promise that resolves with the exported texture
  77655. */
  77656. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77657. /**
  77658. * Define this method to get notified when a texture info is created
  77659. * @param context The context when loading the asset
  77660. * @param textureInfo The glTF texture info
  77661. * @param babylonTexture The Babylon.js texture
  77662. */
  77663. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77664. /**
  77665. * Define this method to modify the default behavior when exporting texture info
  77666. * @param context The context when loading the asset
  77667. * @param meshPrimitive glTF mesh primitive
  77668. * @param babylonSubMesh Babylon submesh
  77669. * @param binaryWriter glTF serializer binary writer instance
  77670. * @returns nullable IMeshPrimitive promise
  77671. */
  77672. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77673. /**
  77674. * Define this method to modify the default behavior when exporting a node
  77675. * @param context The context when exporting the node
  77676. * @param node glTF node
  77677. * @param babylonNode BabylonJS node
  77678. * @returns nullable INode promise
  77679. */
  77680. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77681. [key: number]: number;
  77682. }): Promise<Nullable<INode>>;
  77683. /**
  77684. * Define this method to modify the default behavior when exporting a material
  77685. * @param material glTF material
  77686. * @param babylonMaterial BabylonJS material
  77687. * @returns nullable IMaterial promise
  77688. */
  77689. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77690. /**
  77691. * Define this method to return additional textures to export from a material
  77692. * @param material glTF material
  77693. * @param babylonMaterial BabylonJS material
  77694. * @returns List of textures
  77695. */
  77696. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77697. /** Gets a boolean indicating that this extension was used */
  77698. wasUsed: boolean;
  77699. /** Gets a boolean indicating that this extension is required for the file to work */
  77700. required: boolean;
  77701. /**
  77702. * Called after the exporter state changes to EXPORTING
  77703. */
  77704. onExporting?(): void;
  77705. }
  77706. }
  77707. declare module BABYLON.GLTF2.Exporter {
  77708. /**
  77709. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77710. * @hidden
  77711. */
  77712. export class _GLTFMaterialExporter {
  77713. /**
  77714. * Represents the dielectric specular values for R, G and B
  77715. */
  77716. private static readonly _DielectricSpecular;
  77717. /**
  77718. * Allows the maximum specular power to be defined for material calculations
  77719. */
  77720. private static readonly _MaxSpecularPower;
  77721. /**
  77722. * Mapping to store textures
  77723. */
  77724. private _textureMap;
  77725. /**
  77726. * Numeric tolerance value
  77727. */
  77728. private static readonly _Epsilon;
  77729. /**
  77730. * Reference to the glTF Exporter
  77731. */
  77732. private _exporter;
  77733. constructor(exporter: _Exporter);
  77734. /**
  77735. * Specifies if two colors are approximately equal in value
  77736. * @param color1 first color to compare to
  77737. * @param color2 second color to compare to
  77738. * @param epsilon threshold value
  77739. */
  77740. private static FuzzyEquals;
  77741. /**
  77742. * Gets the materials from a Babylon scene and converts them to glTF materials
  77743. * @param scene babylonjs scene
  77744. * @param mimeType texture mime type
  77745. * @param images array of images
  77746. * @param textures array of textures
  77747. * @param materials array of materials
  77748. * @param imageData mapping of texture names to base64 textures
  77749. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77750. */
  77751. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77752. /**
  77753. * Makes a copy of the glTF material without the texture parameters
  77754. * @param originalMaterial original glTF material
  77755. * @returns glTF material without texture parameters
  77756. */
  77757. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77758. /**
  77759. * Specifies if the material has any texture parameters present
  77760. * @param material glTF Material
  77761. * @returns boolean specifying if texture parameters are present
  77762. */
  77763. _hasTexturesPresent(material: IMaterial): boolean;
  77764. /**
  77765. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77766. * @param babylonStandardMaterial
  77767. * @returns glTF Metallic Roughness Material representation
  77768. */
  77769. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77770. /**
  77771. * Computes the metallic factor
  77772. * @param diffuse diffused value
  77773. * @param specular specular value
  77774. * @param oneMinusSpecularStrength one minus the specular strength
  77775. * @returns metallic value
  77776. */
  77777. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77778. /**
  77779. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77780. * @param glTFMaterial glTF material
  77781. * @param babylonMaterial Babylon material
  77782. */
  77783. private static _SetAlphaMode;
  77784. /**
  77785. * Converts a Babylon Standard Material to a glTF Material
  77786. * @param babylonStandardMaterial BJS Standard Material
  77787. * @param mimeType mime type to use for the textures
  77788. * @param images array of glTF image interfaces
  77789. * @param textures array of glTF texture interfaces
  77790. * @param materials array of glTF material interfaces
  77791. * @param imageData map of image file name to data
  77792. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77793. */
  77794. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77795. private _finishMaterial;
  77796. /**
  77797. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77798. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77799. * @param mimeType mime type to use for the textures
  77800. * @param images array of glTF image interfaces
  77801. * @param textures array of glTF texture interfaces
  77802. * @param materials array of glTF material interfaces
  77803. * @param imageData map of image file name to data
  77804. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77805. */
  77806. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77807. /**
  77808. * Converts an image typed array buffer to a base64 image
  77809. * @param buffer typed array buffer
  77810. * @param width width of the image
  77811. * @param height height of the image
  77812. * @param mimeType mimetype of the image
  77813. * @returns base64 image string
  77814. */
  77815. private _createBase64FromCanvasAsync;
  77816. /**
  77817. * Generates a white texture based on the specified width and height
  77818. * @param width width of the texture in pixels
  77819. * @param height height of the texture in pixels
  77820. * @param scene babylonjs scene
  77821. * @returns white texture
  77822. */
  77823. private _createWhiteTexture;
  77824. /**
  77825. * 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
  77826. * @param texture1 first texture to resize
  77827. * @param texture2 second texture to resize
  77828. * @param scene babylonjs scene
  77829. * @returns resized textures or null
  77830. */
  77831. private _resizeTexturesToSameDimensions;
  77832. /**
  77833. * Converts an array of pixels to a Float32Array
  77834. * Throws an error if the pixel format is not supported
  77835. * @param pixels - array buffer containing pixel values
  77836. * @returns Float32 of pixels
  77837. */
  77838. private _convertPixelArrayToFloat32;
  77839. /**
  77840. * Convert Specular Glossiness Textures to Metallic Roughness
  77841. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77842. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77843. * @param diffuseTexture texture used to store diffuse information
  77844. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77845. * @param factors specular glossiness material factors
  77846. * @param mimeType the mime type to use for the texture
  77847. * @returns pbr metallic roughness interface or null
  77848. */
  77849. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77850. /**
  77851. * Converts specular glossiness material properties to metallic roughness
  77852. * @param specularGlossiness interface with specular glossiness material properties
  77853. * @returns interface with metallic roughness material properties
  77854. */
  77855. private _convertSpecularGlossinessToMetallicRoughness;
  77856. /**
  77857. * Calculates the surface reflectance, independent of lighting conditions
  77858. * @param color Color source to calculate brightness from
  77859. * @returns number representing the perceived brightness, or zero if color is undefined
  77860. */
  77861. private _getPerceivedBrightness;
  77862. /**
  77863. * Returns the maximum color component value
  77864. * @param color
  77865. * @returns maximum color component value, or zero if color is null or undefined
  77866. */
  77867. private _getMaxComponent;
  77868. /**
  77869. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77870. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77871. * @param mimeType mime type to use for the textures
  77872. * @param images array of glTF image interfaces
  77873. * @param textures array of glTF texture interfaces
  77874. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77875. * @param imageData map of image file name to data
  77876. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77877. * @returns glTF PBR Metallic Roughness factors
  77878. */
  77879. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77880. private _getGLTFTextureSampler;
  77881. private _getGLTFTextureWrapMode;
  77882. private _getGLTFTextureWrapModesSampler;
  77883. /**
  77884. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77885. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77886. * @param mimeType mime type to use for the textures
  77887. * @param images array of glTF image interfaces
  77888. * @param textures array of glTF texture interfaces
  77889. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77890. * @param imageData map of image file name to data
  77891. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77892. * @returns glTF PBR Metallic Roughness factors
  77893. */
  77894. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77895. /**
  77896. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77897. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77898. * @param mimeType mime type to use for the textures
  77899. * @param images array of glTF image interfaces
  77900. * @param textures array of glTF texture interfaces
  77901. * @param materials array of glTF material interfaces
  77902. * @param imageData map of image file name to data
  77903. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77904. */
  77905. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77906. private setMetallicRoughnessPbrMaterial;
  77907. private getPixelsFromTexture;
  77908. /**
  77909. * Extracts a texture from a Babylon texture into file data and glTF data
  77910. * @param babylonTexture Babylon texture to extract
  77911. * @param mimeType Mime Type of the babylonTexture
  77912. * @return glTF texture info, or null if the texture format is not supported
  77913. */
  77914. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77915. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77916. /**
  77917. * Builds a texture from base64 string
  77918. * @param base64Texture base64 texture string
  77919. * @param baseTextureName Name to use for the texture
  77920. * @param mimeType image mime type for the texture
  77921. * @param images array of images
  77922. * @param textures array of textures
  77923. * @param imageData map of image data
  77924. * @returns glTF texture info, or null if the texture format is not supported
  77925. */
  77926. private _getTextureInfoFromBase64;
  77927. }
  77928. }
  77929. declare module BABYLON {
  77930. /**
  77931. * Class for holding and downloading glTF file data
  77932. */
  77933. export class GLTFData {
  77934. /**
  77935. * Object which contains the file name as the key and its data as the value
  77936. */
  77937. glTFFiles: {
  77938. [fileName: string]: string | Blob;
  77939. };
  77940. /**
  77941. * Initializes the glTF file object
  77942. */
  77943. constructor();
  77944. /**
  77945. * Downloads the glTF data as files based on their names and data
  77946. */
  77947. downloadFiles(): void;
  77948. }
  77949. }
  77950. declare module BABYLON {
  77951. /**
  77952. * Holds a collection of exporter options and parameters
  77953. */
  77954. export interface IExportOptions {
  77955. /**
  77956. * Function which indicates whether a babylon node should be exported or not
  77957. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77958. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77959. */
  77960. shouldExportNode?(node: Node): boolean;
  77961. /**
  77962. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77963. * @param metadata source metadata to read from
  77964. * @returns the data to store to glTF node extras
  77965. */
  77966. metadataSelector?(metadata: any): any;
  77967. /**
  77968. * The sample rate to bake animation curves
  77969. */
  77970. animationSampleRate?: number;
  77971. /**
  77972. * Begin serialization without waiting for the scene to be ready
  77973. */
  77974. exportWithoutWaitingForScene?: boolean;
  77975. /**
  77976. * Indicates if coordinate system swapping root nodes should be included in export
  77977. */
  77978. includeCoordinateSystemConversionNodes?: boolean;
  77979. }
  77980. /**
  77981. * Class for generating glTF data from a Babylon scene.
  77982. */
  77983. export class GLTF2Export {
  77984. /**
  77985. * Exports the geometry of the scene to .gltf file format asynchronously
  77986. * @param scene Babylon scene with scene hierarchy information
  77987. * @param filePrefix File prefix to use when generating the glTF file
  77988. * @param options Exporter options
  77989. * @returns Returns an object with a .gltf file and associates texture names
  77990. * as keys and their data and paths as values
  77991. */
  77992. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77993. private static _PreExportAsync;
  77994. private static _PostExportAsync;
  77995. /**
  77996. * Exports the geometry of the scene to .glb file format asychronously
  77997. * @param scene Babylon scene with scene hierarchy information
  77998. * @param filePrefix File prefix to use when generating glb file
  77999. * @param options Exporter options
  78000. * @returns Returns an object with a .glb filename as key and data as value
  78001. */
  78002. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  78003. }
  78004. }
  78005. declare module BABYLON.GLTF2.Exporter {
  78006. /**
  78007. * @hidden
  78008. */
  78009. export class _GLTFUtilities {
  78010. /**
  78011. * Creates a buffer view based on the supplied arguments
  78012. * @param bufferIndex index value of the specified buffer
  78013. * @param byteOffset byte offset value
  78014. * @param byteLength byte length of the bufferView
  78015. * @param byteStride byte distance between conequential elements
  78016. * @param name name of the buffer view
  78017. * @returns bufferView for glTF
  78018. */
  78019. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  78020. /**
  78021. * Creates an accessor based on the supplied arguments
  78022. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  78023. * @param name The name of the accessor
  78024. * @param type The type of the accessor
  78025. * @param componentType The datatype of components in the attribute
  78026. * @param count The number of attributes referenced by this accessor
  78027. * @param byteOffset The offset relative to the start of the bufferView in bytes
  78028. * @param min Minimum value of each component in this attribute
  78029. * @param max Maximum value of each component in this attribute
  78030. * @returns accessor for glTF
  78031. */
  78032. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  78033. /**
  78034. * Calculates the minimum and maximum values of an array of position floats
  78035. * @param positions Positions array of a mesh
  78036. * @param vertexStart Starting vertex offset to calculate min and max values
  78037. * @param vertexCount Number of vertices to check for min and max values
  78038. * @returns min number array and max number array
  78039. */
  78040. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  78041. min: number[];
  78042. max: number[];
  78043. };
  78044. /**
  78045. * Converts a new right-handed Vector3
  78046. * @param vector vector3 array
  78047. * @returns right-handed Vector3
  78048. */
  78049. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  78050. /**
  78051. * Converts a Vector3 to right-handed
  78052. * @param vector Vector3 to convert to right-handed
  78053. */
  78054. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  78055. /**
  78056. * Converts a three element number array to right-handed
  78057. * @param vector number array to convert to right-handed
  78058. */
  78059. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  78060. /**
  78061. * Converts a new right-handed Vector3
  78062. * @param vector vector3 array
  78063. * @returns right-handed Vector3
  78064. */
  78065. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  78066. /**
  78067. * Converts a Vector3 to right-handed
  78068. * @param vector Vector3 to convert to right-handed
  78069. */
  78070. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  78071. /**
  78072. * Converts a three element number array to right-handed
  78073. * @param vector number array to convert to right-handed
  78074. */
  78075. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  78076. /**
  78077. * Converts a Vector4 to right-handed
  78078. * @param vector Vector4 to convert to right-handed
  78079. */
  78080. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  78081. /**
  78082. * Converts a Vector4 to right-handed
  78083. * @param vector Vector4 to convert to right-handed
  78084. */
  78085. static _GetRightHandedArray4FromRef(vector: number[]): void;
  78086. /**
  78087. * Converts a Quaternion to right-handed
  78088. * @param quaternion Source quaternion to convert to right-handed
  78089. */
  78090. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  78091. /**
  78092. * Converts a Quaternion to right-handed
  78093. * @param quaternion Source quaternion to convert to right-handed
  78094. */
  78095. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  78096. static _NormalizeTangentFromRef(tangent: Vector4): void;
  78097. }
  78098. }
  78099. declare module BABYLON.GLTF2.Exporter {
  78100. /**
  78101. * Converts Babylon Scene into glTF 2.0.
  78102. * @hidden
  78103. */
  78104. export class _Exporter {
  78105. /**
  78106. * Stores the glTF to export
  78107. */
  78108. _glTF: IGLTF;
  78109. /**
  78110. * Stores all generated buffer views, which represents views into the main glTF buffer data
  78111. */
  78112. _bufferViews: IBufferView[];
  78113. /**
  78114. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  78115. */
  78116. _accessors: IAccessor[];
  78117. /**
  78118. * Stores all the generated nodes, which contains transform and/or mesh information per node
  78119. */
  78120. _nodes: INode[];
  78121. /**
  78122. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  78123. */
  78124. private _scenes;
  78125. /**
  78126. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78127. */
  78128. private _meshes;
  78129. /**
  78130. * Stores all the generated material information, which represents the appearance of each primitive
  78131. */
  78132. _materials: IMaterial[];
  78133. _materialMap: {
  78134. [materialID: number]: number;
  78135. };
  78136. /**
  78137. * Stores all the generated texture information, which is referenced by glTF materials
  78138. */
  78139. _textures: ITexture[];
  78140. /**
  78141. * Stores all the generated image information, which is referenced by glTF textures
  78142. */
  78143. _images: IImage[];
  78144. /**
  78145. * Stores all the texture samplers
  78146. */
  78147. _samplers: ISampler[];
  78148. /**
  78149. * Stores all the generated animation samplers, which is referenced by glTF animations
  78150. */
  78151. /**
  78152. * Stores the animations for glTF models
  78153. */
  78154. private _animations;
  78155. /**
  78156. * Stores the total amount of bytes stored in the glTF buffer
  78157. */
  78158. private _totalByteLength;
  78159. /**
  78160. * Stores a reference to the Babylon scene containing the source geometry and material information
  78161. */
  78162. _babylonScene: Scene;
  78163. /**
  78164. * Stores a map of the image data, where the key is the file name and the value
  78165. * is the image data
  78166. */
  78167. _imageData: {
  78168. [fileName: string]: {
  78169. data: Uint8Array;
  78170. mimeType: ImageMimeType;
  78171. };
  78172. };
  78173. /**
  78174. * Stores a map of the unique id of a node to its index in the node array
  78175. */
  78176. _nodeMap: {
  78177. [key: number]: number;
  78178. };
  78179. /**
  78180. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78181. */
  78182. _convertToRightHandedSystem: boolean;
  78183. /**
  78184. * Specifies if a Babylon node should be converted to right-handed on export
  78185. */
  78186. _convertToRightHandedSystemMap: {
  78187. [nodeId: number]: boolean;
  78188. };
  78189. _includeCoordinateSystemConversionNodes: boolean;
  78190. /**
  78191. * Baked animation sample rate
  78192. */
  78193. private _animationSampleRate;
  78194. private _options;
  78195. private _localEngine;
  78196. _glTFMaterialExporter: _GLTFMaterialExporter;
  78197. private _extensions;
  78198. private static _ExtensionNames;
  78199. private static _ExtensionFactories;
  78200. private _applyExtension;
  78201. private _applyExtensions;
  78202. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78203. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78204. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78205. [key: number]: number;
  78206. }): Promise<Nullable<INode>>;
  78207. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78208. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78209. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78210. private _forEachExtensions;
  78211. private _extensionsOnExporting;
  78212. /**
  78213. * Load glTF serializer extensions
  78214. */
  78215. private _loadExtensions;
  78216. /**
  78217. * Creates a glTF Exporter instance, which can accept optional exporter options
  78218. * @param babylonScene Babylon scene object
  78219. * @param options Options to modify the behavior of the exporter
  78220. */
  78221. constructor(babylonScene: Scene, options?: IExportOptions);
  78222. dispose(): void;
  78223. /**
  78224. * Registers a glTF exporter extension
  78225. * @param name Name of the extension to export
  78226. * @param factory The factory function that creates the exporter extension
  78227. */
  78228. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78229. /**
  78230. * Un-registers an exporter extension
  78231. * @param name The name fo the exporter extension
  78232. * @returns A boolean indicating whether the extension has been un-registered
  78233. */
  78234. static UnregisterExtension(name: string): boolean;
  78235. /**
  78236. * Lazy load a local engine
  78237. */
  78238. _getLocalEngine(): Engine;
  78239. private reorderIndicesBasedOnPrimitiveMode;
  78240. /**
  78241. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78242. * clock-wise during export to glTF
  78243. * @param submesh BabylonJS submesh
  78244. * @param primitiveMode Primitive mode of the mesh
  78245. * @param sideOrientation the winding order of the submesh
  78246. * @param vertexBufferKind The type of vertex attribute
  78247. * @param meshAttributeArray The vertex attribute data
  78248. * @param byteOffset The offset to the binary data
  78249. * @param binaryWriter The binary data for the glTF file
  78250. * @param convertToRightHandedSystem Converts the values to right-handed
  78251. */
  78252. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78253. /**
  78254. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78255. * clock-wise during export to glTF
  78256. * @param submesh BabylonJS submesh
  78257. * @param primitiveMode Primitive mode of the mesh
  78258. * @param sideOrientation the winding order of the submesh
  78259. * @param vertexBufferKind The type of vertex attribute
  78260. * @param meshAttributeArray The vertex attribute data
  78261. * @param byteOffset The offset to the binary data
  78262. * @param binaryWriter The binary data for the glTF file
  78263. * @param convertToRightHandedSystem Converts the values to right-handed
  78264. */
  78265. private reorderTriangleFillMode;
  78266. /**
  78267. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78268. * clock-wise during export to glTF
  78269. * @param submesh BabylonJS submesh
  78270. * @param primitiveMode Primitive mode of the mesh
  78271. * @param sideOrientation the winding order of the submesh
  78272. * @param vertexBufferKind The type of vertex attribute
  78273. * @param meshAttributeArray The vertex attribute data
  78274. * @param byteOffset The offset to the binary data
  78275. * @param binaryWriter The binary data for the glTF file
  78276. * @param convertToRightHandedSystem Converts the values to right-handed
  78277. */
  78278. private reorderTriangleStripDrawMode;
  78279. /**
  78280. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78281. * clock-wise during export to glTF
  78282. * @param submesh BabylonJS submesh
  78283. * @param primitiveMode Primitive mode of the mesh
  78284. * @param sideOrientation the winding order of the submesh
  78285. * @param vertexBufferKind The type of vertex attribute
  78286. * @param meshAttributeArray The vertex attribute data
  78287. * @param byteOffset The offset to the binary data
  78288. * @param binaryWriter The binary data for the glTF file
  78289. * @param convertToRightHandedSystem Converts the values to right-handed
  78290. */
  78291. private reorderTriangleFanMode;
  78292. /**
  78293. * Writes the vertex attribute data to binary
  78294. * @param vertices The vertices to write to the binary writer
  78295. * @param byteOffset The offset into the binary writer to overwrite binary data
  78296. * @param vertexAttributeKind The vertex attribute type
  78297. * @param meshAttributeArray The vertex attribute data
  78298. * @param binaryWriter The writer containing the binary data
  78299. * @param convertToRightHandedSystem Converts the values to right-handed
  78300. */
  78301. private writeVertexAttributeData;
  78302. /**
  78303. * Writes mesh attribute data to a data buffer
  78304. * Returns the bytelength of the data
  78305. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78306. * @param meshAttributeArray Array containing the attribute data
  78307. * @param binaryWriter The buffer to write the binary data to
  78308. * @param indices Used to specify the order of the vertex data
  78309. * @param convertToRightHandedSystem Converts the values to right-handed
  78310. */
  78311. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78312. /**
  78313. * Generates glTF json data
  78314. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78315. * @param glTFPrefix Text to use when prefixing a glTF file
  78316. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78317. * @returns json data as string
  78318. */
  78319. private generateJSON;
  78320. /**
  78321. * Generates data for .gltf and .bin files based on the glTF prefix string
  78322. * @param glTFPrefix Text to use when prefixing a glTF file
  78323. * @param dispose Dispose the exporter
  78324. * @returns GLTFData with glTF file data
  78325. */
  78326. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78327. /**
  78328. * Creates a binary buffer for glTF
  78329. * @returns array buffer for binary data
  78330. */
  78331. private _generateBinaryAsync;
  78332. /**
  78333. * Pads the number to a multiple of 4
  78334. * @param num number to pad
  78335. * @returns padded number
  78336. */
  78337. private _getPadding;
  78338. /**
  78339. * @hidden
  78340. */
  78341. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78342. /**
  78343. * Sets the TRS for each node
  78344. * @param node glTF Node for storing the transformation data
  78345. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78346. * @param convertToRightHandedSystem Converts the values to right-handed
  78347. */
  78348. private setNodeTransformation;
  78349. private getVertexBufferFromMesh;
  78350. /**
  78351. * Creates a bufferview based on the vertices type for the Babylon mesh
  78352. * @param kind Indicates the type of vertices data
  78353. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78354. * @param binaryWriter The buffer to write the bufferview data to
  78355. * @param convertToRightHandedSystem Converts the values to right-handed
  78356. */
  78357. private createBufferViewKind;
  78358. /**
  78359. * The primitive mode of the Babylon mesh
  78360. * @param babylonMesh The BabylonJS mesh
  78361. */
  78362. private getMeshPrimitiveMode;
  78363. /**
  78364. * Sets the primitive mode of the glTF mesh primitive
  78365. * @param meshPrimitive glTF mesh primitive
  78366. * @param primitiveMode The primitive mode
  78367. */
  78368. private setPrimitiveMode;
  78369. /**
  78370. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78371. * @param meshPrimitive glTF mesh primitive
  78372. * @param attributeKind vertex attribute
  78373. * @returns boolean specifying if uv coordinates are present
  78374. */
  78375. private setAttributeKind;
  78376. /**
  78377. * Sets data for the primitive attributes of each submesh
  78378. * @param mesh glTF Mesh object to store the primitive attribute information
  78379. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78380. * @param binaryWriter Buffer to write the attribute data to
  78381. * @param convertToRightHandedSystem Converts the values to right-handed
  78382. */
  78383. private setPrimitiveAttributesAsync;
  78384. /**
  78385. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78386. * @param node The node to check
  78387. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78388. */
  78389. private isBabylonCoordinateSystemConvertingNode;
  78390. /**
  78391. * Creates a glTF scene based on the array of meshes
  78392. * Returns the the total byte offset
  78393. * @param babylonScene Babylon scene to get the mesh data from
  78394. * @param binaryWriter Buffer to write binary data to
  78395. */
  78396. private createSceneAsync;
  78397. /**
  78398. * Creates a mapping of Node unique id to node index and handles animations
  78399. * @param babylonScene Babylon Scene
  78400. * @param nodes Babylon transform nodes
  78401. * @param binaryWriter Buffer to write binary data to
  78402. * @returns Node mapping of unique id to index
  78403. */
  78404. private createNodeMapAndAnimationsAsync;
  78405. /**
  78406. * Creates a glTF node from a Babylon mesh
  78407. * @param babylonMesh Source Babylon mesh
  78408. * @param binaryWriter Buffer for storing geometry data
  78409. * @param convertToRightHandedSystem Converts the values to right-handed
  78410. * @param nodeMap Node mapping of unique id to glTF node index
  78411. * @returns glTF node
  78412. */
  78413. private createNodeAsync;
  78414. }
  78415. /**
  78416. * @hidden
  78417. *
  78418. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78419. */
  78420. export class _BinaryWriter {
  78421. /**
  78422. * Array buffer which stores all binary data
  78423. */
  78424. private _arrayBuffer;
  78425. /**
  78426. * View of the array buffer
  78427. */
  78428. private _dataView;
  78429. /**
  78430. * byte offset of data in array buffer
  78431. */
  78432. private _byteOffset;
  78433. /**
  78434. * Initialize binary writer with an initial byte length
  78435. * @param byteLength Initial byte length of the array buffer
  78436. */
  78437. constructor(byteLength: number);
  78438. /**
  78439. * Resize the array buffer to the specified byte length
  78440. * @param byteLength
  78441. */
  78442. private resizeBuffer;
  78443. /**
  78444. * Get an array buffer with the length of the byte offset
  78445. * @returns ArrayBuffer resized to the byte offset
  78446. */
  78447. getArrayBuffer(): ArrayBuffer;
  78448. /**
  78449. * Get the byte offset of the array buffer
  78450. * @returns byte offset
  78451. */
  78452. getByteOffset(): number;
  78453. /**
  78454. * Stores an UInt8 in the array buffer
  78455. * @param entry
  78456. * @param byteOffset If defined, specifies where to set the value as an offset.
  78457. */
  78458. setUInt8(entry: number, byteOffset?: number): void;
  78459. /**
  78460. * Gets an UInt32 in the array buffer
  78461. * @param entry
  78462. * @param byteOffset If defined, specifies where to set the value as an offset.
  78463. */
  78464. getUInt32(byteOffset: number): number;
  78465. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78466. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78467. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78468. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78469. /**
  78470. * Stores a Float32 in the array buffer
  78471. * @param entry
  78472. */
  78473. setFloat32(entry: number, byteOffset?: number): void;
  78474. /**
  78475. * Stores an UInt32 in the array buffer
  78476. * @param entry
  78477. * @param byteOffset If defined, specifies where to set the value as an offset.
  78478. */
  78479. setUInt32(entry: number, byteOffset?: number): void;
  78480. }
  78481. }
  78482. declare module BABYLON.GLTF2.Exporter {
  78483. /**
  78484. * @hidden
  78485. * Interface to store animation data.
  78486. */
  78487. export interface _IAnimationData {
  78488. /**
  78489. * Keyframe data.
  78490. */
  78491. inputs: number[];
  78492. /**
  78493. * Value data.
  78494. */
  78495. outputs: number[][];
  78496. /**
  78497. * Animation interpolation data.
  78498. */
  78499. samplerInterpolation: AnimationSamplerInterpolation;
  78500. /**
  78501. * Minimum keyframe value.
  78502. */
  78503. inputsMin: number;
  78504. /**
  78505. * Maximum keyframe value.
  78506. */
  78507. inputsMax: number;
  78508. }
  78509. /**
  78510. * @hidden
  78511. */
  78512. export interface _IAnimationInfo {
  78513. /**
  78514. * The target channel for the animation
  78515. */
  78516. animationChannelTargetPath: AnimationChannelTargetPath;
  78517. /**
  78518. * The glTF accessor type for the data.
  78519. */
  78520. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78521. /**
  78522. * Specifies if quaternions should be used.
  78523. */
  78524. useQuaternion: boolean;
  78525. }
  78526. /**
  78527. * @hidden
  78528. * Utility class for generating glTF animation data from BabylonJS.
  78529. */
  78530. export class _GLTFAnimation {
  78531. /**
  78532. * @ignore
  78533. *
  78534. * Creates glTF channel animation from BabylonJS animation.
  78535. * @param babylonTransformNode - BabylonJS mesh.
  78536. * @param animation - animation.
  78537. * @param animationChannelTargetPath - The target animation channel.
  78538. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78539. * @param useQuaternion - Specifies if quaternions are used.
  78540. * @returns nullable IAnimationData
  78541. */
  78542. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78543. private static _DeduceAnimationInfo;
  78544. /**
  78545. * @ignore
  78546. * Create node animations from the transform node animations
  78547. * @param babylonNode
  78548. * @param runtimeGLTFAnimation
  78549. * @param idleGLTFAnimations
  78550. * @param nodeMap
  78551. * @param nodes
  78552. * @param binaryWriter
  78553. * @param bufferViews
  78554. * @param accessors
  78555. * @param convertToRightHandedSystem
  78556. * @param animationSampleRate
  78557. */
  78558. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78559. [key: number]: number;
  78560. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78561. /**
  78562. * @ignore
  78563. * Create node animations from the animation groups
  78564. * @param babylonScene
  78565. * @param glTFAnimations
  78566. * @param nodeMap
  78567. * @param nodes
  78568. * @param binaryWriter
  78569. * @param bufferViews
  78570. * @param accessors
  78571. * @param convertToRightHandedSystemMap
  78572. * @param animationSampleRate
  78573. */
  78574. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78575. [key: number]: number;
  78576. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78577. [nodeId: number]: boolean;
  78578. }, animationSampleRate: number): void;
  78579. private static AddAnimation;
  78580. /**
  78581. * Create a baked animation
  78582. * @param babylonTransformNode BabylonJS mesh
  78583. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78584. * @param animationChannelTargetPath animation target channel
  78585. * @param minFrame minimum animation frame
  78586. * @param maxFrame maximum animation frame
  78587. * @param fps frames per second of the animation
  78588. * @param inputs input key frames of the animation
  78589. * @param outputs output key frame data of the animation
  78590. * @param convertToRightHandedSystem converts the values to right-handed
  78591. * @param useQuaternion specifies if quaternions should be used
  78592. */
  78593. private static _CreateBakedAnimation;
  78594. private static _ConvertFactorToVector3OrQuaternion;
  78595. private static _SetInterpolatedValue;
  78596. /**
  78597. * Creates linear animation from the animation key frames
  78598. * @param babylonTransformNode BabylonJS mesh
  78599. * @param animation BabylonJS animation
  78600. * @param animationChannelTargetPath The target animation channel
  78601. * @param frameDelta The difference between the last and first frame of the animation
  78602. * @param inputs Array to store the key frame times
  78603. * @param outputs Array to store the key frame data
  78604. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78605. * @param useQuaternion Specifies if quaternions are used in the animation
  78606. */
  78607. private static _CreateLinearOrStepAnimation;
  78608. /**
  78609. * Creates cubic spline animation from the animation key frames
  78610. * @param babylonTransformNode BabylonJS mesh
  78611. * @param animation BabylonJS animation
  78612. * @param animationChannelTargetPath The target animation channel
  78613. * @param frameDelta The difference between the last and first frame of the animation
  78614. * @param inputs Array to store the key frame times
  78615. * @param outputs Array to store the key frame data
  78616. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78617. * @param useQuaternion Specifies if quaternions are used in the animation
  78618. */
  78619. private static _CreateCubicSplineAnimation;
  78620. private static _GetBasePositionRotationOrScale;
  78621. /**
  78622. * Adds a key frame value
  78623. * @param keyFrame
  78624. * @param animation
  78625. * @param outputs
  78626. * @param animationChannelTargetPath
  78627. * @param basePositionRotationOrScale
  78628. * @param convertToRightHandedSystem
  78629. * @param useQuaternion
  78630. */
  78631. private static _AddKeyframeValue;
  78632. /**
  78633. * Determine the interpolation based on the key frames
  78634. * @param keyFrames
  78635. * @param animationChannelTargetPath
  78636. * @param useQuaternion
  78637. */
  78638. private static _DeduceInterpolation;
  78639. /**
  78640. * Adds an input tangent or output tangent to the output data
  78641. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78642. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78643. * @param outputs The animation data by keyframe
  78644. * @param animationChannelTargetPath The target animation channel
  78645. * @param interpolation The interpolation type
  78646. * @param keyFrame The key frame with the animation data
  78647. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78648. * @param useQuaternion Specifies if quaternions are used
  78649. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78650. */
  78651. private static AddSplineTangent;
  78652. /**
  78653. * Get the minimum and maximum key frames' frame values
  78654. * @param keyFrames animation key frames
  78655. * @returns the minimum and maximum key frame value
  78656. */
  78657. private static calculateMinMaxKeyFrames;
  78658. }
  78659. }
  78660. declare module BABYLON.GLTF2.Exporter {
  78661. /** @hidden */
  78662. export var textureTransformPixelShader: {
  78663. name: string;
  78664. shader: string;
  78665. };
  78666. }
  78667. declare module BABYLON.GLTF2.Exporter.Extensions {
  78668. /**
  78669. * @hidden
  78670. */
  78671. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78672. private _recordedTextures;
  78673. /** Name of this extension */
  78674. readonly name: string;
  78675. /** Defines whether this extension is enabled */
  78676. enabled: boolean;
  78677. /** Defines whether this extension is required */
  78678. required: boolean;
  78679. /** Reference to the glTF exporter */
  78680. private _wasUsed;
  78681. constructor(exporter: _Exporter);
  78682. dispose(): void;
  78683. /** @hidden */
  78684. get wasUsed(): boolean;
  78685. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78686. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78687. /**
  78688. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78689. * @param babylonTexture
  78690. * @param offset
  78691. * @param rotation
  78692. * @param scale
  78693. * @param scene
  78694. */
  78695. private _textureTransformTextureAsync;
  78696. }
  78697. }
  78698. declare module BABYLON.GLTF2.Exporter.Extensions {
  78699. /**
  78700. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78701. */
  78702. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78703. /** The name of this extension. */
  78704. readonly name: string;
  78705. /** Defines whether this extension is enabled. */
  78706. enabled: boolean;
  78707. /** Defines whether this extension is required */
  78708. required: boolean;
  78709. /** Reference to the glTF exporter */
  78710. private _exporter;
  78711. private _lights;
  78712. /** @hidden */
  78713. constructor(exporter: _Exporter);
  78714. /** @hidden */
  78715. dispose(): void;
  78716. /** @hidden */
  78717. get wasUsed(): boolean;
  78718. /** @hidden */
  78719. onExporting(): void;
  78720. /**
  78721. * Define this method to modify the default behavior when exporting a node
  78722. * @param context The context when exporting the node
  78723. * @param node glTF node
  78724. * @param babylonNode BabylonJS node
  78725. * @param nodeMap Node mapping of unique id to glTF node index
  78726. * @returns nullable INode promise
  78727. */
  78728. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78729. [key: number]: number;
  78730. }): Promise<Nullable<INode>>;
  78731. }
  78732. }
  78733. declare module BABYLON.GLTF2.Exporter.Extensions {
  78734. /**
  78735. * @hidden
  78736. */
  78737. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78738. /** Name of this extension */
  78739. readonly name: string;
  78740. /** Defines whether this extension is enabled */
  78741. enabled: boolean;
  78742. /** Defines whether this extension is required */
  78743. required: boolean;
  78744. /** Reference to the glTF exporter */
  78745. private _textureInfos;
  78746. private _exportedTextures;
  78747. private _wasUsed;
  78748. constructor(exporter: _Exporter);
  78749. dispose(): void;
  78750. /** @hidden */
  78751. get wasUsed(): boolean;
  78752. private _getTextureIndex;
  78753. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78754. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78755. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78756. }
  78757. }
  78758. declare module BABYLON {
  78759. /**
  78760. * Class for generating STL data from a Babylon scene.
  78761. */
  78762. export class STLExport {
  78763. /**
  78764. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78765. * @param meshes list defines the mesh to serialize
  78766. * @param download triggers the automatic download of the file.
  78767. * @param fileName changes the downloads fileName.
  78768. * @param binary changes the STL to a binary type.
  78769. * @param isLittleEndian toggle for binary type exporter.
  78770. * @returns the STL as UTF8 string
  78771. */
  78772. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78773. }
  78774. }
  78775. declare module "babylonjs-gltf2interface" {
  78776. export = BABYLON.GLTF2;
  78777. }
  78778. /**
  78779. * Module for glTF 2.0 Interface
  78780. */
  78781. declare module BABYLON.GLTF2 {
  78782. /**
  78783. * The datatype of the components in the attribute
  78784. */
  78785. const enum AccessorComponentType {
  78786. /**
  78787. * Byte
  78788. */
  78789. BYTE = 5120,
  78790. /**
  78791. * Unsigned Byte
  78792. */
  78793. UNSIGNED_BYTE = 5121,
  78794. /**
  78795. * Short
  78796. */
  78797. SHORT = 5122,
  78798. /**
  78799. * Unsigned Short
  78800. */
  78801. UNSIGNED_SHORT = 5123,
  78802. /**
  78803. * Unsigned Int
  78804. */
  78805. UNSIGNED_INT = 5125,
  78806. /**
  78807. * Float
  78808. */
  78809. FLOAT = 5126,
  78810. }
  78811. /**
  78812. * Specifies if the attirbute is a scalar, vector, or matrix
  78813. */
  78814. const enum AccessorType {
  78815. /**
  78816. * Scalar
  78817. */
  78818. SCALAR = "SCALAR",
  78819. /**
  78820. * Vector2
  78821. */
  78822. VEC2 = "VEC2",
  78823. /**
  78824. * Vector3
  78825. */
  78826. VEC3 = "VEC3",
  78827. /**
  78828. * Vector4
  78829. */
  78830. VEC4 = "VEC4",
  78831. /**
  78832. * Matrix2x2
  78833. */
  78834. MAT2 = "MAT2",
  78835. /**
  78836. * Matrix3x3
  78837. */
  78838. MAT3 = "MAT3",
  78839. /**
  78840. * Matrix4x4
  78841. */
  78842. MAT4 = "MAT4",
  78843. }
  78844. /**
  78845. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78846. */
  78847. const enum AnimationChannelTargetPath {
  78848. /**
  78849. * Translation
  78850. */
  78851. TRANSLATION = "translation",
  78852. /**
  78853. * Rotation
  78854. */
  78855. ROTATION = "rotation",
  78856. /**
  78857. * Scale
  78858. */
  78859. SCALE = "scale",
  78860. /**
  78861. * Weights
  78862. */
  78863. WEIGHTS = "weights",
  78864. }
  78865. /**
  78866. * Interpolation algorithm
  78867. */
  78868. const enum AnimationSamplerInterpolation {
  78869. /**
  78870. * The animated values are linearly interpolated between keyframes
  78871. */
  78872. LINEAR = "LINEAR",
  78873. /**
  78874. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78875. */
  78876. STEP = "STEP",
  78877. /**
  78878. * The animation's interpolation is computed using a cubic spline with specified tangents
  78879. */
  78880. CUBICSPLINE = "CUBICSPLINE",
  78881. }
  78882. /**
  78883. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78884. */
  78885. const enum CameraType {
  78886. /**
  78887. * A perspective camera containing properties to create a perspective projection matrix
  78888. */
  78889. PERSPECTIVE = "perspective",
  78890. /**
  78891. * An orthographic camera containing properties to create an orthographic projection matrix
  78892. */
  78893. ORTHOGRAPHIC = "orthographic",
  78894. }
  78895. /**
  78896. * The mime-type of the image
  78897. */
  78898. const enum ImageMimeType {
  78899. /**
  78900. * JPEG Mime-type
  78901. */
  78902. JPEG = "image/jpeg",
  78903. /**
  78904. * PNG Mime-type
  78905. */
  78906. PNG = "image/png",
  78907. }
  78908. /**
  78909. * The alpha rendering mode of the material
  78910. */
  78911. const enum MaterialAlphaMode {
  78912. /**
  78913. * The alpha value is ignored and the rendered output is fully opaque
  78914. */
  78915. OPAQUE = "OPAQUE",
  78916. /**
  78917. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78918. */
  78919. MASK = "MASK",
  78920. /**
  78921. * 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)
  78922. */
  78923. BLEND = "BLEND",
  78924. }
  78925. /**
  78926. * The type of the primitives to render
  78927. */
  78928. const enum MeshPrimitiveMode {
  78929. /**
  78930. * Points
  78931. */
  78932. POINTS = 0,
  78933. /**
  78934. * Lines
  78935. */
  78936. LINES = 1,
  78937. /**
  78938. * Line Loop
  78939. */
  78940. LINE_LOOP = 2,
  78941. /**
  78942. * Line Strip
  78943. */
  78944. LINE_STRIP = 3,
  78945. /**
  78946. * Triangles
  78947. */
  78948. TRIANGLES = 4,
  78949. /**
  78950. * Triangle Strip
  78951. */
  78952. TRIANGLE_STRIP = 5,
  78953. /**
  78954. * Triangle Fan
  78955. */
  78956. TRIANGLE_FAN = 6,
  78957. }
  78958. /**
  78959. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78960. */
  78961. const enum TextureMagFilter {
  78962. /**
  78963. * Nearest
  78964. */
  78965. NEAREST = 9728,
  78966. /**
  78967. * Linear
  78968. */
  78969. LINEAR = 9729,
  78970. }
  78971. /**
  78972. * Minification filter. All valid values correspond to WebGL enums
  78973. */
  78974. const enum TextureMinFilter {
  78975. /**
  78976. * Nearest
  78977. */
  78978. NEAREST = 9728,
  78979. /**
  78980. * Linear
  78981. */
  78982. LINEAR = 9729,
  78983. /**
  78984. * Nearest Mip-Map Nearest
  78985. */
  78986. NEAREST_MIPMAP_NEAREST = 9984,
  78987. /**
  78988. * Linear Mipmap Nearest
  78989. */
  78990. LINEAR_MIPMAP_NEAREST = 9985,
  78991. /**
  78992. * Nearest Mipmap Linear
  78993. */
  78994. NEAREST_MIPMAP_LINEAR = 9986,
  78995. /**
  78996. * Linear Mipmap Linear
  78997. */
  78998. LINEAR_MIPMAP_LINEAR = 9987,
  78999. }
  79000. /**
  79001. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79002. */
  79003. const enum TextureWrapMode {
  79004. /**
  79005. * Clamp to Edge
  79006. */
  79007. CLAMP_TO_EDGE = 33071,
  79008. /**
  79009. * Mirrored Repeat
  79010. */
  79011. MIRRORED_REPEAT = 33648,
  79012. /**
  79013. * Repeat
  79014. */
  79015. REPEAT = 10497,
  79016. }
  79017. /**
  79018. * glTF Property
  79019. */
  79020. interface IProperty {
  79021. /**
  79022. * Dictionary object with extension-specific objects
  79023. */
  79024. extensions?: {
  79025. [key: string]: any;
  79026. };
  79027. /**
  79028. * Application-Specific data
  79029. */
  79030. extras?: any;
  79031. }
  79032. /**
  79033. * glTF Child of Root Property
  79034. */
  79035. interface IChildRootProperty extends IProperty {
  79036. /**
  79037. * The user-defined name of this object
  79038. */
  79039. name?: string;
  79040. }
  79041. /**
  79042. * Indices of those attributes that deviate from their initialization value
  79043. */
  79044. interface IAccessorSparseIndices extends IProperty {
  79045. /**
  79046. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79047. */
  79048. bufferView: number;
  79049. /**
  79050. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79051. */
  79052. byteOffset?: number;
  79053. /**
  79054. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  79055. */
  79056. componentType: AccessorComponentType;
  79057. }
  79058. /**
  79059. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  79060. */
  79061. interface IAccessorSparseValues extends IProperty {
  79062. /**
  79063. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  79064. */
  79065. bufferView: number;
  79066. /**
  79067. * The offset relative to the start of the bufferView in bytes. Must be aligned
  79068. */
  79069. byteOffset?: number;
  79070. }
  79071. /**
  79072. * Sparse storage of attributes that deviate from their initialization value
  79073. */
  79074. interface IAccessorSparse extends IProperty {
  79075. /**
  79076. * The number of attributes encoded in this sparse accessor
  79077. */
  79078. count: number;
  79079. /**
  79080. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  79081. */
  79082. indices: IAccessorSparseIndices;
  79083. /**
  79084. * 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
  79085. */
  79086. values: IAccessorSparseValues;
  79087. }
  79088. /**
  79089. * 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
  79090. */
  79091. interface IAccessor extends IChildRootProperty {
  79092. /**
  79093. * The index of the bufferview
  79094. */
  79095. bufferView?: number;
  79096. /**
  79097. * The offset relative to the start of the bufferView in bytes
  79098. */
  79099. byteOffset?: number;
  79100. /**
  79101. * The datatype of components in the attribute
  79102. */
  79103. componentType: AccessorComponentType;
  79104. /**
  79105. * Specifies whether integer data values should be normalized
  79106. */
  79107. normalized?: boolean;
  79108. /**
  79109. * The number of attributes referenced by this accessor
  79110. */
  79111. count: number;
  79112. /**
  79113. * Specifies if the attribute is a scalar, vector, or matrix
  79114. */
  79115. type: AccessorType;
  79116. /**
  79117. * Maximum value of each component in this attribute
  79118. */
  79119. max?: number[];
  79120. /**
  79121. * Minimum value of each component in this attribute
  79122. */
  79123. min?: number[];
  79124. /**
  79125. * Sparse storage of attributes that deviate from their initialization value
  79126. */
  79127. sparse?: IAccessorSparse;
  79128. }
  79129. /**
  79130. * Targets an animation's sampler at a node's property
  79131. */
  79132. interface IAnimationChannel extends IProperty {
  79133. /**
  79134. * The index of a sampler in this animation used to compute the value for the target
  79135. */
  79136. sampler: number;
  79137. /**
  79138. * The index of the node and TRS property to target
  79139. */
  79140. target: IAnimationChannelTarget;
  79141. }
  79142. /**
  79143. * The index of the node and TRS property that an animation channel targets
  79144. */
  79145. interface IAnimationChannelTarget extends IProperty {
  79146. /**
  79147. * The index of the node to target
  79148. */
  79149. node: number;
  79150. /**
  79151. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79152. */
  79153. path: AnimationChannelTargetPath;
  79154. }
  79155. /**
  79156. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79157. */
  79158. interface IAnimationSampler extends IProperty {
  79159. /**
  79160. * The index of an accessor containing keyframe input values, e.g., time
  79161. */
  79162. input: number;
  79163. /**
  79164. * Interpolation algorithm
  79165. */
  79166. interpolation?: AnimationSamplerInterpolation;
  79167. /**
  79168. * The index of an accessor, containing keyframe output values
  79169. */
  79170. output: number;
  79171. }
  79172. /**
  79173. * A keyframe animation
  79174. */
  79175. interface IAnimation extends IChildRootProperty {
  79176. /**
  79177. * An array of channels, each of which targets an animation's sampler at a node's property
  79178. */
  79179. channels: IAnimationChannel[];
  79180. /**
  79181. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79182. */
  79183. samplers: IAnimationSampler[];
  79184. }
  79185. /**
  79186. * Metadata about the glTF asset
  79187. */
  79188. interface IAsset extends IChildRootProperty {
  79189. /**
  79190. * A copyright message suitable for display to credit the content creator
  79191. */
  79192. copyright?: string;
  79193. /**
  79194. * Tool that generated this glTF model. Useful for debugging
  79195. */
  79196. generator?: string;
  79197. /**
  79198. * The glTF version that this asset targets
  79199. */
  79200. version: string;
  79201. /**
  79202. * The minimum glTF version that this asset targets
  79203. */
  79204. minVersion?: string;
  79205. }
  79206. /**
  79207. * A buffer points to binary geometry, animation, or skins
  79208. */
  79209. interface IBuffer extends IChildRootProperty {
  79210. /**
  79211. * 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
  79212. */
  79213. uri?: string;
  79214. /**
  79215. * The length of the buffer in bytes
  79216. */
  79217. byteLength: number;
  79218. }
  79219. /**
  79220. * A view into a buffer generally representing a subset of the buffer
  79221. */
  79222. interface IBufferView extends IChildRootProperty {
  79223. /**
  79224. * The index of the buffer
  79225. */
  79226. buffer: number;
  79227. /**
  79228. * The offset into the buffer in bytes
  79229. */
  79230. byteOffset?: number;
  79231. /**
  79232. * The lenth of the bufferView in bytes
  79233. */
  79234. byteLength: number;
  79235. /**
  79236. * The stride, in bytes
  79237. */
  79238. byteStride?: number;
  79239. }
  79240. /**
  79241. * An orthographic camera containing properties to create an orthographic projection matrix
  79242. */
  79243. interface ICameraOrthographic extends IProperty {
  79244. /**
  79245. * The floating-point horizontal magnification of the view. Must not be zero
  79246. */
  79247. xmag: number;
  79248. /**
  79249. * The floating-point vertical magnification of the view. Must not be zero
  79250. */
  79251. ymag: number;
  79252. /**
  79253. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79254. */
  79255. zfar: number;
  79256. /**
  79257. * The floating-point distance to the near clipping plane
  79258. */
  79259. znear: number;
  79260. }
  79261. /**
  79262. * A perspective camera containing properties to create a perspective projection matrix
  79263. */
  79264. interface ICameraPerspective extends IProperty {
  79265. /**
  79266. * The floating-point aspect ratio of the field of view
  79267. */
  79268. aspectRatio?: number;
  79269. /**
  79270. * The floating-point vertical field of view in radians
  79271. */
  79272. yfov: number;
  79273. /**
  79274. * The floating-point distance to the far clipping plane
  79275. */
  79276. zfar?: number;
  79277. /**
  79278. * The floating-point distance to the near clipping plane
  79279. */
  79280. znear: number;
  79281. }
  79282. /**
  79283. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79284. */
  79285. interface ICamera extends IChildRootProperty {
  79286. /**
  79287. * An orthographic camera containing properties to create an orthographic projection matrix
  79288. */
  79289. orthographic?: ICameraOrthographic;
  79290. /**
  79291. * A perspective camera containing properties to create a perspective projection matrix
  79292. */
  79293. perspective?: ICameraPerspective;
  79294. /**
  79295. * Specifies if the camera uses a perspective or orthographic projection
  79296. */
  79297. type: CameraType;
  79298. }
  79299. /**
  79300. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79301. */
  79302. interface IImage extends IChildRootProperty {
  79303. /**
  79304. * 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
  79305. */
  79306. uri?: string;
  79307. /**
  79308. * The image's MIME type
  79309. */
  79310. mimeType?: ImageMimeType;
  79311. /**
  79312. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79313. */
  79314. bufferView?: number;
  79315. }
  79316. /**
  79317. * Material Normal Texture Info
  79318. */
  79319. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79320. /**
  79321. * The scalar multiplier applied to each normal vector of the normal texture
  79322. */
  79323. scale?: number;
  79324. }
  79325. /**
  79326. * Material Occlusion Texture Info
  79327. */
  79328. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79329. /**
  79330. * A scalar multiplier controlling the amount of occlusion applied
  79331. */
  79332. strength?: number;
  79333. }
  79334. /**
  79335. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79336. */
  79337. interface IMaterialPbrMetallicRoughness {
  79338. /**
  79339. * The material's base color factor
  79340. */
  79341. baseColorFactor?: number[];
  79342. /**
  79343. * The base color texture
  79344. */
  79345. baseColorTexture?: ITextureInfo;
  79346. /**
  79347. * The metalness of the material
  79348. */
  79349. metallicFactor?: number;
  79350. /**
  79351. * The roughness of the material
  79352. */
  79353. roughnessFactor?: number;
  79354. /**
  79355. * The metallic-roughness texture
  79356. */
  79357. metallicRoughnessTexture?: ITextureInfo;
  79358. }
  79359. /**
  79360. * The material appearance of a primitive
  79361. */
  79362. interface IMaterial extends IChildRootProperty {
  79363. /**
  79364. * 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
  79365. */
  79366. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79367. /**
  79368. * The normal map texture
  79369. */
  79370. normalTexture?: IMaterialNormalTextureInfo;
  79371. /**
  79372. * The occlusion map texture
  79373. */
  79374. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79375. /**
  79376. * The emissive map texture
  79377. */
  79378. emissiveTexture?: ITextureInfo;
  79379. /**
  79380. * 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
  79381. */
  79382. emissiveFactor?: number[];
  79383. /**
  79384. * The alpha rendering mode of the material
  79385. */
  79386. alphaMode?: MaterialAlphaMode;
  79387. /**
  79388. * The alpha cutoff value of the material
  79389. */
  79390. alphaCutoff?: number;
  79391. /**
  79392. * Specifies whether the material is double sided
  79393. */
  79394. doubleSided?: boolean;
  79395. }
  79396. /**
  79397. * Geometry to be rendered with the given material
  79398. */
  79399. interface IMeshPrimitive extends IProperty {
  79400. /**
  79401. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79402. */
  79403. attributes: {
  79404. [name: string]: number;
  79405. };
  79406. /**
  79407. * The index of the accessor that contains the indices
  79408. */
  79409. indices?: number;
  79410. /**
  79411. * The index of the material to apply to this primitive when rendering
  79412. */
  79413. material?: number;
  79414. /**
  79415. * The type of primitives to render. All valid values correspond to WebGL enums
  79416. */
  79417. mode?: MeshPrimitiveMode;
  79418. /**
  79419. * 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
  79420. */
  79421. targets?: {
  79422. [name: string]: number;
  79423. }[];
  79424. }
  79425. /**
  79426. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79427. */
  79428. interface IMesh extends IChildRootProperty {
  79429. /**
  79430. * An array of primitives, each defining geometry to be rendered with a material
  79431. */
  79432. primitives: IMeshPrimitive[];
  79433. /**
  79434. * Array of weights to be applied to the Morph Targets
  79435. */
  79436. weights?: number[];
  79437. }
  79438. /**
  79439. * A node in the node hierarchy
  79440. */
  79441. interface INode extends IChildRootProperty {
  79442. /**
  79443. * The index of the camera referenced by this node
  79444. */
  79445. camera?: number;
  79446. /**
  79447. * The indices of this node's children
  79448. */
  79449. children?: number[];
  79450. /**
  79451. * The index of the skin referenced by this node
  79452. */
  79453. skin?: number;
  79454. /**
  79455. * A floating-point 4x4 transformation matrix stored in column-major order
  79456. */
  79457. matrix?: number[];
  79458. /**
  79459. * The index of the mesh in this node
  79460. */
  79461. mesh?: number;
  79462. /**
  79463. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79464. */
  79465. rotation?: number[];
  79466. /**
  79467. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79468. */
  79469. scale?: number[];
  79470. /**
  79471. * The node's translation along the x, y, and z axes
  79472. */
  79473. translation?: number[];
  79474. /**
  79475. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79476. */
  79477. weights?: number[];
  79478. }
  79479. /**
  79480. * Texture sampler properties for filtering and wrapping modes
  79481. */
  79482. interface ISampler extends IChildRootProperty {
  79483. /**
  79484. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79485. */
  79486. magFilter?: TextureMagFilter;
  79487. /**
  79488. * Minification filter. All valid values correspond to WebGL enums
  79489. */
  79490. minFilter?: TextureMinFilter;
  79491. /**
  79492. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79493. */
  79494. wrapS?: TextureWrapMode;
  79495. /**
  79496. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79497. */
  79498. wrapT?: TextureWrapMode;
  79499. }
  79500. /**
  79501. * The root nodes of a scene
  79502. */
  79503. interface IScene extends IChildRootProperty {
  79504. /**
  79505. * The indices of each root node
  79506. */
  79507. nodes: number[];
  79508. }
  79509. /**
  79510. * Joints and matrices defining a skin
  79511. */
  79512. interface ISkin extends IChildRootProperty {
  79513. /**
  79514. * 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
  79515. */
  79516. inverseBindMatrices?: number;
  79517. /**
  79518. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79519. */
  79520. skeleton?: number;
  79521. /**
  79522. * 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)
  79523. */
  79524. joints: number[];
  79525. }
  79526. /**
  79527. * A texture and its sampler
  79528. */
  79529. interface ITexture extends IChildRootProperty {
  79530. /**
  79531. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79532. */
  79533. sampler?: number;
  79534. /**
  79535. * The index of the image used by this texture
  79536. */
  79537. source: number;
  79538. }
  79539. /**
  79540. * Reference to a texture
  79541. */
  79542. interface ITextureInfo extends IProperty {
  79543. /**
  79544. * The index of the texture
  79545. */
  79546. index: number;
  79547. /**
  79548. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79549. */
  79550. texCoord?: number;
  79551. }
  79552. /**
  79553. * The root object for a glTF asset
  79554. */
  79555. interface IGLTF extends IProperty {
  79556. /**
  79557. * An array of accessors. An accessor is a typed view into a bufferView
  79558. */
  79559. accessors?: IAccessor[];
  79560. /**
  79561. * An array of keyframe animations
  79562. */
  79563. animations?: IAnimation[];
  79564. /**
  79565. * Metadata about the glTF asset
  79566. */
  79567. asset: IAsset;
  79568. /**
  79569. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79570. */
  79571. buffers?: IBuffer[];
  79572. /**
  79573. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79574. */
  79575. bufferViews?: IBufferView[];
  79576. /**
  79577. * An array of cameras
  79578. */
  79579. cameras?: ICamera[];
  79580. /**
  79581. * Names of glTF extensions used somewhere in this asset
  79582. */
  79583. extensionsUsed?: string[];
  79584. /**
  79585. * Names of glTF extensions required to properly load this asset
  79586. */
  79587. extensionsRequired?: string[];
  79588. /**
  79589. * An array of images. An image defines data used to create a texture
  79590. */
  79591. images?: IImage[];
  79592. /**
  79593. * An array of materials. A material defines the appearance of a primitive
  79594. */
  79595. materials?: IMaterial[];
  79596. /**
  79597. * An array of meshes. A mesh is a set of primitives to be rendered
  79598. */
  79599. meshes?: IMesh[];
  79600. /**
  79601. * An array of nodes
  79602. */
  79603. nodes?: INode[];
  79604. /**
  79605. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79606. */
  79607. samplers?: ISampler[];
  79608. /**
  79609. * The index of the default scene
  79610. */
  79611. scene?: number;
  79612. /**
  79613. * An array of scenes
  79614. */
  79615. scenes?: IScene[];
  79616. /**
  79617. * An array of skins. A skin is defined by joints and matrices
  79618. */
  79619. skins?: ISkin[];
  79620. /**
  79621. * An array of textures
  79622. */
  79623. textures?: ITexture[];
  79624. }
  79625. /**
  79626. * The glTF validation results
  79627. * @ignore
  79628. */
  79629. interface IGLTFValidationResults {
  79630. info: {
  79631. generator: string;
  79632. hasAnimations: boolean;
  79633. hasDefaultScene: boolean;
  79634. hasMaterials: boolean;
  79635. hasMorphTargets: boolean;
  79636. hasSkins: boolean;
  79637. hasTextures: boolean;
  79638. maxAttributesUsed: number;
  79639. primitivesCount: number
  79640. };
  79641. issues: {
  79642. messages: Array<string>;
  79643. numErrors: number;
  79644. numHints: number;
  79645. numInfos: number;
  79646. numWarnings: number;
  79647. truncated: boolean
  79648. };
  79649. mimeType: string;
  79650. uri: string;
  79651. validatedAt: string;
  79652. validatorVersion: string;
  79653. }
  79654. /**
  79655. * The glTF validation options
  79656. */
  79657. interface IGLTFValidationOptions {
  79658. /** Uri to use */
  79659. uri?: string;
  79660. /** Function used to load external resources */
  79661. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79662. /** Boolean indicating that we need to validate accessor data */
  79663. validateAccessorData?: boolean;
  79664. /** max number of issues allowed */
  79665. maxIssues?: number;
  79666. /** Ignored issues */
  79667. ignoredIssues?: Array<string>;
  79668. /** Value to override severy settings */
  79669. severityOverrides?: Object;
  79670. }
  79671. /**
  79672. * The glTF validator object
  79673. * @ignore
  79674. */
  79675. interface IGLTFValidator {
  79676. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79677. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79678. }
  79679. }
  79680. declare module BABYLON {
  79681. /** @hidden */
  79682. export var cellPixelShader: {
  79683. name: string;
  79684. shader: string;
  79685. };
  79686. }
  79687. declare module BABYLON {
  79688. /** @hidden */
  79689. export var cellVertexShader: {
  79690. name: string;
  79691. shader: string;
  79692. };
  79693. }
  79694. declare module BABYLON {
  79695. export class CellMaterial extends BABYLON.PushMaterial {
  79696. private _diffuseTexture;
  79697. diffuseTexture: BABYLON.BaseTexture;
  79698. diffuseColor: BABYLON.Color3;
  79699. _computeHighLevel: boolean;
  79700. computeHighLevel: boolean;
  79701. private _disableLighting;
  79702. disableLighting: boolean;
  79703. private _maxSimultaneousLights;
  79704. maxSimultaneousLights: number;
  79705. constructor(name: string, scene: BABYLON.Scene);
  79706. needAlphaBlending(): boolean;
  79707. needAlphaTesting(): boolean;
  79708. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79709. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79710. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79711. getAnimatables(): BABYLON.IAnimatable[];
  79712. getActiveTextures(): BABYLON.BaseTexture[];
  79713. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79714. dispose(forceDisposeEffect?: boolean): void;
  79715. getClassName(): string;
  79716. clone(name: string): CellMaterial;
  79717. serialize(): any;
  79718. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79719. }
  79720. }
  79721. declare module BABYLON {
  79722. export class CustomShaderStructure {
  79723. FragmentStore: string;
  79724. VertexStore: string;
  79725. constructor();
  79726. }
  79727. export class ShaderSpecialParts {
  79728. constructor();
  79729. Fragment_Begin: string;
  79730. Fragment_Definitions: string;
  79731. Fragment_MainBegin: string;
  79732. Fragment_Custom_Diffuse: string;
  79733. Fragment_Before_Lights: string;
  79734. Fragment_Before_Fog: string;
  79735. Fragment_Custom_Alpha: string;
  79736. Fragment_Before_FragColor: string;
  79737. Vertex_Begin: string;
  79738. Vertex_Definitions: string;
  79739. Vertex_MainBegin: string;
  79740. Vertex_Before_PositionUpdated: string;
  79741. Vertex_Before_NormalUpdated: string;
  79742. Vertex_After_WorldPosComputed: string;
  79743. Vertex_MainEnd: string;
  79744. }
  79745. export class CustomMaterial extends BABYLON.StandardMaterial {
  79746. static ShaderIndexer: number;
  79747. CustomParts: ShaderSpecialParts;
  79748. _isCreatedShader: boolean;
  79749. _createdShaderName: string;
  79750. _customUniform: string[];
  79751. _newUniforms: string[];
  79752. _newUniformInstances: any[];
  79753. _newSamplerInstances: BABYLON.Texture[];
  79754. _customAttributes: string[];
  79755. FragmentShader: string;
  79756. VertexShader: string;
  79757. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79758. ReviewUniform(name: string, arr: string[]): string[];
  79759. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79760. constructor(name: string, scene: BABYLON.Scene);
  79761. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79762. AddAttribute(name: string): CustomMaterial;
  79763. Fragment_Begin(shaderPart: string): CustomMaterial;
  79764. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79765. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79766. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79767. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79768. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79769. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79770. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79771. Vertex_Begin(shaderPart: string): CustomMaterial;
  79772. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79773. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79774. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79775. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79776. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  79777. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79778. }
  79779. }
  79780. declare module BABYLON {
  79781. export class ShaderAlebdoParts {
  79782. constructor();
  79783. Fragment_Begin: string;
  79784. Fragment_Definitions: string;
  79785. Fragment_MainBegin: string;
  79786. Fragment_Custom_Albedo: string;
  79787. Fragment_Before_Lights: string;
  79788. Fragment_Custom_MetallicRoughness: string;
  79789. Fragment_Custom_MicroSurface: string;
  79790. Fragment_Before_Fog: string;
  79791. Fragment_Custom_Alpha: string;
  79792. Fragment_Before_FragColor: string;
  79793. Vertex_Begin: string;
  79794. Vertex_Definitions: string;
  79795. Vertex_MainBegin: string;
  79796. Vertex_Before_PositionUpdated: string;
  79797. Vertex_Before_NormalUpdated: string;
  79798. Vertex_After_WorldPosComputed: string;
  79799. Vertex_MainEnd: string;
  79800. }
  79801. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79802. static ShaderIndexer: number;
  79803. CustomParts: ShaderAlebdoParts;
  79804. _isCreatedShader: boolean;
  79805. _createdShaderName: string;
  79806. _customUniform: string[];
  79807. _newUniforms: string[];
  79808. _newUniformInstances: any[];
  79809. _newSamplerInstances: BABYLON.Texture[];
  79810. _customAttributes: string[];
  79811. FragmentShader: string;
  79812. VertexShader: string;
  79813. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79814. ReviewUniform(name: string, arr: string[]): string[];
  79815. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  79816. constructor(name: string, scene: BABYLON.Scene);
  79817. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79818. AddAttribute(name: string): PBRCustomMaterial;
  79819. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79820. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79821. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79822. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79823. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79824. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79825. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79826. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79827. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79828. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79829. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79830. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79831. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79832. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79833. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79834. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  79835. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79836. }
  79837. }
  79838. declare module BABYLON {
  79839. /** @hidden */
  79840. export var firePixelShader: {
  79841. name: string;
  79842. shader: string;
  79843. };
  79844. }
  79845. declare module BABYLON {
  79846. /** @hidden */
  79847. export var fireVertexShader: {
  79848. name: string;
  79849. shader: string;
  79850. };
  79851. }
  79852. declare module BABYLON {
  79853. export class FireMaterial extends BABYLON.PushMaterial {
  79854. private _diffuseTexture;
  79855. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79856. private _distortionTexture;
  79857. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79858. private _opacityTexture;
  79859. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79860. diffuseColor: BABYLON.Color3;
  79861. speed: number;
  79862. private _scaledDiffuse;
  79863. private _lastTime;
  79864. constructor(name: string, scene: BABYLON.Scene);
  79865. needAlphaBlending(): boolean;
  79866. needAlphaTesting(): boolean;
  79867. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79868. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79869. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79870. getAnimatables(): BABYLON.IAnimatable[];
  79871. getActiveTextures(): BABYLON.BaseTexture[];
  79872. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79873. getClassName(): string;
  79874. dispose(forceDisposeEffect?: boolean): void;
  79875. clone(name: string): FireMaterial;
  79876. serialize(): any;
  79877. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79878. }
  79879. }
  79880. declare module BABYLON {
  79881. /** @hidden */
  79882. export var furPixelShader: {
  79883. name: string;
  79884. shader: string;
  79885. };
  79886. }
  79887. declare module BABYLON {
  79888. /** @hidden */
  79889. export var furVertexShader: {
  79890. name: string;
  79891. shader: string;
  79892. };
  79893. }
  79894. declare module BABYLON {
  79895. export class FurMaterial extends BABYLON.PushMaterial {
  79896. private _diffuseTexture;
  79897. diffuseTexture: BABYLON.BaseTexture;
  79898. private _heightTexture;
  79899. heightTexture: BABYLON.BaseTexture;
  79900. diffuseColor: BABYLON.Color3;
  79901. furLength: number;
  79902. furAngle: number;
  79903. furColor: BABYLON.Color3;
  79904. furOffset: number;
  79905. furSpacing: number;
  79906. furGravity: BABYLON.Vector3;
  79907. furSpeed: number;
  79908. furDensity: number;
  79909. furOcclusion: number;
  79910. furTexture: BABYLON.DynamicTexture;
  79911. private _disableLighting;
  79912. disableLighting: boolean;
  79913. private _maxSimultaneousLights;
  79914. maxSimultaneousLights: number;
  79915. highLevelFur: boolean;
  79916. _meshes: BABYLON.AbstractMesh[];
  79917. private _furTime;
  79918. constructor(name: string, scene: BABYLON.Scene);
  79919. get furTime(): number;
  79920. set furTime(furTime: number);
  79921. needAlphaBlending(): boolean;
  79922. needAlphaTesting(): boolean;
  79923. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79924. updateFur(): void;
  79925. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79926. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79927. getAnimatables(): BABYLON.IAnimatable[];
  79928. getActiveTextures(): BABYLON.BaseTexture[];
  79929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79930. dispose(forceDisposeEffect?: boolean): void;
  79931. clone(name: string): FurMaterial;
  79932. serialize(): any;
  79933. getClassName(): string;
  79934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79935. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79936. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79937. }
  79938. }
  79939. declare module BABYLON {
  79940. /** @hidden */
  79941. export var gradientPixelShader: {
  79942. name: string;
  79943. shader: string;
  79944. };
  79945. }
  79946. declare module BABYLON {
  79947. /** @hidden */
  79948. export var gradientVertexShader: {
  79949. name: string;
  79950. shader: string;
  79951. };
  79952. }
  79953. declare module BABYLON {
  79954. export class GradientMaterial extends BABYLON.PushMaterial {
  79955. private _maxSimultaneousLights;
  79956. maxSimultaneousLights: number;
  79957. topColor: BABYLON.Color3;
  79958. topColorAlpha: number;
  79959. bottomColor: BABYLON.Color3;
  79960. bottomColorAlpha: number;
  79961. offset: number;
  79962. scale: number;
  79963. smoothness: number;
  79964. private _disableLighting;
  79965. disableLighting: boolean;
  79966. constructor(name: string, scene: BABYLON.Scene);
  79967. needAlphaBlending(): boolean;
  79968. needAlphaTesting(): boolean;
  79969. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79970. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79971. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79972. getAnimatables(): BABYLON.IAnimatable[];
  79973. dispose(forceDisposeEffect?: boolean): void;
  79974. clone(name: string): GradientMaterial;
  79975. serialize(): any;
  79976. getClassName(): string;
  79977. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79978. }
  79979. }
  79980. declare module BABYLON {
  79981. /** @hidden */
  79982. export var gridPixelShader: {
  79983. name: string;
  79984. shader: string;
  79985. };
  79986. }
  79987. declare module BABYLON {
  79988. /** @hidden */
  79989. export var gridVertexShader: {
  79990. name: string;
  79991. shader: string;
  79992. };
  79993. }
  79994. declare module BABYLON {
  79995. /**
  79996. * The grid materials allows you to wrap any shape with a grid.
  79997. * Colors are customizable.
  79998. */
  79999. export class GridMaterial extends BABYLON.PushMaterial {
  80000. /**
  80001. * Main color of the grid (e.g. between lines)
  80002. */
  80003. mainColor: BABYLON.Color3;
  80004. /**
  80005. * Color of the grid lines.
  80006. */
  80007. lineColor: BABYLON.Color3;
  80008. /**
  80009. * The scale of the grid compared to unit.
  80010. */
  80011. gridRatio: number;
  80012. /**
  80013. * Allows setting an offset for the grid lines.
  80014. */
  80015. gridOffset: BABYLON.Vector3;
  80016. /**
  80017. * The frequency of thicker lines.
  80018. */
  80019. majorUnitFrequency: number;
  80020. /**
  80021. * The visibility of minor units in the grid.
  80022. */
  80023. minorUnitVisibility: number;
  80024. /**
  80025. * The grid opacity outside of the lines.
  80026. */
  80027. opacity: number;
  80028. /**
  80029. * Determine RBG output is premultiplied by alpha value.
  80030. */
  80031. preMultiplyAlpha: boolean;
  80032. private _opacityTexture;
  80033. opacityTexture: BABYLON.BaseTexture;
  80034. private _gridControl;
  80035. /**
  80036. * constructor
  80037. * @param name The name given to the material in order to identify it afterwards.
  80038. * @param scene The scene the material is used in.
  80039. */
  80040. constructor(name: string, scene: BABYLON.Scene);
  80041. /**
  80042. * Returns wehter or not the grid requires alpha blending.
  80043. */
  80044. needAlphaBlending(): boolean;
  80045. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80046. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80047. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80048. /**
  80049. * Dispose the material and its associated resources.
  80050. * @param forceDisposeEffect will also dispose the used effect when true
  80051. */
  80052. dispose(forceDisposeEffect?: boolean): void;
  80053. clone(name: string): GridMaterial;
  80054. serialize(): any;
  80055. getClassName(): string;
  80056. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  80057. }
  80058. }
  80059. declare module BABYLON {
  80060. /** @hidden */
  80061. export var lavaPixelShader: {
  80062. name: string;
  80063. shader: string;
  80064. };
  80065. }
  80066. declare module BABYLON {
  80067. /** @hidden */
  80068. export var lavaVertexShader: {
  80069. name: string;
  80070. shader: string;
  80071. };
  80072. }
  80073. declare module BABYLON {
  80074. export class LavaMaterial extends BABYLON.PushMaterial {
  80075. private _diffuseTexture;
  80076. diffuseTexture: BABYLON.BaseTexture;
  80077. noiseTexture: BABYLON.BaseTexture;
  80078. fogColor: BABYLON.Color3;
  80079. speed: number;
  80080. movingSpeed: number;
  80081. lowFrequencySpeed: number;
  80082. fogDensity: number;
  80083. private _lastTime;
  80084. diffuseColor: BABYLON.Color3;
  80085. private _disableLighting;
  80086. disableLighting: boolean;
  80087. private _unlit;
  80088. unlit: boolean;
  80089. private _maxSimultaneousLights;
  80090. maxSimultaneousLights: number;
  80091. private _scaledDiffuse;
  80092. constructor(name: string, scene: BABYLON.Scene);
  80093. needAlphaBlending(): boolean;
  80094. needAlphaTesting(): boolean;
  80095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80096. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80097. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80098. getAnimatables(): BABYLON.IAnimatable[];
  80099. getActiveTextures(): BABYLON.BaseTexture[];
  80100. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80101. dispose(forceDisposeEffect?: boolean): void;
  80102. clone(name: string): LavaMaterial;
  80103. serialize(): any;
  80104. getClassName(): string;
  80105. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  80106. }
  80107. }
  80108. declare module BABYLON {
  80109. /** @hidden */
  80110. export var mixPixelShader: {
  80111. name: string;
  80112. shader: string;
  80113. };
  80114. }
  80115. declare module BABYLON {
  80116. /** @hidden */
  80117. export var mixVertexShader: {
  80118. name: string;
  80119. shader: string;
  80120. };
  80121. }
  80122. declare module BABYLON {
  80123. export class MixMaterial extends BABYLON.PushMaterial {
  80124. /**
  80125. * Mix textures
  80126. */
  80127. private _mixTexture1;
  80128. mixTexture1: BABYLON.BaseTexture;
  80129. private _mixTexture2;
  80130. mixTexture2: BABYLON.BaseTexture;
  80131. /**
  80132. * Diffuse textures
  80133. */
  80134. private _diffuseTexture1;
  80135. diffuseTexture1: BABYLON.Texture;
  80136. private _diffuseTexture2;
  80137. diffuseTexture2: BABYLON.Texture;
  80138. private _diffuseTexture3;
  80139. diffuseTexture3: BABYLON.Texture;
  80140. private _diffuseTexture4;
  80141. diffuseTexture4: BABYLON.Texture;
  80142. private _diffuseTexture5;
  80143. diffuseTexture5: BABYLON.Texture;
  80144. private _diffuseTexture6;
  80145. diffuseTexture6: BABYLON.Texture;
  80146. private _diffuseTexture7;
  80147. diffuseTexture7: BABYLON.Texture;
  80148. private _diffuseTexture8;
  80149. diffuseTexture8: BABYLON.Texture;
  80150. /**
  80151. * Uniforms
  80152. */
  80153. diffuseColor: BABYLON.Color3;
  80154. specularColor: BABYLON.Color3;
  80155. specularPower: number;
  80156. private _disableLighting;
  80157. disableLighting: boolean;
  80158. private _maxSimultaneousLights;
  80159. maxSimultaneousLights: number;
  80160. constructor(name: string, scene: BABYLON.Scene);
  80161. needAlphaBlending(): boolean;
  80162. needAlphaTesting(): boolean;
  80163. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80164. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80165. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80166. getAnimatables(): BABYLON.IAnimatable[];
  80167. getActiveTextures(): BABYLON.BaseTexture[];
  80168. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80169. dispose(forceDisposeEffect?: boolean): void;
  80170. clone(name: string): MixMaterial;
  80171. serialize(): any;
  80172. getClassName(): string;
  80173. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80174. }
  80175. }
  80176. declare module BABYLON {
  80177. /** @hidden */
  80178. export var normalPixelShader: {
  80179. name: string;
  80180. shader: string;
  80181. };
  80182. }
  80183. declare module BABYLON {
  80184. /** @hidden */
  80185. export var normalVertexShader: {
  80186. name: string;
  80187. shader: string;
  80188. };
  80189. }
  80190. declare module BABYLON {
  80191. export class NormalMaterial extends BABYLON.PushMaterial {
  80192. private _diffuseTexture;
  80193. diffuseTexture: BABYLON.BaseTexture;
  80194. diffuseColor: BABYLON.Color3;
  80195. private _disableLighting;
  80196. disableLighting: boolean;
  80197. private _maxSimultaneousLights;
  80198. maxSimultaneousLights: number;
  80199. constructor(name: string, scene: BABYLON.Scene);
  80200. needAlphaBlending(): boolean;
  80201. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80202. needAlphaTesting(): boolean;
  80203. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80204. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80205. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80206. getAnimatables(): BABYLON.IAnimatable[];
  80207. getActiveTextures(): BABYLON.BaseTexture[];
  80208. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80209. dispose(forceDisposeEffect?: boolean): void;
  80210. clone(name: string): NormalMaterial;
  80211. serialize(): any;
  80212. getClassName(): string;
  80213. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80214. }
  80215. }
  80216. declare module BABYLON {
  80217. /** @hidden */
  80218. export var shadowOnlyPixelShader: {
  80219. name: string;
  80220. shader: string;
  80221. };
  80222. }
  80223. declare module BABYLON {
  80224. /** @hidden */
  80225. export var shadowOnlyVertexShader: {
  80226. name: string;
  80227. shader: string;
  80228. };
  80229. }
  80230. declare module BABYLON {
  80231. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80232. private _activeLight;
  80233. constructor(name: string, scene: BABYLON.Scene);
  80234. shadowColor: BABYLON.Color3;
  80235. needAlphaBlending(): boolean;
  80236. needAlphaTesting(): boolean;
  80237. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80238. get activeLight(): BABYLON.IShadowLight;
  80239. set activeLight(light: BABYLON.IShadowLight);
  80240. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80241. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80242. clone(name: string): ShadowOnlyMaterial;
  80243. serialize(): any;
  80244. getClassName(): string;
  80245. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80246. }
  80247. }
  80248. declare module BABYLON {
  80249. /** @hidden */
  80250. export var simplePixelShader: {
  80251. name: string;
  80252. shader: string;
  80253. };
  80254. }
  80255. declare module BABYLON {
  80256. /** @hidden */
  80257. export var simpleVertexShader: {
  80258. name: string;
  80259. shader: string;
  80260. };
  80261. }
  80262. declare module BABYLON {
  80263. export class SimpleMaterial extends BABYLON.PushMaterial {
  80264. private _diffuseTexture;
  80265. diffuseTexture: BABYLON.BaseTexture;
  80266. diffuseColor: BABYLON.Color3;
  80267. private _disableLighting;
  80268. disableLighting: boolean;
  80269. private _maxSimultaneousLights;
  80270. maxSimultaneousLights: number;
  80271. constructor(name: string, scene: BABYLON.Scene);
  80272. needAlphaBlending(): boolean;
  80273. needAlphaTesting(): boolean;
  80274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80277. getAnimatables(): BABYLON.IAnimatable[];
  80278. getActiveTextures(): BABYLON.BaseTexture[];
  80279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80280. dispose(forceDisposeEffect?: boolean): void;
  80281. clone(name: string): SimpleMaterial;
  80282. serialize(): any;
  80283. getClassName(): string;
  80284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80285. }
  80286. }
  80287. declare module BABYLON {
  80288. /** @hidden */
  80289. export var skyPixelShader: {
  80290. name: string;
  80291. shader: string;
  80292. };
  80293. }
  80294. declare module BABYLON {
  80295. /** @hidden */
  80296. export var skyVertexShader: {
  80297. name: string;
  80298. shader: string;
  80299. };
  80300. }
  80301. declare module BABYLON {
  80302. /**
  80303. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80304. * @see https://doc.babylonjs.com/extensions/sky
  80305. */
  80306. export class SkyMaterial extends BABYLON.PushMaterial {
  80307. /**
  80308. * Defines the overall luminance of sky in interval ]0, 1[.
  80309. */
  80310. luminance: number;
  80311. /**
  80312. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80313. */
  80314. turbidity: number;
  80315. /**
  80316. * Defines the sky appearance (light intensity).
  80317. */
  80318. rayleigh: number;
  80319. /**
  80320. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80321. */
  80322. mieCoefficient: number;
  80323. /**
  80324. * Defines the amount of haze particles following the Mie scattering theory.
  80325. */
  80326. mieDirectionalG: number;
  80327. /**
  80328. * Defines the distance of the sun according to the active scene camera.
  80329. */
  80330. distance: number;
  80331. /**
  80332. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80333. * "inclined".
  80334. */
  80335. inclination: number;
  80336. /**
  80337. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80338. * an object direction and a reference direction.
  80339. */
  80340. azimuth: number;
  80341. /**
  80342. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80343. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80344. */
  80345. sunPosition: BABYLON.Vector3;
  80346. /**
  80347. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80348. * .sunPosition property.
  80349. */
  80350. useSunPosition: boolean;
  80351. /**
  80352. * Defines an offset vector used to get a horizon offset.
  80353. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80354. */
  80355. cameraOffset: BABYLON.Vector3;
  80356. private _cameraPosition;
  80357. /**
  80358. * Instantiates a new sky material.
  80359. * This material allows to create dynamic and texture free
  80360. * effects for skyboxes by taking care of the atmosphere state.
  80361. * @see https://doc.babylonjs.com/extensions/sky
  80362. * @param name Define the name of the material in the scene
  80363. * @param scene Define the scene the material belong to
  80364. */
  80365. constructor(name: string, scene: BABYLON.Scene);
  80366. /**
  80367. * Specifies if the material will require alpha blending
  80368. * @returns a boolean specifying if alpha blending is needed
  80369. */
  80370. needAlphaBlending(): boolean;
  80371. /**
  80372. * Specifies if this material should be rendered in alpha test mode
  80373. * @returns false as the sky material doesn't need alpha testing.
  80374. */
  80375. needAlphaTesting(): boolean;
  80376. /**
  80377. * Get the texture used for alpha test purpose.
  80378. * @returns null as the sky material has no texture.
  80379. */
  80380. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80381. /**
  80382. * Get if the submesh is ready to be used and all its information available.
  80383. * Child classes can use it to update shaders
  80384. * @param mesh defines the mesh to check
  80385. * @param subMesh defines which submesh to check
  80386. * @param useInstances specifies that instances should be used
  80387. * @returns a boolean indicating that the submesh is ready or not
  80388. */
  80389. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80390. /**
  80391. * Binds the submesh to this material by preparing the effect and shader to draw
  80392. * @param world defines the world transformation matrix
  80393. * @param mesh defines the mesh containing the submesh
  80394. * @param subMesh defines the submesh to bind the material to
  80395. */
  80396. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80397. /**
  80398. * Get the list of animatables in the material.
  80399. * @returns the list of animatables object used in the material
  80400. */
  80401. getAnimatables(): BABYLON.IAnimatable[];
  80402. /**
  80403. * Disposes the material
  80404. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80405. */
  80406. dispose(forceDisposeEffect?: boolean): void;
  80407. /**
  80408. * Makes a duplicate of the material, and gives it a new name
  80409. * @param name defines the new name for the duplicated material
  80410. * @returns the cloned material
  80411. */
  80412. clone(name: string): SkyMaterial;
  80413. /**
  80414. * Serializes this material in a JSON representation
  80415. * @returns the serialized material object
  80416. */
  80417. serialize(): any;
  80418. /**
  80419. * Gets the current class name of the material e.g. "SkyMaterial"
  80420. * Mainly use in serialization.
  80421. * @returns the class name
  80422. */
  80423. getClassName(): string;
  80424. /**
  80425. * Creates a sky material from parsed material data
  80426. * @param source defines the JSON representation of the material
  80427. * @param scene defines the hosting scene
  80428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80429. * @returns a new sky material
  80430. */
  80431. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /** @hidden */
  80436. export var terrainPixelShader: {
  80437. name: string;
  80438. shader: string;
  80439. };
  80440. }
  80441. declare module BABYLON {
  80442. /** @hidden */
  80443. export var terrainVertexShader: {
  80444. name: string;
  80445. shader: string;
  80446. };
  80447. }
  80448. declare module BABYLON {
  80449. export class TerrainMaterial extends BABYLON.PushMaterial {
  80450. private _mixTexture;
  80451. mixTexture: BABYLON.BaseTexture;
  80452. private _diffuseTexture1;
  80453. diffuseTexture1: BABYLON.Texture;
  80454. private _diffuseTexture2;
  80455. diffuseTexture2: BABYLON.Texture;
  80456. private _diffuseTexture3;
  80457. diffuseTexture3: BABYLON.Texture;
  80458. private _bumpTexture1;
  80459. bumpTexture1: BABYLON.Texture;
  80460. private _bumpTexture2;
  80461. bumpTexture2: BABYLON.Texture;
  80462. private _bumpTexture3;
  80463. bumpTexture3: BABYLON.Texture;
  80464. diffuseColor: BABYLON.Color3;
  80465. specularColor: BABYLON.Color3;
  80466. specularPower: number;
  80467. private _disableLighting;
  80468. disableLighting: boolean;
  80469. private _maxSimultaneousLights;
  80470. maxSimultaneousLights: number;
  80471. constructor(name: string, scene: BABYLON.Scene);
  80472. needAlphaBlending(): boolean;
  80473. needAlphaTesting(): boolean;
  80474. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80475. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80476. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80477. getAnimatables(): BABYLON.IAnimatable[];
  80478. getActiveTextures(): BABYLON.BaseTexture[];
  80479. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80480. dispose(forceDisposeEffect?: boolean): void;
  80481. clone(name: string): TerrainMaterial;
  80482. serialize(): any;
  80483. getClassName(): string;
  80484. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80485. }
  80486. }
  80487. declare module BABYLON {
  80488. /** @hidden */
  80489. export var triplanarPixelShader: {
  80490. name: string;
  80491. shader: string;
  80492. };
  80493. }
  80494. declare module BABYLON {
  80495. /** @hidden */
  80496. export var triplanarVertexShader: {
  80497. name: string;
  80498. shader: string;
  80499. };
  80500. }
  80501. declare module BABYLON {
  80502. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80503. mixTexture: BABYLON.BaseTexture;
  80504. private _diffuseTextureX;
  80505. diffuseTextureX: BABYLON.BaseTexture;
  80506. private _diffuseTextureY;
  80507. diffuseTextureY: BABYLON.BaseTexture;
  80508. private _diffuseTextureZ;
  80509. diffuseTextureZ: BABYLON.BaseTexture;
  80510. private _normalTextureX;
  80511. normalTextureX: BABYLON.BaseTexture;
  80512. private _normalTextureY;
  80513. normalTextureY: BABYLON.BaseTexture;
  80514. private _normalTextureZ;
  80515. normalTextureZ: BABYLON.BaseTexture;
  80516. tileSize: number;
  80517. diffuseColor: BABYLON.Color3;
  80518. specularColor: BABYLON.Color3;
  80519. specularPower: number;
  80520. private _disableLighting;
  80521. disableLighting: boolean;
  80522. private _maxSimultaneousLights;
  80523. maxSimultaneousLights: number;
  80524. constructor(name: string, scene: BABYLON.Scene);
  80525. needAlphaBlending(): boolean;
  80526. needAlphaTesting(): boolean;
  80527. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80528. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80529. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80530. getAnimatables(): BABYLON.IAnimatable[];
  80531. getActiveTextures(): BABYLON.BaseTexture[];
  80532. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80533. dispose(forceDisposeEffect?: boolean): void;
  80534. clone(name: string): TriPlanarMaterial;
  80535. serialize(): any;
  80536. getClassName(): string;
  80537. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80538. }
  80539. }
  80540. declare module BABYLON {
  80541. /** @hidden */
  80542. export var waterPixelShader: {
  80543. name: string;
  80544. shader: string;
  80545. };
  80546. }
  80547. declare module BABYLON {
  80548. /** @hidden */
  80549. export var waterVertexShader: {
  80550. name: string;
  80551. shader: string;
  80552. };
  80553. }
  80554. declare module BABYLON {
  80555. export class WaterMaterial extends BABYLON.PushMaterial {
  80556. renderTargetSize: BABYLON.Vector2;
  80557. private _bumpTexture;
  80558. bumpTexture: BABYLON.BaseTexture;
  80559. diffuseColor: BABYLON.Color3;
  80560. specularColor: BABYLON.Color3;
  80561. specularPower: number;
  80562. private _disableLighting;
  80563. disableLighting: boolean;
  80564. private _maxSimultaneousLights;
  80565. maxSimultaneousLights: number;
  80566. /**
  80567. * @param {number}: Represents the wind force
  80568. */
  80569. windForce: number;
  80570. /**
  80571. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80572. */
  80573. windDirection: BABYLON.Vector2;
  80574. /**
  80575. * @param {number}: Wave height, represents the height of the waves
  80576. */
  80577. waveHeight: number;
  80578. /**
  80579. * @param {number}: Bump height, represents the bump height related to the bump map
  80580. */
  80581. bumpHeight: number;
  80582. /**
  80583. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80584. */
  80585. private _bumpSuperimpose;
  80586. bumpSuperimpose: boolean;
  80587. /**
  80588. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80589. */
  80590. private _fresnelSeparate;
  80591. fresnelSeparate: boolean;
  80592. /**
  80593. * @param {boolean}: bump Waves modify the reflection.
  80594. */
  80595. private _bumpAffectsReflection;
  80596. bumpAffectsReflection: boolean;
  80597. /**
  80598. * @param {number}: The water color blended with the refraction (near)
  80599. */
  80600. waterColor: BABYLON.Color3;
  80601. /**
  80602. * @param {number}: The blend factor related to the water color
  80603. */
  80604. colorBlendFactor: number;
  80605. /**
  80606. * @param {number}: The water color blended with the reflection (far)
  80607. */
  80608. waterColor2: BABYLON.Color3;
  80609. /**
  80610. * @param {number}: The blend factor related to the water color (reflection, far)
  80611. */
  80612. colorBlendFactor2: number;
  80613. /**
  80614. * @param {number}: Represents the maximum length of a wave
  80615. */
  80616. waveLength: number;
  80617. /**
  80618. * @param {number}: Defines the waves speed
  80619. */
  80620. waveSpeed: number;
  80621. /**
  80622. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80623. * will avoid calculating useless pixels in the pixel shader of the water material.
  80624. */
  80625. disableClipPlane: boolean;
  80626. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80627. private _mesh;
  80628. private _refractionRTT;
  80629. private _reflectionRTT;
  80630. private _reflectionTransform;
  80631. private _lastTime;
  80632. private _lastDeltaTime;
  80633. private _useLogarithmicDepth;
  80634. private _waitingRenderList;
  80635. private _imageProcessingConfiguration;
  80636. private _imageProcessingObserver;
  80637. /**
  80638. * Gets a boolean indicating that current material needs to register RTT
  80639. */
  80640. get hasRenderTargetTextures(): boolean;
  80641. /**
  80642. * Constructor
  80643. */
  80644. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80645. get useLogarithmicDepth(): boolean;
  80646. set useLogarithmicDepth(value: boolean);
  80647. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80648. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80649. addToRenderList(node: any): void;
  80650. enableRenderTargets(enable: boolean): void;
  80651. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80652. get renderTargetsEnabled(): boolean;
  80653. needAlphaBlending(): boolean;
  80654. needAlphaTesting(): boolean;
  80655. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80656. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80657. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80658. private _createRenderTargets;
  80659. getAnimatables(): BABYLON.IAnimatable[];
  80660. getActiveTextures(): BABYLON.BaseTexture[];
  80661. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80662. dispose(forceDisposeEffect?: boolean): void;
  80663. clone(name: string): WaterMaterial;
  80664. serialize(): any;
  80665. getClassName(): string;
  80666. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80667. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80668. }
  80669. }
  80670. declare module BABYLON {
  80671. /** @hidden */
  80672. export var asciiartPixelShader: {
  80673. name: string;
  80674. shader: string;
  80675. };
  80676. }
  80677. declare module BABYLON {
  80678. /**
  80679. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80680. *
  80681. * It basically takes care rendering the font front the given font size to a texture.
  80682. * This is used later on in the postprocess.
  80683. */
  80684. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80685. private _font;
  80686. private _text;
  80687. private _charSize;
  80688. /**
  80689. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80690. */
  80691. get charSize(): number;
  80692. /**
  80693. * Create a new instance of the Ascii Art FontTexture class
  80694. * @param name the name of the texture
  80695. * @param font the font to use, use the W3C CSS notation
  80696. * @param text the caracter set to use in the rendering.
  80697. * @param scene the scene that owns the texture
  80698. */
  80699. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80700. /**
  80701. * Gets the max char width of a font.
  80702. * @param font the font to use, use the W3C CSS notation
  80703. * @return the max char width
  80704. */
  80705. private getFontWidth;
  80706. /**
  80707. * Gets the max char height of a font.
  80708. * @param font the font to use, use the W3C CSS notation
  80709. * @return the max char height
  80710. */
  80711. private getFontHeight;
  80712. /**
  80713. * Clones the current AsciiArtTexture.
  80714. * @return the clone of the texture.
  80715. */
  80716. clone(): AsciiArtFontTexture;
  80717. /**
  80718. * Parses a json object representing the texture and returns an instance of it.
  80719. * @param source the source JSON representation
  80720. * @param scene the scene to create the texture for
  80721. * @return the parsed texture
  80722. */
  80723. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80724. }
  80725. /**
  80726. * Option available in the Ascii Art Post Process.
  80727. */
  80728. export interface IAsciiArtPostProcessOptions {
  80729. /**
  80730. * The font to use following the w3c font definition.
  80731. */
  80732. font?: string;
  80733. /**
  80734. * The character set to use in the postprocess.
  80735. */
  80736. characterSet?: string;
  80737. /**
  80738. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80739. * This number is defined between 0 and 1;
  80740. */
  80741. mixToTile?: number;
  80742. /**
  80743. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80744. * This number is defined between 0 and 1;
  80745. */
  80746. mixToNormal?: number;
  80747. }
  80748. /**
  80749. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80750. *
  80751. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80752. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80753. */
  80754. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80755. /**
  80756. * The font texture used to render the char in the post process.
  80757. */
  80758. private _asciiArtFontTexture;
  80759. /**
  80760. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80761. * This number is defined between 0 and 1;
  80762. */
  80763. mixToTile: number;
  80764. /**
  80765. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80766. * This number is defined between 0 and 1;
  80767. */
  80768. mixToNormal: number;
  80769. /**
  80770. * Instantiates a new Ascii Art Post Process.
  80771. * @param name the name to give to the postprocess
  80772. * @camera the camera to apply the post process to.
  80773. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80774. */
  80775. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80776. }
  80777. }
  80778. declare module BABYLON {
  80779. /** @hidden */
  80780. export var digitalrainPixelShader: {
  80781. name: string;
  80782. shader: string;
  80783. };
  80784. }
  80785. declare module BABYLON {
  80786. /**
  80787. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80788. *
  80789. * It basically takes care rendering the font front the given font size to a texture.
  80790. * This is used later on in the postprocess.
  80791. */
  80792. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80793. private _font;
  80794. private _text;
  80795. private _charSize;
  80796. /**
  80797. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80798. */
  80799. get charSize(): number;
  80800. /**
  80801. * Create a new instance of the Digital Rain FontTexture class
  80802. * @param name the name of the texture
  80803. * @param font the font to use, use the W3C CSS notation
  80804. * @param text the caracter set to use in the rendering.
  80805. * @param scene the scene that owns the texture
  80806. */
  80807. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80808. /**
  80809. * Gets the max char width of a font.
  80810. * @param font the font to use, use the W3C CSS notation
  80811. * @return the max char width
  80812. */
  80813. private getFontWidth;
  80814. /**
  80815. * Gets the max char height of a font.
  80816. * @param font the font to use, use the W3C CSS notation
  80817. * @return the max char height
  80818. */
  80819. private getFontHeight;
  80820. /**
  80821. * Clones the current DigitalRainFontTexture.
  80822. * @return the clone of the texture.
  80823. */
  80824. clone(): DigitalRainFontTexture;
  80825. /**
  80826. * Parses a json object representing the texture and returns an instance of it.
  80827. * @param source the source JSON representation
  80828. * @param scene the scene to create the texture for
  80829. * @return the parsed texture
  80830. */
  80831. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80832. }
  80833. /**
  80834. * Option available in the Digital Rain Post Process.
  80835. */
  80836. export interface IDigitalRainPostProcessOptions {
  80837. /**
  80838. * The font to use following the w3c font definition.
  80839. */
  80840. font?: string;
  80841. /**
  80842. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80843. * This number is defined between 0 and 1;
  80844. */
  80845. mixToTile?: number;
  80846. /**
  80847. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80848. * This number is defined between 0 and 1;
  80849. */
  80850. mixToNormal?: number;
  80851. }
  80852. /**
  80853. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80854. *
  80855. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80856. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80857. */
  80858. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80859. /**
  80860. * The font texture used to render the char in the post process.
  80861. */
  80862. private _digitalRainFontTexture;
  80863. /**
  80864. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80865. * This number is defined between 0 and 1;
  80866. */
  80867. mixToTile: number;
  80868. /**
  80869. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80870. * This number is defined between 0 and 1;
  80871. */
  80872. mixToNormal: number;
  80873. /**
  80874. * Instantiates a new Digital Rain Post Process.
  80875. * @param name the name to give to the postprocess
  80876. * @camera the camera to apply the post process to.
  80877. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80878. */
  80879. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80880. }
  80881. }
  80882. declare module BABYLON {
  80883. /** @hidden */
  80884. export var brickProceduralTexturePixelShader: {
  80885. name: string;
  80886. shader: string;
  80887. };
  80888. }
  80889. declare module BABYLON {
  80890. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80891. private _numberOfBricksHeight;
  80892. private _numberOfBricksWidth;
  80893. private _jointColor;
  80894. private _brickColor;
  80895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80896. updateShaderUniforms(): void;
  80897. get numberOfBricksHeight(): number;
  80898. set numberOfBricksHeight(value: number);
  80899. get numberOfBricksWidth(): number;
  80900. set numberOfBricksWidth(value: number);
  80901. get jointColor(): BABYLON.Color3;
  80902. set jointColor(value: BABYLON.Color3);
  80903. get brickColor(): BABYLON.Color3;
  80904. set brickColor(value: BABYLON.Color3);
  80905. /**
  80906. * Serializes this brick procedural texture
  80907. * @returns a serialized brick procedural texture object
  80908. */
  80909. serialize(): any;
  80910. /**
  80911. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80912. * @param parsedTexture defines parsed texture data
  80913. * @param scene defines the current scene
  80914. * @param rootUrl defines the root URL containing brick procedural texture information
  80915. * @returns a parsed Brick Procedural BABYLON.Texture
  80916. */
  80917. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80918. }
  80919. }
  80920. declare module BABYLON {
  80921. /** @hidden */
  80922. export var cloudProceduralTexturePixelShader: {
  80923. name: string;
  80924. shader: string;
  80925. };
  80926. }
  80927. declare module BABYLON {
  80928. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80929. private _skyColor;
  80930. private _cloudColor;
  80931. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80932. updateShaderUniforms(): void;
  80933. get skyColor(): BABYLON.Color4;
  80934. set skyColor(value: BABYLON.Color4);
  80935. get cloudColor(): BABYLON.Color4;
  80936. set cloudColor(value: BABYLON.Color4);
  80937. /**
  80938. * Serializes this cloud procedural texture
  80939. * @returns a serialized cloud procedural texture object
  80940. */
  80941. serialize(): any;
  80942. /**
  80943. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80944. * @param parsedTexture defines parsed texture data
  80945. * @param scene defines the current scene
  80946. * @param rootUrl defines the root URL containing cloud procedural texture information
  80947. * @returns a parsed Cloud Procedural BABYLON.Texture
  80948. */
  80949. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80950. }
  80951. }
  80952. declare module BABYLON {
  80953. /** @hidden */
  80954. export var fireProceduralTexturePixelShader: {
  80955. name: string;
  80956. shader: string;
  80957. };
  80958. }
  80959. declare module BABYLON {
  80960. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80961. private _time;
  80962. private _speed;
  80963. private _autoGenerateTime;
  80964. private _fireColors;
  80965. private _alphaThreshold;
  80966. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80967. updateShaderUniforms(): void;
  80968. render(useCameraPostProcess?: boolean): void;
  80969. static get PurpleFireColors(): BABYLON.Color3[];
  80970. static get GreenFireColors(): BABYLON.Color3[];
  80971. static get RedFireColors(): BABYLON.Color3[];
  80972. static get BlueFireColors(): BABYLON.Color3[];
  80973. get autoGenerateTime(): boolean;
  80974. set autoGenerateTime(value: boolean);
  80975. get fireColors(): BABYLON.Color3[];
  80976. set fireColors(value: BABYLON.Color3[]);
  80977. get time(): number;
  80978. set time(value: number);
  80979. get speed(): BABYLON.Vector2;
  80980. set speed(value: BABYLON.Vector2);
  80981. get alphaThreshold(): number;
  80982. set alphaThreshold(value: number);
  80983. /**
  80984. * Serializes this fire procedural texture
  80985. * @returns a serialized fire procedural texture object
  80986. */
  80987. serialize(): any;
  80988. /**
  80989. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80990. * @param parsedTexture defines parsed texture data
  80991. * @param scene defines the current scene
  80992. * @param rootUrl defines the root URL containing fire procedural texture information
  80993. * @returns a parsed Fire Procedural BABYLON.Texture
  80994. */
  80995. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80996. }
  80997. }
  80998. declare module BABYLON {
  80999. /** @hidden */
  81000. export var grassProceduralTexturePixelShader: {
  81001. name: string;
  81002. shader: string;
  81003. };
  81004. }
  81005. declare module BABYLON {
  81006. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  81007. private _grassColors;
  81008. private _groundColor;
  81009. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81010. updateShaderUniforms(): void;
  81011. get grassColors(): BABYLON.Color3[];
  81012. set grassColors(value: BABYLON.Color3[]);
  81013. get groundColor(): BABYLON.Color3;
  81014. set groundColor(value: BABYLON.Color3);
  81015. /**
  81016. * Serializes this grass procedural texture
  81017. * @returns a serialized grass procedural texture object
  81018. */
  81019. serialize(): any;
  81020. /**
  81021. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  81022. * @param parsedTexture defines parsed texture data
  81023. * @param scene defines the current scene
  81024. * @param rootUrl defines the root URL containing grass procedural texture information
  81025. * @returns a parsed Grass Procedural BABYLON.Texture
  81026. */
  81027. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  81028. }
  81029. }
  81030. declare module BABYLON {
  81031. /** @hidden */
  81032. export var marbleProceduralTexturePixelShader: {
  81033. name: string;
  81034. shader: string;
  81035. };
  81036. }
  81037. declare module BABYLON {
  81038. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  81039. private _numberOfTilesHeight;
  81040. private _numberOfTilesWidth;
  81041. private _amplitude;
  81042. private _jointColor;
  81043. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81044. updateShaderUniforms(): void;
  81045. get numberOfTilesHeight(): number;
  81046. set numberOfTilesHeight(value: number);
  81047. get amplitude(): number;
  81048. set amplitude(value: number);
  81049. get numberOfTilesWidth(): number;
  81050. set numberOfTilesWidth(value: number);
  81051. get jointColor(): BABYLON.Color3;
  81052. set jointColor(value: BABYLON.Color3);
  81053. /**
  81054. * Serializes this marble procedural texture
  81055. * @returns a serialized marble procedural texture object
  81056. */
  81057. serialize(): any;
  81058. /**
  81059. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  81060. * @param parsedTexture defines parsed texture data
  81061. * @param scene defines the current scene
  81062. * @param rootUrl defines the root URL containing marble procedural texture information
  81063. * @returns a parsed Marble Procedural BABYLON.Texture
  81064. */
  81065. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  81066. }
  81067. }
  81068. declare module BABYLON {
  81069. /** @hidden */
  81070. export var normalMapProceduralTexturePixelShader: {
  81071. name: string;
  81072. shader: string;
  81073. };
  81074. }
  81075. declare module BABYLON {
  81076. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  81077. private _baseTexture;
  81078. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81079. updateShaderUniforms(): void;
  81080. render(useCameraPostProcess?: boolean): void;
  81081. resize(size: any, generateMipMaps: any): void;
  81082. get baseTexture(): BABYLON.Texture;
  81083. set baseTexture(texture: BABYLON.Texture);
  81084. /**
  81085. * Serializes this normal map procedural texture
  81086. * @returns a serialized normal map procedural texture object
  81087. */
  81088. serialize(): any;
  81089. /**
  81090. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  81091. * @param parsedTexture defines parsed texture data
  81092. * @param scene defines the current scene
  81093. * @param rootUrl defines the root URL containing normal map procedural texture information
  81094. * @returns a parsed Normal Map Procedural BABYLON.Texture
  81095. */
  81096. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  81097. }
  81098. }
  81099. declare module BABYLON {
  81100. /** @hidden */
  81101. export var perlinNoiseProceduralTexturePixelShader: {
  81102. name: string;
  81103. shader: string;
  81104. };
  81105. }
  81106. declare module BABYLON {
  81107. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  81108. time: number;
  81109. timeScale: number;
  81110. translationSpeed: number;
  81111. private _currentTranslation;
  81112. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81113. updateShaderUniforms(): void;
  81114. render(useCameraPostProcess?: boolean): void;
  81115. resize(size: any, generateMipMaps: any): void;
  81116. /**
  81117. * Serializes this perlin noise procedural texture
  81118. * @returns a serialized perlin noise procedural texture object
  81119. */
  81120. serialize(): any;
  81121. /**
  81122. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81123. * @param parsedTexture defines parsed texture data
  81124. * @param scene defines the current scene
  81125. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81126. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81127. */
  81128. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81129. }
  81130. }
  81131. declare module BABYLON {
  81132. /** @hidden */
  81133. export var roadProceduralTexturePixelShader: {
  81134. name: string;
  81135. shader: string;
  81136. };
  81137. }
  81138. declare module BABYLON {
  81139. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81140. private _roadColor;
  81141. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81142. updateShaderUniforms(): void;
  81143. get roadColor(): BABYLON.Color3;
  81144. set roadColor(value: BABYLON.Color3);
  81145. /**
  81146. * Serializes this road procedural texture
  81147. * @returns a serialized road procedural texture object
  81148. */
  81149. serialize(): any;
  81150. /**
  81151. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81152. * @param parsedTexture defines parsed texture data
  81153. * @param scene defines the current scene
  81154. * @param rootUrl defines the root URL containing road procedural texture information
  81155. * @returns a parsed Road Procedural BABYLON.Texture
  81156. */
  81157. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81158. }
  81159. }
  81160. declare module BABYLON {
  81161. /** @hidden */
  81162. export var starfieldProceduralTexturePixelShader: {
  81163. name: string;
  81164. shader: string;
  81165. };
  81166. }
  81167. declare module BABYLON {
  81168. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81169. private _time;
  81170. private _alpha;
  81171. private _beta;
  81172. private _zoom;
  81173. private _formuparam;
  81174. private _stepsize;
  81175. private _tile;
  81176. private _brightness;
  81177. private _darkmatter;
  81178. private _distfading;
  81179. private _saturation;
  81180. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81181. updateShaderUniforms(): void;
  81182. get time(): number;
  81183. set time(value: number);
  81184. get alpha(): number;
  81185. set alpha(value: number);
  81186. get beta(): number;
  81187. set beta(value: number);
  81188. get formuparam(): number;
  81189. set formuparam(value: number);
  81190. get stepsize(): number;
  81191. set stepsize(value: number);
  81192. get zoom(): number;
  81193. set zoom(value: number);
  81194. get tile(): number;
  81195. set tile(value: number);
  81196. get brightness(): number;
  81197. set brightness(value: number);
  81198. get darkmatter(): number;
  81199. set darkmatter(value: number);
  81200. get distfading(): number;
  81201. set distfading(value: number);
  81202. get saturation(): number;
  81203. set saturation(value: number);
  81204. /**
  81205. * Serializes this starfield procedural texture
  81206. * @returns a serialized starfield procedural texture object
  81207. */
  81208. serialize(): any;
  81209. /**
  81210. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81211. * @param parsedTexture defines parsed texture data
  81212. * @param scene defines the current scene
  81213. * @param rootUrl defines the root URL containing startfield procedural texture information
  81214. * @returns a parsed Starfield Procedural BABYLON.Texture
  81215. */
  81216. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81217. }
  81218. }
  81219. declare module BABYLON {
  81220. /** @hidden */
  81221. export var woodProceduralTexturePixelShader: {
  81222. name: string;
  81223. shader: string;
  81224. };
  81225. }
  81226. declare module BABYLON {
  81227. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81228. private _ampScale;
  81229. private _woodColor;
  81230. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81231. updateShaderUniforms(): void;
  81232. get ampScale(): number;
  81233. set ampScale(value: number);
  81234. get woodColor(): BABYLON.Color3;
  81235. set woodColor(value: BABYLON.Color3);
  81236. /**
  81237. * Serializes this wood procedural texture
  81238. * @returns a serialized wood procedural texture object
  81239. */
  81240. serialize(): any;
  81241. /**
  81242. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81243. * @param parsedTexture defines parsed texture data
  81244. * @param scene defines the current scene
  81245. * @param rootUrl defines the root URL containing wood procedural texture information
  81246. * @returns a parsed Wood Procedural BABYLON.Texture
  81247. */
  81248. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81249. }
  81250. }